Skip to content

Commit 1a7bb9d

Browse files
committed
small change to allow cloning to work with #61692
1 parent df4edfa commit 1a7bb9d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { ClonePanelAction } from '.';
3232

3333
// eslint-disable-next-line
3434
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
35-
import { PLACEHOLDER_EMBEDDABLE } from '../embeddable/placeholder';
3635

3736
const { setup, doStart } = embeddablePluginMock.createInstance();
3837
setup.registerEmbeddableFactory(
@@ -116,7 +115,7 @@ test('Clones an embeddable without a saved object ID', async () => {
116115
test('Clones an embeddable with a saved object ID', async () => {
117116
const dashboard = embeddable.getRoot() as IContainer;
118117
const panel = dashboard.getInput().panels[embeddable.id] as DashboardPanelState;
119-
panel.savedObjectId = 'holySavedObjectBatman';
118+
panel.explicitInput.savedObjectId = 'holySavedObjectBatman';
120119
const action = new ClonePanelAction(coreStart);
121120
// @ts-ignore
122121
const newPanel = await action.cloneEmbeddable(panel, embeddable.type);

src/plugins/dashboard/public/application/actions/clone_panel_action.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import uuid from 'uuid';
2323
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
2424
import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin';
2525
import { SavedObject } from '../../../../saved_objects/public';
26-
import { PanelNotFoundError } from '../../../../embeddable/public';
26+
import { PanelNotFoundError, EmbeddableInput } from '../../../../embeddable/public';
2727
import {
2828
placePanelBeside,
2929
IPanelPlacementBesideArgs,
@@ -125,19 +125,19 @@ export class ClonePanelAction implements ActionByType<typeof ACTION_CLONE_PANEL>
125125
panelToClone: DashboardPanelState,
126126
embeddableType: string
127127
): Promise<Partial<PanelState>> {
128-
const panelState: Partial<PanelState> = {
128+
const panelState: PanelState<EmbeddableInput> = {
129129
type: embeddableType,
130130
explicitInput: {
131131
...panelToClone.explicitInput,
132132
id: uuid.v4(),
133133
},
134134
};
135135
let newTitle: string = '';
136-
if (panelToClone.savedObjectId) {
136+
if (panelToClone.explicitInput.savedObjectId) {
137137
// Fetch existing saved object
138138
const savedObjectToClone = await this.core.savedObjects.client.get<SavedObject>(
139139
embeddableType,
140-
panelToClone.savedObjectId
140+
panelToClone.explicitInput.savedObjectId
141141
);
142142

143143
// Clone the saved object
@@ -150,7 +150,7 @@ export class ClonePanelAction implements ActionByType<typeof ACTION_CLONE_PANEL>
150150
},
151151
{ references: _.cloneDeep(savedObjectToClone.references) }
152152
);
153-
panelState.savedObjectId = clonedSavedObject.id;
153+
panelState.explicitInput.savedObjectId = clonedSavedObject.id;
154154
}
155155
this.core.notifications.toasts.addSuccess({
156156
title: i18n.translate('dashboard.panel.clonedToast', {

0 commit comments

Comments
 (0)