Skip to content

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

Merged
panteliselef merged 8 commits intomainfrom
elef/CORE-383-fetch-roles
Nov 3, 2023
Merged

feat(clerk-js,types): Fetch custom roles and localize them#2004
panteliselef merged 8 commits intomainfrom
elef/CORE-383-fetch-roles

Conversation

@panteliselef
Copy link
Copy Markdown
Contributor

@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 a team and chanioxaris November 1, 2023 13:46
@panteliselef panteliselef self-assigned this Nov 1, 2023
@changeset-bot
Copy link
Copy Markdown

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
Copy Markdown
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
Comment thread packages/clerk-js/src/ui/components/OrganizationProfile/ActiveMembersList.tsx Outdated
@panteliselef
Copy link
Copy Markdown
Contributor Author

!snapshot

Copy link
Copy Markdown
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?

Comment thread packages/types/src/permission.ts Outdated
Comment thread packages/types/src/organizationMembership.ts
Comment thread packages/types/src/organization.ts
*/
roles: {
[r: string]: LocalizationValue;
};
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.

nice!

Comment thread packages/clerk-js/src/ui/components/OrganizationProfile/MemberListTable.tsx Outdated
Comment thread packages/clerk-js/src/ui/components/OrganizationProfile/MemberListTable.tsx Outdated
@panteliselef
Copy link
Copy Markdown
Contributor 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
Comment thread packages/clerk-js/src/ui/hooks/useFetch.ts Outdated
@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
@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