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

🚨2️⃣[ORG-59] List invitations in <OrganizationSwitcher /> #1554

Merged
merged 11 commits into from
Aug 10, 2023

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Aug 4, 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.

In order to display this list we introduced the following:

  • useInView a minor hook wrapper on top of IntersectionObserver
 // use the ref to track an element
  const { ref } = useInView({
    threshold: 0,
    onChange: inView => {
      if (inView) {
       // When the element is visible fetch the next page
        void userInvitations.fetchNext?.();
      }
    },
  });

Result (Photo)

image

@panteliselef panteliselef self-assigned this Aug 4, 2023
@changeset-bot
Copy link

changeset-bot bot commented Aug 4, 2023

🦋 Changeset detected

Latest commit: 386ce2e

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

This PR includes changesets to release 12 packages
Name Type
@clerk/localizations Patch
@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/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.

❌ The following Jit checks failed to run:

  • secret-detection

#jit_bypass_commit in this PR to bypass, Jit Admin privileges required.

More info in the Jit platform.

@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.59e2549
@clerk/chrome-extension 0.3.27-snapshot.59e2549
@clerk/clerk-js 4.56.0-snapshot.59e2549
eslint-config-custom 0.3.0
@clerk/clerk-expo 0.18.18-snapshot.59e2549
@clerk/fastify 0.6.4-snapshot.59e2549
gatsby-plugin-clerk 4.4.5-snapshot.59e2549
@clerk/localizations 1.24.2-snapshot.59e2549
@clerk/nextjs 4.23.3-snapshot.59e2549
@clerk/clerk-react 4.24.0-snapshot.59e2549
@clerk/remix 2.9.2-snapshot.59e2549
@clerk/clerk-sdk-node 4.12.3-snapshot.59e2549
@clerk/shared 0.22.0-snapshot.59e2549
@clerk/themes 1.7.5
@clerk/types 3.50.0-snapshot.59e2549

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

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

@panteliselef panteliselef changed the title [ORG-59] List invitations in <OrganizationSwitcher /> 🚫2️⃣[ORG-59] List invitations in <OrganizationSwitcher /> Aug 9, 2023
@clerk-cookie clerk-cookie removed the react label Aug 9, 2023
@panteliselef panteliselef changed the title 🚫2️⃣[ORG-59] List invitations in <OrganizationSwitcher /> 🚨2️⃣[ORG-59] List invitations in <OrganizationSwitcher /> Aug 9, 2023
@panteliselef panteliselef marked this pull request as ready for review August 9, 2023 13:06
Copy link
Member

@BRKalow BRKalow left a comment

Choose a reason for hiding this comment

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

Looking good! I don't have a ton of context here, but left a high-level review.

packages/clerk-js/src/ui/hooks/useInView.ts Outdated Show resolved Hide resolved
packages/clerk-js/src/ui/hooks/useInView.ts Outdated Show resolved Hide resolved
@@ -350,7 +350,7 @@ export interface UserOrganizationInvitationJSON extends ClerkResourceJSON {
public_organization_data: {
id: string;
name: string;
slug: string;
slug: string | null;
Copy link
Member

Choose a reason for hiding this comment

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

❓ Why did we have to change this type?

Copy link
Member Author

Choose a reason for hiding this comment

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

Some reason as bellow 👇

@@ -25,7 +25,7 @@ export interface UserOrganizationInvitationResource extends ClerkResource {
imageUrl: string;
name: string;
id: string;
slug: string;
slug: string | null;
Copy link
Member

Choose a reason for hiding this comment

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

❓ Why did we have to change this type?

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 didn't properly type this one. Organizations have a slug of string | null so the slug of UserOrganizationInvitationResource needs to match that

Copy link
Contributor

Choose a reason for hiding this comment

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

@panteliselef, @desiprisg since the response of the BAPI/FAPI is defined as slug: string i think we should update the type to have it the same.
If there are cases where the Organization type is used as part of a request param, I would suggest we update it to another type to avoid confusion.
Do you think the refactoring is feasible or am i missing something? If you agree with my suggestion could you open a ticket to refactor this?

packages/clerk-js/src/ui/hooks/useInView.ts Show resolved Hide resolved
packages/clerk-js/src/ui/hooks/useInView.ts Show resolved Hide resolved
@panteliselef panteliselef force-pushed the ORG-59_switcher branch 2 times, most recently from 2e78889 to 8a48c3f Compare August 10, 2023 07:01
Copy link
Contributor

@SokratisVidros SokratisVidros left a comment

Choose a reason for hiding this comment

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

@panteliselef I am accepting this for now but we should add a mental note to add list virtualization to every list in ClerkJS components.

@panteliselef panteliselef merged commit 09bfb79 into main Aug 10, 2023
8 checks passed
@panteliselef panteliselef deleted the ORG-59_switcher branch August 10, 2023 09:18
@clerk-cookie clerk-cookie mentioned this pull request Aug 10, 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 28, 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