Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unified search] Moves dataview picker to the search bar #126560

Merged
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d78aaf4
[Unified search] Moves dataview picker to the search bar
stratoula Mar 1, 2022
9292972
alter texts
stratoula Mar 1, 2022
acc3d4d
Remove unused file
stratoula Mar 1, 2022
f73d85a
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 8, 2022
cad3238
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 10, 2022
620b871
[ChangeDataView] Design cleanup
Mar 10, 2022
12e5569
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 11, 2022
72b70e3
Merge branch 'unified-search-1' into unified--dataviewpicker-1
cchaos Mar 11, 2022
a5f0ace
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 14, 2022
f08329a
Fix services mock failure
stratoula Mar 14, 2022
a07371e
Show newly created datavuew on the list
stratoula Mar 14, 2022
83ad474
Keep dataview picker in discover in mobile view
stratoula Mar 14, 2022
404f47d
Cleanup
stratoula Mar 14, 2022
ba443a4
Cleanup translations
stratoula Mar 14, 2022
68ea6d9
Fix some discover FTs
stratoula Mar 14, 2022
50c740a
Fix management FTs
stratoula Mar 14, 2022
bea56df
More test fixes
stratoula Mar 14, 2022
f726e95
Added a dismissible tour
Mar 14, 2022
b52ce42
Pulled the selectabl list into a new component
Mar 14, 2022
05e3261
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 15, 2022
a555d1d
Fix broken jest test
stratoula Mar 15, 2022
37847f9
Use the same picker component on Discover mobile view
stratoula Mar 15, 2022
b85736b
Apply some CI fixes
stratoula Mar 15, 2022
afe4e4f
Fix more functional tests
stratoula Mar 15, 2022
eb6dfb1
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 15, 2022
db2b39e
More FTs fixes
stratoula Mar 15, 2022
0a1dde5
Close the tour popover for lens tests
stratoula Mar 15, 2022
7f7fd9a
More FTs fixes
stratoula Mar 15, 2022
9cf83dd
Fix lens FTs
stratoula Mar 15, 2022
2fd88f7
Using new `styles.ts` pattern for custom styles and allowing for `ful…
Mar 15, 2022
f2c1b8c
Merge branch 'unified--dataviewpicker-1' of github.com:stratoula/kiba…
Mar 15, 2022
935ff6a
Better tour text and i18n
Mar 15, 2022
7892db2
Update copy
Mar 15, 2022
80a3b22
No exclamation point
Mar 15, 2022
d3aa0e3
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 16, 2022
3d354e5
Cleanup
stratoula Mar 16, 2022
44ea2e7
Fixes on discover tests
stratoula Mar 16, 2022
74b8b1f
Fixes on Lens Fts - create runtime fields
stratoula Mar 16, 2022
6f46de5
Fixes on edit permission of add field in discover and some FTs fixes
stratoula Mar 16, 2022
cdefc53
Further Fts fixes
stratoula Mar 16, 2022
6a91bc6
More FTs fixes
stratoula Mar 16, 2022
19ca283
Made tour opt-in with `showNewMenuTour`
Mar 16, 2022
c08a610
Refactor the OSS FTs to change less files
stratoula Mar 16, 2022
f802d07
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 17, 2022
b32d1c3
Further cleanup on the FTs
stratoula Mar 17, 2022
301fb74
Merge branch 'unified--dataviewpicker-1' of https://github.com/strato…
stratoula Mar 17, 2022
c5e7c70
Remove unecessary action
stratoula Mar 17, 2022
c1872c8
Fix dataview creation bug
stratoula Mar 17, 2022
74c5d0f
Add a unit test to the new component
stratoula Mar 17, 2022
6c62ac1
More fixes
stratoula Mar 17, 2022
fe170f6
Fix OSS a11y tests
stratoula Mar 17, 2022
44c4845
Adds another unit test for Lens permissions
stratoula Mar 17, 2022
0064344
Merge with the feature branch and resolve conflicts
stratoula Mar 17, 2022
8b8995a
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 18, 2022
fe001e2
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 18, 2022
ee6ded5
Make a change to stabilize the tests
stratoula Mar 18, 2022
a7d667f
Clear flyout prop as it is not used anymore
stratoula Mar 18, 2022
231a6c7
Deisgn fixes for mobile view
stratoula Mar 18, 2022
c99c76b
Merge branch 'unified-search-1' into unified--dataviewpicker-1
kibanamachine Mar 21, 2022
2dc9cc4
Address PR comments WIP
stratoula Mar 21, 2022
e54f662
Merge branch 'unified-search-1' into unified--dataviewpicker-1
stratoula Mar 21, 2022
e52c18c
Update the layrpanl dataview list when a new dataview is created
stratoula Mar 21, 2022
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
2 changes: 1 addition & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export * from './deprecated';
*/

export { getEsQueryConfig, FilterStateStore } from '../common';
export { FilterLabel, FilterItem } from './ui';
export { FilterLabel, FilterItem, DataViewsList, DataViewPicker } from './ui';
export { getDisplayValueFromFilter, generateFilters, extractTimeRange } from './query';

/**
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export interface IDataPluginServices extends Partial<CoreStart> {
uiSettings: CoreStart['uiSettings'];
savedObjects: CoreStart['savedObjects'];
notifications: CoreStart['notifications'];
application: CoreStart['application'];
http: CoreStart['http'];
storage: IStorageWrapper;
data: DataPublicPluginStart;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const DATA_VIEW_POPOVER_CONTENT_WIDTH = 280;

export const ChangeDataViewStyles = ({ fullWidth }: { fullWidth?: boolean }) => {
return {
trigger: {
maxWidth: fullWidth ? undefined : DATA_VIEW_POPOVER_CONTENT_WIDTH,
},
popoverContent: {
width: DATA_VIEW_POPOVER_CONTENT_WIDTH,
},
};
};
137 changes: 137 additions & 0 deletions src/plugins/data/public/ui/dataview_picker/change_dataview.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { I18nProvider } from '@kbn/i18n-react';
import { act } from 'react-dom/test-utils';
import { mountWithIntl as mount } from '@kbn/test-jest-helpers';
import { KibanaContextProvider } from 'src/plugins/kibana_react/public';
import { dataPluginMock } from '../../mocks';
import { ChangeDataView } from './change_dataview';
import { EuiTourStep } from '@elastic/eui';
import type { DataViewPickerProps } from './index';

describe('DataView component', () => {
const createMockWebStorage = () => ({
clear: jest.fn(),
getItem: jest.fn(),
key: jest.fn(),
removeItem: jest.fn(),
setItem: jest.fn(),
length: 0,
});

const createMockStorage = () => ({
storage: createMockWebStorage(),
get: jest.fn(),
set: jest.fn(),
remove: jest.fn(),
clear: jest.fn(),
});
const getStorage = (v: boolean) => {
const storage = createMockStorage();
storage.get.mockReturnValue(v);
return storage;
};

function wrapDataViewComponentInContext(testProps: DataViewPickerProps, storageValue: boolean) {
let dataMock = dataPluginMock.createStartContract();
dataMock = {
...dataMock,
dataViews: {
...dataMock.dataViews,
getIdsWithTitle: jest.fn(),
},
};
const services = {
data: dataMock,
storage: getStorage(storageValue),
};

return (
<I18nProvider>
<KibanaContextProvider services={services}>
<ChangeDataView {...testProps} />
</KibanaContextProvider>
</I18nProvider>
);
}
let props: DataViewPickerProps;
beforeEach(() => {
props = {
currentDataViewId: 'dataview-1',
trigger: {
label: 'Dataview 1',
title: 'Dataview 1',
fullWidth: true,
'data-test-subj': 'dataview-trigger',
},
onChangeDataView: jest.fn(),
};
});
it('should not render the tour component by default', async () => {
await act(async () => {
const component = mount(wrapDataViewComponentInContext(props, true));
expect(component.find(EuiTourStep).prop('isStepOpen')).toBe(false);
});
});
it('should render the tour component if the showNewMenuTour is true', async () => {
const component = mount(
wrapDataViewComponentInContext({ ...props, showNewMenuTour: true }, false)
);
expect(component.find(EuiTourStep).prop('isStepOpen')).toBe(true);
});

it('should not render the add runtime field menu if addField is not given', async () => {
await act(async () => {
const component = mount(wrapDataViewComponentInContext(props, true));
component.find('[data-test-subj="dataview-trigger"]').first().simulate('click');
expect(component.find('[data-test-subj="indexPattern-add-field"]').length).toBe(0);
});
});

it('should render the add runtime field menu if addField is given', async () => {
const addFieldSpy = jest.fn();
const component = mount(
wrapDataViewComponentInContext(
{ ...props, onAddField: addFieldSpy, showNewMenuTour: true },
false
)
);
component.find('[data-test-subj="dataview-trigger"]').first().simulate('click');
expect(component.find('[data-test-subj="indexPattern-add-field"]').at(0).text()).toContain(
'Add a field to this data view'
);
component.find('[data-test-subj="indexPattern-add-field"]').first().simulate('click');
expect(addFieldSpy).toHaveBeenCalled();
});

it('should not render the add datavuew menu if onDataViewCreated is not given', async () => {
await act(async () => {
const component = mount(wrapDataViewComponentInContext(props, true));
component.find('[data-test-subj="dataview-trigger"]').first().simulate('click');
expect(component.find('[data-test-subj="idataview-create-new"]').length).toBe(0);
});
});

it('should render the add datavuew menu if onDataViewCreated is given', async () => {
const addDataViewSpy = jest.fn();
const component = mount(
wrapDataViewComponentInContext(
{ ...props, onDataViewCreated: addDataViewSpy, showNewMenuTour: true },
false
)
);
component.find('[data-test-subj="dataview-trigger"]').first().simulate('click');
expect(component.find('[data-test-subj="dataview-create-new"]').at(0).text()).toContain(
'Create a data view'
);
component.find('[data-test-subj="dataview-create-new"]').first().simulate('click');
expect(addDataViewSpy).toHaveBeenCalled();
});
});
Loading