Dashboards: support undo/redo when grouping panels (#114787)
This commit is contained in:
@@ -19,6 +19,7 @@ import kbn from 'app/core/utils/kbn';
|
||||
import { ShowConfirmModalEvent } from 'app/types/events';
|
||||
|
||||
import { ConditionalRenderingGroup } from '../../conditional-rendering/group/ConditionalRenderingGroup';
|
||||
import { dashboardEditActions } from '../../edit-pane/shared';
|
||||
import { serializeRow } from '../../serialization/layoutSerializers/RowsLayoutSerializer';
|
||||
import { getElements } from '../../serialization/layoutSerializers/utils';
|
||||
import { getDashboardSceneFor } from '../../utils/utils';
|
||||
@@ -110,7 +111,18 @@ export class RowItem
|
||||
}
|
||||
|
||||
public switchLayout(layout: DashboardLayoutManager) {
|
||||
this.setState({ layout });
|
||||
const currentLayout = this.state.layout;
|
||||
|
||||
dashboardEditActions.edit({
|
||||
description: t('dashboard.edit-actions.switch-layout-row', 'Switch layout'),
|
||||
source: this,
|
||||
perform: () => {
|
||||
this.setState({ layout });
|
||||
},
|
||||
undo: () => {
|
||||
this.setState({ layout: currentLayout });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public useEditPaneOptions = useEditOptions.bind(this);
|
||||
|
||||
@@ -19,6 +19,7 @@ import kbn from 'app/core/utils/kbn';
|
||||
import { ShowConfirmModalEvent } from 'app/types/events';
|
||||
|
||||
import { ConditionalRenderingGroup } from '../../conditional-rendering/group/ConditionalRenderingGroup';
|
||||
import { dashboardEditActions } from '../../edit-pane/shared';
|
||||
import { serializeTab } from '../../serialization/layoutSerializers/TabsLayoutSerializer';
|
||||
import { getElements } from '../../serialization/layoutSerializers/utils';
|
||||
import { getDashboardSceneFor } from '../../utils/utils';
|
||||
@@ -108,7 +109,18 @@ export class TabItem
|
||||
}
|
||||
|
||||
public switchLayout(layout: DashboardLayoutManager) {
|
||||
this.setState({ layout });
|
||||
const currentLayout = this.state.layout;
|
||||
|
||||
dashboardEditActions.edit({
|
||||
description: t('dashboard.edit-actions.switch-layout-tab', 'Switch layout'),
|
||||
source: this,
|
||||
perform: () => {
|
||||
this.setState({ layout });
|
||||
},
|
||||
undo: () => {
|
||||
this.setState({ layout: currentLayout });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public useEditPaneOptions = useEditOptions.bind(this);
|
||||
|
||||
@@ -4781,6 +4781,8 @@
|
||||
"remove": "Remove {{typeName}}",
|
||||
"row-title": "Change row title",
|
||||
"switch-layout": "Switch layout",
|
||||
"switch-layout-row": "Switch layout",
|
||||
"switch-layout-tab": "Switch layout",
|
||||
"tab-title": "Change tab title"
|
||||
},
|
||||
"edit-pane": {
|
||||
|
||||
Reference in New Issue
Block a user