Skip to content

Commit e48d768

Browse files
committed
move dataspace features under the feature flag
1 parent 0f595d8 commit e48d768

File tree

4 files changed

+39
-24
lines changed

4 files changed

+39
-24
lines changed

app/[locale]/dashboard/[entityType]/[entitySlug]/layout.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import React from 'react';
4-
import { useParams } from 'next/navigation';
4+
import { notFound, useParams } from 'next/navigation';
55
import { SidebarNavItem } from '@/types';
66

77
import { cn } from '@/lib/utils';
@@ -16,9 +16,15 @@ interface DashboardLayoutProps {
1616

1717
export default function OrgDashboardLayout({ children }: DashboardLayoutProps) {
1818
const [isOpened, setIsOpened] = React.useState(false);
19-
2019
const params = useParams<{ entityType: string; entitySlug: string }>();
2120

21+
if (
22+
process.env.NEXT_PUBLIC_DATASPACE_FEATURE_ENABLED !== 'true' &&
23+
params.entityType === 'dataspace'
24+
) {
25+
return notFound();
26+
}
27+
2228
const orgSidebarNav: Array<SidebarNavItem> = [
2329
{
2430
title: 'Datasets',
@@ -32,8 +38,6 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) {
3238
},
3339
];
3440

35-
const entitySlug = params.entitySlug;
36-
3741
return (
3842
<>
3943
<BreadCrumbs
@@ -55,7 +59,7 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) {
5559
' bg-surfaceDefault p-4 md:flex'
5660
)}
5761
>
58-
<DashboardNav items={orgSidebarNav} entitySlug={entitySlug} />
62+
<DashboardNav items={orgSidebarNav} entitySlug={params.entitySlug} />
5963

6064
<div className="z-1 basis-2 md:hidden">
6165
<MobileDashboardNav

app/[locale]/dashboard/[entityType]/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import Image from 'next/image';
44
import Link from 'next/link';
5-
import { useParams, usePathname } from 'next/navigation';
5+
import { notFound, useParams, usePathname } from 'next/navigation';
66
import { useQuery } from '@tanstack/react-query';
77
import { Icon, Text } from 'opub-ui';
88

@@ -58,6 +58,13 @@ const Page = () => {
5858
)
5959
);
6060

61+
if (
62+
process.env.NEXT_PUBLIC_DATASPACE_FEATURE_ENABLED !== 'true' &&
63+
params.entityType === 'dataspace'
64+
) {
65+
return notFound();
66+
}
67+
6168
return (
6269
<div className=" bg-surfaceDefault">
6370
<div>

app/[locale]/dashboard/components/dashboard-header.tsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ export function DashboardHeader({ currentPath }: { currentPath: string }) {
99
selected: currentPath.indexOf('user') >= 0,
1010
disabled: false,
1111
},
12-
{
13-
label: 'My Data Spaces',
14-
url: `/dashboard/dataspace`,
15-
selected: currentPath.indexOf('dataspace') >= 0,
16-
disabled: false,
17-
},
12+
process.env.NEXT_PUBLIC_DATASPACE_FEATURE_ENABLED === 'true'
13+
? {
14+
label: 'My Data Spaces',
15+
url: `/dashboard/dataspace`,
16+
selected: currentPath.indexOf('dataspace') >= 0,
17+
disabled: false,
18+
}
19+
: null,
1820
{
1921
label: 'My Organizations',
2022
url: `/dashboard/organization`,
@@ -29,7 +31,7 @@ export function DashboardHeader({ currentPath }: { currentPath: string }) {
2931
};
3032

3133
const initialTabLabel =
32-
userDashboardOptions.find((option) => option.selected)?.label ||
34+
userDashboardOptions.find((option) => option?.selected)?.label ||
3335
'My Datasets';
3436

3537
return (
@@ -41,16 +43,18 @@ export function DashboardHeader({ currentPath }: { currentPath: string }) {
4143
<div>
4244
<Tabs defaultValue={initialTabLabel}>
4345
<TabList fitted>
44-
{userDashboardOptions.map((item, index) => (
45-
<Tab
46-
value={item.label}
47-
key={index}
48-
onClick={() => handleTabClick(item.url)}
49-
disabled={item.disabled}
50-
>
51-
{item.label}
52-
</Tab>
53-
))}
46+
{userDashboardOptions
47+
.filter((item) => item !== null)
48+
.map((item, index) => (
49+
<Tab
50+
value={item.label}
51+
key={index}
52+
onClick={() => handleTabClick(item.url)}
53+
disabled={item.disabled}
54+
>
55+
{item.label}
56+
</Tab>
57+
))}
5458
</TabList>
5559
</Tabs>
5660
</div>

app/[locale]/dashboard/not-found.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button, Text } from 'opub-ui';
44

55
export default function NotFound() {
66
return (
7-
<div className="flex h-full flex-col items-center justify-center gap-2">
7+
<div className="flex h-[90lvh] flex-col items-center justify-center gap-2">
88
<Text variant="heading3xl">404</Text>
99
<Text variant="headingMd">Page not found</Text>
1010
<div className="mt-2">

0 commit comments

Comments
 (0)