Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions web-common/src/features/dashboards/pivot/PivotDisplay.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { usePivotForExplore } from "./pivot-data-store";
import PivotEmpty from "./PivotEmpty.svelte";
import PivotHeader from "./PivotHeader.svelte";
import type { PivotChipData } from "./types";
import PivotSidebar from "./PivotSidebar.svelte";
import PivotTable from "./PivotTable.svelte";
import PivotToolbar from "./PivotToolbar.svelte";
Expand All @@ -22,6 +23,7 @@
const {
exploreName,
dashboardStore,
validSpecStore,
selectors: {
pivot: { columns, measures, dimensions },
},
Expand Down Expand Up @@ -55,6 +57,32 @@

$: ({ isFetching, assembled } = $pivotDataStore);

// Build a description lookup from the metricsView so pivot chips get
// descriptions even when the metricsView loads after the pivot state
// is deserialized (e.g. public URL first load).
$: descriptionMap = new Map<string, string | undefined>([
...($validSpecStore.data?.metricsView?.dimensions ?? []).map(
(d) => [d.name, d.description] as [string, string | undefined],
),
...($validSpecStore.data?.metricsView?.measures ?? []).map(
(m) => [m.name, m.description] as [string, string | undefined],
),
]);

function enrichDescriptions(chips: PivotChipData[]): PivotChipData[] {
return chips.map((chip) => {
if (chip.description) return chip;
const desc = descriptionMap.get(chip.id);
return desc ? { ...chip, description: desc } : chip;
});
}

$: enrichedPivotState = {
...$dashboardStore.pivot,
rows: enrichDescriptions($dashboardStore.pivot.rows),
columns: enrichDescriptions($dashboardStore.pivot.columns),
};

$: hasColumnAndNoMeasure =
$columns.dimension.length > 0 && $columns.measure.length === 0;

Expand All @@ -67,7 +95,7 @@
<div class="layout" class:h-full={!$dynamicHeight}>
{#if showPanels}
<PivotSidebar
pivotState={$dashboardStore.pivot}
pivotState={enrichedPivotState}
measures={$measures}
dimensions={$dimensions}
{timeControlsForPillActions}
Expand All @@ -80,7 +108,7 @@
>
{#if showPanels}
<PivotHeader
pivotState={$dashboardStore.pivot}
pivotState={enrichedPivotState}
setRows={(rows) =>
metricsExplorerStore.setPivotRows($exploreName, rows)}
setColumns={(columns) =>
Expand All @@ -96,7 +124,7 @@
}}
>
<PivotToolbar
pivotState={$dashboardStore.pivot}
pivotState={enrichedPivotState}
setTableMode={(tableMode, rows, columns) =>
metricsExplorerStore.setPivotTableMode(
$exploreName,
Expand Down
Loading