Skip to content

fix(types,clerk-js): Allow organization admin to leave, if there are more admins#1498

Merged
chanioxaris merged 1 commit intomainfrom
haris/org-44-allow-an-admin-to-leave-an-org-if-not-the-last-in-orgprofile
Jul 20, 2023
Merged

fix(types,clerk-js): Allow organization admin to leave, if there are more admins#1498
chanioxaris merged 1 commit intomainfrom
haris/org-44-allow-an-admin-to-leave-an-org-if-not-the-last-in-orgprofile

Conversation

@chanioxaris
Copy link
Copy Markdown
Member

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

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-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

Description

  • npm test runs as expected.
  • npm run build runs 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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 19, 2023

🦋 Changeset detected

Latest commit: c8fc6ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

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';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the right place to place a common test helper for this component

Copy link
Copy Markdown
Member

@anagstef anagstef Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that this helper is specific to this component, so it's a good place I guess.

Copy link
Copy Markdown

@jit-ci jit-ci Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Great news! Jit hasn't found any security issues in your PR. Good Job! 🏆

</OptionsProvider>
</EnvironmentProvider>
</CoreClerkContextWrapper>
<SWRConfig value={{ provider: () => new Map(), dedupingInterval: 0 }}>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 All tests seem to pass correctly, so it is good news this does not mess with anything else.

Comment thread .changeset/weak-ducks-double.md Outdated
'@clerk/clerk-js': patch
---

In <OrganizationProfile /> component, allow an admin to leave the current organization if there are more admins present.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 I think we should add reverse quotes on the element to be treated as a code in markdown, e.g.:

Suggested change
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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

Copy link
Copy Markdown
Member

@anagstef anagstef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯


const OrganizationDangerSection = () => {
const { organization, membership } = useCoreOrganization();
const { organization, membership, membershipList } = useCoreOrganization({
Copy link
Copy Markdown
Contributor

@desiprisg desiprisg Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do membershipList: adminMembershipList to be a bit clearer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!


export type GetMembershipsParams = ClerkPaginationParams;
export type GetMembershipsParams = {
role?: MembershipRole[];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this optional?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to specify the role, If it is left empty or undefined it will return memberships of any role

Copy link
Copy Markdown
Contributor

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯


export type GetMembershipsParams = ClerkPaginationParams;
export type GetMembershipsParams = {
role?: MembershipRole[];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 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.
@chanioxaris chanioxaris force-pushed the haris/org-44-allow-an-admin-to-leave-an-org-if-not-the-last-in-orgprofile branch from e02349d to c8fc6ec Compare July 20, 2023 12:41
@chanioxaris chanioxaris merged commit 808e45d into main Jul 20, 2023
@chanioxaris chanioxaris deleted the haris/org-44-allow-an-admin-to-leave-an-org-if-not-the-last-in-orgprofile branch July 20, 2023 12:54
@clerk-cookie clerk-cookie mentioned this pull request Jul 20, 2023
@clerk-cookie
Copy link
Copy Markdown
Collaborator

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.

@clerk clerk locked as resolved and limited conversation to collaborators Jul 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants