Skip to content

Commit 4978fab

Browse files
committed
[Lens] Only show copy on save for previously saved docs
1 parent 7cd746b commit 4978fab

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { EditorFrameInstance } from '../types';
1212
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
1313
import { Document, SavedObjectStore } from '../persistence';
1414
import { mount } from 'enzyme';
15+
import { SavedObjectSaveModal } from '../../../../../../src/plugins/saved_objects/public';
1516
import {
1617
esFilters,
1718
FilterManager,
@@ -647,6 +648,27 @@ describe('Lens App', () => {
647648
},
648649
});
649650
});
651+
652+
it('does not show the copy button on first save', async () => {
653+
const args = defaultArgs;
654+
args.editorFrame = frame;
655+
656+
instance = mount(<App {...args} />);
657+
658+
const onChange = frame.mount.mock.calls[0][1].onChange;
659+
await act(async () =>
660+
onChange({
661+
filterableIndexPatterns: [],
662+
doc: ({ expression: 'valid expression' } as unknown) as Document,
663+
})
664+
);
665+
instance.update();
666+
667+
await act(async () => getButton(instance).run(instance.getDOMNode()));
668+
instance.update();
669+
670+
expect(instance.find(SavedObjectSaveModal).prop('showCopyOnSave')).toEqual(false);
671+
});
650672
});
651673
});
652674

x-pack/legacy/plugins/lens/public/app_plugin/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export function App({
385385
}}
386386
onClose={() => setState(s => ({ ...s, isSaveModalVisible: false }))}
387387
title={lastKnownDoc.title || ''}
388-
showCopyOnSave={!addToDashboardMode}
388+
showCopyOnSave={!!lastKnownDoc.id && !addToDashboardMode}
389389
objectType={i18n.translate('xpack.lens.app.saveModalType', {
390390
defaultMessage: 'Lens visualization',
391391
})}

0 commit comments

Comments
 (0)