This commit is contained in:
Erik Jan de Wit 2021-11-15 08:30:53 +01:00 committed by GitHub
parent 4428a4e088
commit 9b3cd978c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View file

@ -225,6 +225,10 @@ export const SamlKeys = ({ clientId, save }: SamlKeysProps) => {
save();
setRefresh(refresh + 1);
}}
onCancel={() => {
setValue(KEYS_MAPPING[selectedType!].name, "false");
setIsChanged(undefined);
}}
/>
)}
<DisableConfirm />

View file

@ -34,6 +34,7 @@ type SamlKeysDialogProps = {
id: string;
attr: KeyTypes;
onClose: () => void;
onCancel: () => void;
};
export type SamlKeysDialogForm = KeyStoreConfig & {
@ -65,11 +66,21 @@ export const submitForm = async (
}
};
export const SamlKeysDialog = ({ id, attr, onClose }: SamlKeysDialogProps) => {
export const SamlKeysDialog = ({
id,
attr,
onClose,
onCancel,
}: SamlKeysDialogProps) => {
const { t } = useTranslation("clients");
const [type, setType] = useState(false);
const [keys, setKeys] = useState<CertificateRepresentation>();
const { register, control, handleSubmit } = useForm<SamlKeysDialogForm>();
const {
register,
control,
handleSubmit,
formState: { isDirty },
} = useForm<SamlKeysDialogForm>();
const adminClient = useAdminClient();
const { addAlert, addError } = useAlerts();
@ -122,6 +133,7 @@ export const SamlKeysDialog = ({ id, attr, onClose }: SamlKeysDialogProps) => {
key="confirm"
data-testid="confirm"
variant="primary"
isDisabled={!isDirty && !keys}
onClick={() => {
if (type) {
handleSubmit(submit)();
@ -136,7 +148,7 @@ export const SamlKeysDialog = ({ id, attr, onClose }: SamlKeysDialogProps) => {
key="cancel"
data-testid="cancel"
variant={ButtonVariant.link}
onClick={onClose}
onClick={onCancel}
>
{t("common:cancel")}
</Button>,