This introduces a user-scoped dashboard with board-style view/edit pages while keeping it unavailable in team context, and moves website targeting to component config so dashboard components can each select their own website.
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
'use client';
|
|
import { Column } from '@umami/react-zen';
|
|
import { useEffect } from 'react';
|
|
import { BoardViewBody } from '@/app/(main)/boards/[boardId]/BoardViewBody';
|
|
import { EmptyPlaceholder } from '@/components/common/EmptyPlaceholder';
|
|
import { PageBody } from '@/components/common/PageBody';
|
|
import { useBoard, useMessages, useNavigation } from '@/components/hooks';
|
|
import { DashboardProvider } from './DashboardProvider';
|
|
import { DashboardViewHeader } from './DashboardViewHeader';
|
|
|
|
function DashboardContent() {
|
|
const { board } = useBoard();
|
|
const { t, labels, messages } = useMessages();
|
|
const rows = board?.parameters?.rows ?? [];
|
|
const hasComponents = rows.some(row => row.columns?.some(column => !!column.component));
|
|
|
|
if (!hasComponents) {
|
|
return (
|
|
<EmptyPlaceholder title={t(labels.dashboard)} description={t(messages.emptyDashboard)} />
|
|
);
|
|
}
|
|
|
|
return <BoardViewBody />;
|
|
}
|
|
|
|
export function DashboardViewPage() {
|
|
const { teamId, router } = useNavigation();
|
|
|
|
useEffect(() => {
|
|
if (teamId) {
|
|
router.replace('/dashboard');
|
|
}
|
|
}, [teamId, router]);
|
|
|
|
if (teamId) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<DashboardProvider>
|
|
<PageBody>
|
|
<Column>
|
|
<DashboardViewHeader />
|
|
<DashboardContent />
|
|
</Column>
|
|
</PageBody>
|
|
</DashboardProvider>
|
|
);
|
|
}
|