Add personal dashboard flow and per-component website selection
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.
This commit is contained in:
1 parent
2633697585
commit
631cc46f7f
73 files changed
+418
-88
No files matched your search
@@ -8,7 +8,7 @@ function BoardComponentRendererComponent({
|
||||
websiteId,
|
||||
}: {
|
||||
config: BoardComponentConfig;
|
||||
websiteId: string;
|
||||
websiteId?: string;
|
||||
}) {
|
||||
const definition = getComponentDefinition(config.type);
|
||||
|
||||
@@ -22,6 +22,14 @@ function BoardComponentRendererComponent({
|
||||
|
||||
const Component = definition.component;
|
||||
|
||||
if (!websiteId) {
|
||||
return (
|
||||
<Column alignItems="center" justifyContent="center" width="100%" height="100%">
|
||||
<Text color="muted">Select a website</Text>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
return <Component websiteId={websiteId} {...config.props} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Panel } from '@/components/common/Panel';
|
||||
import { useMessages } from '@/components/hooks';
|
||||
import { WebsiteSelect } from '@/components/input/WebsiteSelect';
|
||||
import type { BoardComponentConfig } from '@/lib/types';
|
||||
import {
|
||||
CATEGORIES,
|
||||
@@ -21,12 +22,16 @@ import {
|
||||
import { BoardComponentRenderer } from './BoardComponentRenderer';
|
||||
|
||||
export function BoardComponentSelect({
|
||||
teamId,
|
||||
websiteId,
|
||||
defaultWebsiteId,
|
||||
initialConfig,
|
||||
onSelect,
|
||||
onClose,
|
||||
}: {
|
||||
websiteId: string;
|
||||
teamId?: string;
|
||||
websiteId?: string;
|
||||
defaultWebsiteId?: string;
|
||||
initialConfig?: BoardComponentConfig;
|
||||
onSelect: (config: BoardComponentConfig) => void;
|
||||
onClose: () => void;
|
||||
@@ -34,6 +39,9 @@ export function BoardComponentSelect({
|
||||
const { t, labels, messages } = useMessages();
|
||||
const [selectedDef, setSelectedDef] = useState<ComponentDefinition | null>(null);
|
||||
const [configValues, setConfigValues] = useState<Record<string, any>>({});
|
||||
const [selectedWebsiteId, setSelectedWebsiteId] = useState(
|
||||
initialConfig?.websiteId || websiteId || defaultWebsiteId,
|
||||
);
|
||||
const [title, setTitle] = useState('');
|
||||
const [description, setDescription] = useState('');
|
||||
|
||||
@@ -73,9 +81,10 @@ export function BoardComponentSelect({
|
||||
|
||||
setSelectedDef(definition);
|
||||
setConfigValues(getDefaultConfigValues(definition, initialConfig));
|
||||
setSelectedWebsiteId(initialConfig.websiteId || websiteId || defaultWebsiteId);
|
||||
setTitle(initialConfig.title ?? '');
|
||||
setDescription(initialConfig.description || '');
|
||||
}, [initialConfig, allDefinitions]);
|
||||
}, [initialConfig, allDefinitions, websiteId, defaultWebsiteId]);
|
||||
|
||||
const handleSelectComponent = (def: ComponentDefinition) => {
|
||||
setSelectedDef(def);
|
||||
@@ -107,6 +116,7 @@ export function BoardComponentSelect({
|
||||
|
||||
const config: BoardComponentConfig = {
|
||||
type: selectedDef.type,
|
||||
websiteId: selectedWebsiteId,
|
||||
title,
|
||||
description,
|
||||
};
|
||||
@@ -172,12 +182,14 @@ export function BoardComponentSelect({
|
||||
|
||||
<Column gap="3" flexGrow={1} style={{ minWidth: 0 }}>
|
||||
<Panel maxHeight="100%">
|
||||
{previewConfig && websiteId ? (
|
||||
<BoardComponentRenderer config={previewConfig} websiteId={websiteId} />
|
||||
{previewConfig && selectedWebsiteId ? (
|
||||
<BoardComponentRenderer config={previewConfig} websiteId={selectedWebsiteId} />
|
||||
) : (
|
||||
<Column alignItems="center" justifyContent="center" height="100%">
|
||||
<Text color="muted">
|
||||
{websiteId ? t(messages.selectComponentPreview) : t(messages.selectWebsiteFirst)}
|
||||
{selectedWebsiteId
|
||||
? t(messages.selectComponentPreview)
|
||||
: t(messages.selectWebsiteFirst)}
|
||||
</Text>
|
||||
</Column>
|
||||
)}
|
||||
@@ -187,6 +199,18 @@ export function BoardComponentSelect({
|
||||
<Column gap="3" style={{ width: 320, flexShrink: 0, overflowY: 'auto' }}>
|
||||
<Text weight="bold">{t(labels.properties)}</Text>
|
||||
|
||||
<Column gap="2">
|
||||
<Text size="sm" color="muted">
|
||||
{t(labels.website)}
|
||||
</Text>
|
||||
<WebsiteSelect
|
||||
websiteId={selectedWebsiteId}
|
||||
teamId={teamId}
|
||||
placeholder={t(labels.selectWebsite)}
|
||||
onChange={setSelectedWebsiteId}
|
||||
/>
|
||||
</Column>
|
||||
|
||||
<Column gap="2">
|
||||
<Text size="sm" color="muted">
|
||||
{t(labels.title)}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { GripHorizontal, Plus } from '@/components/icons';
|
||||
import { BoardEditRow } from './BoardEditRow';
|
||||
import { BUTTON_ROW_HEIGHT, MAX_ROW_HEIGHT, MIN_ROW_HEIGHT } from './boardConstants';
|
||||
|
||||
export function BoardEditBody() {
|
||||
export function BoardEditBody({ requiresBoardWebsite = true }: { requiresBoardWebsite?: boolean }) {
|
||||
const { board, updateBoard, registerLayoutGetter } = useBoard();
|
||||
const rowGroupRef = useRef<GroupImperativeHandle>(null);
|
||||
const columnGroupRefs = useRef<Map<string, GroupImperativeHandle>>(new Map());
|
||||
@@ -103,6 +103,7 @@ export function BoardEditBody() {
|
||||
};
|
||||
|
||||
const websiteId = board?.parameters?.websiteId;
|
||||
const canEdit = requiresBoardWebsite ? !!websiteId : true;
|
||||
const rows = board?.parameters?.rows ?? [];
|
||||
const minHeight = (rows.length || 1) * MAX_ROW_HEIGHT + BUTTON_ROW_HEIGHT;
|
||||
|
||||
@@ -122,7 +123,7 @@ export function BoardEditBody() {
|
||||
rowId={row.id}
|
||||
rowIndex={index}
|
||||
rowCount={rows.length}
|
||||
canEdit={!!websiteId}
|
||||
canEdit={canEdit}
|
||||
onRemove={handleRemoveRow}
|
||||
onMoveUp={handleMoveRowUp}
|
||||
onMoveDown={handleMoveRowDown}
|
||||
@@ -157,7 +158,7 @@ export function BoardEditBody() {
|
||||
)}
|
||||
</Fragment>
|
||||
))}
|
||||
{!!websiteId && (
|
||||
{canEdit && (
|
||||
<Panel minSize={BUTTON_ROW_HEIGHT}>
|
||||
<Row padding="3">
|
||||
<TooltipTrigger delay={0}>
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from '@umami/react-zen';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { Panel } from '@/components/common/Panel';
|
||||
import { useBoard, useMessages } from '@/components/hooks';
|
||||
import { useBoard, useMessages, useNavigation } from '@/components/hooks';
|
||||
import { Pencil, Plus, X } from '@/components/icons';
|
||||
import type { BoardComponentConfig } from '@/lib/types';
|
||||
import { BoardComponentRenderer } from './BoardComponentRenderer';
|
||||
@@ -36,7 +36,9 @@ export function BoardEditColumn({
|
||||
const [showActions, setShowActions] = useState(false);
|
||||
const { board } = useBoard();
|
||||
const { t, labels } = useMessages();
|
||||
const websiteId = board?.parameters?.websiteId;
|
||||
const { teamId } = useNavigation();
|
||||
const boardWebsiteId = board?.parameters?.websiteId;
|
||||
const websiteId = component?.websiteId || boardWebsiteId;
|
||||
const renderedComponent = useMemo(() => {
|
||||
if (!component || !websiteId) {
|
||||
return null;
|
||||
@@ -126,7 +128,9 @@ export function BoardEditColumn({
|
||||
>
|
||||
{() => (
|
||||
<BoardComponentSelect
|
||||
teamId={teamId}
|
||||
websiteId={websiteId}
|
||||
defaultWebsiteId={boardWebsiteId}
|
||||
initialConfig={component}
|
||||
onSelect={handleSelect}
|
||||
onClose={() => setShowSelect(false)}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { BoardComponentRenderer } from './BoardComponentRenderer';
|
||||
|
||||
export function BoardViewColumn({ component }: { component?: BoardComponentConfig }) {
|
||||
const { board } = useBoard();
|
||||
const websiteId = board?.parameters?.websiteId;
|
||||
const websiteId = component?.websiteId || board?.parameters?.websiteId;
|
||||
|
||||
if (!component || !websiteId) {
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user