Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clerk-js,types): Fetch custom roles and localize them #2004

Merged
merged 8 commits into from
Nov 3, 2023

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Nov 1, 2023

Description

This PR

  • Introduces RoleResource and PermissionResource.
  • Updates RoleSelect to accept roles as a prop.
  • Fetch custom roles from FAPI inside InviteMembersPage & ActiveMembers.
  • Accept custom localizations based on role key when this is passed in the localization object via ClerkProvider.

This PR will need to backported to v4 as it is complementary to "custom roles & permissions"

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

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

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

@panteliselef panteliselef requested review from chanioxaris and a team November 1, 2023 13:46
@panteliselef panteliselef self-assigned this Nov 1, 2023
Copy link

changeset-bot bot commented Nov 1, 2023

🦋 Changeset detected

Latest commit: bc8b4d6

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

This PR includes changesets to release 12 packages
Name Type
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/backend Patch
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/clerk-sdk-node 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

Copy link
Member

@chanioxaris chanioxaris left a comment

Choose a reason for hiding this comment

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

Let's add to any newly introduced resource and type the experimental tag as the feature is currently under active development

@panteliselef panteliselef force-pushed the elef/CORE-383-fetch-roles branch 2 times, most recently from cbe3aea to a83fa63 Compare November 2, 2023 09:17
@panteliselef
Copy link
Member Author

!snapshot

Copy link
Contributor

@dimkl dimkl left a comment

Choose a reason for hiding this comment

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

☁️ I will approve this PR since i don't have the context of this feature but i am kind of thinking that i will have a performance impact for all customers. Based on the test changes with this PR we introduce an API call in each of the the following components loading. Shouldn't we somehow make that call only for the customers that have the custom roles feature enabled or is it by default enabled for all customers?

packages/types/src/permission.ts Outdated Show resolved Hide resolved
packages/types/src/organizationMembership.ts Show resolved Hide resolved
packages/types/src/organization.ts Show resolved Hide resolved
*/
roles: {
[r: string]: LocalizationValue;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

@panteliselef
Copy link
Member Author

☁️ I will approve this PR since i don't have the context of this feature but i am kind of thinking that i will have a performance impact for all customers. Based on the test changes with this PR we introduce an API call in each of the the following components loading. Shouldn't we somehow make that call only for the customers that have the custom roles feature enabled or is it by default enabled for all customers?

Custom roles comes with the organization feature, every app from now on should fetch the roles as they are introduced dynamically per instance and stored in the DB. The "legacy" roles that continue to exist in the database are only there until FAPI starts serving all of our clients with custom roles.

@panteliselef panteliselef force-pushed the elef/CORE-383-fetch-roles branch from 0d465db to faac9bf Compare November 3, 2023 10:34
@panteliselef panteliselef force-pushed the elef/CORE-383-fetch-roles branch 2 times, most recently from ba188b6 to d4c7861 Compare November 3, 2023 13:55
@panteliselef panteliselef force-pushed the elef/CORE-383-fetch-roles branch from d4c7861 to bc8b4d6 Compare November 3, 2023 17:03
@panteliselef panteliselef added this pull request to the merge queue Nov 3, 2023
Merged via the queue into main with commit 0293f29 Nov 3, 2023
8 checks passed
@panteliselef panteliselef deleted the elef/CORE-383-fetch-roles branch November 3, 2023 17:26
panteliselef added a commit that referenced this pull request Nov 3, 2023
* feat(clerk-js,types): Fetch custom roles and localize them

* test(clerk-js): Fetch custom roles and localize them

* feat(clerk-js,types): Create PermissionResource

* chore(clerk-js): Add changeset

* chore(clerk-js): Add experimental tags

* test(clerk-js): Add test case for displaying custom roles in select menu

* chore(clerk-js): Improve types & add comments

* chore(clerk-js): Address PR comments

(cherry picked from commit 0293f29)
github-merge-queue bot pushed a commit that referenced this pull request Nov 3, 2023
…2039)

* feat(clerk-js,types): Fetch custom roles and localize them

* test(clerk-js): Fetch custom roles and localize them

* feat(clerk-js,types): Create PermissionResource

* chore(clerk-js): Add changeset

* chore(clerk-js): Add experimental tags

* test(clerk-js): Add test case for displaying custom roles in select menu

* chore(clerk-js): Improve types & add comments

* chore(clerk-js): Address PR comments

(cherry picked from commit 0293f29)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants