Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions x-pack/plugins/lens/public/app_plugin/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EditorFrameInstance } from '../types';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
import { Document, SavedObjectStore } from '../persistence';
import { mount } from 'enzyme';
import { SavedObjectSaveModal } from '../../../../../src/plugins/saved_objects/public';
import {
esFilters,
FilterManager,
Expand Down Expand Up @@ -650,6 +651,27 @@ describe('Lens App', () => {
},
});
});

it('does not show the copy button on first save', async () => {
const args = defaultArgs;
args.editorFrame = frame;

instance = mount(<App {...args} />);

const onChange = frame.mount.mock.calls[0][1].onChange;
await act(async () =>
onChange({
filterableIndexPatterns: [],
doc: ({ expression: 'valid expression' } as unknown) as Document,
})
);
instance.update();

await act(async () => getButton(instance).run(instance.getDOMNode()));
instance.update();

expect(instance.find(SavedObjectSaveModal).prop('showCopyOnSave')).toEqual(false);
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/app_plugin/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export function App({
}}
onClose={() => setState(s => ({ ...s, isSaveModalVisible: false }))}
title={lastKnownDoc.title || ''}
showCopyOnSave={!addToDashboardMode}
showCopyOnSave={!!lastKnownDoc.id && !addToDashboardMode}
objectType={i18n.translate('xpack.lens.app.saveModalType', {
defaultMessage: 'Lens visualization',
})}
Expand Down