Dashboard: Add feature flag for undo/redo (#111096)
This commit is contained in:
+1
@@ -8,6 +8,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
viewport: { width: 1920, height: 1080 },
|
||||
|
||||
@@ -8,6 +8,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
// these tests require a larger viewport
|
||||
|
||||
@@ -8,6 +8,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ test.use({
|
||||
featureToggles: {
|
||||
kubernetesDashboards: true,
|
||||
dashboardNewLayouts: true,
|
||||
dashboardUndoRedo: true,
|
||||
groupByVariable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -55,7 +55,13 @@ Cypress.on('uncaught:exception', (err) => {
|
||||
//
|
||||
|
||||
// TODO: read from toggles_gen.csv?
|
||||
const featureToggles = ['kubernetesDashboards', 'dashboardNewLayouts', 'dashboardScene', 'groupByVariable'];
|
||||
const featureToggles = [
|
||||
'kubernetesDashboards',
|
||||
'dashboardNewLayouts',
|
||||
'dashboardScene',
|
||||
'groupByVariable',
|
||||
'dashboardUndoRedo',
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
let toggles = [];
|
||||
|
||||
@@ -380,6 +380,10 @@ export interface FeatureToggles {
|
||||
*/
|
||||
dashboardNewLayouts?: boolean;
|
||||
/**
|
||||
* Enables undo/redo in dynamic dashboards
|
||||
*/
|
||||
dashboardUndoRedo?: boolean;
|
||||
/**
|
||||
* Enables use of the `systemPanelFilterVar` variable to filter panels in a dashboard
|
||||
*/
|
||||
panelFilterVariable?: boolean;
|
||||
|
||||
@@ -629,6 +629,13 @@ var (
|
||||
FrontendOnly: true,
|
||||
Owner: grafanaDashboardsSquad,
|
||||
},
|
||||
{
|
||||
Name: "dashboardUndoRedo",
|
||||
Description: "Enables undo/redo in dynamic dashboards",
|
||||
Stage: FeatureStageExperimental,
|
||||
FrontendOnly: true,
|
||||
Owner: grafanaDashboardsSquad,
|
||||
},
|
||||
{
|
||||
Name: "panelFilterVariable",
|
||||
Description: "Enables use of the `systemPanelFilterVar` variable to filter panels in a dashboard",
|
||||
|
||||
@@ -83,6 +83,7 @@ dashboardSceneForViewers,GA,@grafana/dashboards-squad,false,false,true
|
||||
dashboardSceneSolo,GA,@grafana/dashboards-squad,false,false,true
|
||||
dashboardScene,GA,@grafana/dashboards-squad,false,false,true
|
||||
dashboardNewLayouts,experimental,@grafana/dashboards-squad,false,false,true
|
||||
dashboardUndoRedo,experimental,@grafana/dashboards-squad,false,false,true
|
||||
panelFilterVariable,experimental,@grafana/dashboards-squad,false,false,true
|
||||
pdfTables,preview,@grafana/grafana-operator-experience-squad,false,false,false
|
||||
canvasPanelPanZoom,preview,@grafana/dataviz-squad,false,false,true
|
||||
|
||||
|
@@ -343,6 +343,10 @@ const (
|
||||
// Enables experimental new dashboard layouts
|
||||
FlagDashboardNewLayouts = "dashboardNewLayouts"
|
||||
|
||||
// FlagDashboardUndoRedo
|
||||
// Enables undo/redo in dynamic dashboards
|
||||
FlagDashboardUndoRedo = "dashboardUndoRedo"
|
||||
|
||||
// FlagPanelFilterVariable
|
||||
// Enables use of the `systemPanelFilterVar` variable to filter panels in a dashboard
|
||||
FlagPanelFilterVariable = "panelFilterVariable"
|
||||
|
||||
@@ -1066,6 +1066,19 @@
|
||||
"codeowner": "@grafana/grafana-app-platform-squad"
|
||||
}
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"name": "dashboardUndoRedo",
|
||||
"resourceVersion": "1757940426210",
|
||||
"creationTimestamp": "2025-09-15T12:47:06Z"
|
||||
},
|
||||
"spec": {
|
||||
"description": "Enables undo/redo in dynamic dashboards",
|
||||
"stage": "experimental",
|
||||
"codeowner": "@grafana/dashboards-squad",
|
||||
"frontend": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"name": "dashgpt",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { css } from '@emotion/css';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { ToolbarButton, ToolbarButtonRow, useStyles2 } from '@grafana/ui';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import { playlistSrv } from 'app/features/playlist/PlaylistSrv';
|
||||
@@ -43,10 +44,12 @@ export const RightActions = ({ dashboard }: { dashboard: DashboardScene }) => {
|
||||
const isEditingAndShowingDashboard = isEditingDashboard && isShowingDashboard;
|
||||
const isSnapshot = Boolean(meta.isSnapshot);
|
||||
const canSaveInFolder = contextSrv.hasEditPermissionInFolders;
|
||||
const canEditDashboard = dashboard.canEditDashboard();
|
||||
|
||||
const showPanelButtons = isEditingPanel && !hasEditView && !isViewingPanel;
|
||||
const showPlayButtons = isPlaying && isShowingDashboard && !isEditingDashboard;
|
||||
const showShareButton = hasUid && !isSnapshot && !isPlaying && !isEditingPanel;
|
||||
const showUndoRedoButtons = isEditingAndShowingDashboard && !!config.featureToggles.dashboardUndoRedo;
|
||||
|
||||
return (
|
||||
<ToolbarButtonRow alignment="right" className={styles.container}>
|
||||
@@ -107,19 +110,19 @@ export const RightActions = ({ dashboard }: { dashboard: DashboardScene }) => {
|
||||
key: 'dashboard-undo',
|
||||
component: UndoButton,
|
||||
group: 'dashboard',
|
||||
condition: isEditingAndShowingDashboard && dashboard.canEditDashboard(),
|
||||
condition: showUndoRedoButtons,
|
||||
},
|
||||
{
|
||||
key: 'dashboard-redo',
|
||||
component: RedoButton,
|
||||
group: 'dashboard',
|
||||
condition: isEditingAndShowingDashboard && dashboard.canEditDashboard(),
|
||||
condition: showUndoRedoButtons,
|
||||
},
|
||||
{
|
||||
key: 'dashboard-settings',
|
||||
component: DashboardSettingsButton,
|
||||
group: 'dashboard',
|
||||
condition: isEditingAndShowingDashboard && dashboard.canEditDashboard(),
|
||||
condition: isEditingAndShowingDashboard && canEditDashboard,
|
||||
},
|
||||
{
|
||||
key: 'save-dashboard',
|
||||
@@ -131,14 +134,14 @@ export const RightActions = ({ dashboard }: { dashboard: DashboardScene }) => {
|
||||
key: 'make-dashboard-editable-button',
|
||||
component: MakeDashboardEditableButton,
|
||||
group: 'save-edit',
|
||||
condition: !isEditing && dashboard.canEditDashboard() && !isViewingPanel && !isEditable && !isPlaying,
|
||||
condition: !isEditing && canEditDashboard && !isViewingPanel && !isEditable && !isPlaying,
|
||||
},
|
||||
{
|
||||
key: 'edit-dashboard-switch',
|
||||
component: EditDashboardSwitch,
|
||||
group: 'save-edit',
|
||||
condition:
|
||||
dashboard.canEditDashboard() &&
|
||||
canEditDashboard &&
|
||||
!isEditingPanel &&
|
||||
!isEditingLibraryPanel &&
|
||||
!isViewingPanel &&
|
||||
|
||||
Reference in New Issue
Block a user