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

Construct urls based on Organization or User <OrganizationSwitcher/> #1503

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Jul 20, 2023

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.

Demo for this PR

You can test the changes of this PR in this app

  • Url changes when switching between organizations
  • after creation of an organization we are navigated to it's profile with the constructed url

@changeset-bot
Copy link

changeset-bot bot commented Jul 20, 2023

🦋 Changeset detected

Latest commit: 7017b8e

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 Patch
@clerk/types Patch
@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

@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! 🏆

@panteliselef panteliselef force-pushed the ORG-64 branch 2 times, most recently from 440127a to 043c566 Compare July 21, 2023 09:00
@panteliselef
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @panteliselef - the snapshot version command generated the following package versions:

Package Version
@clerk/backend 0.26.1-snapshot.043c566
@clerk/chrome-extension 0.3.25-snapshot.043c566
@clerk/clerk-js 4.54.2-snapshot.043c566
eslint-config-custom 0.3.0
@clerk/clerk-expo 0.18.16-snapshot.043c566
@clerk/fastify 0.6.3-snapshot.043c566
gatsby-plugin-clerk 4.4.3-snapshot.043c566
@clerk/localizations 1.23.3-snapshot.043c566
@clerk/nextjs 4.23.1-snapshot.043c566
@clerk/clerk-react 4.23.2-snapshot.043c566
@clerk/remix 2.9.1-snapshot.043c566
@clerk/clerk-sdk-node 4.12.1-snapshot.043c566
@clerk/shared 0.20.0
@clerk/themes 1.7.5
@clerk/types 3.48.2-snapshot.043c566

Tip: use the snippet copy button below to quickly install the required packages.

# @clerk/backend
npm i @clerk/backend@0.26.1-snapshot.043c566
# @clerk/chrome-extension
npm i @clerk/chrome-extension@0.3.25-snapshot.043c566
# @clerk/clerk-js
npm i @clerk/clerk-js@4.54.2-snapshot.043c566
# eslint-config-custom
npm i eslint-config-custom@0.3.0
# @clerk/clerk-expo
npm i @clerk/clerk-expo@0.18.16-snapshot.043c566
# @clerk/fastify
npm i @clerk/fastify@0.6.3-snapshot.043c566
# gatsby-plugin-clerk
npm i gatsby-plugin-clerk@4.4.3-snapshot.043c566
# @clerk/localizations
npm i @clerk/localizations@1.23.3-snapshot.043c566
# @clerk/nextjs
npm i @clerk/nextjs@4.23.1-snapshot.043c566
# @clerk/clerk-react
npm i @clerk/clerk-react@4.23.2-snapshot.043c566
# @clerk/remix
npm i @clerk/remix@2.9.1-snapshot.043c566
# @clerk/clerk-sdk-node
npm i @clerk/clerk-sdk-node@4.12.1-snapshot.043c566
# @clerk/shared
npm i @clerk/shared@0.20.0
# @clerk/themes
npm i @clerk/themes@1.7.5
# @clerk/types
npm i @clerk/types@3.48.2-snapshot.043c566

@panteliselef panteliselef changed the title [WIP] Org 64 Construct urls based on Organization or User <OrganizationSwitcher/> Jul 21, 2023
@panteliselef
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @panteliselef - the snapshot version command generated the following package versions:

Package Version
@clerk/backend 0.28.0-snapshot.a1792a4
@clerk/chrome-extension 0.3.27-snapshot.a1792a4
@clerk/clerk-js 4.56.0-snapshot.a1792a4
eslint-config-custom 0.3.0
@clerk/clerk-expo 0.18.18-snapshot.a1792a4
@clerk/fastify 0.6.4-snapshot.a1792a4
gatsby-plugin-clerk 4.4.5-snapshot.a1792a4
@clerk/localizations 1.24.2-snapshot.a1792a4
@clerk/nextjs 4.23.3-snapshot.a1792a4
@clerk/clerk-react 4.23.3-snapshot.a1792a4
@clerk/remix 2.9.2-snapshot.a1792a4
@clerk/clerk-sdk-node 4.12.3-snapshot.a1792a4
@clerk/shared 0.21.0
@clerk/themes 1.7.5
@clerk/types 3.50.0-snapshot.a1792a4

Tip: use the snippet copy button below to quickly install the required packages.

# @clerk/backend
npm i @clerk/backend@0.28.0-snapshot.a1792a4
# @clerk/chrome-extension
npm i @clerk/chrome-extension@0.3.27-snapshot.a1792a4
# @clerk/clerk-js
npm i @clerk/clerk-js@4.56.0-snapshot.a1792a4
# eslint-config-custom
npm i eslint-config-custom@0.3.0
# @clerk/clerk-expo
npm i @clerk/clerk-expo@0.18.18-snapshot.a1792a4
# @clerk/fastify
npm i @clerk/fastify@0.6.4-snapshot.a1792a4
# gatsby-plugin-clerk
npm i gatsby-plugin-clerk@4.4.5-snapshot.a1792a4
# @clerk/localizations
npm i @clerk/localizations@1.24.2-snapshot.a1792a4
# @clerk/nextjs
npm i @clerk/nextjs@4.23.3-snapshot.a1792a4
# @clerk/clerk-react
npm i @clerk/clerk-react@4.23.3-snapshot.a1792a4
# @clerk/remix
npm i @clerk/remix@2.9.2-snapshot.a1792a4
# @clerk/clerk-sdk-node
npm i @clerk/clerk-sdk-node@4.12.3-snapshot.a1792a4
# @clerk/shared
npm i @clerk/shared@0.21.0
# @clerk/themes
npm i @clerk/themes@1.7.5
# @clerk/types
npm i @clerk/types@3.50.0-snapshot.a1792a4

packages/types/src/clerk.ts Outdated Show resolved Hide resolved
packages/types/src/clerk.ts Outdated Show resolved Hide resolved
packages/types/src/clerk.ts Show resolved Hide resolved
return urlWithParam;
};

const parse = createDynamicParamParser({ regex: /:(\w+)/ });
Copy link
Member

Choose a reason for hiding this comment

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

❓ Do we have a need for multiple parsers right now? If not, I'd prefer a more explicit/simple approach with a more explicit name for the parse function.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do like having the createDynamicParamParser util here. I renamed it to populateParamFromObject

Copy link
Member

Choose a reason for hiding this comment

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

Okay! Can we move it to its own file and write a couple of unit tests covering it? I see the tests for ClerkUIComponentsContext but lets include a few tests to better document this one :)

const navigateAfterSwitchOrganization = () =>
ctx.afterSwitchOrganizationUrl ? navigate(ctx.afterSwitchOrganizationUrl) : Promise.resolve();

const navigateAfterSwitchOrganization = ({
Copy link
Member

Choose a reason for hiding this comment

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

Are we going to keep the internal name or should we rename this to navigateAfterSelectOrganization?

Copy link
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 that would be helpful.

If we split this to 2 function then we are exposing the conditional logic inside of handlePersonalWorkspaceClicked in order to have the same result. If in any case we want to create more than 2 handlePersonalWorkspaceClicked functions in more than 2 components this will result to more duplicate code.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry If I wasn't clear - I'm just saying that we probably want to rename this to better match the new public API

Copy link
Member

@nikosdouvlis nikosdouvlis left a comment

Choose a reason for hiding this comment

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

Good job @panteliselef :)
Added an extra comment but approved!

…rganizationSwitcher/>

+ Introduces dynamicParamParser (+tests)
+ Add types for functions and string literals in OrganizationSwitcherProps & CreateOrganizationProps
+ afterSelectPersonalUrl & afterSelectOrganizationUrl
@panteliselef panteliselef merged commit 52ce791 into main Aug 8, 2023
8 checks passed
@panteliselef panteliselef deleted the ORG-64 branch August 8, 2023 10:20
@clerk-cookie clerk-cookie mentioned this pull request Aug 8, 2023
@clerk-cookie
Copy link
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 Aug 8, 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.

3 participants