From 21b6176bac0c676b767d5e0b2d6e5fd60f4dda3f Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Fri, 27 Dec 2024 23:31:14 +0800 Subject: [PATCH 01/10] add w100% to collectionBanner --- .../dashboard/components/CollectionBanner/CollectionBanner.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/studio/src/features/dashboard/components/CollectionBanner/CollectionBanner.tsx b/apps/studio/src/features/dashboard/components/CollectionBanner/CollectionBanner.tsx index 8d61087e37..22fcf121ee 100644 --- a/apps/studio/src/features/dashboard/components/CollectionBanner/CollectionBanner.tsx +++ b/apps/studio/src/features/dashboard/components/CollectionBanner/CollectionBanner.tsx @@ -17,6 +17,7 @@ export const CollectionBanner = (): JSX.Element | null => { return ( Date: Fri, 27 Dec 2024 23:31:27 +0800 Subject: [PATCH 02/10] add common Dashboard component --- .../dashboard/components/Dashboard.tsx | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 apps/studio/src/features/dashboard/components/Dashboard.tsx diff --git a/apps/studio/src/features/dashboard/components/Dashboard.tsx b/apps/studio/src/features/dashboard/components/Dashboard.tsx new file mode 100644 index 0000000000..e5310db8c9 --- /dev/null +++ b/apps/studio/src/features/dashboard/components/Dashboard.tsx @@ -0,0 +1,103 @@ +import type { ReactNode } from "react" +import NextLink from "next/link" +import { + Box, + BreadcrumbItem, + BreadcrumbLink, + Flex, + HStack, + Text, + VStack, +} from "@chakra-ui/react" +import { Breadcrumb } from "@opengovsg/design-system-react" + +export const Dashboard = ({ + breadcrumbs, + icon, + title, + buttons, + banner, + table, +}: { + breadcrumbs: { + href: string + label: string + }[] + icon: ReactNode + title: string + buttons: ReactNode + banner?: ReactNode + table: ReactNode +}) => { + const allBreadcrumbsExceptLast = breadcrumbs.slice(0, -1) + const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1] + return ( + + + + {allBreadcrumbsExceptLast.map(({ href, label }, index) => { + return ( + + + + {label} + + + + ) + })} + + + {lastBreadcrumb?.label} + + + + + + + {icon} + + + {title} + + + {buttons} + + + {banner && banner} + {table} + + ) +} From 90c2c8848dcc3c92f238f9db47f228a8917c4dab Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Fri, 27 Dec 2024 23:32:14 +0800 Subject: [PATCH 03/10] have Collection and Folder page use it --- .../[siteId]/collections/[resourceId].tsx | 73 +++---- .../[siteId]/folders/[folderId]/index.tsx | 182 ++++++------------ 2 files changed, 80 insertions(+), 175 deletions(-) diff --git a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx index 5995537de7..e44661bbf3 100644 --- a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx +++ b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx @@ -1,14 +1,5 @@ -import NextLink from "next/link" -import { - Box, - BreadcrumbItem, - BreadcrumbLink, - HStack, - Stack, - Text, - useDisclosure, -} from "@chakra-ui/react" -import { Breadcrumb, Button } from "@opengovsg/design-system-react" +import { useDisclosure } from "@chakra-ui/react" +import { Button } from "@opengovsg/design-system-react" import { useSetAtom } from "jotai" import { BiData } from "react-icons/bi" import { z } from "zod" @@ -17,6 +8,7 @@ import { PermissionsBoundary } from "~/components/AuthWrappers" import { folderSettingsModalAtom } from "~/features/dashboard/atoms" import { CollectionBanner } from "~/features/dashboard/components/CollectionBanner" import { CollectionTable } from "~/features/dashboard/components/CollectionTable" +import { Dashboard } from "~/features/dashboard/components/Dashboard" import { DeleteResourceModal } from "~/features/dashboard/components/DeleteResourceModal/DeleteResourceModal" import { FolderSettingsModal } from "~/features/dashboard/components/FolderSettingsModal" import { PageSettingsModal } from "~/features/dashboard/components/PageSettingsModal" @@ -49,38 +41,21 @@ const CollectionResourceListPage: NextPageWithLayout = () => { return ( <> - - - - - - Home - - - - - - - {metadata.title} - - - - - - - - - - - {metadata.title} - - - + } + title={metadata.title} + buttons={ + <> - - - - - - - + + } + banner={} + table={} + /> { return ( <> - - - - {breadcrumbs.map(({ href, label }, index) => { - return ( - - - - {label} - - - - ) - })} - } + title={title} + buttons={ + <> + - - {({ isOpen }) => ( - <> - - Create new... - - - - } - > - Folder - - } - > - Page - - - - - )} - - - - - - - - + Folder settings + + + {({ isOpen }) => ( + <> + + Create new... + + + + } + > + Folder + + } + > + Page + + + + + )} + + + } + table={ - - + } + /> Date: Fri, 27 Dec 2024 23:40:27 +0800 Subject: [PATCH 04/10] have homepage use same Dashboard --- .../dashboard/components/Dashboard.tsx | 6 +- .../[siteId]/collections/[resourceId].tsx | 2 +- .../studio/src/pages/sites/[siteId]/index.tsx | 73 ++++++------------- 3 files changed, 25 insertions(+), 56 deletions(-) diff --git a/apps/studio/src/features/dashboard/components/Dashboard.tsx b/apps/studio/src/features/dashboard/components/Dashboard.tsx index e5310db8c9..bb0cbc64ca 100644 --- a/apps/studio/src/features/dashboard/components/Dashboard.tsx +++ b/apps/studio/src/features/dashboard/components/Dashboard.tsx @@ -16,7 +16,7 @@ export const Dashboard = ({ icon, title, buttons, - banner, + preTableContent, table, }: { breadcrumbs: { @@ -26,7 +26,7 @@ export const Dashboard = ({ icon: ReactNode title: string buttons: ReactNode - banner?: ReactNode + preTableContent?: ReactNode table: ReactNode }) => { const allBreadcrumbsExceptLast = breadcrumbs.slice(0, -1) @@ -96,7 +96,7 @@ export const Dashboard = ({ {buttons} - {banner && banner} + {preTableContent && preTableContent} {table} ) diff --git a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx index e44661bbf3..4b6b43d897 100644 --- a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx +++ b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx @@ -72,7 +72,7 @@ const CollectionResourceListPage: NextPageWithLayout = () => { } - banner={} + preTableContent={} table={} /> { return ( <> - - - - - - Home - - - - - - - - - - Home - - - - - - - - - - + } + title="Home" + buttons={ + + } + preTableContent={} + table={} + /> Date: Fri, 27 Dec 2024 23:45:04 +0800 Subject: [PATCH 05/10] ensure breadcrumb always same height --- .../src/features/dashboard/components/Dashboard.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/studio/src/features/dashboard/components/Dashboard.tsx b/apps/studio/src/features/dashboard/components/Dashboard.tsx index bb0cbc64ca..a7d3acefa5 100644 --- a/apps/studio/src/features/dashboard/components/Dashboard.tsx +++ b/apps/studio/src/features/dashboard/components/Dashboard.tsx @@ -41,7 +41,13 @@ export const Dashboard = ({ minH="100%" > - + {allBreadcrumbsExceptLast.map(({ href, label }, index) => { return ( From 1b37efec580622945fbc5960371546f14578ab0c Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Sun, 29 Dec 2024 18:25:31 +0800 Subject: [PATCH 06/10] undo auto overflow --- apps/studio/src/components/CmsSidebar/CmsContainer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/studio/src/components/CmsSidebar/CmsContainer.tsx b/apps/studio/src/components/CmsSidebar/CmsContainer.tsx index fb8041f800..93fbf9fa2b 100644 --- a/apps/studio/src/components/CmsSidebar/CmsContainer.tsx +++ b/apps/studio/src/components/CmsSidebar/CmsContainer.tsx @@ -75,7 +75,7 @@ export function CmsContainer({ {sidenav} - + Date: Mon, 13 Jan 2025 16:26:45 +0800 Subject: [PATCH 07/10] make table as a children instead --- .../src/features/dashboard/components/Dashboard.tsx | 6 +++--- .../sites/[siteId]/collections/[resourceId].tsx | 5 +++-- .../sites/[siteId]/folders/[folderId]/index.tsx | 13 ++++++------- apps/studio/src/pages/sites/[siteId]/index.tsx | 5 +++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/apps/studio/src/features/dashboard/components/Dashboard.tsx b/apps/studio/src/features/dashboard/components/Dashboard.tsx index a7d3acefa5..99d12d2565 100644 --- a/apps/studio/src/features/dashboard/components/Dashboard.tsx +++ b/apps/studio/src/features/dashboard/components/Dashboard.tsx @@ -17,7 +17,7 @@ export const Dashboard = ({ title, buttons, preTableContent, - table, + children, }: { breadcrumbs: { href: string @@ -27,7 +27,7 @@ export const Dashboard = ({ title: string buttons: ReactNode preTableContent?: ReactNode - table: ReactNode + children: ReactNode }) => { const allBreadcrumbsExceptLast = breadcrumbs.slice(0, -1) const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1] @@ -103,7 +103,7 @@ export const Dashboard = ({ {preTableContent && preTableContent} - {table} + {children} ) } diff --git a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx index 4b6b43d897..f6c03aab3a 100644 --- a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx +++ b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx @@ -73,8 +73,9 @@ const CollectionResourceListPage: NextPageWithLayout = () => { } preTableContent={} - table={} - /> + > + + { } - table={ - - } - /> + > + + { /> } preTableContent={} - table={} - /> + > + + Date: Mon, 13 Jan 2025 16:28:39 +0800 Subject: [PATCH 08/10] rename to DashboardLayout for improved readability --- .../components/{Dashboard.tsx => DashboardLayout.tsx} | 2 +- .../src/pages/sites/[siteId]/collections/[resourceId].tsx | 6 +++--- .../src/pages/sites/[siteId]/folders/[folderId]/index.tsx | 6 +++--- apps/studio/src/pages/sites/[siteId]/index.tsx | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) rename apps/studio/src/features/dashboard/components/{Dashboard.tsx => DashboardLayout.tsx} (98%) diff --git a/apps/studio/src/features/dashboard/components/Dashboard.tsx b/apps/studio/src/features/dashboard/components/DashboardLayout.tsx similarity index 98% rename from apps/studio/src/features/dashboard/components/Dashboard.tsx rename to apps/studio/src/features/dashboard/components/DashboardLayout.tsx index 99d12d2565..bd19d73497 100644 --- a/apps/studio/src/features/dashboard/components/Dashboard.tsx +++ b/apps/studio/src/features/dashboard/components/DashboardLayout.tsx @@ -11,7 +11,7 @@ import { } from "@chakra-ui/react" import { Breadcrumb } from "@opengovsg/design-system-react" -export const Dashboard = ({ +export const DashboardLayout = ({ breadcrumbs, icon, title, diff --git a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx index f6c03aab3a..cd484742bb 100644 --- a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx +++ b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx @@ -8,7 +8,7 @@ import { PermissionsBoundary } from "~/components/AuthWrappers" import { folderSettingsModalAtom } from "~/features/dashboard/atoms" import { CollectionBanner } from "~/features/dashboard/components/CollectionBanner" import { CollectionTable } from "~/features/dashboard/components/CollectionTable" -import { Dashboard } from "~/features/dashboard/components/Dashboard" +import { DashboardLayout } from "~/features/dashboard/components/DashboardLayout" import { DeleteResourceModal } from "~/features/dashboard/components/DeleteResourceModal/DeleteResourceModal" import { FolderSettingsModal } from "~/features/dashboard/components/FolderSettingsModal" import { PageSettingsModal } from "~/features/dashboard/components/PageSettingsModal" @@ -41,7 +41,7 @@ const CollectionResourceListPage: NextPageWithLayout = () => { return ( <> - { preTableContent={} > - + { return ( <> - { siteId={parseInt(siteId)} resourceId={parseInt(folderId)} /> - + { return ( <> - { preTableContent={} > - + Date: Thu, 16 Jan 2025 14:23:09 +0800 Subject: [PATCH 09/10] move width=100% to datatable --- apps/studio/src/components/Datatable/Datatable.tsx | 7 ++++++- .../src/features/dashboard/components/DashboardLayout.tsx | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/studio/src/components/Datatable/Datatable.tsx b/apps/studio/src/components/Datatable/Datatable.tsx index ff63c4d4ad..129c281236 100644 --- a/apps/studio/src/components/Datatable/Datatable.tsx +++ b/apps/studio/src/components/Datatable/Datatable.tsx @@ -48,7 +48,12 @@ export const Datatable = ({ const styles = useMultiStyleConfig("Table", tableProps) return ( - + {isFetching && ( <> {preTableContent && preTableContent} - {children} + {children} ) } From 9ef37cb02d876a9c7fd2b29b3dea664fb8a0b3e8 Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Thu, 16 Jan 2025 14:27:47 +0800 Subject: [PATCH 10/10] remove preTableContent --- .../src/features/dashboard/components/DashboardLayout.tsx | 3 --- .../src/pages/sites/[siteId]/collections/[resourceId].tsx | 2 +- apps/studio/src/pages/sites/[siteId]/index.tsx | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/studio/src/features/dashboard/components/DashboardLayout.tsx b/apps/studio/src/features/dashboard/components/DashboardLayout.tsx index f20a07acd9..4559eba917 100644 --- a/apps/studio/src/features/dashboard/components/DashboardLayout.tsx +++ b/apps/studio/src/features/dashboard/components/DashboardLayout.tsx @@ -16,7 +16,6 @@ export const DashboardLayout = ({ icon, title, buttons, - preTableContent, children, }: { breadcrumbs: { @@ -26,7 +25,6 @@ export const DashboardLayout = ({ icon: ReactNode title: string buttons: ReactNode - preTableContent?: ReactNode children: ReactNode }) => { const allBreadcrumbsExceptLast = breadcrumbs.slice(0, -1) @@ -102,7 +100,6 @@ export const DashboardLayout = ({ {buttons} - {preTableContent && preTableContent} {children} ) diff --git a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx index cd484742bb..aa22afa6d3 100644 --- a/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx +++ b/apps/studio/src/pages/sites/[siteId]/collections/[resourceId].tsx @@ -72,8 +72,8 @@ const CollectionResourceListPage: NextPageWithLayout = () => { } - preTableContent={} > + { onCollectionCreateModalOpen={onCollectionCreateModalOpen} /> } - preTableContent={} > +