From c4d67f489e9845e34a313ed4930c1cd63f58396d Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Fri, 30 Sep 2022 18:07:29 +0530 Subject: [PATCH] Fix UI :- fix the Password field showing in SSO login (#7811) * Fix the Password field showing in SSO login * changes as per comments --- .../CreateUser/CreateUser.component.tsx | 198 ++++++++++-------- 1 file changed, 105 insertions(+), 93 deletions(-) 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 5845fac8bad..369e7c76892 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,7 @@ import { AxiosError } from 'axios'; import classNames from 'classnames'; import { isUndefined } from 'lodash'; import { EditorContentRef } from 'Models'; -import React, { useRef, useState } from 'react'; +import React, { useMemo, useRef, useState } from 'react'; import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; import { generateRandomPwd } from '../../axiosAPIs/auth-API'; import { getBotsPagePath, getUsersPagePath } from '../../constants/constants'; @@ -36,6 +36,7 @@ import { validEmailRegEx, } from '../../constants/regex.constants'; import { PageLayoutType } from '../../enums/layout.enum'; +import { AuthTypes } from '../../enums/signin.enum'; import { CreatePasswordGenerator } from '../../enums/user.enum'; import { CreatePasswordType, @@ -109,6 +110,11 @@ const CreateUser = ({ {} as SSOClientConfig ); + const isAuthProviderBasic = useMemo( + () => authConfig?.provider === AuthTypes.BASIC, + [authConfig] + ); + const slashedBreadcrumbList = [ { name: forceBot ? 'Bots' : 'Users', @@ -775,101 +781,107 @@ const CreateUser = ({ - - - Automatic Generate - - - Create Password - - + {isAuthProviderBasic && ( + <> + + + Automatic Generate + + + Create Password + + - {passwordGenerator === CreatePasswordGenerator.CreatePassword ? ( -
- - - + {passwordGenerator === CreatePasswordGenerator.CreatePassword ? ( +
+ + + - { - if (value !== password) { - return Promise.reject("Password doesn't match"); + { + if (value !== password) { + return Promise.reject("Password doesn't match"); + } + + return Promise.resolve(); + }, + }, + ]}> + + +
+ ) : ( +
+ + +
+ {isPasswordGenerating ? ( + + ) : ( + + )} +
+ +
+ +
+
} - - return Promise.resolve(); - }, - }, - ]}> - - -
- ) : ( -
- - -
- {isPasswordGenerating ? ( - - ) : ( - - )} -
- -
- -
-
- } - name="generatedPassword" - value={generatedPassword} - /> - - + name="generatedPassword" + value={generatedPassword} + /> + + + )} + )} {!forceBot && (