Skip to content

Commit d7cd008

Browse files
committed
test: Add tests for containers, tabs, reordering, and grouping
54 tests: group always 1 tab, add tab creates 2nd, title syncs, delete to 1 keeps tab, fill-right positioning, section reorder.
1 parent 3279ca4 commit d7cd008

File tree

2 files changed

+529
-38
lines changed

2 files changed

+529
-38
lines changed

packages/app/src/DBDashboardPage.tsx

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ type MoveTarget = {
148148
containerId: string;
149149
tabId?: string;
150150
label: string;
151-
// For tabs: the group name shown as a section header in the menu
152-
groupLabel?: string;
151+
// For tabs in a group: names of sibling tabs shown dimmed
152+
siblingLabels?: string[];
153153
};
154154

155155
const tileToLayoutItem = (chart: Tile): RGL.Layout => ({
@@ -444,40 +444,39 @@ const Tile = forwardRef(
444444
(Ungrouped)
445445
</Menu.Item>
446446
)}
447-
{(() => {
448-
const filtered = moveTargets.filter(
447+
{moveTargets
448+
.filter(
449449
t =>
450450
!(
451451
t.containerId === chart.containerId &&
452452
t.tabId === chart.tabId
453453
),
454-
);
455-
let lastGroup: string | undefined;
456-
return filtered.map(t => {
457-
const items: React.ReactNode[] = [];
458-
// Add group header when entering a new tab group
459-
if (t.groupLabel && t.groupLabel !== lastGroup) {
460-
items.push(
461-
<Menu.Label key={`group-${t.containerId}`}>
462-
{t.groupLabel}
463-
</Menu.Label>,
464-
);
465-
lastGroup = t.groupLabel;
466-
} else if (!t.groupLabel) {
467-
lastGroup = undefined;
468-
}
469-
items.push(
470-
<Menu.Item
471-
key={`${t.containerId}-${t.tabId ?? ''}`}
472-
onClick={() => onMoveToSection(t.containerId, t.tabId)}
473-
style={t.groupLabel ? { paddingLeft: 24 } : undefined}
474-
>
475-
{t.label}
476-
</Menu.Item>,
477-
);
478-
return items;
479-
});
480-
})()}
454+
)
455+
.map(t => (
456+
<Menu.Item
457+
key={`${t.containerId}-${t.tabId ?? ''}`}
458+
onClick={() => onMoveToSection(t.containerId, t.tabId)}
459+
>
460+
{t.siblingLabels ? (
461+
<span>
462+
{t.label}
463+
{t.siblingLabels.map((s, i) => (
464+
<span
465+
key={i}
466+
style={{
467+
color: 'var(--mantine-color-dimmed)',
468+
}}
469+
>
470+
{' | '}
471+
{s}
472+
</span>
473+
))}
474+
</span>
475+
) : (
476+
t.label
477+
)}
478+
</Menu.Item>
479+
))}
481480
</Menu.Dropdown>
482481
</Menu>
483482
)}
@@ -1231,13 +1230,14 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
12311230
for (const c of sections) {
12321231
const cTabs = c.tabs ?? [];
12331232
if (c.type === 'group' && cTabs.length >= 2) {
1234-
const groupLabel = cTabs[0]?.title ?? c.title;
1233+
// Build pipe-separated label: target tab normal, siblings dimmed
12351234
for (const tab of cTabs) {
1235+
const siblings = cTabs.filter(t => t.id !== tab.id);
12361236
targets.push({
12371237
containerId: c.id,
12381238
tabId: tab.id,
12391239
label: tab.title,
1240-
groupLabel,
1240+
siblingLabels: siblings.map(s => s.title),
12411241
});
12421242
}
12431243
} else if (c.type === 'group' && cTabs.length === 1) {

0 commit comments

Comments
 (0)