Skip to content

Commit d12d87f

Browse files
committed
refactor(platform): ask whether a held workspace tab is shown in its own page
The workspace layout reads workspace-tab-flags for the tab bar, so a runtime import there grew every workspace page's server graph past its baseline. The five held pages now ask isWorkspaceTabShown themselves.
1 parent ecddcdf commit d12d87f

6 files changed

Lines changed: 21 additions & 20 deletions

File tree

‎apps/sim/app/(product)/workspace/[workspaceId]/changelog/[entryId]/page.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { workspacePath } from '@/lib/navigation/paths'
44
import { ChangelogDetails } from '@/app/(product)/workspace/[workspaceId]/changelog/_components/changelog-details/changelog-details'
55
import { platformHref, readScenario } from '@/platform/lib/navigation'
66
import type { ProductPageProps } from '@/platform/lib/route-props'
7+
import { isWorkspaceTabShown } from '@/platform/lib/workspace-navigation'
78
import { withChangelogView } from '@/platform/lib/workspace-views'
89

910
export const metadata: Metadata = { title: 'Changelog' }
@@ -29,12 +30,13 @@ export default async function Page({
2930
if (!entry) notFound()
3031
return <ChangelogDetails entry={entry} back={back} />
3132
}
32-
const [{ readWorkspaceTabShown }, { LiveRelease }] = await Promise.all([
33+
const [{ readWorkspaceTabFlags }, { LiveRelease }] = await Promise.all([
3334
import('@/platform/lib/data/workspace-tab-flags'),
3435
import(
3536
'@/app/(product)/workspace/[workspaceId]/changelog/_components/live-release/live-release'
3637
),
3738
])
38-
if (!(await readWorkspaceTabShown('changelog'))) notFound()
39+
// A tab live data does not list has no page.
40+
if (!isWorkspaceTabShown('changelog', await readWorkspaceTabFlags())) notFound()
3941
return <LiveRelease workspaceId={workspaceId} releaseId={id} back={back} />
4042
}

‎apps/sim/app/(product)/workspace/[workspaceId]/changelog/page.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Metadata } from 'next'
22
import { notFound } from 'next/navigation'
33
import { readScenario } from '@/platform/lib/navigation'
44
import type { ProductPageProps } from '@/platform/lib/route-props'
5+
import { isWorkspaceTabShown } from '@/platform/lib/workspace-navigation'
56

67
export const metadata: Metadata = { title: 'Changelog' }
78

@@ -25,12 +26,13 @@ export default async function Page({
2526
if (!data) notFound()
2627
return <ChangelogRoute data={data} />
2728
}
28-
const [{ readWorkspaceTabShown }, { LiveChangelog }] = await Promise.all([
29+
const [{ readWorkspaceTabFlags }, { LiveChangelog }] = await Promise.all([
2930
import('@/platform/lib/data/workspace-tab-flags'),
3031
import(
3132
'@/app/(product)/workspace/[workspaceId]/changelog/_components/live-changelog/live-changelog'
3233
),
3334
])
34-
if (!(await readWorkspaceTabShown('changelog'))) notFound()
35+
// A tab live data does not list has no page.
36+
if (!isWorkspaceTabShown('changelog', await readWorkspaceTabFlags())) notFound()
3537
return <LiveChangelog workspaceId={workspaceId} />
3638
}

‎apps/sim/app/(product)/workspace/[workspaceId]/dashboards/page.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Metadata } from 'next'
22
import { notFound } from 'next/navigation'
33
import { readScenario } from '@/platform/lib/navigation'
44
import type { ProductPageProps } from '@/platform/lib/route-props'
5+
import { isWorkspaceTabShown } from '@/platform/lib/workspace-navigation'
56

67
export const metadata: Metadata = { title: 'Dashboard' }
78

@@ -25,10 +26,11 @@ export default async function Page({
2526
if (!data) notFound()
2627
return <DashboardRoute data={data} />
2728
}
28-
const [{ readWorkspaceTabShown }, { LiveDashboard }] = await Promise.all([
29+
const [{ readWorkspaceTabFlags }, { LiveDashboard }] = await Promise.all([
2930
import('@/platform/lib/data/workspace-tab-flags'),
3031
import('@/app/(product)/_components/workspace/dashboards/live-dashboard/live-dashboard'),
3132
])
32-
if (!(await readWorkspaceTabShown('dashboards'))) notFound()
33+
// A tab live data does not list has no page.
34+
if (!isWorkspaceTabShown('dashboards', await readWorkspaceTabFlags())) notFound()
3335
return <LiveDashboard workspaceId={workspaceId} />
3436
}

‎apps/sim/app/(product)/workspace/[workspaceId]/tests/[name]/page.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from 'next'
22
import { notFound } from 'next/navigation'
33
import { resolvePlatformMode } from '@/platform/lib/data/mode'
4+
import { isWorkspaceTabShown } from '@/platform/lib/workspace-navigation'
45

56
export const metadata: Metadata = { title: 'Test' }
67

@@ -13,11 +14,12 @@ export default async function Page({
1314
params: Promise<{ workspaceId: string; name: string }>
1415
}) {
1516
if (resolvePlatformMode() !== 'live') notFound()
16-
const [{ workspaceId, name }, { readWorkspaceTabShown }, { TestDetails }] = await Promise.all([
17+
const [{ workspaceId, name }, { readWorkspaceTabFlags }, { TestDetails }] = await Promise.all([
1718
params,
1819
import('@/platform/lib/data/workspace-tab-flags'),
1920
import('@/app/(product)/workspace/[workspaceId]/tests/_components/test-details/test-details'),
2021
])
21-
if (!(await readWorkspaceTabShown('tests'))) notFound()
22+
// A tab live data does not list has no page.
23+
if (!isWorkspaceTabShown('tests', await readWorkspaceTabFlags())) notFound()
2224
return <TestDetails key={name} workspaceId={workspaceId} name={decodeURIComponent(name)} />
2325
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from 'next'
22
import { notFound } from 'next/navigation'
33
import { resolvePlatformMode } from '@/platform/lib/data/mode'
4+
import { isWorkspaceTabShown } from '@/platform/lib/workspace-navigation'
45

56
export const metadata: Metadata = { title: 'Tests' }
67

@@ -9,11 +10,12 @@ export const dynamic = 'force-dynamic'
910

1011
export default async function Page({ params }: { params: Promise<{ workspaceId: string }> }) {
1112
if (resolvePlatformMode() !== 'live') notFound()
12-
const [{ workspaceId }, { readWorkspaceTabShown }, { TestList }] = await Promise.all([
13+
const [{ workspaceId }, { readWorkspaceTabFlags }, { TestList }] = await Promise.all([
1314
params,
1415
import('@/platform/lib/data/workspace-tab-flags'),
1516
import('@/app/(product)/workspace/[workspaceId]/tests/_components/test-list/test-list'),
1617
])
17-
if (!(await readWorkspaceTabShown('tests'))) notFound()
18+
// A tab live data does not list has no page.
19+
if (!isWorkspaceTabShown('tests', await readWorkspaceTabFlags())) notFound()
1820
return <TestList workspaceId={workspaceId} />
1921
}
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import 'server-only'
22
import { readOrganizationSurface } from '@/platform/lib/data/surface'
3-
import {
4-
isWorkspaceTabShown,
5-
type WorkspaceTab,
6-
type WorkspaceTabFlags,
7-
} from '@/platform/lib/workspace-navigation'
3+
import type { WorkspaceTabFlags } from '@/platform/lib/workspace-navigation'
84

95
/**
106
* The flags the workspace tabs depend on, from the surface the shell already read in this request.
@@ -21,8 +17,3 @@ export async function readWorkspaceTabFlags(): Promise<WorkspaceTabFlags> {
2117
'platform-preview': featureFlags['platform-preview'],
2218
}
2319
}
24-
25-
/** Whether live data lists `section` for the viewer, so a page whose tab is not shown answers 404. */
26-
export async function readWorkspaceTabShown(section: WorkspaceTab): Promise<boolean> {
27-
return isWorkspaceTabShown(section, await readWorkspaceTabFlags())
28-
}

0 commit comments

Comments
 (0)