Skip to content

Commit ac549ac

Browse files
Wylie Conlonmbondyra
andauthored
[Lens] Only show copy on save for previously saved docs (#63535)
* [Lens] Only show copy on save for previously saved docs * Update app.test.tsx import after kibana platform changes Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
1 parent 716211f commit ac549ac

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

x-pack/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,
@@ -650,6 +651,27 @@ describe('Lens App', () => {
650651
},
651652
});
652653
});
654+
655+
it('does not show the copy button on first save', async () => {
656+
const args = defaultArgs;
657+
args.editorFrame = frame;
658+
659+
instance = mount(<App {...args} />);
660+
661+
const onChange = frame.mount.mock.calls[0][1].onChange;
662+
await act(async () =>
663+
onChange({
664+
filterableIndexPatterns: [],
665+
doc: ({ expression: 'valid expression' } as unknown) as Document,
666+
})
667+
);
668+
instance.update();
669+
670+
await act(async () => getButton(instance).run(instance.getDOMNode()));
671+
instance.update();
672+
673+
expect(instance.find(SavedObjectSaveModal).prop('showCopyOnSave')).toEqual(false);
674+
});
653675
});
654676
});
655677

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

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

0 commit comments

Comments
 (0)