From cc0bad210f236da79ee8a945f079edb6e02a4eb5 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Tue, 1 Apr 2025 11:29:16 -0600 Subject: [PATCH] dashboard layout updates --- .../dashboards/[dashboardId]/file/loading.tsx | 5 +++ .../dashboards/[dashboardId]/file/page.tsx | 11 ++++++ .../dashboards/[dashboardId]/layout.tsx | 13 +++++++ .../dashboards/[dashboardId]/page.tsx | 15 ++++---- .../dashboards/[dashboardId]/file/loading.tsx | 5 +++ .../dashboards/[dashboardId]/file/page.tsx | 7 ++++ .../dashboards/[dashboardId]/layout.tsx | 13 +++++++ .../dashboards/[dashboardId]/page.tsx | 9 ++--- .../DashboardViewFileController.tsx | 2 ++ .../controllers/DashboardController/config.ts | 1 - .../DashboardLayout/DashboardLayout.tsx | 16 +++++++++ .../DashboardLayoutContainer.tsx | 36 +++++++++++++++++++ web/src/layouts/DashboardLayout/index.ts | 1 + .../routes/busterRoutes/busterAppRoutes.ts | 9 +++++ 14 files changed, 126 insertions(+), 17 deletions(-) create mode 100644 web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/file/loading.tsx create mode 100644 web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/file/page.tsx create mode 100644 web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx create mode 100644 web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/file/loading.tsx create mode 100644 web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/file/page.tsx create mode 100644 web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx create mode 100644 web/src/layouts/DashboardLayout/DashboardLayout.tsx create mode 100644 web/src/layouts/DashboardLayout/DashboardLayoutContainer.tsx create mode 100644 web/src/layouts/DashboardLayout/index.ts diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/file/loading.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/file/loading.tsx new file mode 100644 index 000000000..02fb527af --- /dev/null +++ b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/file/loading.tsx @@ -0,0 +1,5 @@ +import { FileIndeterminateLoader } from '@/components/features/FileIndeterminateLoader'; + +export default function Loading() { + return ; +} diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/file/page.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/file/page.tsx new file mode 100644 index 000000000..36d8d3f1a --- /dev/null +++ b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/file/page.tsx @@ -0,0 +1,11 @@ +import { DashboardViewFileController } from '@/controllers/DashboardController/DashboardViewFileController'; + +export default async function Page({ + params +}: { + params: Promise<{ dashboardId: string; chatId: string }>; +}) { + const { dashboardId, chatId } = await params; + + return ; +} diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx new file mode 100644 index 000000000..69cae866c --- /dev/null +++ b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx @@ -0,0 +1,13 @@ +import { DashboardLayout } from '@/layouts/DashboardLayout'; + +export default async function Layout({ + children, + params +}: { + children: React.ReactNode; + params: Promise<{ dashboardId: string }>; +}) { + const { dashboardId } = await params; + + return {children}; +} diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/page.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/page.tsx index 2b955849f..b087f7670 100644 --- a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/page.tsx +++ b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/page.tsx @@ -1,14 +1,11 @@ -import { DashboardController } from '@/controllers/DashboardController'; -import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout'; +import { DashboardViewDashboardController } from '@/controllers/DashboardController/DashboardViewDashboardController'; -export default async function DashboardPage(props: { params: Promise<{ dashboardId: string }> }) { +export default async function Page(props: { + params: Promise<{ dashboardId: string; chatId: string }>; +}) { const params = await props.params; - const { dashboardId } = params; + const { dashboardId, chatId } = params; - return ( - - - - ); + return ; } diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/file/loading.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/file/loading.tsx new file mode 100644 index 000000000..02fb527af --- /dev/null +++ b/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/file/loading.tsx @@ -0,0 +1,5 @@ +import { FileIndeterminateLoader } from '@/components/features/FileIndeterminateLoader'; + +export default function Loading() { + return ; +} diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/file/page.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/file/page.tsx new file mode 100644 index 000000000..a3aea6660 --- /dev/null +++ b/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/file/page.tsx @@ -0,0 +1,7 @@ +import { DashboardViewFileController } from '@/controllers/DashboardController/DashboardViewFileController'; + +export default async function Page({ params }: { params: Promise<{ dashboardId: string }> }) { + const { dashboardId } = await params; + + return ; +} diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx new file mode 100644 index 000000000..69cae866c --- /dev/null +++ b/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx @@ -0,0 +1,13 @@ +import { DashboardLayout } from '@/layouts/DashboardLayout'; + +export default async function Layout({ + children, + params +}: { + children: React.ReactNode; + params: Promise<{ dashboardId: string }>; +}) { + const { dashboardId } = await params; + + return {children}; +} diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/page.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/page.tsx index fff5cf0e9..ac4002c30 100644 --- a/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/page.tsx +++ b/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/page.tsx @@ -1,14 +1,9 @@ -import { DashboardController } from '@/controllers/DashboardController'; -import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout'; +import { DashboardViewDashboardController } from '@/controllers/DashboardController/DashboardViewDashboardController'; export default async function Page(props: { params: Promise<{ dashboardId: string }> }) { const params = await props.params; const { dashboardId } = params; - return ( - - - - ); + return ; } diff --git a/web/src/controllers/DashboardController/DashboardViewFileController/DashboardViewFileController.tsx b/web/src/controllers/DashboardController/DashboardViewFileController/DashboardViewFileController.tsx index 148af500e..1af9f67c7 100644 --- a/web/src/controllers/DashboardController/DashboardViewFileController/DashboardViewFileController.tsx +++ b/web/src/controllers/DashboardController/DashboardViewFileController/DashboardViewFileController.tsx @@ -1,3 +1,5 @@ +'use client'; + import React, { useEffect } from 'react'; import { CodeCard } from '@/components/ui/card'; import { useMemoizedFn } from '@/hooks'; diff --git a/web/src/controllers/DashboardController/config.ts b/web/src/controllers/DashboardController/config.ts index 9ea88a19a..afaf52063 100644 --- a/web/src/controllers/DashboardController/config.ts +++ b/web/src/controllers/DashboardController/config.ts @@ -2,7 +2,6 @@ import type { DashboardFileView } from '@/layouts/ChatLayout'; import { DashboardViewDashboardController } from './DashboardViewDashboardController'; import { DashboardViewFileController } from './DashboardViewFileController'; import React from 'react'; -import dynamic from 'next/dynamic'; export interface DashboardViewProps { dashboardId: string; diff --git a/web/src/layouts/DashboardLayout/DashboardLayout.tsx b/web/src/layouts/DashboardLayout/DashboardLayout.tsx new file mode 100644 index 000000000..85bb0cd85 --- /dev/null +++ b/web/src/layouts/DashboardLayout/DashboardLayout.tsx @@ -0,0 +1,16 @@ +'use server'; + +import React from 'react'; +import { AppAssetCheckLayout } from '../AppAssetCheckLayout'; +import { DashboardLayoutContainer } from './DashboardLayoutContainer'; + +export const DashboardLayout: React.FC<{ dashboardId: string; children: React.ReactNode }> = ({ + dashboardId, + children +}) => { + return ( + + {children} + + ); +}; diff --git a/web/src/layouts/DashboardLayout/DashboardLayoutContainer.tsx b/web/src/layouts/DashboardLayout/DashboardLayoutContainer.tsx new file mode 100644 index 000000000..3da3985aa --- /dev/null +++ b/web/src/layouts/DashboardLayout/DashboardLayoutContainer.tsx @@ -0,0 +1,36 @@ +'use client'; + +import { useGetDashboard } from '@/api/buster_rest/dashboards'; +import { AddToDashboardModal } from '@/components/features/modal/AddToDashboardModal'; +import { useDashboardContentStore } from '@/context/Dashboards'; +import { canEdit } from '@/lib/share'; +import React from 'react'; + +export const DashboardLayoutContainer: React.FC<{ + children: React.ReactNode; + dashboardId: string; +}> = ({ children, dashboardId }) => { + const { data: permission } = useGetDashboard({ id: dashboardId }, (x) => x.permission); + const isEditor = canEdit(permission); + + return ( + <> + {children} + {isEditor && } + + ); +}; + +const MemoizedAddToDashboardModal = React.memo(({ dashboardId }: { dashboardId: string }) => { + const { openAddContentModal, onCloseAddContentModal } = useDashboardContentStore(); + + return ( + + ); +}); + +MemoizedAddToDashboardModal.displayName = 'MemoizedAddToDashboardModal'; diff --git a/web/src/layouts/DashboardLayout/index.ts b/web/src/layouts/DashboardLayout/index.ts new file mode 100644 index 000000000..fc36c152c --- /dev/null +++ b/web/src/layouts/DashboardLayout/index.ts @@ -0,0 +1 @@ +export * from './DashboardLayout'; diff --git a/web/src/routes/busterRoutes/busterAppRoutes.ts b/web/src/routes/busterRoutes/busterAppRoutes.ts index 979e8a397..0970f52cd 100644 --- a/web/src/routes/busterRoutes/busterAppRoutes.ts +++ b/web/src/routes/busterRoutes/busterAppRoutes.ts @@ -69,6 +69,10 @@ export type BusterAppRoutesWithArgs = { route: BusterAppRoutes.APP_DASHBOARD_ID; dashboardId: string; }; + [BusterAppRoutes.APP_DASHBOARD_ID_FILE]: { + route: BusterAppRoutes.APP_DASHBOARD_ID_FILE; + dashboardId: string; + }; [BusterAppRoutes.APP_DATASETS]: { route: BusterAppRoutes.APP_DATASETS }; [BusterAppRoutes.APP_TERMS]: { route: BusterAppRoutes.APP_TERMS }; [BusterAppRoutes.APP_DATASETS_ID]: { route: BusterAppRoutes.APP_DATASETS_ID; datasetId: string }; @@ -148,6 +152,11 @@ export type BusterAppRoutesWithArgs = { chatId: string; dashboardId: string; }; + [BusterAppRoutes.APP_CHAT_ID_DASHBOARD_ID_FILE]: { + route: BusterAppRoutes.APP_CHAT_ID_DASHBOARD_ID_FILE; + chatId: string; + dashboardId: string; + }; [BusterAppRoutes.APP_CHAT_ID_DATASET_ID]: { route: BusterAppRoutes.APP_CHAT_ID_DATASET_ID; chatId: string;