From 8bd087338f77952c2e35a717e762a1082ac05897 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Svanstr=C3=B6m?= Date: Tue, 19 Nov 2024 18:31:52 +0100 Subject: [PATCH] Hide attach sso behind feature flag --- .../containers/members/MemberActions.tsx | 28 ++++++++++++---------- .../UsersAndAddressesSection.tsx | 3 +++ packages/unleash/UnleashFeatureFlags.ts | 1 + 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/components/containers/members/MemberActions.tsx b/packages/components/containers/members/MemberActions.tsx index e4ed030e16..1189326b05 100644 --- a/packages/components/containers/members/MemberActions.tsx +++ b/packages/components/containers/members/MemberActions.tsx @@ -60,6 +60,7 @@ export const MagicLinkMemberActions = ({ export const getMemberPermissions = ({ appName, + attachSSOEnabled, user, addresses, member, @@ -69,6 +70,7 @@ export const getMemberPermissions = ({ ssoDomainsSet, }: { ssoDomainsSet: ReturnType; + attachSSOEnabled: boolean; addresses: PartialMemberAddress[] | undefined; appName: APP_NAMES; user: UserModel; @@ -119,18 +121,20 @@ export const getMemberPermissions = ({ const isMemberSSO = Boolean(member.SSO); const canAddAddress = !isMemberSSO && addresses && addresses.length === 0; - const canDetachSSO = isMemberSSO; - const canAttachSSO = Boolean( - ssoDomainsSet.size && - !isMemberSSO && - hasKeysSetup && - isNonPrivate && - addresses?.length && - addresses.some((address) => { - const [, domain] = getEmailParts(address.Email); - return ssoDomainsSet.has(domain.toLowerCase()); - }) - ); + const canDetachSSO = attachSSOEnabled && isMemberSSO; + const canAttachSSO = + attachSSOEnabled && + Boolean( + ssoDomainsSet.size && + !isMemberSSO && + hasKeysSetup && + isNonPrivate && + addresses?.length && + addresses.some((address) => { + const [, domain] = getEmailParts(address.Email); + return ssoDomainsSet.has(domain.toLowerCase()); + }) + ); return { canAddAddress, diff --git a/packages/components/containers/members/UsersAndAddressesSection/UsersAndAddressesSection.tsx b/packages/components/containers/members/UsersAndAddressesSection/UsersAndAddressesSection.tsx index 863f64d74c..7ebdc09551 100644 --- a/packages/components/containers/members/UsersAndAddressesSection/UsersAndAddressesSection.tsx +++ b/packages/components/containers/members/UsersAndAddressesSection/UsersAndAddressesSection.tsx @@ -67,6 +67,7 @@ import { getOrganizationKeyInfo, validateOrganizationKey, } from '@proton/shared/lib/organization/helper'; +import useFlag from '@proton/unleash/useFlag'; import clsx from '@proton/utils/clsx'; import Tooltip from '../../../components/tooltip/Tooltip'; @@ -94,6 +95,7 @@ import UserTableBadge from './UsersTableBadge'; const UsersAndAddressesSection = ({ app, onceRef }: { app: APP_NAMES; onceRef: MutableRefObject }) => { const { APP_NAME } = useConfig(); + const attachSSOEnabled = useFlag('AttachSSO'); const [organization, loadingOrganization] = useOrganization(); const [organizationKey] = useOrganizationKey(); const getOrganizationKey = useGetOrganizationKey(); @@ -589,6 +591,7 @@ const UsersAndAddressesSection = ({ app, onceRef }: { app: APP_NAMES; onceRef: M const memberPermissions = getMemberPermissions({ ssoDomainsSet, + attachSSOEnabled, appName: APP_NAME, user, member, diff --git a/packages/unleash/UnleashFeatureFlags.ts b/packages/unleash/UnleashFeatureFlags.ts index ecb1718147..642b4aad04 100644 --- a/packages/unleash/UnleashFeatureFlags.ts +++ b/packages/unleash/UnleashFeatureFlags.ts @@ -51,6 +51,7 @@ enum AccountFlag { UserGroupsMembersPermissionCheck = 'UserGroupsMembersPermissionCheck', B2BAuthenticationLogs = 'B2BAuthenticationLogs', GlobalSSO = 'GlobalSSO', + AttachSSO = 'AttachSSO', EasySwitchConsentExperiment = 'EasySwitchConsentExperiment', } -- 2.11.4.GIT