Skip to content

Commit a1aaff3

Browse files
authored
chore(shared,ui): Remove deprecated hideSlug prop from organization AIOs (#7283)
1 parent cf0d0dc commit a1aaff3

File tree

12 files changed

+38
-140
lines changed

12 files changed

+38
-140
lines changed

.changeset/ninety-days-dream.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@clerk/shared': major
3+
'@clerk/ui': major
4+
---
5+
6+
Remove deprecated `hideSlug` in favor of `organizationSettings.slug.disabled` setting
7+
8+
Slugs can now be enabled directly from the Organization Settings page in the Clerk Dashboard

packages/shared/src/types/clerk.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,12 +1664,6 @@ export type CreateOrganizationProps = RoutingOptions & {
16641664
* prop of ClerkProvider (if one is provided)
16651665
*/
16661666
appearance?: CreateOrganizationTheme;
1667-
/**
1668-
* @deprecated
1669-
* This prop will be removed in a future version.
1670-
* Configure whether organization slug is enabled via the Clerk Dashboard under Organization Settings.
1671-
*/
1672-
hideSlug?: boolean;
16731667
};
16741668

16751669
export type CreateOrganizationModalProps = WithoutRouting<CreateOrganizationProps>;
@@ -1837,12 +1831,6 @@ export type OrganizationSwitcherProps = CreateOrganizationMode &
18371831
* the number of max allowed members is equal to 1
18381832
*/
18391833
skipInvitationScreen?: boolean;
1840-
/**
1841-
* @deprecated
1842-
* This prop will be removed in a future version.
1843-
* Configure whether organization slug is enabled via the Clerk Dashboard under Organization Settings.
1844-
*/
1845-
hideSlug?: boolean;
18461834
/**
18471835
* Customisation options to fully match the Clerk components to your own brand.
18481836
* These options serve as overrides and will be merged with the global `appearance`
@@ -1903,12 +1891,6 @@ export type OrganizationListProps = {
19031891
* @default undefined`
19041892
*/
19051893
afterSelectPersonalUrl?: ((user: UserResource) => string) | LooseExtractedParams<PrimitiveKeys<UserResource>>;
1906-
/**
1907-
* @deprecated
1908-
* This prop will be removed in a future version.
1909-
* Configure whether organization slug is enabled via the Clerk Dashboard under Organization Settings.
1910-
*/
1911-
hideSlug?: boolean;
19121894
};
19131895

19141896
export type WaitlistProps = {

packages/ui/src/components/CreateOrganization/CreateOrganizationForm.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ type CreateOrganizationFormProps = {
3434
headerTitle?: LocalizationKey;
3535
headerSubtitle?: LocalizationKey;
3636
};
37-
/**
38-
* @deprecated
39-
* This prop will be removed in a future version.
40-
* Configure whether organization slug is enabled via the Clerk Dashboard under Organization Settings.
41-
*/
42-
hideSlug?: boolean;
4337
};
4438

4539
export const CreateOrganizationForm = withCardStateProvider((props: CreateOrganizationFormProps) => {
@@ -70,7 +64,7 @@ export const CreateOrganizationForm = withCardStateProvider((props: CreateOrgani
7064
const canSubmit = dataChanged;
7165

7266
// Environment setting takes precedence over prop
73-
const organizationSlugEnabled = !organizationSettings.slug.disabled && !props.hideSlug;
67+
const organizationSlugEnabled = !organizationSettings.slug.disabled;
7468

7569
const onSubmit = async (e: React.FormEvent) => {
7670
e.preventDefault();

packages/ui/src/components/CreateOrganization/CreateOrganizationPage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CreateOrganizationForm } from './CreateOrganizationForm';
1111
export const CreateOrganizationPage = withCardStateProvider(() => {
1212
const { closeCreateOrganization } = useClerk();
1313

14-
const { mode, navigateAfterCreateOrganization, skipInvitationScreen, hideSlug } = useCreateOrganizationContext();
14+
const { mode, navigateAfterCreateOrganization, skipInvitationScreen } = useCreateOrganizationContext();
1515
const card = useCardState();
1616
const { showDevModeNotice } = useDevMode();
1717

@@ -33,7 +33,6 @@ export const CreateOrganizationPage = withCardStateProvider(() => {
3333
closeCreateOrganization();
3434
}
3535
}}
36-
hideSlug={hideSlug}
3736
/>
3837
</Card.Content>
3938
<Card.Footer />

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

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -80,40 +80,6 @@ describe('CreateOrganization', () => {
8080
expect(getByRole('heading', { name: 'Create organization', level: 1 })).toBeInTheDocument();
8181
});
8282

83-
describe('with `hideSlug` prop', () => {
84-
it('renders component without slug field', async () => {
85-
const { wrapper, fixtures, props } = await createFixtures(f => {
86-
f.withOrganizations();
87-
f.withUser({
88-
email_addresses: ['test@clerk.com'],
89-
});
90-
});
91-
92-
fixtures.clerk.createOrganization.mockReturnValue(
93-
Promise.resolve(
94-
getCreatedOrg({
95-
maxAllowedMemberships: 1,
96-
slug: 'new-org-1722578361',
97-
}),
98-
),
99-
);
100-
101-
props.setProps({ hideSlug: true });
102-
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, {
103-
wrapper,
104-
});
105-
106-
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument();
107-
108-
await userEvent.type(getByLabelText(/Name/i), 'new org');
109-
await userEvent.click(getByRole('button', { name: /create organization/i }));
110-
111-
await waitFor(() => {
112-
expect(queryByText(/Invite new members/i)).toBeInTheDocument();
113-
});
114-
});
115-
});
116-
11783
describe('with organization slug configured on environment', () => {
11884
it('when disabled, renders component without slug field', async () => {
11985
const { wrapper, fixtures } = await createFixtures(f => {
@@ -178,72 +144,6 @@ describe('CreateOrganization', () => {
178144
expect(queryByText(/Invite new members/i)).toBeInTheDocument();
179145
});
180146
});
181-
182-
it('when enabled and `hideSlug` prop is passed, renders component without slug field', async () => {
183-
const { wrapper, fixtures, props } = await createFixtures(f => {
184-
f.withOrganizations();
185-
f.withOrganizationSlug(true);
186-
f.withUser({
187-
email_addresses: ['test@clerk.com'],
188-
});
189-
});
190-
191-
fixtures.clerk.createOrganization.mockReturnValue(
192-
Promise.resolve(
193-
getCreatedOrg({
194-
maxAllowedMemberships: 1,
195-
slug: 'new-org-1722578361',
196-
}),
197-
),
198-
);
199-
200-
props.setProps({ hideSlug: true });
201-
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, {
202-
wrapper,
203-
});
204-
205-
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument();
206-
207-
await userEvent.type(getByLabelText(/Name/i), 'new org');
208-
await userEvent.click(getByRole('button', { name: /create organization/i }));
209-
210-
await waitFor(() => {
211-
expect(queryByText(/Invite new members/i)).toBeInTheDocument();
212-
});
213-
});
214-
215-
it('when disabled and `hideSlug` prop is passed, renders component without slug field', async () => {
216-
const { wrapper, fixtures, props } = await createFixtures(f => {
217-
f.withOrganizations();
218-
f.withOrganizationSlug(false); // Environment disables slug
219-
f.withUser({
220-
email_addresses: ['test@clerk.com'],
221-
});
222-
});
223-
224-
fixtures.clerk.createOrganization.mockReturnValue(
225-
Promise.resolve(
226-
getCreatedOrg({
227-
maxAllowedMemberships: 1,
228-
slug: 'new-org-1722578361',
229-
}),
230-
),
231-
);
232-
233-
props.setProps({ hideSlug: true });
234-
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, {
235-
wrapper,
236-
});
237-
238-
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument();
239-
240-
await userEvent.type(getByLabelText(/Name/i), 'new org');
241-
await userEvent.click(getByRole('button', { name: /create organization/i }));
242-
243-
await waitFor(() => {
244-
expect(queryByText(/Invite new members/i)).toBeInTheDocument();
245-
});
246-
});
247147
});
248148

249149
it('skips invitation screen', async () => {

packages/ui/src/components/OrganizationList/OrganizationListPage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const OrganizationListPage = withCardStateProvider(() => {
8585

8686
const OrganizationListFlows = ({ showListInitially }: { showListInitially: boolean }) => {
8787
const card = useCardState();
88-
const { navigateAfterCreateOrganization, skipInvitationScreen, hideSlug } = useOrganizationListContext();
88+
const { navigateAfterCreateOrganization, skipInvitationScreen } = useOrganizationListContext();
8989
const [isCreateOrganizationFlow, setCreateOrganizationFlow] = useState(!showListInitially);
9090
return (
9191
<>
@@ -112,7 +112,6 @@ const OrganizationListFlows = ({ showListInitially }: { showListInitially: boole
112112
onCancel={
113113
showListInitially && isCreateOrganizationFlow ? () => setCreateOrganizationFlow(false) : undefined
114114
}
115-
hideSlug={hideSlug}
116115
/>
117116
</Box>
118117
</>

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { describe, expect, it, vi } from 'vitest';
33
import { bindCreateFixtures } from '@/test/create-fixtures';
44
import { render, waitFor } from '@/test/utils';
55

6+
import { OrganizationList } from '../';
67
import { createFakeOrganization } from '../../CreateOrganization/__tests__/CreateOrganization.test';
78
import {
89
createFakeUserOrganizationInvitation,
910
createFakeUserOrganizationMembership,
1011
} from '../../OrganizationSwitcher/__tests__/test-utils';
11-
import { OrganizationList } from '../';
1212

1313
const { createFixtures } = bindCreateFixtures('OrganizationList');
1414

@@ -277,16 +277,16 @@ describe('OrganizationList', () => {
277277
});
278278
});
279279

280-
it('displays CreateOrganization without slug field', async () => {
281-
const { wrapper, props } = await createFixtures(f => {
280+
it("does not display slug field if it's disabled on environment", async () => {
281+
const { wrapper } = await createFixtures(f => {
282282
f.withOrganizations();
283+
f.withOrganizationSlug(false);
283284
f.withUser({
284285
email_addresses: ['test@clerk.com'],
285286
create_organization_enabled: true,
286287
});
287288
});
288289

289-
props.setProps({ hideSlug: true });
290290
const { findByRole, getByRole, userEvent, queryByLabelText } = render(<OrganizationList />, { wrapper });
291291

292292
await waitFor(async () =>
@@ -297,6 +297,26 @@ describe('OrganizationList', () => {
297297
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument();
298298
});
299299

300+
it("display slug field if it's enabled on environment", async () => {
301+
const { wrapper } = await createFixtures(f => {
302+
f.withOrganizations();
303+
f.withOrganizationSlug(true);
304+
f.withUser({
305+
email_addresses: ['test@clerk.com'],
306+
create_organization_enabled: true,
307+
});
308+
});
309+
310+
const { findByRole, getByRole, userEvent, queryByLabelText } = render(<OrganizationList />, { wrapper });
311+
312+
await waitFor(async () =>
313+
expect(await findByRole('menuitem', { name: 'Create organization' })).toBeInTheDocument(),
314+
);
315+
await userEvent.click(getByRole('menuitem', { name: 'Create organization' }));
316+
expect(queryByLabelText(/Name/i)).toBeInTheDocument();
317+
expect(queryByLabelText(/Slug/i)).toBeInTheDocument();
318+
});
319+
300320
it('does not display CreateOrganization within OrganizationList when disabled', async () => {
301321
const { wrapper } = await createFixtures(f => {
302322
f.withOrganizations();

packages/ui/src/components/OrganizationSwitcher/OrganizationSwitcherPopover.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export const OrganizationSwitcherPopover = React.forwardRef<HTMLDivElement, Orga
4949

5050
organizationProfileProps,
5151
skipInvitationScreen,
52-
hideSlug,
5352
} = useOrganizationSwitcherContext();
5453

5554
const { user } = useUser();
@@ -86,7 +85,7 @@ export const OrganizationSwitcherPopover = React.forwardRef<HTMLDivElement, Orga
8685
if (createOrganizationMode === 'navigation') {
8786
return navigateCreateOrganization();
8887
}
89-
return openCreateOrganization({ afterCreateOrganizationUrl, skipInvitationScreen, hideSlug });
88+
return openCreateOrganization({ afterCreateOrganizationUrl, skipInvitationScreen });
9089
};
9190

9291
const handleItemClick = () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,15 @@ describe('OrganizationSwitcher', () => {
305305
});
306306

307307
it('opens create organization without slug field', async () => {
308-
const { wrapper, fixtures, props } = await createFixtures(f => {
308+
const { wrapper, fixtures } = await createFixtures(f => {
309309
f.withOrganizations();
310+
f.withOrganizationSlug(false);
310311
f.withUser({
311312
email_addresses: ['test@clerk.com'],
312313
create_organization_enabled: true,
313314
});
314315
});
315316

316-
props.setProps({ hideSlug: true });
317317
const { getByRole, queryByLabelText, userEvent } = render(<OrganizationSwitcher />, { wrapper });
318318
await userEvent.click(getByRole('button', { name: 'Open organization switcher' }));
319319
await userEvent.click(getByRole('menuitem', { name: 'Create organization' }));

packages/ui/src/contexts/components/CreateOrganization.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const useCreateOrganizationContext = () => {
3838
return {
3939
...ctx,
4040
skipInvitationScreen: ctx.skipInvitationScreen || false,
41-
hideSlug: ctx.hideSlug || false,
4241
navigateAfterCreateOrganization,
4342
componentName,
4443
};

0 commit comments

Comments
 (0)