Skip to content

Commit

Permalink
[Lens] Only show copy on save for previously saved docs (#63535)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
Wylie Conlon and mbondyra committed Apr 15, 2020
1 parent 716211f commit ac549ac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
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

0 comments on commit ac549ac

Please sign in to comment.