Skip to content

Commit 6e345b0

Browse files
committed
Add protect as children of content
1 parent 9772afb commit 6e345b0

3 files changed

Lines changed: 21 additions & 23 deletions

File tree

packages/ui/src/components/ConfigureSSO/ConfigureSSO.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ const AuthenticatedContent = withCoreUserGuard(() => {
5858
flex: 1,
5959
})}
6060
>
61-
<ConfigureSSOProtect>
62-
<ConfigureSSOContent contentRef={contentRef} />
63-
</ConfigureSSOProtect>
61+
<ConfigureSSOContent contentRef={contentRef} />
6462
</Col>
6563
</ConfigureSSONavbar>
6664
</ProfileCard.Root>
@@ -86,16 +84,18 @@ export const ConfigureSSOContent = ({ contentRef }: { contentRef: React.RefObjec
8684
}
8785

8886
return (
89-
<ConfigureSSOProvider
90-
hasSuccessfulTestRun={hasSuccessfulTestRun}
91-
enterpriseConnection={enterpriseConnection}
92-
contentRef={contentRef}
93-
createEnterpriseConnection={createEnterpriseConnection}
94-
updateEnterpriseConnection={updateEnterpriseConnection}
95-
deleteEnterpriseConnection={deleteEnterpriseConnection}
96-
>
97-
<ConfigureSSOSteps />
98-
</ConfigureSSOProvider>
87+
<ConfigureSSOProtect>
88+
<ConfigureSSOProvider
89+
hasSuccessfulTestRun={hasSuccessfulTestRun}
90+
enterpriseConnection={enterpriseConnection}
91+
contentRef={contentRef}
92+
createEnterpriseConnection={createEnterpriseConnection}
93+
updateEnterpriseConnection={updateEnterpriseConnection}
94+
deleteEnterpriseConnection={deleteEnterpriseConnection}
95+
>
96+
<ConfigureSSOSteps />
97+
</ConfigureSSOProvider>
98+
</ConfigureSSOProtect>
9999
);
100100
};
101101

@@ -151,7 +151,7 @@ const ConfigureSSOSteps = () => {
151151
);
152152
};
153153

154-
export const ConfigureSSOProtect = ({ children }: { children: React.ReactNode }) => {
154+
const ConfigureSSOProtect = ({ children }: { children: React.ReactNode }) => {
155155
const { session } = useSession();
156156
const isPersonalWorkspace = !session?.lastActiveOrganizationId;
157157
const canManageEnterpriseConnections = useProtect(
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useOrganization } from '@clerk/shared/react';
22
import { useRef } from 'react';
33

4-
import { ConfigureSSOContent, ConfigureSSOProtect } from '../ConfigureSSO/ConfigureSSO';
4+
import { ConfigureSSOContent } from '../ConfigureSSO/ConfigureSSO';
55

66
export const OrganizationSelfServeSSOPage = () => {
77
const { organization } = useOrganization();
@@ -12,9 +12,5 @@ export const OrganizationSelfServeSSOPage = () => {
1212
return null;
1313
}
1414

15-
return (
16-
<ConfigureSSOProtect>
17-
<ConfigureSSOContent contentRef={contentRef} />
18-
</ConfigureSSOProtect>
19-
);
15+
return <ConfigureSSOContent contentRef={contentRef} />;
2016
};

packages/ui/src/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ describe('OrganizationProfile', () => {
539539
});
540540

541541
it('includes SSO even when the user does not have the manage enterprise connections permission, but the page surfaces a warning', async () => {
542-
const { wrapper } = await createFixtures(f => {
542+
const { wrapper, fixtures } = await createFixtures(f => {
543543
f.withEnterpriseSso({ selfServeSSO: true });
544544
f.withOrganizations();
545545
f.withUser({
@@ -554,14 +554,16 @@ describe('OrganizationProfile', () => {
554554
});
555555
});
556556

557+
fixtures.clerk.user?.getEnterpriseConnections.mockResolvedValue([]);
558+
557559
render(<OrganizationProfile />, { wrapper });
558560
expect(await screen.findByText('Single Sign-On (SSO)')).toBeDefined();
559561

560562
cleanup();
561563
render(<OrganizationSelfServeSSOPage />, { wrapper });
562-
expect(await screen.findByText(/you do not have permission to manage enterprise connections/i)).toBeDefined();
564+
expect(await screen.findByText(/you do not have permission to manage single sign-on/i)).toBeDefined();
563565
expect(
564-
screen.queryByText(/contact your organization administrator in order to have permissions/i),
566+
screen.queryByText(/contact your organization.*administrator to upgrade your permissions/i),
565567
).toBeInTheDocument();
566568
});
567569
});

0 commit comments

Comments
 (0)