Wrap SamlKeysDialog in FormProvider (#3975)

This commit is contained in:
Jon Koops 2022-12-12 00:46:19 +01:00 committed by GitHub
parent 9ac61efab4
commit 6f43a8d9ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -153,68 +153,66 @@ export const SamlKeysDialog = ({
</Button>,
]}
>
<Form isHorizontal>
<FormGroup
label={t("selectMethod")}
fieldId="selectMethod"
hasNoPaddingTop
>
<Flex>
<FlexItem>
<Radio
isChecked={!type}
name="selectMethodType"
onChange={() => setType(false)}
label={t("selectMethodType.generate")}
id="selectMethodType-generate"
/>
</FlexItem>
<FlexItem>
<Radio
isChecked={type}
name="selectMethodType"
onChange={() => setType(true)}
label={t("selectMethodType.import")}
id="selectMethodType-import"
/>
</FlexItem>
</Flex>
</FormGroup>
</Form>
{!type && (
<Form>
<FormProvider {...form}>
<Form isHorizontal>
<FormGroup
label={t("certificate")}
fieldId="certificate"
labelIcon={
<HelpItem
helpText="clients-help:certificate"
fieldLabelId="clients:certificate"
/>
}
label={t("selectMethod")}
fieldId="selectMethod"
hasNoPaddingTop
>
<Split hasGutter>
<SplitItem isFilled>
<Certificate plain keyInfo={keys} />
</SplitItem>
<SplitItem>
<Button
variant="secondary"
data-testid="generate"
onClick={generate}
>
{t("generate")}
</Button>
</SplitItem>
</Split>
<Flex>
<FlexItem>
<Radio
isChecked={!type}
name="selectMethodType"
onChange={() => setType(false)}
label={t("selectMethodType.generate")}
id="selectMethodType-generate"
/>
</FlexItem>
<FlexItem>
<Radio
isChecked={type}
name="selectMethodType"
onChange={() => setType(true)}
label={t("selectMethodType.import")}
id="selectMethodType-import"
/>
</FlexItem>
</Flex>
</FormGroup>
</Form>
)}
{type && (
<FormProvider {...form}>
<KeyForm useFile />
</FormProvider>
)}
{!type && (
<Form>
<FormGroup
label={t("certificate")}
fieldId="certificate"
labelIcon={
<HelpItem
helpText="clients-help:certificate"
fieldLabelId="clients:certificate"
/>
}
>
<Split hasGutter>
<SplitItem isFilled>
<Certificate plain keyInfo={keys} />
</SplitItem>
<SplitItem>
<Button
variant="secondary"
data-testid="generate"
onClick={generate}
>
{t("generate")}
</Button>
</SplitItem>
</Split>
</FormGroup>
</Form>
)}
{type && <KeyForm useFile />}
</FormProvider>
</Modal>
);
};