From cd24896de1d6e6af2e98cc3444e951fa7ed2848c Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Fri, 11 Aug 2023 08:00:39 +0200 Subject: [PATCH] added update email button (#22361) fixes: #20902 --- .../public/locales/en/translation.json | 1 + .../src/personal-info/FormField.tsx | 53 +++++++++++++++---- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/js/apps/account-ui/public/locales/en/translation.json b/js/apps/account-ui/public/locales/en/translation.json index d9b9cd060b..3617d725a8 100644 --- a/js/apps/account-ui/public/locales/en/translation.json +++ b/js/apps/account-ui/public/locales/en/translation.json @@ -153,6 +153,7 @@ "unShareSuccess": "Resource successfully un-shared.", "update": "Update", "updateCredAriaLabel": "Update credential", + "updateEmail": "Update email", "updateError": "Could not update the resource due to: {{error}}", "updateSuccess": "Resource successfully updated.", "user": "User", diff --git a/js/apps/account-ui/src/personal-info/FormField.tsx b/js/apps/account-ui/src/personal-info/FormField.tsx index 0a1b37a67f..7a68a3474b 100644 --- a/js/apps/account-ui/src/personal-info/FormField.tsx +++ b/js/apps/account-ui/src/personal-info/FormField.tsx @@ -1,11 +1,20 @@ -import { FormGroup, Select, SelectOption } from "@patternfly/react-core"; +import { + Button, + FormGroup, + InputGroup, + Select, + SelectOption, +} from "@patternfly/react-core"; +import { ExternalLinkSquareAltIcon } from "@patternfly/react-icons"; import { get } from "lodash-es"; import { useState } from "react"; import { Controller, useFormContext } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { KeycloakTextInput } from "ui-shared"; import { UserProfileAttributeMetadata } from "../api/representations"; +import { environment } from "../environment"; import { TFuncKey } from "../i18n"; +import { keycloak } from "../keycloak"; import { LocaleSelector } from "./LocaleSelector"; import { fieldName, isBundleKey, unWrap } from "./PersonalInfo"; @@ -26,6 +35,13 @@ export const FormField = ({ attribute }: FormFieldProps) => { const isSelect = (attribute: UserProfileAttributeMetadata) => Object.hasOwn(attribute.validators, "options"); + const { + updateEmailFeatureEnabled, + updateEmailActionEnabled, + isRegistrationEmailAsUsername, + isEditUserNameAllowed, + } = environment.features; + if (attribute.name === "locale") return ; return ( { )} /> ) : ( - + + + {attribute.name === "email" && + updateEmailFeatureEnabled && + updateEmailActionEnabled && + (!isRegistrationEmailAsUsername || isEditUserNameAllowed) && ( + + )} + )} );