Skip to content

Commit f75aa50

Browse files
authored
feat: persist dashboaard filters across dashboards within a session (#8666)
* feat: persist dashboaard filters across dashboards within a session * fix some settings not persisting * Add a toggle to dashboard navigation dropdown * Remove DashboardsBreadcrumbItem * Move to a feature flag instead of a toggle
1 parent 46ef7b8 commit f75aa50

File tree

12 files changed

+183
-127
lines changed

12 files changed

+183
-127
lines changed

runtime/feature_flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ var defaultFeatureFlags = map[string]string{
6262
"generate_canvas": "false",
6363
// Controls if the developer agent tool is available.
6464
"developer_agent": "true",
65+
// Controls if the dashboard state is persisted when navigating to a different dashboard.
66+
"sticky_dashboard_state": "false",
6567
}
6668

6769
// ResolveFeatureFlags resolves feature flags for the given instance and the provided user attributes.

runtime/feature_flags_test.go

Lines changed: 72 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,24 @@ func Test_ResolveFeatureFlags(t *testing.T) {
2727
"domain": "rilldata.com",
2828
},
2929
featureFlags: map[string]bool{
30-
"exports": true,
31-
"cloudDataViewer": false,
32-
"dimensionSearch": true,
33-
"twoTieredNavigation": false,
34-
"rillTime": true,
35-
"hidePublicUrl": false,
36-
"exportHeader": false,
37-
"alerts": true,
38-
"reports": true,
39-
"darkMode": true,
40-
"chat": true,
41-
"dashboardChat": false,
42-
"developerChat": false,
43-
"chatCharts": true,
44-
"deploy": true,
45-
"generateCanvas": false,
46-
"developerAgent": true,
30+
"exports": true,
31+
"cloudDataViewer": false,
32+
"dimensionSearch": true,
33+
"twoTieredNavigation": false,
34+
"rillTime": true,
35+
"hidePublicUrl": false,
36+
"exportHeader": false,
37+
"alerts": true,
38+
"reports": true,
39+
"darkMode": true,
40+
"chat": true,
41+
"dashboardChat": false,
42+
"developerChat": false,
43+
"chatCharts": true,
44+
"deploy": true,
45+
"generateCanvas": false,
46+
"developerAgent": true,
47+
"stickyDashboardState": false,
4748
},
4849
},
4950
{
@@ -52,23 +53,24 @@ func Test_ResolveFeatureFlags(t *testing.T) {
5253
"domain": "gmail.com",
5354
},
5455
featureFlags: map[string]bool{
55-
"exports": true,
56-
"cloudDataViewer": false,
57-
"dimensionSearch": false,
58-
"twoTieredNavigation": false,
59-
"rillTime": true,
60-
"hidePublicUrl": false,
61-
"exportHeader": false,
62-
"alerts": false,
63-
"reports": true,
64-
"darkMode": true,
65-
"chat": true,
66-
"dashboardChat": false,
67-
"developerChat": false,
68-
"chatCharts": true,
69-
"deploy": true,
70-
"generateCanvas": false,
71-
"developerAgent": true,
56+
"exports": true,
57+
"cloudDataViewer": false,
58+
"dimensionSearch": false,
59+
"twoTieredNavigation": false,
60+
"rillTime": true,
61+
"hidePublicUrl": false,
62+
"exportHeader": false,
63+
"alerts": false,
64+
"reports": true,
65+
"darkMode": true,
66+
"chat": true,
67+
"dashboardChat": false,
68+
"developerChat": false,
69+
"chatCharts": true,
70+
"deploy": true,
71+
"generateCanvas": false,
72+
"developerAgent": true,
73+
"stickyDashboardState": false,
7274
},
7375
},
7476
{
@@ -77,23 +79,24 @@ func Test_ResolveFeatureFlags(t *testing.T) {
7779
"domain": "yahoo.com",
7880
},
7981
featureFlags: map[string]bool{
80-
"exports": true,
81-
"cloudDataViewer": false,
82-
"dimensionSearch": false,
83-
"twoTieredNavigation": false,
84-
"rillTime": true,
85-
"hidePublicUrl": false,
86-
"exportHeader": false,
87-
"alerts": false,
88-
"reports": false,
89-
"darkMode": true,
90-
"chat": true,
91-
"dashboardChat": false,
92-
"developerChat": false,
93-
"chatCharts": true,
94-
"deploy": true,
95-
"generateCanvas": false,
96-
"developerAgent": true,
82+
"exports": true,
83+
"cloudDataViewer": false,
84+
"dimensionSearch": false,
85+
"twoTieredNavigation": false,
86+
"rillTime": true,
87+
"hidePublicUrl": false,
88+
"exportHeader": false,
89+
"alerts": false,
90+
"reports": false,
91+
"darkMode": true,
92+
"chat": true,
93+
"dashboardChat": false,
94+
"developerChat": false,
95+
"chatCharts": true,
96+
"deploy": true,
97+
"generateCanvas": false,
98+
"developerAgent": true,
99+
"stickyDashboardState": false,
97100
},
98101
},
99102
{
@@ -102,23 +105,24 @@ func Test_ResolveFeatureFlags(t *testing.T) {
102105
"embed": true,
103106
},
104107
featureFlags: map[string]bool{
105-
"exports": true,
106-
"cloudDataViewer": false,
107-
"dimensionSearch": false,
108-
"twoTieredNavigation": false,
109-
"rillTime": true,
110-
"hidePublicUrl": true,
111-
"exportHeader": false,
112-
"alerts": false,
113-
"reports": false,
114-
"darkMode": true,
115-
"chat": false,
116-
"dashboardChat": false, // forced false because chat is false
117-
"developerChat": false,
118-
"chatCharts": true,
119-
"deploy": true,
120-
"generateCanvas": false,
121-
"developerAgent": true,
108+
"exports": true,
109+
"cloudDataViewer": false,
110+
"dimensionSearch": false,
111+
"twoTieredNavigation": false,
112+
"rillTime": true,
113+
"hidePublicUrl": true,
114+
"exportHeader": false,
115+
"alerts": false,
116+
"reports": false,
117+
"darkMode": true,
118+
"chat": false,
119+
"dashboardChat": false, // forced false because chat is false
120+
"developerChat": false,
121+
"chatCharts": true,
122+
"deploy": true,
123+
"generateCanvas": false,
124+
"developerAgent": true,
125+
"stickyDashboardState": false,
122126
},
123127
},
124128
}

web-admin/src/features/embeds/TopNavigationBarEmbed.svelte

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
$: shouldRender =
2424
navigationEnabled ||
25-
(dashboardChat &&
25+
($dashboardChat &&
2626
(activeResource?.kind === ResourceKind.Explore.toString() ||
2727
activeResource?.kind === ResourceKind.MetricsView.toString()));
2828
@@ -35,8 +35,8 @@
3535
);
3636
$: currentResourceName = currentResource?.meta?.name?.name;
3737
38-
$: breadcrumbOptions = dashboards?.reduce(
39-
(map, { meta, explore, canvas }) => {
38+
$: breadcrumbOptions = {
39+
options: dashboards?.reduce((map, { meta, explore, canvas }) => {
4040
const name = meta.name.name;
4141
const isExplore = !!explore;
4242
return map.set(name.toLowerCase(), {
@@ -47,9 +47,8 @@
4747
href: `/-/embed/${isExplore ? "explore" : "canvas"}/${name}`,
4848
preloadData: false,
4949
});
50-
},
51-
new Map(),
52-
);
50+
}, new Map()),
51+
};
5352
</script>
5453

5554
{#if $isErrorStoreEmpty && shouldRender}
@@ -69,13 +68,13 @@
6968
{#if currentResource}
7069
{#if $twoTieredNavigation}
7170
<TwoTieredBreadcrumbItem
72-
options={breadcrumbOptions}
71+
pathOptions={breadcrumbOptions}
7372
current={currentResourceName}
7473
isCurrentPage
7574
/>
7675
{:else}
7776
<BreadcrumbItem
78-
options={breadcrumbOptions}
77+
pathOptions={breadcrumbOptions}
7978
current={currentResourceName}
8079
isCurrentPage
8180
isEmbedded
@@ -88,7 +87,7 @@
8887
<div class="flex-1" />
8988
{/if}
9089

91-
{#if dashboardChat && (activeResource?.kind === ResourceKind.Explore.toString() || activeResource?.kind === ResourceKind.MetricsView.toString())}
90+
{#if $dashboardChat && (activeResource?.kind === ResourceKind.Explore.toString() || activeResource?.kind === ResourceKind.MetricsView.toString())}
9291
<div class="flex gap-x-4 items-center">
9392
<LastRefreshedDate dashboard={activeResource?.name} />
9493
<ChatToggle />

web-admin/src/features/navigation/TopNavigationBar.svelte

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@
4747
export let planDisplayName: string | undefined;
4848
4949
const user = createAdminServiceGetCurrentUser();
50-
const { alerts: alertsFlag, dimensionSearch, dashboardChat } = featureFlags;
50+
const {
51+
alerts: alertsFlag,
52+
dimensionSearch,
53+
dashboardChat,
54+
stickyDashboardState,
55+
} = featureFlags;
5156
5257
$: ({ instanceId } = $runtime);
5358
@@ -103,11 +108,9 @@
103108
$: alerts = $alertsQuery.data?.resources ?? [];
104109
$: reports = $reportsQuery.data?.resources ?? [];
105110
106-
$: organizationPaths = createOrgPaths(
107-
organizations,
108-
organization,
109-
planDisplayName,
110-
);
111+
$: organizationPaths = {
112+
options: createOrgPaths(organizations, organization, planDisplayName),
113+
};
111114
112115
function createOrgPaths(
113116
organizations: V1Organization[],
@@ -135,39 +138,48 @@
135138
return pathMap;
136139
}
137140
138-
$: projectPaths = projects.reduce(
139-
(map, { name }) =>
140-
map.set(name.toLowerCase(), { label: name, preloadData: false }),
141-
new Map<string, PathOption>(),
142-
);
141+
$: projectPaths = {
142+
options: projects.reduce(
143+
(map, { name }) =>
144+
map.set(name.toLowerCase(), { label: name, preloadData: false }),
145+
new Map<string, PathOption>(),
146+
),
147+
};
143148
144-
$: visualizationPaths = visualizations.reduce((map, resource) => {
145-
const name = resource.meta.name.name;
146-
const isMetricsExplorer = !!resource?.explore;
147-
return map.set(name.toLowerCase(), {
148-
label:
149-
(isMetricsExplorer
150-
? resource?.explore?.spec?.displayName
151-
: resource?.canvas?.spec?.displayName) || name,
152-
section: isMetricsExplorer ? "explore" : "canvas",
153-
});
154-
}, new Map<string, PathOption>());
149+
$: visualizationPaths = {
150+
options: visualizations.reduce((map, resource) => {
151+
const name = resource.meta.name.name;
152+
const isMetricsExplorer = !!resource?.explore;
153+
return map.set(name.toLowerCase(), {
154+
label:
155+
(isMetricsExplorer
156+
? resource?.explore?.spec?.displayName
157+
: resource?.canvas?.spec?.displayName) || name,
158+
section: isMetricsExplorer ? "explore" : "canvas",
159+
});
160+
}, new Map<string, PathOption>()),
161+
carryOverSearchParams: $stickyDashboardState,
162+
};
155163
156-
$: alertPaths = alerts.reduce((map, alert) => {
157-
const name = alert.meta.name.name;
158-
return map.set(name.toLowerCase(), {
159-
label: alert.alert.spec.displayName || name,
160-
section: "-/alerts",
161-
});
162-
}, new Map<string, PathOption>());
164+
$: alertPaths = {
165+
options: alerts.reduce((map, alert) => {
166+
const name = alert.meta.name.name;
167+
return map.set(name.toLowerCase(), {
168+
label: alert.alert.spec.displayName || name,
169+
section: "-/alerts",
170+
});
171+
}, new Map<string, PathOption>()),
172+
};
163173
164-
$: reportPaths = reports.reduce((map, report) => {
165-
const name = report.meta.name.name;
166-
return map.set(name.toLowerCase(), {
167-
label: report.report.spec.displayName || name,
168-
section: "-/reports",
169-
});
170-
}, new Map<string, PathOption>());
174+
$: reportPaths = {
175+
options: reports.reduce((map, report) => {
176+
const name = report.meta.name.name;
177+
return map.set(name.toLowerCase(), {
178+
label: report.report.spec.displayName || name,
179+
section: "-/reports",
180+
});
181+
}, new Map<string, PathOption>()),
182+
};
171183
172184
$: pathParts = [
173185
organizationPaths,

0 commit comments

Comments
 (0)