From 18c610d12e2778cc501eb783207b9027f80a257b Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 12 May 2022 10:07:02 +0200 Subject: [PATCH] Use display name instead of alias if set (#2622) --- src/identity-providers/add/DetailSettings.tsx | 293 +++++++++--------- 1 file changed, 152 insertions(+), 141 deletions(-) diff --git a/src/identity-providers/add/DetailSettings.tsx b/src/identity-providers/add/DetailSettings.tsx index 82d19c731c..cce41ca7da 100644 --- a/src/identity-providers/add/DetailSettings.tsx +++ b/src/identity-providers/add/DetailSettings.tsx @@ -1,7 +1,13 @@ import React, { useState } from "react"; import { Link, useHistory, useParams } from "react-router-dom"; import { useTranslation } from "react-i18next"; -import { Controller, FormProvider, useForm } from "react-hook-form"; +import { + Controller, + FormProvider, + useForm, + useFormContext, + useWatch, +} from "react-hook-form"; import { ActionGroup, AlertVariant, @@ -68,9 +74,16 @@ const Header = ({ onChange, value, save, toggleDeleteDialog }: HeaderProps) => { const { t } = useTranslation("identity-providers"); const { alias } = useParams<{ alias: string }>(); + const { control } = useFormContext(); + const displayName = useWatch({ + name: "displayName", + control, + defaultValue: alias, + }); + const [toggleDisableDialog, DisableConfirm] = useConfirmDialog({ titleKey: "identity-providers:disableProvider", - messageKey: t("disableConfirm", { provider: alias }), + messageKey: t("disableConfirm", { provider: displayName }), continueButtonLabel: "common:disable", onConfirm: () => { onChange(!value); @@ -82,7 +95,7 @@ const Header = ({ onChange, value, save, toggleDeleteDialog }: HeaderProps) => { <> toggleDeleteDialog()}> @@ -265,7 +278,7 @@ export default function DetailSettings() { } return ( - <> + - - - {t("common:settings")}} - > - + + {t("common:settings")}} + > + + + {!isOIDC && !isSAML && ( + + )} + {isOIDC && } + {isSAML && } + + {isOIDC && ( + <> + +
+ + + + + + )} + {isSAML && } + {isSAML && ( - {!isOIDC && !isSAML && ( - - )} - {isOIDC && } - {isSAML && } + - {isOIDC && ( - <> - -
- - - - - - )} - {isSAML && } - {isSAML && ( - - - - )} - - + )} + + - - - - - -
-
- {t("common:mappers")}} - > - - history.push( - toIdentityProviderAddMapper({ + + + + + +
+
+ {t("common:mappers")}} + > + + history.push( + toIdentityProviderAddMapper({ + realm, + alias: alias!, + providerId: provider.providerId!, + tab: "mappers", + }) + ) + } + /> + } + loader={loader} + key={key} + ariaLabelKey="identity-providers:mappersList" + searchPlaceholderKey="identity-providers:searchForMapper" + toolbarItem={ + + - - } - columns={[ - { - name: "name", - displayKey: "common:name", - cellRenderer: MapperLink, + })} + /> + )} + data-testid="addMapper" + > + {t("addMapper")} + + + } + columns={[ + { + name: "name", + displayKey: "common:name", + cellRenderer: MapperLink, + }, + { + name: "category", + displayKey: "common:category", + }, + { + name: "type", + displayKey: "common:type", + }, + ]} + actions={[ + { + title: t("common:delete"), + onRowClick: (mapper) => { + setSelectedMapper(mapper); + toggleDeleteMapperDialog(); }, - { - name: "category", - displayKey: "common:category", - }, - { - name: "type", - displayKey: "common:type", - }, - ]} - actions={[ - { - title: t("common:delete"), - onRowClick: (mapper) => { - setSelectedMapper(mapper); - toggleDeleteMapperDialog(); - }, - }, - ]} - /> - - {t("common:permissions")}} - > - - -
-
+ }, + ]} + /> + + {t("common:permissions")}} + > + + +
- +
); }