The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(twenty-front): allow to connect available provider only (#9080)
Antoine Moreaux33b028658ed7
diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsConnectedAccountsListCard.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsConnectedAccountsListCard.tsxindex 6000afa1fe9..c1f9090ade2 100644--- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsConnectedAccountsListCard.tsx+++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsConnectedAccountsListCard.tsx@@ -8,6 +8,9 @@ import { SettingsPath } from '@/types/SettingsPath';import { SettingsAccountsConnectedAccountsRowRightContainer } from '@/settings/accounts/components/SettingsAccountsConnectedAccountsRowRightContainer';import { SettingsListCard } from '../../components/SettingsListCard';+import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';+import { useRecoilValue } from 'recoil';+import { isDefined } from '~/utils/isDefined';const ProviderIcons: { [k: string]: IconComponent } = {google: IconGoogle,@@ -22,11 +25,17 @@ export const SettingsAccountsConnectedAccountsListCard = ({loading?: boolean;}) => {const navigate = useNavigate();+ const currentWorkspace = useRecoilValue(currentWorkspaceState);if (!accounts.length) {return <SettingsAccountsListEmptyStateCard />;}+ const atLeastOneProviderAvailable =+ isDefined(currentWorkspace) &&+ (currentWorkspace?.isGoogleAuthEnabled ||+ currentWorkspace?.isMicrosoftAuthEnabled);+return (<SettingsListCarditems={accounts}@@ -36,7 +45,7 @@ export const SettingsAccountsConnectedAccountsListCard = ({RowRightComponent={({ item: account }) => (<SettingsAccountsConnectedAccountsRowRightContainer account={account} />)}- hasFooter+ hasFooter={atLeastOneProviderAvailable}footerButtonLabel="Add account"onFooterButtonClick={() =>navigate(getSettingsPagePath(SettingsPath.NewAccount))diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsListEmptyStateCard.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsListEmptyStateCard.tsxindex d532691fcc5..7c875b60680 100644--- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsListEmptyStateCard.tsx+++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsListEmptyStateCard.tsx@@ -9,6 +9,8 @@ import {IconGoogle,IconMicrosoft,} from 'twenty-ui';+import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';+import { useRecoilValue } from 'recoil';const StyledHeader = styled(CardHeader)`align-items: center;@@ -30,6 +32,7 @@ export const SettingsAccountsListEmptyStateCard = ({label,}: SettingsAccountsListEmptyStateCardProps) => {const { triggerApisOAuth } = useTriggerApisOAuth();+ const currentWorkspace = useRecoilValue(currentWorkspaceState);const isMicrosoftSyncEnabled = useIsFeatureEnabled('IS_MICROSOFT_SYNC_ENABLED',);@@ -38,13 +41,15 @@ export const SettingsAccountsListEmptyStateCard = ({<Card><StyledHeader>{label || 'No connected account'}</StyledHeader><StyledBody>- <Button- Icon={IconGoogle}- title="Connect with Google"- variant="secondary"- onClick={() => triggerApisOAuth('google')}- />- {isMicrosoftSyncEnabled && (+ {currentWorkspace?.isGoogleAuthEnabled && (+ <Button+ Icon={IconGoogle}+ title="Connect with Google"+ variant="secondary"+ onClick={() => triggerApisOAuth('google')}+ />+ )}+ {isMicrosoftSyncEnabled && currentWorkspace?.isMicrosoftAuthEnabled && (<ButtonIcon={IconMicrosoft}title="Connect with Microsoft"