Fixed copyTo by only copying explicit input (#98083)
This commit is contained in:
parent
b6e8e7be14
commit
6d9159e0b3
|
@ -25,8 +25,13 @@ import {
|
||||||
import { DashboardCopyToCapabilities } from './copy_to_dashboard_action';
|
import { DashboardCopyToCapabilities } from './copy_to_dashboard_action';
|
||||||
import { LazyDashboardPicker, withSuspense } from '../../services/presentation_util';
|
import { LazyDashboardPicker, withSuspense } from '../../services/presentation_util';
|
||||||
import { dashboardCopyToDashboardAction } from '../../dashboard_strings';
|
import { dashboardCopyToDashboardAction } from '../../dashboard_strings';
|
||||||
import { EmbeddableStateTransfer, IEmbeddable } from '../../services/embeddable';
|
import {
|
||||||
import { createDashboardEditUrl, DashboardConstants } from '../..';
|
EmbeddableStateTransfer,
|
||||||
|
IEmbeddable,
|
||||||
|
PanelNotFoundError,
|
||||||
|
} from '../../services/embeddable';
|
||||||
|
import { createDashboardEditUrl, DashboardConstants, DashboardContainer } from '../..';
|
||||||
|
import { DashboardPanelState } from '..';
|
||||||
|
|
||||||
interface CopyToDashboardModalProps {
|
interface CopyToDashboardModalProps {
|
||||||
capabilities: DashboardCopyToCapabilities;
|
capabilities: DashboardCopyToCapabilities;
|
||||||
|
@ -53,9 +58,16 @@ export function CopyToDashboardModal({
|
||||||
);
|
);
|
||||||
|
|
||||||
const onSubmit = useCallback(() => {
|
const onSubmit = useCallback(() => {
|
||||||
|
const dashboard = embeddable.getRoot() as DashboardContainer;
|
||||||
|
const panelToCopy = dashboard.getInput().panels[embeddable.id] as DashboardPanelState;
|
||||||
|
if (!panelToCopy) {
|
||||||
|
throw new PanelNotFoundError();
|
||||||
|
}
|
||||||
const state = {
|
const state = {
|
||||||
input: omit(embeddable.getInput(), 'id'),
|
|
||||||
type: embeddable.type,
|
type: embeddable.type,
|
||||||
|
input: {
|
||||||
|
...omit(panelToCopy.explicitInput, 'id'),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const path =
|
const path =
|
||||||
|
|
|
@ -91,6 +91,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
await PageObjects.dashboard.expectOnDashboard(`Editing ${fewPanelsTitle}`);
|
await PageObjects.dashboard.expectOnDashboard(`Editing ${fewPanelsTitle}`);
|
||||||
const newPanelCount = await PageObjects.dashboard.getPanelCount();
|
const newPanelCount = await PageObjects.dashboard.getPanelCount();
|
||||||
expect(newPanelCount).to.be(fewPanelsPanelCount + 1);
|
expect(newPanelCount).to.be(fewPanelsPanelCount + 1);
|
||||||
|
|
||||||
|
// Save & ensure that view mode is applied properly.
|
||||||
|
await PageObjects.dashboard.clickQuickSave();
|
||||||
|
await testSubjects.existOrFail('saveDashboardSuccess');
|
||||||
|
|
||||||
|
await PageObjects.dashboard.clickCancelOutOfEditMode();
|
||||||
|
const panelOptions = await dashboardPanelActions.getPanelHeading(markdownTitle);
|
||||||
|
await dashboardPanelActions.openContextMenu(panelOptions);
|
||||||
|
await dashboardPanelActions.expectMissingEditPanelAction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not show the current dashboard in the dashboard picker', async () => {
|
it('does not show the current dashboard in the dashboard picker', async () => {
|
||||||
|
|
Loading…
Reference in a new issue