Skip to content

Commit 4b299d5

Browse files
authored
Merge branch 'main' into nikos/migrate-types-to-shared
2 parents bbc3738 + e653a58 commit 4b299d5

File tree

10 files changed

+98
-8
lines changed

10 files changed

+98
-8
lines changed

.changeset/gold-planes-wear.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

integration/tests/middleware-placement.test.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,31 @@ function parseSemverMajor(range?: string): number | undefined {
1515
return match ? Number.parseInt(match[0], 10) : undefined;
1616
}
1717

18-
async function detectNext(app: Application): Promise<{ isNext: boolean; version?: string }> {
18+
/**
19+
* Detects the installed Next.js version for a given application.
20+
* Reads the version from node_modules/next/package.json to ensure
21+
* we get the actual installed version rather than a tag like "latest" or "canary".
22+
*/
23+
async function detectNext(app: Application): Promise<{ version: string | undefined | null }> {
1924
// app.appDir exists for normal Application; for long-running apps, read it from the state file by serverUrl
2025
const appDir =
2126
(app as any).appDir ||
2227
Object.values(stateFile.getLongRunningApps() || {}).find(a => a.serverUrl === app.serverUrl)?.appDir;
2328

2429
if (!appDir) {
25-
return { isNext: false };
30+
return { version: null };
2631
}
2732

28-
const pkg = await fs.readJSON(path.join(appDir, 'package.json'));
29-
const nextRange: string | undefined = pkg.dependencies?.next || pkg.devDependencies?.next;
33+
let installedVersion: string | undefined;
34+
try {
35+
const nextPkg = await fs.readJSON(path.join(appDir, 'node_modules', 'next', 'package.json'));
36+
installedVersion = String(nextPkg?.version || '');
37+
} catch {
38+
// ignore
39+
}
3040

31-
return { isNext: Boolean(nextRange), version: nextRange };
41+
console.log('---detectNext---', installedVersion);
42+
return { version: installedVersion };
3243
}
3344

3445
const middlewareFileContents = `

packages/chrome-extension/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## 2.7.10
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`3410bc6`](https://github.com/clerk/javascript/commit/3410bc6f85d1d87c9ed35c9aa4ec764a684cc4ec)]:
8+
- @clerk/clerk-js@5.103.1
9+
310
## 2.7.9
411

512
### Patch Changes

packages/chrome-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@clerk/chrome-extension",
3-
"version": "2.7.9",
3+
"version": "2.7.10",
44
"description": "Clerk SDK for Chrome extensions",
55
"keywords": [
66
"auth",

packages/clerk-js/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## 5.103.1
4+
5+
### Patch Changes
6+
7+
- Bring back OrgPreview within the OrgSwitcher component ([#7091](https://github.com/clerk/javascript/pull/7091)) by [@alexcarpenter](https://github.com/alexcarpenter)
8+
39
## 5.103.0
410

511
### Minor Changes

packages/clerk-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@clerk/clerk-js",
3-
"version": "5.103.0",
3+
"version": "5.103.1",
44
"description": "Clerk JS library",
55
"keywords": [
66
"clerk",

packages/clerk-js/src/ui/components/OrganizationSwitcher/OrganizationSwitcherTrigger.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useOrganization, useOrganizationList, useUser } from '@clerk/shared/react';
22
import { forwardRef } from 'react';
33

4+
import { OrganizationPreview } from '@/ui/elements/OrganizationPreview';
45
import { PersonalWorkspacePreview } from '@/ui/elements/PersonalWorkspacePreview';
56
import { withAvatarShimmer } from '@/ui/elements/withAvatarShimmer';
67

@@ -51,6 +52,16 @@ export const OrganizationSwitcherTrigger = withAvatarShimmer(
5152
aria-haspopup='dialog'
5253
{...rest}
5354
>
55+
{organization && (
56+
<OrganizationPreview
57+
elementId={'organizationSwitcherTrigger'}
58+
gap={3}
59+
size='xs'
60+
organization={organization}
61+
sx={{ maxWidth: '30ch' }}
62+
/>
63+
)}
64+
5465
{!organization && (
5566
<PersonalWorkspacePreview
5667
size='xs'

packages/clerk-js/src/ui/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,52 @@ describe('OrganizationSwitcher', () => {
6262
});
6363

6464
describe('OrganizationSwitcherTrigger', () => {
65+
it('shows OrganizationPreview when user has an active organization', async () => {
66+
const { wrapper, fixtures } = await createFixtures(f => {
67+
f.withOrganizations();
68+
f.withUser({
69+
email_addresses: ['[email protected]'],
70+
organization_memberships: [{ name: 'Test Organization', id: '1', role: 'admin' }],
71+
});
72+
});
73+
74+
// Set the active organization in the context
75+
fixtures.clerk.organization = {
76+
id: '1',
77+
name: 'Test Organization',
78+
slug: 'test-organization',
79+
membersCount: 1,
80+
pendingInvitationsCount: 0,
81+
adminDeleteEnabled: true,
82+
maxAllowedMemberships: 100,
83+
} as any;
84+
85+
const { getByText } = render(<OrganizationSwitcher />, { wrapper });
86+
expect(getByText('Test Organization')).toBeInTheDocument();
87+
});
88+
89+
it('shows PersonalWorkspacePreview when user has no active organization and hidePersonal is false', async () => {
90+
const { wrapper, props } = await createFixtures(f => {
91+
f.withOrganizations();
92+
f.withUser({ email_addresses: ['[email protected]'] });
93+
});
94+
95+
props.setProps({ hidePersonal: false });
96+
const { getByText } = render(<OrganizationSwitcher />, { wrapper });
97+
expect(getByText('Personal account')).toBeInTheDocument();
98+
});
99+
100+
it('shows "No organization selected" when user has no active organization and hidePersonal is true', async () => {
101+
const { wrapper, props } = await createFixtures(f => {
102+
f.withOrganizations();
103+
f.withUser({ email_addresses: ['[email protected]'] });
104+
});
105+
106+
props.setProps({ hidePersonal: true });
107+
const { getByText } = render(<OrganizationSwitcher />, { wrapper });
108+
expect(getByText('No organization selected')).toBeInTheDocument();
109+
});
110+
65111
it('shows the counter for pending suggestions and invitations', async () => {
66112
const { wrapper, fixtures } = await createFixtures(f => {
67113
f.withOrganizations();

packages/expo/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## 2.17.3
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`3410bc6`](https://github.com/clerk/javascript/commit/3410bc6f85d1d87c9ed35c9aa4ec764a684cc4ec)]:
8+
- @clerk/clerk-js@5.103.1
9+
310
## 2.17.2
411

512
### Patch Changes

packages/expo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@clerk/clerk-expo",
3-
"version": "2.17.2",
3+
"version": "2.17.3",
44
"description": "Clerk React Native/Expo library",
55
"keywords": [
66
"react",

0 commit comments

Comments
 (0)