From 06979babdb25ed688a5a5762b4db3c5e093961ef Mon Sep 17 00:00:00 2001 From: Davinder Singh Date: Wed, 25 Oct 2023 12:10:25 +0100 Subject: [PATCH] Group SSO - cleaning ternary operators in status files (#15365) GitOrigin-RevId: 615f95aca66b0c80e54a057cabd61c74b8c3f12d --- .../managed-users/managed-user-status.tsx | 77 ++++++++----------- .../components/managed-users/sso-status.tsx | 55 +++++++------ 2 files changed, 60 insertions(+), 72 deletions(-) diff --git a/services/web/frontend/js/features/group-management/components/managed-users/managed-user-status.tsx b/services/web/frontend/js/features/group-management/components/managed-users/managed-user-status.tsx index 16d9a5c2fd..ea46b60952 100644 --- a/services/web/frontend/js/features/group-management/components/managed-users/managed-user-status.tsx +++ b/services/web/frontend/js/features/group-management/components/managed-users/managed-user-status.tsx @@ -7,49 +7,40 @@ type ManagedUserStatusProps = { } export default function ManagedUserStatus({ user }: ManagedUserStatusProps) { const { t } = useTranslation() - return ( - - {user.isEntityAdmin ? ( - <> - - - ) : ( - <> - {user.invite ? ( - - -   - {t('managed')} - - ) : ( - <> - {user.enrollment?.managedBy ? ( - - -   - {t('managed')} - - ) : ( - - -   - {t('managed')} - - )} - - )} - - )} + const managedUserInvite = ( + + +   + {t('managed')} ) + + const managedUserAccepted = ( + + +   + {t('managed')} + + ) + const managedUserNotAccepted = ( + + +   + {t('managed')} + + ) + + if (user.isEntityAdmin) { + return + } + if (user.invite) { + return managedUserInvite + } + return user.enrollment?.managedBy + ? managedUserAccepted + : managedUserNotAccepted } diff --git a/services/web/frontend/js/features/group-management/components/managed-users/sso-status.tsx b/services/web/frontend/js/features/group-management/components/managed-users/sso-status.tsx index 328f1af3d5..f1165a9308 100644 --- a/services/web/frontend/js/features/group-management/components/managed-users/sso-status.tsx +++ b/services/web/frontend/js/features/group-management/components/managed-users/sso-status.tsx @@ -7,35 +7,32 @@ type SSOStatusProps = { } export default function SSOStatus({ user }: SSOStatusProps) { const { t } = useTranslation() - return ( - - {user.invite ? ( - - -   {t('sso')} - - ) : ( - <> - {user.enrollment?.sso ? ( - - -   {t('sso')} - - ) : ( - - -   {t('sso')} - - )} - - )} + const invitedSSO = ( + + +   {t('sso')} ) + const acceptedSSO = ( + + +   {t('sso')} + + ) + const notAcceptedSSO = ( + + +   {t('sso')} + + ) + + if (user.invite) { + return invitedSSO + } + + return user.enrollment?.sso ? acceptedSSO : notAcceptedSSO }