diff --git a/openmetadata-ui/src/main/resources/ui/src/components/CreateUser/CreateUser.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/CreateUser/CreateUser.component.tsx index 6a23af0f5d4..fa5fe99f1a1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/CreateUser/CreateUser.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/CreateUser/CreateUser.component.tsx @@ -26,7 +26,8 @@ import { AxiosError } from 'axios'; import classNames from 'classnames'; import { isUndefined, trim } from 'lodash'; import { EditorContentRef } from 'Models'; -import React, { useMemo, useRef, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; +import { useTranslation } from 'react-i18next'; import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; import { checkEmailInUse, generateRandomPwd } from '../../axiosAPIs/auth-API'; import { getBotsPagePath, getUsersPagePath } from '../../constants/constants'; @@ -76,6 +77,7 @@ const CreateUser = ({ onSave, forceBot, }: CreateUserProps) => { + const { t } = useTranslation(); const [form] = Form.useForm(); const { authConfig } = useAuthContext(); const markdownRef = useRef(); @@ -93,7 +95,7 @@ const CreateUser = ({ const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [passwordGenerator, setPasswordGenerator] = useState( - CreatePasswordGenerator.AutomatciGenerate + CreatePasswordGenerator.AutomaticGenerate ); const [generatedPassword, setGeneratedPassword] = useState(''); const [isPasswordGenerating, setIsPasswordGenerating] = useState(false); @@ -111,17 +113,22 @@ const CreateUser = ({ [authConfig] ); - const slashedBreadcrumbList = [ - { - name: forceBot ? 'Bots' : 'Users', - url: forceBot ? getBotsPagePath() : getUsersPagePath(), - }, - { - name: `Create ${forceBot ? 'Bot' : 'User'}`, - url: '', - activeTitle: true, - }, - ]; + const slashedBreadcrumbList = useMemo( + () => [ + { + name: forceBot ? t('label.bot-plural') : t('label.users'), + url: forceBot ? getBotsPagePath() : getUsersPagePath(), + }, + { + name: `${t('label.create')} ${ + forceBot ? t('label.bot') : t('label.user') + }`, + url: '', + activeTitle: true, + }, + ], + [forceBot] + ); /** * Handle on change event @@ -279,7 +286,6 @@ const CreateUser = ({ }); }; - // ******* Generate Random Passwprd ***** const generateRandomPassword = async () => { setIsPasswordGenerating(true); try { @@ -300,7 +306,7 @@ const CreateUser = ({ */ const handleSave = () => { const isPasswordGenerated = - passwordGenerator === CreatePasswordGenerator.AutomatciGenerate; + passwordGenerator === CreatePasswordGenerator.AutomaticGenerate; const validRole = selectedRoles.filter( (id) => !isUndefined(id) ) as string[]; @@ -351,27 +357,29 @@ const CreateUser = ({ return ( <> - + @@ -384,52 +392,58 @@ const CreateUser = ({ return ( <> @@ -441,69 +455,75 @@ const CreateUser = ({ return ( <> @@ -515,79 +535,87 @@ const CreateUser = ({ return ( <> - + @@ -599,52 +627,58 @@ const CreateUser = ({ return ( <> @@ -658,6 +692,10 @@ const CreateUser = ({ } }; + useEffect(() => { + generateRandomPassword(); + }, []); + return (
- Create {forceBot ? 'Bot' : 'User'} + {t('label.create-entity', { + entity: forceBot ? t('label.bot') : t('label.user'), + })}
- + @@ -720,14 +760,18 @@ const CreateUser = ({ {forceBot && ( <> { if (!authMechanism) { - return Promise.reject('Auth Mechanism is required'); + return Promise.reject( + t('label.field-required', { + field: t('label.auth-mechanism'), + }) + ); } return Promise.resolve(); @@ -738,7 +782,7 @@ const CreateUser = ({ className="w-full" data-testid="auth-mechanism" defaultValue={authMechanism} - placeholder="Select Auth Mechanism" + placeholder={t('label.select-auth-mechanism')} onChange={(value) => setAuthMechanism(value)}> {getAuthMechanismTypeOptions(authConfig).map((option) => ( @@ -747,14 +791,18 @@ const CreateUser = ({ {authMechanism === AuthType.Jwt && ( { if (!tokenExpiry) { - return Promise.reject('Token Expiration is required'); + return Promise.reject( + t('label.field-required', { + field: t('label.token-expiration'), + }) + ); } return Promise.resolve(); @@ -765,7 +813,7 @@ const CreateUser = ({ className="w-full" data-testid="token-expiry" defaultValue={tokenExpiry} - placeholder="Select Token Expiration" + placeholder={t('label.select-token-expiration')} onChange={(value) => setTokenExpiry(value)}> {getJWTTokenExpiryOptions().map((option) => ( @@ -776,7 +824,7 @@ const CreateUser = ({ {authMechanism === AuthType.Sso && <>{getSSOConfig()}} )} - + @@ -788,11 +836,13 @@ const CreateUser = ({ name="passwordGenerator" value={passwordGenerator} onChange={handleOnChange}> - - Automatic Generate + + {t('label.automatically-generate')} - Create Password + {t('label.password-type', { + type: t('label.create'), + })} @@ -800,7 +850,7 @@ const CreateUser = ({ CreatePasswordGenerator.CreatePassword ? (
{ if (value !== password) { - return Promise.reject("Password doesn't match"); + return Promise.reject( + t('label.password-not-match') + ); } return Promise.resolve(); @@ -835,7 +891,9 @@ const CreateUser = ({ ]}> @@ -844,7 +902,9 @@ const CreateUser = ({ ) : (
) : ( @@ -885,17 +945,17 @@ const CreateUser = ({ )} )} - + - + } type="checkbox" onSelect={(_e, value) => selectedRolesHandler(value)} @@ -904,7 +964,7 @@ const CreateUser = ({ - Admin + {t('label.admin')} <> {saveState === 'waiting' ? ( @@ -937,7 +997,7 @@ const CreateUser = ({ form="create-user-bot-form" htmlType="submit" type="primary"> - Create + {t('label.create')} )} diff --git a/openmetadata-ui/src/main/resources/ui/src/enums/user.enum.ts b/openmetadata-ui/src/main/resources/ui/src/enums/user.enum.ts index a480065e07f..bdbee1e27a2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/enums/user.enum.ts +++ b/openmetadata-ui/src/main/resources/ui/src/enums/user.enum.ts @@ -23,6 +23,6 @@ export enum OwnerType { } export enum CreatePasswordGenerator { - AutomatciGenerate = 'AUTOMATIC_GENERATE', + AutomaticGenerate = 'AUTOMATIC_GENERATE', CreatePassword = 'CREATE_PASSWORD', } diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json index b321d4f7031..dca7dab7fb1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json @@ -2,6 +2,7 @@ "label": { "name": "Name", "type": "Type", + "email": "Email", "description": "Description", "docs": "Docs", "date-filter": "Date Filter", @@ -409,6 +410,7 @@ "ms-teams": "MS Teams", "ms-team": "MS Team", "bot": "Bot", + "bot-plural": "Bots", "policy-name": "Policy name", "add-new-policy": "Add New Policy", "policies": "Policies", @@ -552,7 +554,16 @@ "select-dbt-source": "Select DBT Source", "no-selected-dbt": "No source selected for DBT Configuration.", "dbt": "DBT", - "latest": "Latest" + "latest": "Latest", + "create": "Create", + "admin": "Admin", + "generate": "Generate", + "password-type": "{{type}} Password", + "automatically-generate": "Automatically Generate", + "create-entity": "Create {{entity}}", + "domain": "Domain", + "private-key": "PrivateKey", + "service-email": "Service account Email" }, "message": { "service-email-required": "Service account Email is required",