fix(types,clerk-js): Allow organization admin to leave, if there are more admins#1498
Conversation
🦋 Changeset detectedLatest commit: c8fc6ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| @@ -0,0 +1,35 @@ | |||
| import type { MembershipRole, OrganizationMembershipResource, OrganizationResource } from '@clerk/types'; | |||
There was a problem hiding this comment.
Not sure if this is the right place to place a common test helper for this component
There was a problem hiding this comment.
I can see that this helper is specific to this component, so it's a good place I guess.
| </OptionsProvider> | ||
| </EnvironmentProvider> | ||
| </CoreClerkContextWrapper> | ||
| <SWRConfig value={{ provider: () => new Map(), dedupingInterval: 0 }}> |
There was a problem hiding this comment.
We were forced to wrap our test fixture with a SWR config, as swr uses a global cache for tests and there is no easy way to clear it before every test. This lead to use the same initial response when mocking a method organizations.getMemberships() in our case and every test expect the first one to fail
Related issue
There was a problem hiding this comment.
💯 All tests seem to pass correctly, so it is good news this does not mess with anything else.
| '@clerk/clerk-js': patch | ||
| --- | ||
|
|
||
| In <OrganizationProfile /> component, allow an admin to leave the current organization if there are more admins present. |
There was a problem hiding this comment.
🙃 I think we should add reverse quotes on the element to be treated as a code in markdown, e.g.:
| In <OrganizationProfile /> component, allow an admin to leave the current organization if there are more admins present. | |
| In `<OrganizationProfile />` component, allow an admin to leave the current organization if there are more admins present. |
|
|
||
| const OrganizationDangerSection = () => { | ||
| const { organization, membership } = useCoreOrganization(); | ||
| const { organization, membership, membershipList } = useCoreOrganization({ |
There was a problem hiding this comment.
can we do membershipList: adminMembershipList to be a bit clearer?
|
|
||
| export type GetMembershipsParams = ClerkPaginationParams; | ||
| export type GetMembershipsParams = { | ||
| role?: MembershipRole[]; |
There was a problem hiding this comment.
You don't have to specify the role, If it is left empty or undefined it will return memberships of any role
|
|
||
| export type GetMembershipsParams = ClerkPaginationParams; | ||
| export type GetMembershipsParams = { | ||
| role?: MembershipRole[]; |
There was a problem hiding this comment.
You don't have to specify the role, If it is left empty or undefined it will return memberships of any role
| </OptionsProvider> | ||
| </EnvironmentProvider> | ||
| </CoreClerkContextWrapper> | ||
| <SWRConfig value={{ provider: () => new Map(), dedupingInterval: 0 }}> |
There was a problem hiding this comment.
💯 All tests seem to pass correctly, so it is good news this does not mess with anything else.
…more admins This commit fixes a bug in our <OrganizationProfile /> component where an admin couldn't leave the organization even though there were more org admins present.
e02349d to
c8fc6ec
Compare
|
This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Type of change
Packages affected
@clerk/clerk-js@clerk/clerk-react@clerk/nextjs@clerk/remix@clerk/types@clerk/themes@clerk/localizations@clerk/clerk-expo@clerk/backend@clerk/clerk-sdk-node@clerk/shared@clerk/fastify@clerk/chrome-extensiongatsby-plugin-clerkbuild/tooling/choreDescription
npm testruns as expected.npm run buildruns as expected.This commit fixes a bug in our component where an admin couldn't leave the organization even though there were more org admins present.