-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement organization creation permission controls (#1373)
* feat(clerk-js): Hide 'create organization' button in org switcher if no permissions
- Loading branch information
Showing
8 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@clerk/clerk-js': minor | ||
'@clerk/types': minor | ||
--- | ||
|
||
If user does not have permission to create an org, create org button will not display in the OrganizationSwitcher UI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ describe('OrganizationSwitcher', () => { | |
it('opens the organization switcher popover when clicked', async () => { | ||
const { wrapper, props } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ email_addresses: ['[email protected]'] }); | ||
f.withUser({ email_addresses: ['[email protected]'], create_organization_enabled: true }); | ||
}); | ||
props.setProps({ hidePersonal: true }); | ||
const { getByText, getByRole, userEvent } = render(<OrganizationSwitcher />, { wrapper }); | ||
|
@@ -107,6 +107,7 @@ describe('OrganizationSwitcher', () => { | |
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
organization_memberships: [{ name: 'Org1', role: 'basic_member' }], | ||
create_organization_enabled: true, | ||
}); | ||
}); | ||
props.setProps({ hidePersonal: true }); | ||
|
@@ -116,6 +117,20 @@ describe('OrganizationSwitcher', () => { | |
expect(fixtures.clerk.openCreateOrganization).toHaveBeenCalled(); | ||
}); | ||
|
||
it('does not display create organization button if permissions not present', async () => { | ||
const { wrapper, props } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
organization_memberships: [{ name: 'Org1', role: 'basic_member' }], | ||
create_organization_enabled: false, | ||
}); | ||
}); | ||
props.setProps({ hidePersonal: true }); | ||
const { queryByRole } = render(<OrganizationSwitcher />, { wrapper }); | ||
expect(queryByRole('button', { name: 'Create Organization' })).not.toBeInTheDocument(); | ||
}); | ||
|
||
it.todo('switches between active organizations when one is clicked'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters