Group SSO - cleaning ternary operators in status files (#15365)

GitOrigin-RevId: 615f95aca66b0c80e54a057cabd61c74b8c3f12d
This commit is contained in:
Davinder Singh 2023-10-25 12:10:25 +01:00 committed by Copybot
parent f97689aa87
commit 06979babdb
2 changed files with 60 additions and 72 deletions

View file

@ -7,15 +7,7 @@ type ManagedUserStatusProps = {
}
export default function ManagedUserStatus({ user }: ManagedUserStatusProps) {
const { t } = useTranslation()
return (
<span>
{user.isEntityAdmin ? (
<>
<span className="security-state-group-admin" />
</>
) : (
<>
{user.invite ? (
const managedUserInvite = (
<span className="security-state-invite-pending">
<MaterialIcon
type="schedule"
@ -25,31 +17,30 @@ export default function ManagedUserStatus({ user }: ManagedUserStatusProps) {
&nbsp;
{t('managed')}
</span>
) : (
<>
{user.enrollment?.managedBy ? (
)
const managedUserAccepted = (
<span className="security-state-managed">
<MaterialIcon
type="check"
accessibilityLabel={t('managed')}
/>
<MaterialIcon type="check" accessibilityLabel={t('managed')} />
&nbsp;
{t('managed')}
</span>
) : (
<span className="security-state-not-managed">
<MaterialIcon
type="close"
accessibilityLabel={t('not_managed')}
/>
&nbsp;
{t('managed')}
</span>
)}
</>
)}
</>
)}
</span>
)
const managedUserNotAccepted = (
<span className="security-state-not-managed">
<MaterialIcon type="close" accessibilityLabel={t('not_managed')} />
&nbsp;
{t('managed')}
</span>
)
if (user.isEntityAdmin) {
return <span className="security-state-group-admin" />
}
if (user.invite) {
return managedUserInvite
}
return user.enrollment?.managedBy
? managedUserAccepted
: managedUserNotAccepted
}

View file

@ -7,9 +7,7 @@ type SSOStatusProps = {
}
export default function SSOStatus({ user }: SSOStatusProps) {
const { t } = useTranslation()
return (
<span>
{user.invite ? (
const invitedSSO = (
<span className="security-state-invite-pending">
<MaterialIcon
type="schedule"
@ -18,24 +16,23 @@ export default function SSOStatus({ user }: SSOStatusProps) {
/>
&nbsp; {t('sso')}
</span>
) : (
<>
{user.enrollment?.sso ? (
)
const acceptedSSO = (
<span className="security-state-managed">
<MaterialIcon type="check" accessibilityLabel={t('sso_linked')} />
&nbsp; {t('sso')}
</span>
) : (
)
const notAcceptedSSO = (
<span className="security-state-not-managed">
<MaterialIcon
type="close"
accessibilityLabel={t('sso_unlinked')}
/>
<MaterialIcon type="close" accessibilityLabel={t('sso_unlinked')} />
&nbsp; {t('sso')}
</span>
)}
</>
)}
</span>
)
if (user.invite) {
return invitedSSO
}
return user.enrollment?.sso ? acceptedSSO : notAcceptedSSO
}