Skip to content

Commit 4e59046

Browse files
authored
Merge pull request #185 from CivicDataLab/179-bring-all-the-dataspaces-changes-under-a-feature-flag
move dataspace features under the feature flag
2 parents 31e06be + 480600e commit 4e59046

File tree

4 files changed

+41
-24
lines changed

4 files changed

+41
-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
@@ -62,7 +66,7 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) {
6266
' bg-surfaceDefault p-4 md:flex'
6367
)}
6468
>
65-
<DashboardNav items={orgSidebarNav} entitySlug={entitySlug} />
69+
<DashboardNav items={orgSidebarNav} entitySlug={params.entitySlug} />
6670

6771
<div className="z-1 basis-2 md:hidden">
6872
<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: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ 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+
{
15+
label: 'My Data Spaces',
16+
url: `/dashboard/dataspace`,
17+
selected: currentPath.indexOf('dataspace') >= 0,
18+
disabled: false,
19+
},
20+
]
21+
: []),
1822
{
1923
label: 'My Organizations',
2024
url: `/dashboard/organization`,
@@ -29,7 +33,7 @@ export function DashboardHeader({ currentPath }: { currentPath: string }) {
2933
};
3034

3135
const initialTabLabel =
32-
userDashboardOptions.find((option) => option.selected)?.label ||
36+
userDashboardOptions.find((option) => option?.selected)?.label ||
3337
'My Datasets';
3438

3539
return (
@@ -41,16 +45,18 @@ export function DashboardHeader({ currentPath }: { currentPath: string }) {
4145
<div>
4246
<Tabs defaultValue={initialTabLabel}>
4347
<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-
))}
48+
{userDashboardOptions
49+
.filter((item) => item !== null)
50+
.map((item, index) => (
51+
<Tab
52+
value={item.label}
53+
key={index}
54+
onClick={() => handleTabClick(item.url)}
55+
disabled={item.disabled}
56+
>
57+
{item.label}
58+
</Tab>
59+
))}
5460
</TabList>
5561
</Tabs>
5662
</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)