diff --git a/src/core/server/integration_tests/saved_objects/migrations/check_registered_types.test.ts b/src/core/server/integration_tests/saved_objects/migrations/check_registered_types.test.ts index e7d02da09889d..f6591cf7a7759 100644 --- a/src/core/server/integration_tests/saved_objects/migrations/check_registered_types.test.ts +++ b/src/core/server/integration_tests/saved_objects/migrations/check_registered_types.test.ts @@ -62,11 +62,11 @@ describe('checking migration metadata changes on all registered SO types', () => "app_search_telemetry": "7fc4fc08852bf0924ee29942bb394fda9aa8954d", "application_usage_daily": "6e645e0b60ef3af2e8fde80963c2a4f09a190d61", "application_usage_totals": "b2af3577dcd50bfae492b166a7804f69e2cc41dc", - "canvas-element": "5f32b99ba6ff9c1f17cc093591b975be65a27b9b", - "canvas-workpad": "b60252414fb6159a14f9febf98dbe41e5a8bf199", - "canvas-workpad-template": "c371cad0a8d61385f4782cab9a9063d3cf241ee0", + "canvas-element": "c27505dcf2970760bea8a0fe1d000253f0c40f08", + "canvas-workpad": "eb7b28a3b1c24af615edbf29becddf2e750a4bb5", + "canvas-workpad-template": "34454b811e32993eaa55c6ec85a7aecca00c4cfc", "cases": "7ff5ce930146a2d6fc8fbf536ce2ee16e9df296f", - "cases-comments": "8cfbad4ede637305eb6fb79db680f03dc0ce5ec4", + "cases-comments": "d7c4c1d24e97620cd415e27e5eb7d5b5f2c5b461", "cases-configure": "1afc414f5563a36e4612fa269193d3ed7277c7bd", "cases-connector-mappings": "4b16d440af966e5d6e0fa33368bfa15d987a4b69", "cases-telemetry": "16e261e7378a72acd0806f18df92525dd1da4f37", @@ -76,7 +76,7 @@ describe('checking migration metadata changes on all registered SO types', () => "core-usage-stats": "f40a213da2c597b0de94e364a4326a5a1baa4ca9", "csp-rule-template": "3679c5f2431da8153878db79c78a4e695357fb61", "csp_rule": "d2bb53ea5d2bdfba1a835ad8956dfcd2b2c32e19", - "dashboard": "0b0842b6aa40c125d64233fd81cee11080580dc2", + "dashboard": "742f2d9f110709fd8599b14f7766f38efc30de61", "endpoint:user-artifact": "f94c250a52b30d0a2d32635f8b4c5bdabd1e25c0", "endpoint:user-artifact-manifest": "8c14d49a385d5d1307d956aa743ec78de0b2be88", "enterprise_search_telemetry": "fafcc8318528d34f721c42d1270787c52565bad5", @@ -103,7 +103,7 @@ describe('checking migration metadata changes on all registered SO types', () => "inventory-view": "bc2bd1e7ec7c186159447ab228d269f22bd39056", "kql-telemetry": "29544cd7d3b767c5399878efae6bd724d24c03fd", "legacy-url-alias": "7172dfd54f2e0c89fe263fd7095519b2d826a930", - "lens": "08769c789ad6d1b8a4d0cffebc9d9bb08bf01ad9", + "lens": "236ecd358ed3a4ecfc03ed676d958b64acf0b697", "lens-ui-telemetry": "df2844565c9e18fed2bdb1f6cc3aadd58cf1e45b", "map": "00ca6c4cf46ae59f70f1436262eb9f457b45eb14", "maps-telemetry": "5adbde35bd50ec2b8e9ea5b96d4d9f886e31ecfb", diff --git a/x-pack/examples/embedded_lens_example/public/app.tsx b/x-pack/examples/embedded_lens_example/public/app.tsx index 42784984a0d44..e4df914a54c3c 100644 --- a/x-pack/examples/embedded_lens_example/public/app.tsx +++ b/x-pack/examples/embedded_lens_example/public/app.tsx @@ -100,7 +100,7 @@ function getLensAttributes( ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer1: dataLayer!, }, diff --git a/x-pack/examples/testing_embedded_lens/public/app.tsx b/x-pack/examples/testing_embedded_lens/public/app.tsx index cd550a9280004..2b8799c1951a3 100644 --- a/x-pack/examples/testing_embedded_lens/public/app.tsx +++ b/x-pack/examples/testing_embedded_lens/public/app.tsx @@ -148,7 +148,7 @@ function getBaseAttributes( ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer1: finalDataLayer, }, diff --git a/x-pack/examples/third_party_lens_navigation_prompt/public/plugin.ts b/x-pack/examples/third_party_lens_navigation_prompt/public/plugin.ts index aca5f5d0b37b8..0538c7f501742 100644 --- a/x-pack/examples/third_party_lens_navigation_prompt/public/plugin.ts +++ b/x-pack/examples/third_party_lens_navigation_prompt/public/plugin.ts @@ -71,7 +71,7 @@ function getLensAttributes(defaultDataView: DataView): TypedLensByValueInput['at ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer1: dataLayer, }, diff --git a/x-pack/examples/third_party_vis_lens_example/README.md b/x-pack/examples/third_party_vis_lens_example/README.md index f2fa563f33393..ccb8fc69d41ae 100644 --- a/x-pack/examples/third_party_vis_lens_example/README.md +++ b/x-pack/examples/third_party_vis_lens_example/README.md @@ -16,7 +16,7 @@ To test the migration, you can import the following ndjson file via saved object ``` {"attributes":{"fieldFormatMap":"{\"hour_of_day\":{}}","runtimeFieldMap":"{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['timestamp'].value.getHour());\"}}}","timeFieldName":"timestamp","title":"kibana_sample_data_logs"},"coreMigrationVersion":"8.0.0","id":"90943e30-9a47-11e8-b64d-95841ca0b247","migrationVersion":{"index-pattern":"8.0.0"},"references":[],"type":"index-pattern","updated_at":"2022-01-24T10:54:24.209Z","version":"WzQzMTQ3LDFd"} -{"attributes":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"f2700077-50bf-48e4-829c-f695f87e226d":{"columnOrder":["5e704cac-8490-457a-b635-01f3a5a132b7"],"columns":{"5e704cac-8490-457a-b635-01f3a5a132b7":{"dataType":"number","isBucketed":false,"label":"Count of records","operationType":"count","scale":"ratio","sourceField":"Records"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"column":"5e704cac-8490-457a-b635-01f3a5a132b7","layerId":"f2700077-50bf-48e4-829c-f695f87e226d"}},"title":"Rotating number test","visualizationType":"rotatingNumber"},"coreMigrationVersion":"8.0.0","id":"468f0be0-7e86-11ec-9739-d570ffd3fbe4","migrationVersion":{"lens":"8.0.0"},"references":[{"id":"90943e30-9a47-11e8-b64d-95841ca0b247","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"90943e30-9a47-11e8-b64d-95841ca0b247","name":"indexpattern-datasource-layer-f2700077-50bf-48e4-829c-f695f87e226d","type":"index-pattern"}],"type":"lens","updated_at":"2022-01-26T08:59:31.618Z","version":"WzQzNjUzLDFd"} +{"attributes":{"description":"","state":{"datasourceStates":{"formBased":{"layers":{"f2700077-50bf-48e4-829c-f695f87e226d":{"columnOrder":["5e704cac-8490-457a-b635-01f3a5a132b7"],"columns":{"5e704cac-8490-457a-b635-01f3a5a132b7":{"dataType":"number","isBucketed":false,"label":"Count of records","operationType":"count","scale":"ratio","sourceField":"Records"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"column":"5e704cac-8490-457a-b635-01f3a5a132b7","layerId":"f2700077-50bf-48e4-829c-f695f87e226d"}},"title":"Rotating number test","visualizationType":"rotatingNumber"},"coreMigrationVersion":"8.0.0","id":"468f0be0-7e86-11ec-9739-d570ffd3fbe4","migrationVersion":{"lens":"8.0.0"},"references":[{"id":"90943e30-9a47-11e8-b64d-95841ca0b247","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"90943e30-9a47-11e8-b64d-95841ca0b247","name":"indexpattern-datasource-layer-f2700077-50bf-48e4-829c-f695f87e226d","type":"index-pattern"}],"type":"lens","updated_at":"2022-01-26T08:59:31.618Z","version":"WzQzNjUzLDFd"} {"excludedObjects":[],"excludedObjectsCount":0,"exportedCount":2,"missingRefCount":0,"missingReferences":[]} ``` diff --git a/x-pack/examples/third_party_vis_lens_example/public/plugin.ts b/x-pack/examples/third_party_vis_lens_example/public/plugin.ts index f7a0378619b3a..38922ae676666 100644 --- a/x-pack/examples/third_party_vis_lens_example/public/plugin.ts +++ b/x-pack/examples/third_party_vis_lens_example/public/plugin.ts @@ -67,7 +67,7 @@ function getLensAttributes(defaultDataView: DataView): TypedLensByValueInput['at ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer1: dataLayer, }, diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts index 034f7037fc29a..b053715090c7b 100644 --- a/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts @@ -282,7 +282,7 @@ export function getLensAttributes( ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer1: { columnOrder: ['col1', 'col2'], diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/hosts_table.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/hosts_table.tsx index e92ac801e8612..143f7fedb1420 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/hosts_table.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/hosts_table.tsx @@ -35,7 +35,7 @@ const getLensHostsTable = ( ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { 'cbe5d8a0-381d-49bf-b8ac-f8f312ec7129': { columns: { diff --git a/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx b/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx index 4176e5f1e51a7..f2b4d2b315148 100644 --- a/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx +++ b/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx @@ -644,7 +644,7 @@ export const LensTopNavMenu = ({ setIsOnTextBasedMode(true); dispatch( switchAndCleanDatasource({ - newDatasourceId: 'textBasedLanguages', + newDatasourceId: 'textBased', visualizationId: visualization?.activeId, currentIndexPatternId: currentIndexPattern?.id, }) @@ -764,7 +764,7 @@ export const LensTopNavMenu = ({ if (isOnTextBasedMode) { dispatch( switchAndCleanDatasource({ - newDatasourceId: 'indexpattern', + newDatasourceId: 'formBased', visualizationId: visualization?.activeId, currentIndexPatternId: dataView?.id, }) @@ -795,7 +795,7 @@ export const LensTopNavMenu = ({ if (isOnTextBasedMode) { dispatch( switchAndCleanDatasource({ - newDatasourceId: 'indexpattern', + newDatasourceId: 'formBased', visualizationId: visualization?.activeId, currentIndexPatternId: dataView?.id, }) @@ -838,7 +838,7 @@ export const LensTopNavMenu = ({ if (isOnTextBasedMode) { dispatch( switchAndCleanDatasource({ - newDatasourceId: 'indexpattern', + newDatasourceId: 'formBased', visualizationId: visualization?.activeId, currentIndexPatternId: newIndexPatternId, }) diff --git a/x-pack/plugins/lens/public/app_plugin/show_underlying_data.test.ts b/x-pack/plugins/lens/public/app_plugin/show_underlying_data.test.ts index bd6b7a000ecd6..b185697021105 100644 --- a/x-pack/plugins/lens/public/app_plugin/show_underlying_data.test.ts +++ b/x-pack/plugins/lens/public/app_plugin/show_underlying_data.test.ts @@ -93,7 +93,7 @@ describe('getLayerMetaInfo', () => { it('should return error in case of getFilters returning errors', () => { const mockDatasource = createMockDatasource('testDatasource'); const updatedPublicAPI: DatasourcePublicAPI = { - datasourceId: 'indexpattern', + datasourceId: 'formBased', getOperationForColumnId: jest.fn(), getTableSpec: jest.fn(() => [{ columnId: 'col1', fields: ['bytes'] }]), getVisualDefaults: jest.fn(), @@ -166,7 +166,7 @@ describe('getLayerMetaInfo', () => { it('should basically work collecting fields and filters in the visualization', () => { const mockDatasource = createMockDatasource('testDatasource'); const updatedPublicAPI: DatasourcePublicAPI = { - datasourceId: 'indexpattern', + datasourceId: 'formBased', getOperationForColumnId: jest.fn(), getTableSpec: jest.fn(() => [{ columnId: 'col1', fields: ['bytes'] }]), getVisualDefaults: jest.fn(), diff --git a/x-pack/plugins/lens/public/async_services.ts b/x-pack/plugins/lens/public/async_services.ts index c0ccd2a71ce2b..1aa40cda21445 100644 --- a/x-pack/plugins/lens/public/async_services.ts +++ b/x-pack/plugins/lens/public/async_services.ts @@ -29,12 +29,12 @@ export * from './visualizations/heatmap'; export * from './visualizations/gauge/gauge_visualization'; export * from './visualizations/gauge'; -export * from './indexpattern_datasource/indexpattern'; -export { getTextBasedLanguagesDatasource } from './text_based_languages_datasource/text_based_languages'; -export { createFormulaPublicApi } from './indexpattern_datasource/operations/definitions/formula/formula_public_api'; +export * from './datasources/form_based/form_based'; +export { getTextBasedDatasource } from './datasources/text_based/text_based_languages'; +export { createFormulaPublicApi } from './datasources/form_based/operations/definitions/formula/formula_public_api'; -export * from './text_based_languages_datasource'; -export * from './indexpattern_datasource'; +export * from './datasources/text_based'; +export * from './datasources/form_based'; export * from './lens_ui_telemetry'; export * from './lens_ui_errors'; export * from './editor_frame_service/editor_frame'; diff --git a/x-pack/plugins/lens/public/data_views_service/loader.test.ts b/x-pack/plugins/lens/public/data_views_service/loader.test.ts index 340bc675bf3e7..97ded75233cda 100644 --- a/x-pack/plugins/lens/public/data_views_service/loader.test.ts +++ b/x-pack/plugins/lens/public/data_views_service/loader.test.ts @@ -14,7 +14,7 @@ import { syncExistingFields, } from './loader'; import { sampleIndexPatterns, mockDataViewsService } from './mocks'; -import { documentField } from '../indexpattern_datasource/document_field'; +import { documentField } from '../datasources/form_based/document_field'; import { coreMock } from '@kbn/core/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import type { DataView } from '@kbn/data-views-plugin/public'; diff --git a/x-pack/plugins/lens/public/data_views_service/loader.ts b/x-pack/plugins/lens/public/data_views_service/loader.ts index 3bb1bdf0612a7..f0184d0a11d0b 100644 --- a/x-pack/plugins/lens/public/data_views_service/loader.ts +++ b/x-pack/plugins/lens/public/data_views_service/loader.ts @@ -12,7 +12,7 @@ import { CoreStart } from '@kbn/core/public'; import { DataPublicPluginStart } from '@kbn/data-plugin/public'; import { loadFieldExisting } from '@kbn/unified-field-list-plugin/public'; import { IndexPattern, IndexPatternField, IndexPatternMap, IndexPatternRef } from '../types'; -import { documentField } from '../indexpattern_datasource/document_field'; +import { documentField } from '../datasources/form_based/document_field'; import { DateRange } from '../../common'; import { DataViewsState } from '../state_management'; diff --git a/x-pack/plugins/lens/public/data_views_service/mocks.ts b/x-pack/plugins/lens/public/data_views_service/mocks.ts index 9b7f5cbc2a91a..ed8d6e86e58a4 100644 --- a/x-pack/plugins/lens/public/data_views_service/mocks.ts +++ b/x-pack/plugins/lens/public/data_views_service/mocks.ts @@ -6,11 +6,11 @@ */ import { DataViewsContract } from '@kbn/data-views-plugin/common'; -import { documentField } from '../indexpattern_datasource/document_field'; +import { documentField } from '../datasources/form_based/document_field'; import { createMockedIndexPattern, createMockedRestrictedIndexPattern, -} from '../indexpattern_datasource/mocks'; +} from '../datasources/form_based/mocks'; import { DataViewsState } from '../state_management'; import { ExistingFieldsMap, IndexPattern } from '../types'; import { getFieldByNameFactory } from './loader'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/__mocks__/loader.ts b/x-pack/plugins/lens/public/datasources/form_based/__mocks__/loader.ts similarity index 91% rename from x-pack/plugins/lens/public/indexpattern_datasource/__mocks__/loader.ts rename to x-pack/plugins/lens/public/datasources/form_based/__mocks__/loader.ts index 1273d596576c4..47af8d816b73f 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/__mocks__/loader.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/__mocks__/loader.ts @@ -6,11 +6,11 @@ */ import { createMockedIndexPattern, createMockedRestrictedIndexPattern } from '../mocks'; -import { IndexPatternPrivateState } from '../types'; +import { FormBasedPrivateState } from '../types'; export function loadInitialState() { const indexPattern = createMockedIndexPattern(); - const result: IndexPatternPrivateState = { + const result: FormBasedPrivateState = { currentIndexPatternId: indexPattern.id, layers: {}, }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/__snapshots__/utils.test.tsx.snap b/x-pack/plugins/lens/public/datasources/form_based/__snapshots__/utils.test.tsx.snap similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/__snapshots__/utils.test.tsx.snap rename to x-pack/plugins/lens/public/datasources/form_based/__snapshots__/utils.test.tsx.snap diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.scss b/x-pack/plugins/lens/public/datasources/form_based/datapanel.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/datapanel.scss rename to x-pack/plugins/lens/public/datasources/form_based/datapanel.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/datapanel.test.tsx similarity index 93% rename from x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/datapanel.test.tsx index 7ee461aa63369..deb9642e25dc3 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/datapanel.test.tsx @@ -13,13 +13,13 @@ import { dataViewPluginMocks, Start as DataViewPublicStart, } from '@kbn/data-views-plugin/public/mocks'; -import { InnerIndexPatternDataPanel, IndexPatternDataPanel, Props } from './datapanel'; +import { InnerFormBasedDataPanel, FormBasedDataPanel, Props } from './datapanel'; import { FieldList } from './field_list'; import { FieldItem } from './field_item'; import { NoFieldsCallout } from './no_fields_callout'; import { act } from 'react-dom/test-utils'; import { coreMock } from '@kbn/core/public/mocks'; -import { IndexPatternPrivateState } from './types'; +import { FormBasedPrivateState } from './types'; import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { EuiProgress, EuiLoadingSpinner } from '@elastic/eui'; import { documentField } from './document_field'; @@ -29,12 +29,12 @@ import { indexPatternFieldEditorPluginMock } from '@kbn/data-view-field-editor-p import { getFieldByNameFactory } from './pure_helpers'; import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; import { TermsIndexPatternColumn } from './operations'; -import { DOCUMENT_FIELD_NAME } from '../../common'; -import { createIndexPatternServiceMock } from '../mocks/data_views_service_mock'; -import { createMockFramePublicAPI } from '../mocks'; -import { DataViewsState } from '../state_management'; -import { ExistingFieldsMap, FramePublicAPI, IndexPattern } from '../types'; -import { IndexPatternServiceProps } from '../data_views_service/service'; +import { DOCUMENT_FIELD_NAME } from '../../../common'; +import { createIndexPatternServiceMock } from '../../mocks/data_views_service_mock'; +import { createMockFramePublicAPI } from '../../mocks'; +import { DataViewsState } from '../../state_management'; +import { ExistingFieldsMap, FramePublicAPI, IndexPattern } from '../../types'; +import { IndexPatternServiceProps } from '../../data_views_service/service'; import { FieldSpec, DataView } from '@kbn/data-views-plugin/public'; import { UI_SETTINGS } from '@kbn/data-plugin/public'; @@ -174,7 +174,7 @@ function getExistingFields(indexPatterns: Record) { return existingFields; } -const initialState: IndexPatternPrivateState = { +const initialState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -285,7 +285,7 @@ const dslQuery = { bool: { must: [], filter: [], should: [], must_not: [] } }; // @ts-expect-error Portal mocks are notoriously difficult to type ReactDOM.createPortal = jest.fn((element) => element); -describe('IndexPattern Data Panel', () => { +describe('FormBased Data Panel', () => { const indexPatterns = { a: { id: 'a', @@ -304,7 +304,7 @@ describe('IndexPattern Data Panel', () => { hasRestrictions: false, }, }; - let defaultProps: Parameters[0] & { + let defaultProps: Parameters[0] & { showNoDataPopover: () => void; }; let core: ReturnType; @@ -340,7 +340,7 @@ describe('IndexPattern Data Panel', () => { it('should render a warning if there are no index patterns', () => { const wrapper = shallowWithIntl( - { columns: {}, }, }, - } as IndexPatternPrivateState, + } as FormBasedPrivateState, }; } async function testExistenceLoading( props: Props, - stateChanges?: Partial, + stateChanges?: Partial, propChanges?: Partial ) { - const inst = mountWithIntl(); + const inst = mountWithIntl(); await act(async () => { inst.update(); @@ -601,7 +601,7 @@ describe('IndexPattern Data Panel', () => { it('shows a loading indicator when loading', async () => { const updateIndexPatterns = jest.fn(); const load = async () => {}; - const inst = mountWithIntl(); + const inst = mountWithIntl(); expect(inst.find(EuiProgress).length).toEqual(1); await act(load); inst.update(); @@ -629,7 +629,7 @@ describe('IndexPattern Data Panel', () => { return result; }); - const inst = mountWithIntl(); + const inst = mountWithIntl(); inst.update(); @@ -676,7 +676,7 @@ describe('IndexPattern Data Panel', () => { }); describe('displaying field list', () => { - let props: Parameters[0]; + let props: Parameters[0]; beforeEach(() => { props = { ...defaultProps, @@ -691,7 +691,7 @@ describe('IndexPattern Data Panel', () => { }; }); it('should list all supported fields in the pattern sorted alphabetically in groups', async () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); expect(wrapper.find(FieldItem).first().prop('field').displayName).toEqual('Records'); expect( wrapper @@ -715,7 +715,7 @@ describe('IndexPattern Data Panel', () => { it('should show meta fields accordion', async () => { const wrapper = mountWithIntl( - { it('should display NoFieldsCallout when all fields are empty', async () => { const wrapper = mountWithIntl( - @@ -780,7 +780,7 @@ describe('IndexPattern Data Panel', () => { it('should display spinner for available fields accordion if existing fields are not loaded yet', async () => { const wrapper = mountWithIntl( - @@ -795,7 +795,7 @@ describe('IndexPattern Data Panel', () => { it('should not allow field details when error', () => { const wrapper = mountWithIntl( - @@ -810,7 +810,7 @@ describe('IndexPattern Data Panel', () => { it('should allow field details when timeout', () => { const wrapper = mountWithIntl( - @@ -824,7 +824,7 @@ describe('IndexPattern Data Panel', () => { }); it('should filter down by name', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); act(() => { wrapper.find('[data-test-subj="lnsIndexPatternFieldSearch"]').simulate('change', { target: { value: 'me' }, @@ -843,7 +843,7 @@ describe('IndexPattern Data Panel', () => { }); it('should announce filter in live region', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); act(() => { wrapper.find('[data-test-subj="lnsIndexPatternFieldSearch"]').simulate('change', { target: { value: 'me' }, @@ -862,7 +862,7 @@ describe('IndexPattern Data Panel', () => { }); it('should filter down by type', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); wrapper.find('[data-test-subj="lnsIndexPatternFiltersToggle"]').first().simulate('click'); @@ -874,7 +874,7 @@ describe('IndexPattern Data Panel', () => { }); it('should display no fields in groups when filtered by type Record', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); wrapper.find('[data-test-subj="lnsIndexPatternFiltersToggle"]').first().simulate('click'); @@ -887,7 +887,7 @@ describe('IndexPattern Data Panel', () => { }); it('should toggle type if clicked again', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); wrapper.find('[data-test-subj="lnsIndexPatternFiltersToggle"]').first().simulate('click'); wrapper.find('[data-test-subj="typeFilter-number"]').first().simulate('click'); @@ -903,7 +903,7 @@ describe('IndexPattern Data Panel', () => { }); it('should filter down by type and by name', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); act(() => { wrapper.find('[data-test-subj="lnsIndexPatternFieldSearch"]').simulate('change', { target: { value: 'me' }, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.tsx b/x-pack/plugins/lens/public/datasources/form_based/datapanel.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/datapanel.tsx rename to x-pack/plugins/lens/public/datasources/form_based/datapanel.tsx index 4107cd0c14fa5..970db62925fe6 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/datapanel.tsx @@ -39,18 +39,18 @@ import type { FramePublicAPI, IndexPattern, IndexPatternField, -} from '../types'; -import { ChildDragDropProvider, DragContextState } from '../drag_drop'; -import type { IndexPatternPrivateState } from './types'; -import { Loader } from '../loader'; -import { LensFieldIcon } from '../shared_components/field_picker/lens_field_icon'; +} from '../../types'; +import { ChildDragDropProvider, DragContextState } from '../../drag_drop'; +import type { FormBasedPrivateState } from './types'; +import { Loader } from '../../loader'; +import { LensFieldIcon } from '../../shared_components/field_picker/lens_field_icon'; import { getFieldType } from './pure_utils'; import { FieldGroups, FieldList } from './field_list'; -import { fieldContainsData, fieldExists } from '../shared_components'; -import { IndexPatternServiceAPI } from '../data_views_service/service'; +import { fieldContainsData, fieldExists } from '../../shared_components'; +import { IndexPatternServiceAPI } from '../../data_views_service/service'; export type Props = Omit< - DatasourceDataPanelProps, + DatasourceDataPanelProps, 'core' | 'onChangeIndexPattern' > & { data: DataPublicPluginStart; @@ -124,7 +124,7 @@ function buildSafeEsQuery( } } -export function IndexPatternDataPanel({ +export function FormBasedDataPanel({ state, dragDropContext, core, @@ -264,7 +264,7 @@ const defaultFieldGroups: { const htmlId = htmlIdGenerator('datapanel'); const fieldSearchDescriptionId = htmlId(); -export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({ +export const InnerFormBasedDataPanel = function InnerFormBasedDataPanel({ currentIndexPatternId, query, dateRange, @@ -751,4 +751,4 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({ ); }; -export const MemoizedDataPanel = memo(InnerIndexPatternDataPanel); +export const MemoizedDataPanel = memo(InnerFormBasedDataPanel); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dedupe_aggs.test.ts b/x-pack/plugins/lens/public/datasources/form_based/dedupe_aggs.test.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dedupe_aggs.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/dedupe_aggs.test.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dedupe_aggs.ts b/x-pack/plugins/lens/public/datasources/form_based/dedupe_aggs.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dedupe_aggs.ts rename to x-pack/plugins/lens/public/datasources/form_based/dedupe_aggs.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/advanced_options.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/advanced_options.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/advanced_options.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/advanced_options.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/bucket_nesting_editor.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/bucket_nesting_editor.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/bucket_nesting_editor.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/bucket_nesting_editor.test.tsx index 248cc0f78756e..6c09849df04ac 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/bucket_nesting_editor.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/bucket_nesting_editor.test.tsx @@ -8,8 +8,8 @@ import { mount } from 'enzyme'; import React from 'react'; import { BucketNestingEditor } from './bucket_nesting_editor'; -import { GenericIndexPatternColumn } from '../indexpattern'; -import { IndexPatternField } from '../../types'; +import { GenericIndexPatternColumn } from '../form_based'; +import { IndexPatternField } from '../../../types'; const fieldMap: Record = { a: { displayName: 'a' } as IndexPatternField, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/bucket_nesting_editor.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/bucket_nesting_editor.tsx similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/bucket_nesting_editor.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/bucket_nesting_editor.tsx index 31a4b91706dfa..fb062e4231467 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/bucket_nesting_editor.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/bucket_nesting_editor.tsx @@ -8,10 +8,10 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRow, EuiSwitch, EuiSelect } from '@elastic/eui'; -import { IndexPatternLayer } from '../types'; +import { FormBasedLayer } from '../types'; import { hasField } from '../pure_utils'; import { GenericIndexPatternColumn } from '../operations'; -import { IndexPatternField } from '../../types'; +import { IndexPatternField } from '../../../types'; function nestColumn(columnOrder: string[], outer: string, inner: string) { const result = columnOrder.filter((c) => c !== inner); @@ -38,7 +38,7 @@ export function BucketNestingEditor({ getFieldByName, }: { columnId: string; - layer: IndexPatternLayer; + layer: FormBasedLayer; setColumns: (columns: string[]) => void; getFieldByName: (name: string) => IndexPatternField | undefined; }) { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.scss b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.scss rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx index b4cad9aa73697..330d3285b2951 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx @@ -27,9 +27,9 @@ import { EuiButtonIcon, } from '@elastic/eui'; import ReactDOM from 'react-dom'; -import type { IndexPatternDimensionEditorProps } from './dimension_panel'; +import type { FormBasedDimensionEditorProps } from './dimension_panel'; import type { OperationSupportMatrix } from './operation_support'; -import { deleteColumn, GenericIndexPatternColumn } from '../indexpattern'; +import { deleteColumn, GenericIndexPatternColumn } from '../form_based'; import { operationDefinitionMap, getOperationDisplay, @@ -46,7 +46,7 @@ import { mergeLayer } from '../state_helpers'; import { getReferencedField, hasField } from '../pure_utils'; import { fieldIsInvalid } from '../utils'; import { BucketNestingEditor } from './bucket_nesting_editor'; -import type { IndexPatternLayer } from '../types'; +import type { FormBasedLayer } from '../types'; import { FormatSelector } from './format_selector'; import { ReferenceEditor } from './reference_editor'; import { TimeScaling } from './time_scaling'; @@ -54,8 +54,8 @@ import { Filtering } from './filtering'; import { ReducedTimeRange } from './reduced_time_range'; import { AdvancedOptions } from './advanced_options'; import { TimeShift } from './time_shift'; -import type { LayerType } from '../../../common'; -import { DOCUMENT_FIELD_NAME } from '../../../common'; +import type { LayerType } from '../../../../common'; +import { DOCUMENT_FIELD_NAME } from '../../../../common'; import { quickFunctionsName, staticValueOperationName, @@ -68,15 +68,15 @@ import { } from './dimensions_editor_helpers'; import type { TemporaryState } from './dimensions_editor_helpers'; import { FieldInput } from './field_input'; -import { NameInput } from '../../shared_components'; +import { NameInput } from '../../../shared_components'; import { ParamEditorProps } from '../operations/definitions'; import { WrappingHelpPopover } from '../help_popover'; import { isColumn } from '../operations/definitions/helpers'; import type { FieldChoiceWithOperationType } from './field_select'; -import type { IndexPattern, IndexPatternField } from '../../types'; +import type { IndexPattern, IndexPatternField } from '../../../types'; import { documentField } from '../document_field'; -export interface DimensionEditorProps extends IndexPatternDimensionEditorProps { +export interface DimensionEditorProps extends FormBasedDimensionEditorProps { selectedColumn?: GenericIndexPatternColumn; layerType: LayerType; operationSupportMatrix: OperationSupportMatrix; @@ -142,13 +142,13 @@ export function DimensionEditor(props: DimensionEditorProps) { const setStateWrapper = useCallback( ( setter: - | IndexPatternLayer - | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) + | FormBasedLayer + | ((prevLayer: FormBasedLayer) => FormBasedLayer) | GenericIndexPatternColumn, options: { forceRender?: boolean } = {} ) => { const layer = state.layers[layerId]; - let hypotethicalLayer: IndexPatternLayer; + let hypotethicalLayer: FormBasedLayer; if (isColumn(setter)) { hypotethicalLayer = { ...layer, @@ -164,7 +164,7 @@ export function DimensionEditor(props: DimensionEditorProps) { setState( (prevState) => { - let outputLayer: IndexPatternLayer; + let outputLayer: FormBasedLayer; const prevLayer = prevState.layers[layerId]; if (isColumn(setter)) { outputLayer = { @@ -250,8 +250,8 @@ export function DimensionEditor(props: DimensionEditorProps) { // TODO: revisit this once we get rid of updateDatasourceAsync upstream const moveDefinetelyToStaticValueAndUpdate = ( setter: - | IndexPatternLayer - | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) + | FormBasedLayer + | ((prevLayer: FormBasedLayer) => FormBasedLayer) | GenericIndexPatternColumn ) => { if (temporaryStaticValue) { @@ -501,7 +501,7 @@ export function DimensionEditor(props: DimensionEditorProps) { } else if (!selectedColumn || !compatibleWithCurrentField) { const possibleFields = fieldByOperation[operationType] || new Set(); - let newLayer: IndexPatternLayer; + let newLayer: FormBasedLayer; if (possibleFields.size === 1) { newLayer = insertOrReplaceColumn({ layer: props.state.layers[props.layerId], @@ -585,9 +585,7 @@ export function DimensionEditor(props: DimensionEditorProps) { const paramEditorProps: ParamEditorProps< GenericIndexPatternColumn, - | IndexPatternLayer - | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) - | GenericIndexPatternColumn + FormBasedLayer | ((prevLayer: FormBasedLayer) => FormBasedLayer) | GenericIndexPatternColumn > = { layer: state.layers[layerId], layerId, @@ -769,11 +767,11 @@ export function DimensionEditor(props: DimensionEditorProps) { }} paramEditorUpdater={( setter: - | IndexPatternLayer - | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) + | FormBasedLayer + | ((prevLayer: FormBasedLayer) => FormBasedLayer) | GenericIndexPatternColumn ) => { - let newLayer: IndexPatternLayer; + let newLayer: FormBasedLayer; if (typeof setter === 'function') { newLayer = setter(layer); } else if (isColumn(setter)) { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx similarity index 89% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx index 41dd1df5bcd92..456b1537db97c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx @@ -21,8 +21,8 @@ import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { DataPublicPluginStart } from '@kbn/data-plugin/public'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; import { - IndexPatternDimensionEditorComponent, - IndexPatternDimensionEditorProps, + FormBasedDimensionEditorComponent, + FormBasedDimensionEditorProps, } from './dimension_panel'; import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { @@ -32,9 +32,9 @@ import { CoreStart, } from '@kbn/core/public'; import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public'; +import { generateId } from '../../../id_generator'; +import { FormBasedPrivateState } from '../types'; import { LayerTypes } from '@kbn/expression-xy-plugin/public'; -import { generateId } from '../../id_generator'; -import { IndexPatternPrivateState } from '../types'; import { FiltersIndexPatternColumn, GenericIndexPatternColumn, @@ -42,7 +42,7 @@ import { TermsIndexPatternColumn, } from '../operations'; import { documentField } from '../document_field'; -import { OperationMetadata } from '../../types'; +import { OperationMetadata } from '../../../types'; import { DateHistogramIndexPatternColumn } from '../operations/definitions/date_histogram'; import { getFieldByNameFactory } from '../pure_helpers'; import { Filtering, setFilter } from './filtering'; @@ -69,7 +69,7 @@ jest.mock('lodash', () => { debounce: (fn: unknown) => fn, }; }); -jest.mock('../../id_generator'); +jest.mock('../../../id_generator'); // Mock the Monaco Editor component jest.mock('../operations/definitions/formula/editor/formula_editor', () => { return { @@ -148,10 +148,10 @@ const bytesColumn: GenericIndexPatternColumn = { * - Dimension trigger: Not tested here * - Dimension editor component: First half of the tests */ -describe('IndexPatternDimensionEditorPanel', () => { - let state: IndexPatternPrivateState; +describe('FormBasedDimensionEditor', () => { + let state: FormBasedPrivateState; let setState: jest.Mock; - let defaultProps: IndexPatternDimensionEditorProps; + let defaultProps: FormBasedDimensionEditorProps; function getStateWithColumns(columns: Record) { return { @@ -265,14 +265,14 @@ describe('IndexPatternDimensionEditorPanel', () => { const filterOperations = jest.fn().mockReturnValue(true); wrapper = shallow( - + ); expect(filterOperations).toBeCalled(); }); it('should show field select', () => { - wrapper = mount(); + wrapper = mount(); expect( wrapper.find(EuiComboBox).filter('[data-test-subj="indexPattern-dimension-field"]') @@ -281,7 +281,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should not show field select on fieldless operation', () => { wrapper = mount( - { it('should not show any choices if the filter returns false', () => { wrapper = mount( - false} @@ -320,7 +320,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should list all field names and document as a whole in prioritized order', () => { - wrapper = mount(); + wrapper = mount(); const options = wrapper .find(EuiComboBox) @@ -348,7 +348,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }, }, }; - wrapper = mount(); + wrapper = mount(); const options = wrapper .find(EuiComboBox) @@ -360,7 +360,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should indicate fields which are incompatible for the operation of the current column', () => { wrapper = mount( - @@ -383,7 +383,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should indicate operations which are incompatible for the field of the current column', () => { wrapper = mount( - @@ -407,7 +407,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should indicate when a transition is invalid due to filterOperations', () => { wrapper = mount( - { }); it('should not display hidden operation types', () => { - wrapper = mount(); + wrapper = mount(); const items: EuiListGroupItemProps[] = wrapper.find(EuiListGroup).prop('listItems') || []; @@ -442,7 +442,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should indicate that reference-based operations are not compatible when they are incomplete', () => { wrapper = mount( - { it('should indicate that reference-based operations are compatible sometimes', () => { wrapper = mount( - { }); it('should keep the operation when switching to another field compatible with this operation', () => { - const initialState: IndexPatternPrivateState = getStateWithColumns({ col1: bytesColumn }); + const initialState: FormBasedPrivateState = getStateWithColumns({ col1: bytesColumn }); - wrapper = mount( - - ); + wrapper = mount(); const comboBox = wrapper .find(EuiComboBox) @@ -562,7 +560,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should switch operations when selecting a field that requires another operation', () => { - wrapper = mount(); + wrapper = mount(); const comboBox = wrapper .find(EuiComboBox) @@ -597,7 +595,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should keep the field when switching to another operation compatible for this field', () => { wrapper = mount( - @@ -628,7 +626,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should not set the state if selecting the currently active operation', () => { - wrapper = mount(); + wrapper = mount(); act(() => { wrapper @@ -640,7 +638,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should update label and custom label flag on label input changes', () => { - wrapper = mount(); + wrapper = mount(); act(() => { wrapper @@ -669,7 +667,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should not keep the label as long as it is the default label', () => { wrapper = mount( - @@ -698,7 +696,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should keep the label on operation change if it is custom', () => { wrapper = mount( - { it('should remove customLabel flag if label is set to default', () => { wrapper = mount( - { describe('transient invalid state', () => { it('should set the state if selecting an operation incompatible with the current field', () => { - wrapper = mount(); + wrapper = mount(); act(() => { wrapper @@ -799,7 +797,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should show error message in invalid state', () => { - wrapper = mount(); + wrapper = mount(); wrapper .find('button[data-test-subj="lns-indexPatternDimension-terms incompatible"]') @@ -811,7 +809,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should leave error state if a compatible operation is selected', () => { - wrapper = mount(); + wrapper = mount(); wrapper .find('button[data-test-subj="lns-indexPatternDimension-terms incompatible"]') @@ -825,7 +823,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should leave error state if the original operation is re-selected', () => { - wrapper = mount(); + wrapper = mount(); wrapper .find('button[data-test-subj="lns-indexPatternDimension-terms incompatible"]') @@ -841,7 +839,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should leave error state when switching from incomplete state to fieldless operation', () => { // @ts-expect-error window['__react-beautiful-dnd-disable-dev-warnings'] = true; // issue with enzyme & react-beautiful-dnd throwing errors: https://github.com/atlassian/react-beautiful-dnd/issues/1593 - wrapper = mount(); + wrapper = mount(); wrapper .find('button[data-test-subj="lns-indexPatternDimension-terms incompatible"]') @@ -854,7 +852,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should leave error state when re-selecting the original fieldless function', () => { wrapper = mount( - { }); it('should indicate fields compatible with selected operation', () => { - wrapper = mount(); + wrapper = mount(); wrapper .find('button[data-test-subj="lns-indexPatternDimension-terms incompatible"]') @@ -901,7 +899,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should select compatible operation if field not compatible with selected operation', () => { - wrapper = mount(); + wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click'); @@ -962,11 +960,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }, }); wrapper = mount( - + ); // Transition to a field operation (incompatible) @@ -991,7 +985,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should select the Records field when count is selected on non-existing column', () => { wrapper = mount( - { it('should indicate document and field compatibility with selected document operation', () => { wrapper = mount( - { }); it('should set datasource state if compatible field is selected for operation', () => { - wrapper = mount(); + wrapper = mount(); wrapper .find('button[data-test-subj="lns-indexPatternDimension-terms incompatible"]') @@ -1110,7 +1104,7 @@ describe('IndexPatternDimensionEditorPanel', () => { } it('should default to None if time scaling is not set', () => { - wrapper = mount(); + wrapper = mount(); findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); expect(wrapper.find('[data-test-subj="indexPattern-time-scaling-enable"]')).toHaveLength(1); expect( @@ -1122,7 +1116,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should show current time scaling if set', () => { - wrapper = mount(); + wrapper = mount(); findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); expect( wrapper @@ -1134,7 +1128,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should allow to set time scaling initially', () => { const props = getProps({}); - wrapper = mount(); + wrapper = mount(); findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); wrapper .find('[data-test-subj="indexPattern-time-scaling-unit"]') @@ -1167,7 +1161,7 @@ describe('IndexPatternDimensionEditorPanel', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mount(); + wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ @@ -1194,7 +1188,7 @@ describe('IndexPatternDimensionEditorPanel', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mount(); + wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click'); expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ @@ -1216,7 +1210,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should allow to change time scaling', () => { const props = getProps({ timeScale: 's', label: 'Count of records per second' }); - wrapper = mount(); + wrapper = mount(); findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); wrapper.find('[data-test-subj="indexPattern-time-scaling-unit"] select').simulate('change', { @@ -1243,7 +1237,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should not adjust label if it is custom', () => { const props = getProps({ timeScale: 's', customLabel: true, label: 'My label' }); - wrapper = mount(); + wrapper = mount(); wrapper.find('[data-test-subj="indexPattern-time-scaling-unit"] select').simulate('change', { target: { value: 'h' }, }); @@ -1309,7 +1303,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }), columnId: 'col2', }; - wrapper = mount(); + wrapper = mount(); findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); expect( wrapper.find('[data-test-subj="indexPattern-dimension-reducedTimeRange-row"]') @@ -1318,7 +1312,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should show current reduced time range if set', () => { wrapper = mount( - + ); expect( wrapper.find(ReducedTimeRange).find(EuiComboBox).prop('selectedOptions')[0].value @@ -1327,7 +1321,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should allow to set reduced time range initially', () => { const props = getProps({}); - wrapper = mount(); + wrapper = mount(); findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); wrapper.find(ReducedTimeRange).find(EuiComboBox).prop('onChange')!([ { value: '1h', label: '' }, @@ -1355,7 +1349,7 @@ describe('IndexPatternDimensionEditorPanel', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mount(); + wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); expect((props.setState as jest.Mock).mock.calls[0][0](props.state)).toEqual({ ...props.state, @@ -1377,7 +1371,7 @@ describe('IndexPatternDimensionEditorPanel', () => { const props = getProps({ timeShift: '1d', }); - wrapper = mount(); + wrapper = mount(); wrapper.find(ReducedTimeRange).find(EuiComboBox).prop('onCreateOption')!('7m', []); expect((props.setState as jest.Mock).mock.calls[0][0](props.state)).toEqual({ ...props.state, @@ -1399,7 +1393,7 @@ describe('IndexPatternDimensionEditorPanel', () => { const props = getProps({ reducedTimeRange: '5 months', }); - wrapper = mount(); + wrapper = mount(); expect(wrapper.find(ReducedTimeRange).find(EuiComboBox).prop('isInvalid')).toBeTruthy(); @@ -1457,7 +1451,7 @@ describe('IndexPatternDimensionEditorPanel', () => { columnId: 'col2', }; wrapper = mount( - { }); it('should show custom options if time shift is available', () => { - wrapper = shallow(); + wrapper = shallow(); expect( wrapper .find(DimensionEditor) @@ -1485,7 +1479,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should show current time shift if set', () => { - wrapper = mount(); + wrapper = mount(); expect(wrapper.find(TimeShift).find(EuiComboBox).prop('selectedOptions')[0].value).toEqual( '1d' ); @@ -1493,7 +1487,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should allow to set time shift initially', () => { const props = getProps({}); - wrapper = mount(); + wrapper = mount(); findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); wrapper.find(TimeShift).find(EuiComboBox).prop('onChange')!([{ value: '1h', label: '' }]); expect((props.setState as jest.Mock).mock.calls[0][0](props.state)).toEqual({ @@ -1519,7 +1513,7 @@ describe('IndexPatternDimensionEditorPanel', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mount(); + wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); expect((props.setState as jest.Mock).mock.calls[0][0](props.state)).toEqual({ ...props.state, @@ -1541,7 +1535,7 @@ describe('IndexPatternDimensionEditorPanel', () => { const props = getProps({ timeShift: '1d', }); - wrapper = mount(); + wrapper = mount(); wrapper.find(TimeShift).find(EuiComboBox).prop('onCreateOption')!('1h', []); expect((props.setState as jest.Mock).mock.calls[0][0](props.state)).toEqual({ ...props.state, @@ -1563,7 +1557,7 @@ describe('IndexPatternDimensionEditorPanel', () => { const props = getProps({ timeShift: '5 months', }); - wrapper = mount(); + wrapper = mount(); expect(wrapper.find(TimeShift).find(EuiComboBox).prop('isInvalid')).toBeTruthy(); @@ -1608,7 +1602,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should not show custom options if time scaling is not available', () => { wrapper = mount( - { }); it('should show custom options if filtering is available', () => { - wrapper = mount(); + wrapper = mount(); findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); expect( wrapper.find('[data-test-subj="indexPattern-filter-by-enable"]').hostNodes() @@ -1635,7 +1629,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should show current filter if set', () => { wrapper = mount( - ); @@ -1655,7 +1649,7 @@ describe('IndexPatternDimensionEditorPanel', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mount(); + wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ @@ -1679,7 +1673,7 @@ describe('IndexPatternDimensionEditorPanel', () => { filter: { language: 'kuery', query: 'a: b' }, }); - wrapper = mount(); + wrapper = mount(); act(() => { const { updateLayer, columnId, layer } = wrapper.find(Filtering).props(); @@ -1707,7 +1701,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should render invalid field if field reference is broken', () => { wrapper = mount( - { }); it('should support selecting the operation before the field', () => { - wrapper = mount(); + wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click'); @@ -1784,7 +1778,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should select operation directly if only one field is possible', () => { wrapper = mount( - { }); it('should select operation directly if only document is possible', () => { - wrapper = mount(); + wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); @@ -1845,7 +1839,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should indicate compatible fields when selecting the operation first', () => { - wrapper = mount(); + wrapper = mount(); act(() => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click'); @@ -1871,7 +1865,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should indicate document compatibility when document operation is selected', () => { wrapper = mount( - { }); it('should not update when selecting the current field again', () => { - wrapper = mount(); + wrapper = mount(); const comboBox = wrapper .find(EuiComboBox) @@ -1914,7 +1908,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should show all operations that are not filtered out', () => { wrapper = mount( - !op.isBucketed && op.dataType === 'number'} /> @@ -1946,7 +1940,7 @@ describe('IndexPatternDimensionEditorPanel', () => { // Prevents field format from being loaded setState.mockImplementation(() => {}); - wrapper = mount(); + wrapper = mount(); const comboBox = wrapper .find(EuiComboBox) @@ -1981,12 +1975,10 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should use helper function when changing the function', () => { - const initialState: IndexPatternPrivateState = getStateWithColumns({ + const initialState: FormBasedPrivateState = getStateWithColumns({ col1: bytesColumn, }); - wrapper = mount( - - ); + wrapper = mount(); act(() => { wrapper .find('button[data-test-subj="lns-indexPatternDimension-min"]') @@ -2004,7 +1996,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should keep the latest valid dimension when removing the selection in field combobox', () => { - wrapper = mount(); + wrapper = mount(); act(() => { wrapper @@ -2017,7 +2009,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('allows custom format', () => { - const stateWithNumberCol: IndexPatternPrivateState = getStateWithColumns({ + const stateWithNumberCol: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Average of memory', dataType: 'number', @@ -2029,7 +2021,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount( - + ); act(() => { @@ -2059,7 +2051,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('keeps decimal places while switching', () => { - const stateWithNumberCol: IndexPatternPrivateState = getStateWithColumns({ + const stateWithNumberCol: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Average of memory', dataType: 'number', @@ -2073,7 +2065,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }, }); wrapper = mount( - + ); act(() => { @@ -2099,7 +2091,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('allows custom format with number of decimal places', () => { - const stateWithNumberCol: IndexPatternPrivateState = getStateWithColumns({ + const stateWithNumberCol: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Average of memory', dataType: 'number', @@ -2114,7 +2106,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount( - + ); act(() => { @@ -2145,7 +2137,7 @@ describe('IndexPatternDimensionEditorPanel', () => { it('should hide the top level field selector when switching from non-reference to reference', () => { (generateId as jest.Mock).mockReturnValue(`second`); - wrapper = mount(); + wrapper = mount(); expect(wrapper.find('ReferenceEditor')).toHaveLength(0); @@ -2157,7 +2149,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should hide the reference editors when switching from reference to non-reference', () => { - const stateWithReferences: IndexPatternPrivateState = getStateWithColumns({ + const stateWithReferences: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Differences of (incomplete)', dataType: 'number', @@ -2169,7 +2161,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount( - + ); expect(wrapper.find('ReferenceEditor')).toHaveLength(1); @@ -2182,7 +2174,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should show a warning when the current dimension is no longer configurable', () => { - const stateWithInvalidCol: IndexPatternPrivateState = getStateWithColumns({ + const stateWithInvalidCol: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Invalid differences', dataType: 'number', @@ -2193,7 +2185,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount( - + ); expect( @@ -2205,7 +2197,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should remove options to select references when there are no time fields', () => { - const stateWithoutTime: IndexPatternPrivateState = { + const stateWithoutTime: FormBasedPrivateState = { ...getStateWithColumns({ col1: { label: 'Avg', @@ -2218,7 +2210,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }; wrapper = mount( - { }); it('should not show tabs when formula and static_value operations are not available', () => { - const stateWithInvalidCol: IndexPatternPrivateState = getStateWithColumns({ + const stateWithInvalidCol: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Average of memory', dataType: 'number', @@ -2279,15 +2271,13 @@ describe('IndexPatternDimensionEditorPanel', () => { }), }; - wrapper = mount( - - ); + wrapper = mount(); expect(wrapper.find('[data-test-subj="lens-dimensionTabs"]').exists()).toBeFalsy(); }); it('should show the formula tab when supported', () => { - const stateWithFormulaColumn: IndexPatternPrivateState = getStateWithColumns({ + const stateWithFormulaColumn: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Formula', dataType: 'number', @@ -2299,7 +2289,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount( - + ); expect( @@ -2308,7 +2298,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should not show the static_value tab when not supported', () => { - const stateWithFormulaColumn: IndexPatternPrivateState = getStateWithColumns({ + const stateWithFormulaColumn: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Formula', dataType: 'number', @@ -2320,14 +2310,14 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount( - + ); expect(wrapper.find('[data-test-subj="lens-dimensionTabs-static_value"]').exists()).toBeFalsy(); }); it('should show the static value tab when supported', () => { - const staticWithFormulaColumn: IndexPatternPrivateState = getStateWithColumns({ + const staticWithFormulaColumn: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Formula', dataType: 'number', @@ -2339,7 +2329,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount( - { }); it('should select the quick function tab by default', () => { - const stateWithNoColumn: IndexPatternPrivateState = getStateWithColumns({}); + const stateWithNoColumn: FormBasedPrivateState = getStateWithColumns({}); wrapper = mount( - + ); expect( @@ -2367,10 +2357,10 @@ describe('IndexPatternDimensionEditorPanel', () => { }); it('should select the static value tab when supported by default', () => { - const stateWithNoColumn: IndexPatternPrivateState = getStateWithColumns({}); + const stateWithNoColumn: FormBasedPrivateState = getStateWithColumns({}); wrapper = mount( - { }); it('should not show any tab when formula is in full screen mode', () => { - const stateWithFormulaColumn: IndexPatternPrivateState = getStateWithColumns({ + const stateWithFormulaColumn: FormBasedPrivateState = getStateWithColumns({ col1: { label: 'Formula', dataType: 'number', @@ -2395,7 +2385,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount( - & { +export type FormBasedDimensionTriggerProps = + DatasourceDimensionTriggerProps & { uniqueLabel: string; }; -export type IndexPatternDimensionEditorProps = - DatasourceDimensionEditorProps & { +export type FormBasedDimensionEditorProps = + DatasourceDimensionEditorProps & { uiSettings: IUiSettingsClient; storage: IStorageWrapper; savedObjectsClient: SavedObjectsClientContract; @@ -49,8 +49,8 @@ function wrapOnDot(str?: string) { return str ? str.replace(/\./g, '.\u200B') : ''; } -export const IndexPatternDimensionTriggerComponent = function IndexPatternDimensionTrigger( - props: IndexPatternDimensionTriggerProps +export const FormBasedDimensionTriggerComponent = function FormBasedDimensionTrigger( + props: FormBasedDimensionTriggerProps ) { const layerId = props.layerId; const layer = props.state.layers[layerId]; @@ -80,8 +80,8 @@ export const IndexPatternDimensionTriggerComponent = function IndexPatternDimens ); }; -export const IndexPatternDimensionEditorComponent = function IndexPatternDimensionPanel( - props: IndexPatternDimensionEditorProps +export const FormBasedDimensionEditorComponent = function FormBasedDimensionPanel( + props: FormBasedDimensionEditorProps ) { const layerId = props.layerId; const currentIndexPattern = props.indexPatterns[props.state.layers[layerId]?.indexPatternId]; @@ -103,5 +103,5 @@ export const IndexPatternDimensionEditorComponent = function IndexPatternDimensi ); }; -export const IndexPatternDimensionTrigger = memo(IndexPatternDimensionTriggerComponent); -export const IndexPatternDimensionEditor = memo(IndexPatternDimensionEditorComponent); +export const FormBasedDimensionTrigger = memo(FormBasedDimensionTriggerComponent); +export const FormBasedDimensionEditor = memo(FormBasedDimensionEditorComponent); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimensions_editor_helpers.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimensions_editor_helpers.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/get_drop_props.test.ts b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/get_drop_props.test.ts similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/get_drop_props.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/get_drop_props.test.ts index 2f4d8a0121aa1..21650cffed54a 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/get_drop_props.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/get_drop_props.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { DragDropOperation, OperationMetadata } from '../../../types'; +import { DragDropOperation, OperationMetadata } from '../../../../types'; import { TermsIndexPatternColumn } from '../../operations'; import { getDropProps } from './get_drop_props'; import { @@ -15,7 +15,7 @@ import { mockedDndOperations, mockedColumns, } from './mocks'; -import { generateId } from '../../../id_generator'; +import { generateId } from '../../../../id_generator'; const getDefaultProps = () => ({ indexPatterns: mockDataViews(), @@ -27,7 +27,7 @@ const getDefaultProps = () => ({ source: mockedDndOperations.bucket, }); -describe('IndexPatternDimensionEditorPanel#getDropProps', () => { +describe('FormBasedDimensionEditorPanel#getDropProps', () => { describe('not dragging', () => { it('returns undefined if no drag is happening', () => { expect(getDropProps({ ...getDefaultProps(), source: undefined })).toBe(undefined); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/get_drop_props.ts b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/get_drop_props.ts similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/get_drop_props.ts rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/get_drop_props.ts index a1f16006fd803..a9e81bd6df668 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/get_drop_props.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/get_drop_props.ts @@ -12,22 +12,22 @@ import { IndexPattern, IndexPatternMap, IndexPatternField, -} from '../../../types'; +} from '../../../../types'; import { getCurrentFieldsForOperation, getOperationDisplay, hasOperationSupportForMultipleFields, } from '../../operations'; -import { isDraggedDataViewField, isOperationFromTheSameGroup } from '../../../utils'; +import { isDraggedDataViewField, isOperationFromTheSameGroup } from '../../../../utils'; import { hasField } from '../../pure_utils'; -import { DragContextState } from '../../../drag_drop/providers'; -import { OperationMetadata, DraggedField } from '../../../types'; +import { DragContextState } from '../../../../drag_drop/providers'; +import { OperationMetadata, DraggedField } from '../../../../types'; import { getOperationTypesForField } from '../../operations'; -import { GenericIndexPatternColumn } from '../../indexpattern'; -import { IndexPatternPrivateState, DataViewDragDropOperation } from '../../types'; +import { GenericIndexPatternColumn } from '../../form_based'; +import { FormBasedPrivateState, DataViewDragDropOperation } from '../../types'; interface GetDropPropsArgs { - state: IndexPatternPrivateState; + state: FormBasedPrivateState; source?: DragContextState['dragging']; target: DragDropOperation; indexPatterns: IndexPatternMap; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/index.ts b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/index.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/index.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/mocks.ts b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/mocks.ts similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/mocks.ts rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/mocks.ts index 93b63071d6642..ceb16345f475c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/mocks.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/mocks.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { IndexPatternLayer } from '../../types'; +import { FormBasedLayer } from '../../types'; import { documentField } from '../../document_field'; -import { IndexPatternMap, OperationMetadata } from '../../../types'; +import { IndexPatternMap, OperationMetadata } from '../../../../types'; import { DateHistogramIndexPatternColumn, GenericIndexPatternColumn, @@ -15,7 +15,7 @@ import { TermsIndexPatternColumn, } from '../../operations'; import { getFieldByNameFactory } from '../../pure_helpers'; -jest.mock('../../../id_generator'); +jest.mock('../../../../id_generator'); export const mockDataViews = (): IndexPatternMap => { const fields = [ @@ -191,7 +191,7 @@ export const mockedColumns: Record = { } as GenericIndexPatternColumn, }; -export const mockedLayers: Record IndexPatternLayer> = { +export const mockedLayers: Record FormBasedLayer> = { singleColumnLayer: (id = 'col1') => ({ indexPatternId: 'first', columnOrder: [id], diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/on_drop_handler.test.ts b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/on_drop_handler.test.ts similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/on_drop_handler.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/on_drop_handler.test.ts index 3b468181db6df..1bff858194a36 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/on_drop_handler.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/on_drop_handler.test.ts @@ -6,10 +6,14 @@ */ import { onDrop } from './on_drop_handler'; -import { IndexPatternPrivateState } from '../../types'; -import { OperationMetadata, DropType, DatasourceDimensionDropHandlerProps } from '../../../types'; +import { FormBasedPrivateState } from '../../types'; +import { + OperationMetadata, + DropType, + DatasourceDimensionDropHandlerProps, +} from '../../../../types'; import { FormulaIndexPatternColumn, MedianIndexPatternColumn } from '../../operations'; -import { generateId } from '../../../id_generator'; +import { generateId } from '../../../../id_generator'; import { mockDataViews, mockedLayers, @@ -18,7 +22,7 @@ import { mockedColumns, } from './mocks'; -jest.mock('../../../id_generator'); +jest.mock('../../../../id_generator'); const dimensionGroups = [ { @@ -47,7 +51,7 @@ const dimensionGroups = [ }, ]; -function getStateWithMultiFieldColumn(state: IndexPatternPrivateState) { +function getStateWithMultiFieldColumn(state: FormBasedPrivateState) { return { ...state, layers: { @@ -62,10 +66,10 @@ function getStateWithMultiFieldColumn(state: IndexPatternPrivateState) { }; } -describe('IndexPatternDimensionEditorPanel: onDrop', () => { - let state: IndexPatternPrivateState; +describe('FormBasedDimensionEditorPanel: onDrop', () => { + let state: FormBasedPrivateState; let setState: jest.Mock; - let defaultProps: DatasourceDimensionDropHandlerProps; + let defaultProps: DatasourceDimensionDropHandlerProps; beforeEach(() => { state = { @@ -347,7 +351,7 @@ describe('IndexPatternDimensionEditorPanel: onDrop', () => { describe('dropping a dimension', () => { it('sets correct order in group for metric and bucket columns when duplicating a column in group', () => { - const testState: IndexPatternPrivateState = { + const testState: FormBasedPrivateState = { ...state, layers: { ...state.layers, @@ -439,7 +443,7 @@ describe('IndexPatternDimensionEditorPanel: onDrop', () => { it('when duplicating fullReference column, the referenced columns get duplicated too', () => { (generateId as jest.Mock).mockReturnValue(`ref1Copy`); - const testState: IndexPatternPrivateState = { + const testState: FormBasedPrivateState = { ...state, layers: { ...state.layers, @@ -501,7 +505,7 @@ describe('IndexPatternDimensionEditorPanel: onDrop', () => { it('when duplicating fullReference column, the multiple referenced columns get duplicated too', () => { (generateId as jest.Mock).mockReturnValueOnce(`ref1Copy`); (generateId as jest.Mock).mockReturnValueOnce(`ref2Copy`); - const testState: IndexPatternPrivateState = { + const testState: FormBasedPrivateState = { ...state, layers: { ...state.layers, @@ -566,7 +570,7 @@ describe('IndexPatternDimensionEditorPanel: onDrop', () => { it('when duplicating fullReference column, the referenced columns get duplicated', () => { (generateId as jest.Mock).mockReturnValueOnce(`ref1Copy`); (generateId as jest.Mock).mockReturnValueOnce(`ref2Copy`); - const testState: IndexPatternPrivateState = { + const testState: FormBasedPrivateState = { ...state, layers: { ...state.layers, @@ -854,7 +858,7 @@ describe('IndexPatternDimensionEditorPanel: onDrop', () => { }); describe('dimension group aware ordering and copying', () => { - let testState: IndexPatternPrivateState; + let testState: FormBasedPrivateState; beforeEach(() => { testState = { ...state }; testState.layers.first = { ...mockedLayers.multipleColumnsLayer() }; @@ -1541,7 +1545,7 @@ describe('IndexPatternDimensionEditorPanel: onDrop', () => { }, ]; describe('simple operations', () => { - let props: DatasourceDimensionDropHandlerProps; + let props: DatasourceDimensionDropHandlerProps; beforeEach(() => { setState = jest.fn(); @@ -2087,7 +2091,7 @@ describe('IndexPatternDimensionEditorPanel: onDrop', () => { }); }); describe('references', () => { - let props: DatasourceDimensionDropHandlerProps; + let props: DatasourceDimensionDropHandlerProps; beforeEach(() => { props = { dimensionGroups: defaultDimensionGroups, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/on_drop_handler.ts b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/on_drop_handler.ts similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/on_drop_handler.ts rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/on_drop_handler.ts index 232c96610f04c..ad575d3c53947 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/on_drop_handler.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/droppable/on_drop_handler.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { isDraggedDataViewField } from '../../../utils'; +import { isDraggedDataViewField } from '../../../../utils'; import { DatasourceDimensionDropHandlerProps, DragDropOperation, @@ -14,7 +14,7 @@ import { StateSetter, VisualizationDimensionGroupConfig, DraggedField, -} from '../../../types'; +} from '../../../../types'; import { insertOrReplaceColumn, deleteColumn, @@ -28,12 +28,12 @@ import { } from '../../operations'; import { mergeLayer, mergeLayers } from '../../state_helpers'; import { getNewOperation, getField } from './get_drop_props'; -import { IndexPatternPrivateState, DataViewDragDropOperation } from '../../types'; +import { FormBasedPrivateState, DataViewDragDropOperation } from '../../types'; interface DropHandlerProps { - state: IndexPatternPrivateState; + state: FormBasedPrivateState; setState: StateSetter< - IndexPatternPrivateState, + FormBasedPrivateState, { isDimensionComplete?: boolean; forceRender?: boolean; @@ -46,7 +46,7 @@ interface DropHandlerProps { indexPatterns: IndexPatternMap; } -export function onDrop(props: DatasourceDimensionDropHandlerProps) { +export function onDrop(props: DatasourceDimensionDropHandlerProps) { const { target, source, dropType, state, indexPatterns } = props; if (isDraggedDataViewField(source) && isFieldDropType(dropType)) { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_input.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_input.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_input.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_input.test.tsx index b7ab501f34d16..877dc18156cdf 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_input.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_input.test.tsx @@ -21,7 +21,7 @@ import { import { FieldInput, getErrorMessage } from './field_input'; import { createMockedIndexPattern } from '../mocks'; import { getOperationSupportMatrix } from '.'; -import { GenericIndexPatternColumn, IndexPatternLayer, IndexPatternPrivateState } from '../types'; +import { GenericIndexPatternColumn, FormBasedLayer, FormBasedPrivateState } from '../types'; import { ReferenceBasedIndexPatternColumn } from '../operations/definitions/column_types'; jest.mock('../operations/layer_helpers', () => { @@ -30,7 +30,7 @@ jest.mock('../operations/layer_helpers', () => { return { ...original, insertOrReplaceColumn: () => { - return {} as IndexPatternLayer; + return {} as FormBasedLayer; }, }; }); @@ -113,14 +113,14 @@ function getLayer(col1: GenericIndexPatternColumn = getStringBasedOperationColum }; } function getDefaultOperationSupportMatrix( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, existingFields: Record> ) { return getOperationSupportMatrix({ state: { layers: { layer1: layer }, - } as unknown as IndexPatternPrivateState, + } as unknown as FormBasedPrivateState, layerId: 'layer1', filterOperations: () => true, columnId, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_input.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_input.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_input.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_input.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.scss b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_select.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.scss rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_select.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_select.tsx similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_select.tsx index af5dc76143b17..52b2c128af595 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_select.tsx @@ -10,11 +10,15 @@ import { partition } from 'lodash'; import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiComboBoxOptionOption, EuiComboBoxProps } from '@elastic/eui'; -import type { OperationType } from '../indexpattern'; +import type { OperationType } from '../form_based'; import type { OperationSupportMatrix } from './operation_support'; -import { FieldOption, FieldOptionValue, FieldPicker } from '../../shared_components/field_picker'; -import { fieldContainsData } from '../../shared_components'; -import type { ExistingFieldsMap, IndexPattern } from '../../types'; +import { + FieldOption, + FieldOptionValue, + FieldPicker, +} from '../../../shared_components/field_picker'; +import { fieldContainsData } from '../../../shared_components'; +import type { ExistingFieldsMap, IndexPattern } from '../../../types'; import { getFieldType } from '../pure_utils'; export type FieldChoiceWithOperationType = FieldOptionValue & { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/filtering.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/filtering.tsx similarity index 81% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/filtering.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/filtering.tsx index 059170d9702d8..13db26af12108 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/filtering.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/filtering.tsx @@ -8,11 +8,11 @@ import React, { useCallback } from 'react'; import { isEqual } from 'lodash'; import type { Query } from '@kbn/es-query'; import { GenericIndexPatternColumn, operationDefinitionMap } from '../operations'; -import type { IndexPatternLayer } from '../types'; -import { validateQuery, FilterQueryInput } from '../../shared_components'; -import type { IndexPattern } from '../../types'; +import type { FormBasedLayer } from '../types'; +import { validateQuery, FilterQueryInput } from '../../../shared_components'; +import type { IndexPattern } from '../../../types'; -export function setFilter(columnId: string, layer: IndexPatternLayer, query: Query | undefined) { +export function setFilter(columnId: string, layer: FormBasedLayer, query: Query | undefined) { return { ...layer, columns: { @@ -36,8 +36,8 @@ export function Filtering({ selectedColumn: GenericIndexPatternColumn; indexPattern: IndexPattern; columnId: string; - layer: IndexPatternLayer; - updateLayer: (newLayer: IndexPatternLayer) => void; + layer: FormBasedLayer; + updateLayer: (newLayer: FormBasedLayer) => void; helpMessage: string | null; }) { const inputFilter = selectedColumn.filter; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.test.tsx index d59cb4f136fda..6763d6337880b 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { FormatSelector } from './format_selector'; import { act } from 'react-dom/test-utils'; -import { GenericIndexPatternColumn } from '../..'; +import { GenericIndexPatternColumn } from '../../..'; jest.mock('lodash', () => { const original = jest.requireActual('lodash'); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx index 280829c8c1573..62770711a62df 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx @@ -8,9 +8,9 @@ import React, { useCallback, useMemo, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRow, EuiComboBox, EuiSpacer, EuiRange, EuiFieldText } from '@elastic/eui'; -import { GenericIndexPatternColumn } from '../indexpattern'; +import { GenericIndexPatternColumn } from '../form_based'; import { isColumnFormatted } from '../operations/definitions/helpers'; -import { useDebouncedValue } from '../../shared_components'; +import { useDebouncedValue } from '../../../shared_components'; const supportedFormats: Record = { number: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/index.ts b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/index.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/index.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/operation_support.ts b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/operation_support.ts similarity index 91% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/operation_support.ts rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/operation_support.ts index 43d9770deb228..5c08b98023c74 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/operation_support.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/operation_support.ts @@ -6,10 +6,10 @@ */ import memoizeOne from 'memoize-one'; -import { DatasourceDimensionDropProps, IndexPatternMap, OperationMetadata } from '../../types'; -import { OperationType } from '../indexpattern'; +import { DatasourceDimensionDropProps, IndexPatternMap, OperationMetadata } from '../../../types'; +import { OperationType } from '../form_based'; import { memoizedGetAvailableOperationsByMetadata, OperationFieldTuple } from '../operations'; -import { IndexPatternPrivateState } from '../types'; +import { FormBasedPrivateState } from '../types'; export interface OperationSupportMatrix { operationByField: Partial>>; @@ -18,9 +18,9 @@ export interface OperationSupportMatrix { } type Props = Pick< - DatasourceDimensionDropProps['target'], + DatasourceDimensionDropProps['target'], 'layerId' | 'columnId' | 'filterOperations' -> & { state: IndexPatternPrivateState; indexPatterns: IndexPatternMap }; +> & { state: FormBasedPrivateState; indexPatterns: IndexPatternMap }; function computeOperationMatrix( operationsByMetadata: Array<{ diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reduced_time_range.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/reduced_time_range.tsx similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reduced_time_range.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/reduced_time_range.tsx index 4d160f7923e06..6f92b8dc75c17 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reduced_time_range.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/reduced_time_range.tsx @@ -17,13 +17,13 @@ import { GenericIndexPatternColumn, operationDefinitionMap, } from '../operations'; -import type { IndexPatternLayer } from '../types'; -import type { IndexPattern } from '../../types'; +import type { FormBasedLayer } from '../types'; +import type { IndexPattern } from '../../../types'; import { reducedTimeRangeOptions } from '../reduced_time_range_utils'; export function setReducedTimeRange( columnId: string, - layer: IndexPatternLayer, + layer: FormBasedLayer, reducedTimeRange: string | undefined, skipLabelUpdate?: boolean ) { @@ -69,8 +69,8 @@ export function ReducedTimeRange({ }: { selectedColumn: GenericIndexPatternColumn; columnId: string; - layer: IndexPatternLayer; - updateLayer: (newLayer: IndexPatternLayer) => void; + layer: FormBasedLayer; + updateLayer: (newLayer: FormBasedLayer) => void; indexPattern: IndexPattern; helpMessage: string | null; skipLabelUpdate?: boolean; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/reference_editor.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/reference_editor.test.tsx index 6e5c157e5b9e8..d46dabf6c12f3 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/reference_editor.test.tsx @@ -16,7 +16,7 @@ import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks' import type { IUiSettingsClient, SavedObjectsClientContract, HttpSetup } from '@kbn/core/public'; import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; -import { OperationMetadata } from '../../types'; +import { OperationMetadata } from '../../../types'; import { createMockedIndexPattern, createMockedIndexPatternWithoutType } from '../mocks'; import { ReferenceEditor, ReferenceEditorProps } from './reference_editor'; import { @@ -26,7 +26,7 @@ import { TermsIndexPatternColumn, } from '../operations'; import { FieldSelect } from './field_select'; -import { IndexPatternLayer } from '../types'; +import { FormBasedLayer } from '../types'; jest.mock('../operations'); @@ -148,7 +148,7 @@ describe('reference editor', () => { sourceField: 'bytes', }, }, - } as IndexPatternLayer; + } as FormBasedLayer; wrapper = mount( { sourceField: 'dest', }, }, - } as IndexPatternLayer; + } as FormBasedLayer; wrapper = mount( { sourceField: 'bytes', }, }, - } as IndexPatternLayer; + } as FormBasedLayer; wrapper = mount( { sourceField: 'bytes', }, }, - } as IndexPatternLayer; + } as FormBasedLayer; wrapper = mount( { sourceField: 'dest', }, }, - } as IndexPatternLayer; + } as FormBasedLayer; const onChooseFunction = jest.fn(); wrapper = mount( { sourceField: 'bytes', }, }, - } as IndexPatternLayer; + } as FormBasedLayer; wrapper = mount( { incompleteColumns: { ref: { operationType: 'max' }, }, - } as IndexPatternLayer; + } as FormBasedLayer; wrapper = mount( { incompleteColumns: { ref: { sourceField: 'timestamp' }, }, - } as IndexPatternLayer; + } as FormBasedLayer; wrapper = mount( { sourceField: 'missing', }, }, - } as IndexPatternLayer; + } as FormBasedLayer; wrapper = mount( IndexPatternLayer) + | FormBasedLayer + | ((prevLayer: FormBasedLayer) => FormBasedLayer) | GenericIndexPatternColumn ) => void; onChooseField: (choice: FieldChoiceWithOperationType) => void; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/time_scaling.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_scaling.tsx similarity index 91% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/time_scaling.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_scaling.tsx index 791d3b5846f24..003407649622e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/time_scaling.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_scaling.tsx @@ -20,13 +20,13 @@ import { GenericIndexPatternColumn, operationDefinitionMap, } from '../operations'; -import type { TimeScaleUnit } from '../../../common/expressions'; -import { unitSuffixesLong } from '../../../common/suffix_formatter'; -import type { IndexPatternLayer } from '../types'; +import type { TimeScaleUnit } from '../../../../common/expressions'; +import { unitSuffixesLong } from '../../../../common/suffix_formatter'; +import type { FormBasedLayer } from '../types'; export function setTimeScaling( columnId: string, - layer: IndexPatternLayer, + layer: FormBasedLayer, timeScale: TimeScaleUnit | undefined ) { const currentColumn = layer.columns[columnId]; @@ -62,8 +62,8 @@ export function TimeScaling({ }: { selectedColumn: GenericIndexPatternColumn; columnId: string; - layer: IndexPatternLayer; - updateLayer: (newLayer: IndexPatternLayer) => void; + layer: FormBasedLayer; + updateLayer: (newLayer: FormBasedLayer) => void; }) { const selectedOperation = operationDefinitionMap[selectedColumn.operationType]; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/time_shift.tsx b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_shift.tsx similarity index 94% rename from x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/time_shift.tsx rename to x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_shift.tsx index 63696a3a2196c..35f278cbbe988 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/time_shift.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/dimension_panel/time_shift.tsx @@ -15,18 +15,18 @@ import { GenericIndexPatternColumn, operationDefinitionMap, } from '../operations'; -import type { IndexPatternLayer } from '../types'; -import type { IndexPatternDimensionEditorProps } from './dimension_panel'; +import type { FormBasedLayer } from '../types'; +import type { FormBasedDimensionEditorProps } from './dimension_panel'; import { getDateHistogramInterval, getLayerTimeShiftChecks, timeShiftOptions, } from '../time_shift_utils'; -import type { IndexPattern } from '../../types'; +import type { IndexPattern } from '../../../types'; export function setTimeShift( columnId: string, - layer: IndexPatternLayer, + layer: FormBasedLayer, timeShift: string | undefined ) { const trimmedTimeShift = timeShift?.trim(); @@ -69,9 +69,9 @@ export function TimeShift({ selectedColumn: GenericIndexPatternColumn; indexPattern: IndexPattern; columnId: string; - layer: IndexPatternLayer; - updateLayer: (newLayer: IndexPatternLayer) => void; - activeData: IndexPatternDimensionEditorProps['activeData']; + layer: FormBasedLayer; + updateLayer: (newLayer: FormBasedLayer) => void; + activeData: FormBasedDimensionEditorProps['activeData']; layerId: string; }) { const [localValue, setLocalValue] = useState(selectedColumn.timeShift); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/document_field.ts b/x-pack/plugins/lens/public/datasources/form_based/document_field.ts similarity index 86% rename from x-pack/plugins/lens/public/indexpattern_datasource/document_field.ts rename to x-pack/plugins/lens/public/datasources/form_based/document_field.ts index e6ef0fcfdc0bf..557a087d2a6e6 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/document_field.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/document_field.ts @@ -6,8 +6,8 @@ */ import { i18n } from '@kbn/i18n'; -import { DOCUMENT_FIELD_NAME } from '../../common'; -import type { IndexPatternField } from '../types'; +import { DOCUMENT_FIELD_NAME } from '../../../common'; +import type { IndexPatternField } from '../../types'; const customLabel = i18n.translate('xpack.lens.indexPattern.records', { defaultMessage: 'Records', diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.scss b/x-pack/plugins/lens/public/datasources/form_based/field_item.scss similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/field_item.scss rename to x-pack/plugins/lens/public/datasources/form_based/field_item.scss index 873f5bdcbdf52..5af939906b25c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.scss +++ b/x-pack/plugins/lens/public/datasources/form_based/field_item.scss @@ -1,4 +1,4 @@ -@import '../mixins'; +@import '../../mixins'; .lnsFieldItem { width: 100%; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/field_item.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/field_item.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/field_item.test.tsx index 19b3f9e313267..a0514dafd61b0 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/field_item.test.tsx @@ -15,7 +15,7 @@ import { coreMock } from '@kbn/core/public/mocks'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; -import { IndexPattern } from '../types'; +import { IndexPattern } from '../../types'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { documentField } from './document_field'; import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; @@ -25,9 +25,9 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { DataView, DataViewField } from '@kbn/data-views-plugin/common'; import { loadFieldStats } from '@kbn/unified-field-list-plugin/public/services/field_stats'; +import { DOCUMENT_FIELD_NAME } from '../../../common'; +import { LensFieldIcon } from '../../shared_components'; import { FieldStats, FieldVisualizeButton } from '@kbn/unified-field-list-plugin/public'; -import { DOCUMENT_FIELD_NAME } from '../../common'; -import { LensFieldIcon } from '../shared_components'; jest.mock('@kbn/unified-field-list-plugin/public/services/field_stats', () => ({ loadFieldStats: jest.fn().mockResolvedValue({}), diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx b/x-pack/plugins/lens/public/datasources/form_based/field_item.tsx similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx rename to x-pack/plugins/lens/public/datasources/form_based/field_item.tsx index 17b1ce35f38b0..5ebfecc4cc95a 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/field_item.tsx @@ -26,16 +26,16 @@ import { FieldPopoverVisualize, } from '@kbn/unified-field-list-plugin/public'; import { generateFilters, getEsQueryConfig } from '@kbn/data-plugin/public'; -import { APP_ID } from '../../common/constants'; -import { DragDrop } from '../drag_drop'; -import { DatasourceDataPanelProps, DataType } from '../types'; -import { DOCUMENT_FIELD_NAME } from '../../common'; -import type { IndexPattern, IndexPatternField } from '../types'; -import { LensFieldIcon } from '../shared_components/field_picker/lens_field_icon'; -import type { LensAppServices } from '../app_plugin/types'; -import { debouncedComponent } from '../debounced_component'; +import { DragDrop } from '../../drag_drop'; +import { DatasourceDataPanelProps, DataType } from '../../types'; +import { DOCUMENT_FIELD_NAME } from '../../../common'; +import type { IndexPattern, IndexPatternField } from '../../types'; +import { LensFieldIcon } from '../../shared_components/field_picker/lens_field_icon'; +import type { LensAppServices } from '../../app_plugin/types'; +import { debouncedComponent } from '../../debounced_component'; +import { APP_ID } from '../../../common/constants'; import { getFieldType } from './pure_utils'; -import { combineQueryAndFilters } from '../app_plugin/show_underlying_data'; +import { combineQueryAndFilters } from '../../app_plugin/show_underlying_data'; export interface FieldItemProps { core: DatasourceDataPanelProps['core']; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/field_list.scss b/x-pack/plugins/lens/public/datasources/form_based/field_list.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/field_list.scss rename to x-pack/plugins/lens/public/datasources/form_based/field_list.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/field_list.tsx b/x-pack/plugins/lens/public/datasources/form_based/field_list.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/field_list.tsx rename to x-pack/plugins/lens/public/datasources/form_based/field_list.tsx index 18da8488db212..e2226def27a9a 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/field_list.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/field_list.tsx @@ -13,7 +13,7 @@ import { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { FieldItem } from './field_item'; import { NoFieldsCallout } from './no_fields_callout'; import { FieldItemSharedProps, FieldsAccordion } from './fields_accordion'; -import type { DatasourceDataPanelProps, IndexPatternField } from '../types'; +import type { DatasourceDataPanelProps, IndexPatternField } from '../../types'; const PAGINATION_SIZE = 50; export type FieldGroups = Record< diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/fields_accordion.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/fields_accordion.test.tsx index 864ba4ac55af9..a471f8e0fa309 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/fields_accordion.test.tsx @@ -10,7 +10,7 @@ import { EuiLoadingSpinner, EuiNotificationBadge } from '@elastic/eui'; import { coreMock } from '@kbn/core/public/mocks'; import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; -import { IndexPattern } from '../types'; +import { IndexPattern } from '../../types'; import { FieldItem } from './field_item'; import { FieldsAccordion, FieldsAccordionProps, FieldItemSharedProps } from './fields_accordion'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.tsx b/x-pack/plugins/lens/public/datasources/form_based/fields_accordion.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.tsx rename to x-pack/plugins/lens/public/datasources/form_based/fields_accordion.tsx index 5db910e6d3eff..105c9583e300d 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/fields_accordion.tsx @@ -23,7 +23,7 @@ import type { Query } from '@kbn/es-query'; import { ChartsPluginSetup } from '@kbn/charts-plugin/public'; import { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { FieldItem } from './field_item'; -import type { DatasourceDataPanelProps, IndexPattern, IndexPatternField } from '../types'; +import type { DatasourceDataPanelProps, IndexPattern, IndexPatternField } from '../../types'; export interface FieldItemSharedProps { core: DatasourceDataPanelProps['core']; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts b/x-pack/plugins/lens/public/datasources/form_based/form_based.test.ts similarity index 93% rename from x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/form_based.test.ts index aefb4c7327463..5a30dad263123 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/form_based.test.ts @@ -10,7 +10,7 @@ import { SavedObjectReference } from '@kbn/core/public'; import { isFragment } from 'react-is'; import { coreMock } from '@kbn/core/public/mocks'; import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public'; -import { IndexPatternPersistedState, IndexPatternPrivateState } from './types'; +import { FormBasedPersistedState, FormBasedPrivateState } from './types'; import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks'; import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; @@ -20,8 +20,8 @@ import { indexPatternFieldEditorPluginMock } from '@kbn/data-view-field-editor-p import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; import { TinymathAST } from '@kbn/tinymath'; -import { getIndexPatternDatasource, GenericIndexPatternColumn } from './indexpattern'; -import { DatasourcePublicAPI, Datasource, FramePublicAPI, OperationDescriptor } from '../types'; +import { getFormBasedDatasource, GenericIndexPatternColumn } from './form_based'; +import { DatasourcePublicAPI, Datasource, FramePublicAPI, OperationDescriptor } from '../../types'; import { getFieldByNameFactory } from './pure_helpers'; import { operationDefinitionMap, @@ -42,10 +42,10 @@ import { import { createMockedFullReference } from './operations/mocks'; import { cloneDeep } from 'lodash'; import { DatatableColumn } from '@kbn/expressions-plugin/common'; -import { createMockFramePublicAPI } from '../mocks'; +import { createMockFramePublicAPI } from '../../mocks'; jest.mock('./loader'); -jest.mock('../id_generator'); +jest.mock('../../id_generator'); jest.mock('./operations'); jest.mock('./dimension_panel/reference_editor', () => ({ ReferenceEditor: () => null, @@ -178,11 +178,11 @@ const expectedIndexPatterns = { const indexPatterns = expectedIndexPatterns; describe('IndexPattern Data Source', () => { - let baseState: IndexPatternPrivateState; - let indexPatternDatasource: Datasource; + let baseState: FormBasedPrivateState; + let FormBasedDatasource: Datasource; beforeEach(() => { - indexPatternDatasource = getIndexPatternDatasource({ + FormBasedDatasource = getFormBasedDatasource({ unifiedSearch: unifiedSearchPluginMock.createStartContract(), storage: {} as IStorageWrapper, core: coreMock.createStart(), @@ -230,7 +230,7 @@ describe('IndexPattern Data Source', () => { operationType: 'count', sourceField: '___records___', }; - const map = indexPatternDatasource.uniqueLabels({ + const map = FormBasedDatasource.uniqueLabels({ layers: { a: { columnOrder: ['a', 'b'], @@ -252,7 +252,7 @@ describe('IndexPattern Data Source', () => { indexPatternId: 'foo', }, }, - } as unknown as IndexPatternPrivateState); + } as unknown as FormBasedPrivateState); expect(map).toMatchInlineSnapshot(` Object { @@ -267,7 +267,7 @@ describe('IndexPattern Data Source', () => { describe('#getPersistedState', () => { it('should persist from saved state', async () => { - expect(indexPatternDatasource.getPersistableState(baseState)).toEqual({ + expect(FormBasedDatasource.getPersistableState(baseState)).toEqual({ state: { layers: { first: { @@ -300,12 +300,12 @@ describe('IndexPattern Data Source', () => { describe('#toExpression', () => { it('should generate an empty expression when no columns are selected', async () => { - const state = indexPatternDatasource.initialize(); - expect(indexPatternDatasource.toExpression(state, 'first', indexPatterns)).toEqual(null); + const state = FormBasedDatasource.initialize(); + expect(FormBasedDatasource.toExpression(state, 'first', indexPatterns)).toEqual(null); }); it('should create a table when there is a formula without aggs', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -324,7 +324,7 @@ describe('IndexPattern Data Source', () => { }, }, }; - expect(indexPatternDatasource.toExpression(queryBaseState, 'first', indexPatterns)).toEqual({ + expect(FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns)).toEqual({ chain: [ { function: 'createTable', @@ -342,7 +342,7 @@ describe('IndexPattern Data Source', () => { }); it('should generate an expression for an aggregated query', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -371,7 +371,7 @@ describe('IndexPattern Data Source', () => { }, }; - expect(indexPatternDatasource.toExpression(queryBaseState, 'first', indexPatterns)) + expect(FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns)) .toMatchInlineSnapshot(` Object { "chain": Array [ @@ -496,7 +496,7 @@ describe('IndexPattern Data Source', () => { }); it('should put all time fields used in date_histograms to the esaggs timeFields parameter if not ignoring global time range', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -546,16 +546,12 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; expect(ast.chain[1].arguments.timeFields).toEqual(['timestamp', 'another_datefield']); }); it('should pass time shift parameter to metric agg functions', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -585,11 +581,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; expect((ast.chain[1].arguments.aggs[1] as Ast).chain[0].arguments.timeShift).toEqual(['1d']); }); @@ -609,7 +601,7 @@ describe('IndexPattern Data Source', () => { * The sum has its own shift and does not respected the shift from the moving average * The differences has a filter which is inherited to the median, but not the average as it has its own filter */ - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -796,11 +788,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; const count = (ast.chain[1].arguments.aggs[1] as Ast).chain[0]; const sum = (ast.chain[1].arguments.aggs[2] as Ast).chain[0]; const average = (ast.chain[1].arguments.aggs[3] as Ast).chain[0]; @@ -822,7 +810,7 @@ describe('IndexPattern Data Source', () => { }); it('should wrap filtered metrics in filtered metric aggregation', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -864,11 +852,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; expect(ast.chain[1].arguments.aggs[0]).toMatchInlineSnapshot(` Object { "chain": Array [ @@ -954,7 +938,7 @@ describe('IndexPattern Data Source', () => { }); it('should add time_scale and format function if time scale is set and supported', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -992,11 +976,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; const timeScaleCalls = ast.chain.filter((fn) => fn.function === 'lens_time_scale'); const formatCalls = ast.chain.filter((fn) => fn.function === 'lens_format_column'); expect(timeScaleCalls).toHaveLength(1); @@ -1040,7 +1020,7 @@ describe('IndexPattern Data Source', () => { }); it('should not add time shift to nested count metric', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1061,11 +1041,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; const filteredMetricAgg = (ast.chain[1].arguments.aggs[0] as Ast).chain[0].arguments; const metricAgg = (filteredMetricAgg.customMetric[0] as Ast).chain[0].arguments; const bucketAgg = (filteredMetricAgg.customBucket[0] as Ast).chain[0].arguments; @@ -1076,7 +1052,7 @@ describe('IndexPattern Data Source', () => { }); it('should put column formatters after calculated columns', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1116,18 +1092,14 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; const formatIndex = ast.chain.findIndex((fn) => fn.function === 'lens_format_column'); const calculationIndex = ast.chain.findIndex((fn) => fn.function === 'moving_average'); expect(calculationIndex).toBeLessThan(formatIndex); }); it('should rename the output from esaggs when using flat query', () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1168,11 +1140,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; expect(ast.chain[1].arguments.metricsAtAllLevels).toEqual([false]); expect(JSON.parse(ast.chain[2].arguments.idMap[0] as string)).toEqual({ 'col-0-0': [expect.objectContaining({ id: 'bucket1' })], @@ -1182,7 +1150,7 @@ describe('IndexPattern Data Source', () => { }); it('should not put date fields used outside date_histograms to the esaggs timeFields parameter', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1211,18 +1179,14 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; expect(ast.chain[1].arguments.timeFields).toEqual(['timestamp']); expect(ast.chain[1].arguments.timeFields).not.toContain('timefield'); }); describe('optimizations', () => { it('should call optimizeEsAggs once per operation for which it is available', () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1272,7 +1236,7 @@ describe('IndexPattern Data Source', () => { const optimizeMock = jest.spyOn(operationDefinitionMap.percentile, 'optimizeEsAggs'); - indexPatternDatasource.toExpression(queryBaseState, 'first', indexPatterns); + FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns); expect(operationDefinitionMap.percentile.optimizeEsAggs).toHaveBeenCalledTimes(1); @@ -1280,7 +1244,7 @@ describe('IndexPattern Data Source', () => { }); it('should update anticipated esAggs column IDs based on the order of the optimized agg expression builders', () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1340,11 +1304,7 @@ describe('IndexPattern Data Source', () => { return { aggs: aggs.reverse(), esAggsIdMap }; }); - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; expect(operationDefinitionMap.percentile.optimizeEsAggs).toHaveBeenCalledTimes(1); @@ -1356,7 +1316,7 @@ describe('IndexPattern Data Source', () => { }); it('should deduplicate aggs for supported operations', () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1408,11 +1368,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; const idMap = JSON.parse(ast.chain[2].arguments.idMap as unknown as string); @@ -1491,7 +1447,7 @@ describe('IndexPattern Data Source', () => { }); it('should collect expression references and append them', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1517,18 +1473,14 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; // @ts-expect-error we can't isolate just the reference type expect(operationDefinitionMap.testReference.toExpression).toHaveBeenCalled(); expect(ast.chain[3]).toEqual('mock'); }); it('should keep correct column mapping keys with reference columns present', async () => { - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1554,11 +1506,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; expect(JSON.parse(ast.chain[2].arguments.idMap[0] as string)).toEqual({ 'col-0-0': [ @@ -1571,7 +1519,7 @@ describe('IndexPattern Data Source', () => { it('should topologically sort references', () => { // This is a real example of count() + count() - const queryBaseState: IndexPatternPrivateState = { + const queryBaseState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -1645,11 +1593,7 @@ describe('IndexPattern Data Source', () => { }, }; - const ast = indexPatternDatasource.toExpression( - queryBaseState, - 'first', - indexPatterns - ) as Ast; + const ast = FormBasedDatasource.toExpression(queryBaseState, 'first', indexPatterns) as Ast; const chainLength = ast.chain.length; expect(ast.chain[chainLength - 2].arguments.name).toEqual(['math']); expect(ast.chain[chainLength - 1].arguments.id).toEqual(['formula']); @@ -1674,7 +1618,7 @@ describe('IndexPattern Data Source', () => { }, currentIndexPatternId: '1', }; - expect(indexPatternDatasource.insertLayer(state, 'newLayer')).toEqual({ + expect(FormBasedDatasource.insertLayer(state, 'newLayer')).toEqual({ ...state, layers: { ...state.layers, @@ -1705,7 +1649,7 @@ describe('IndexPattern Data Source', () => { }, currentIndexPatternId: '1', }; - expect(indexPatternDatasource.removeLayer(state, 'first')).toEqual({ + expect(FormBasedDatasource.removeLayer(state, 'first')).toEqual({ ...state, layers: { second: { @@ -1720,7 +1664,7 @@ describe('IndexPattern Data Source', () => { describe('#createEmptyLayer', () => { it('creates state with empty layers', () => { - expect(indexPatternDatasource.createEmptyLayer('index-pattern-id')).toEqual({ + expect(FormBasedDatasource.createEmptyLayer('index-pattern-id')).toEqual({ currentIndexPatternId: 'index-pattern-id', layers: {}, }); @@ -1730,7 +1674,7 @@ describe('IndexPattern Data Source', () => { describe('#getLayers', () => { it('should list the current layers', () => { expect( - indexPatternDatasource.getLayers({ + FormBasedDatasource.getLayers({ layers: { first: { indexPatternId: '1', @@ -1753,7 +1697,7 @@ describe('IndexPattern Data Source', () => { let publicAPI: DatasourcePublicAPI; beforeEach(async () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: baseState, layerId: 'first', indexPatterns, @@ -1770,7 +1714,7 @@ describe('IndexPattern Data Source', () => { }); it('should skip columns that are being referenced', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -1808,7 +1752,7 @@ describe('IndexPattern Data Source', () => { }); it('should collect all fields (also from referenced columns)', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -1847,7 +1791,7 @@ describe('IndexPattern Data Source', () => { }); it('should collect and organize fields per visible column', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -1917,7 +1861,7 @@ describe('IndexPattern Data Source', () => { }); it('should return null for referenced columns', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -1962,7 +1906,7 @@ describe('IndexPattern Data Source', () => { describe('getFilters', () => { it('should return all filters in metrics, grouped by language', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2004,7 +1948,7 @@ describe('IndexPattern Data Source', () => { }); }); it('should ignore empty filtered metrics', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2034,7 +1978,7 @@ describe('IndexPattern Data Source', () => { }); }); it('shuold collect top values fields as kuery existence filters if no data is provided', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2089,7 +2033,7 @@ describe('IndexPattern Data Source', () => { }); }); it('shuold collect top values fields and terms as kuery filters if data is provided', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2160,7 +2104,7 @@ describe('IndexPattern Data Source', () => { }); }); it('shuold collect top values fields and terms and carefully handle empty string values', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2231,7 +2175,7 @@ describe('IndexPattern Data Source', () => { }); }); it('should ignore top values fields if other/missing option is enabled', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2278,7 +2222,7 @@ describe('IndexPattern Data Source', () => { }); }); it('should collect custom ranges as kuery filters', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2333,7 +2277,7 @@ describe('IndexPattern Data Source', () => { }); }); it('should collect custom ranges as kuery filters as partial', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2393,7 +2337,7 @@ describe('IndexPattern Data Source', () => { }); }); it('should collect filters within filters operation grouped by language', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2464,7 +2408,7 @@ describe('IndexPattern Data Source', () => { }); }); it('should ignore filtered metrics if at least one metric is unfiltered', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2502,7 +2446,7 @@ describe('IndexPattern Data Source', () => { }); }); it('should ignore filtered metrics if at least one metric is unfiltered in formula', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2575,7 +2519,7 @@ describe('IndexPattern Data Source', () => { }); }); it('should support complete scenarios', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2662,7 +2606,7 @@ describe('IndexPattern Data Source', () => { }); it('should avoid duplicate filters when formula has a global filter', () => { - publicAPI = indexPatternDatasource.getPublicAPI({ + publicAPI = FormBasedDatasource.getPublicAPI({ state: { ...baseState, layers: { @@ -2770,7 +2714,7 @@ describe('IndexPattern Data Source', () => { it('should use the results of getErrorMessages directly when single layer', () => { (getErrorMessages as jest.Mock).mockClear(); (getErrorMessages as jest.Mock).mockReturnValueOnce(['error 1', 'error 2']); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { layers: { first: { indexPatternId: '1', @@ -2780,7 +2724,7 @@ describe('IndexPattern Data Source', () => { }, currentIndexPatternId: '1', }; - expect(indexPatternDatasource.getErrorMessages(state, indexPatterns)).toEqual([ + expect(FormBasedDatasource.getErrorMessages(state, indexPatterns)).toEqual([ { longMessage: 'error 1', shortMessage: '' }, { longMessage: 'error 2', shortMessage: '' }, ]); @@ -2790,7 +2734,7 @@ describe('IndexPattern Data Source', () => { it('should prepend each error with its layer number on multi-layer chart', () => { (getErrorMessages as jest.Mock).mockClear(); (getErrorMessages as jest.Mock).mockReturnValueOnce(['error 1', 'error 2']); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { layers: { first: { indexPatternId: '1', @@ -2805,7 +2749,7 @@ describe('IndexPattern Data Source', () => { }, currentIndexPatternId: '1', }; - expect(indexPatternDatasource.getErrorMessages(state, indexPatterns)).toEqual([ + expect(FormBasedDatasource.getErrorMessages(state, indexPatterns)).toEqual([ { longMessage: 'Layer 1 error: error 1', shortMessage: '' }, { longMessage: 'Layer 1 error: error 2', shortMessage: '' }, ]); @@ -2814,7 +2758,7 @@ describe('IndexPattern Data Source', () => { }); describe('#getWarningMessages', () => { - let state: IndexPatternPrivateState; + let state: FormBasedPrivateState; let framePublicAPI: FramePublicAPI; beforeEach(() => { @@ -2948,12 +2892,7 @@ describe('IndexPattern Data Source', () => { ); it('should return mismatched time shifts', () => { - const warnings = indexPatternDatasource.getWarningMessages!( - state, - framePublicAPI, - {}, - () => {} - ); + const warnings = FormBasedDatasource.getWarningMessages!(state, framePublicAPI, {}, () => {}); expect(extractTranslationIdsFromWarnings(warnings)).toMatchInlineSnapshot(` Array [ @@ -2966,12 +2905,7 @@ describe('IndexPattern Data Source', () => { it('should show different types of warning messages', () => { framePublicAPI.activeData!.first.columns[1].meta.sourceParams!.hasPrecisionError = true; - const warnings = indexPatternDatasource.getWarningMessages!( - state, - framePublicAPI, - {}, - () => {} - ); + const warnings = FormBasedDatasource.getWarningMessages!(state, framePublicAPI, {}, () => {}); expect(extractTranslationIdsFromWarnings(warnings)).toMatchInlineSnapshot(` Array [ @@ -3002,7 +2936,7 @@ describe('IndexPattern Data Source', () => { currentIndexPatternId: '1', }; - expect(indexPatternDatasource.getErrorMessages(state, indexPatterns)).toEqual([ + expect(FormBasedDatasource.getErrorMessages(state, indexPatterns)).toEqual([ { longMessage: 'Layer 1 error: error 1', shortMessage: '' }, { longMessage: 'Layer 1 error: error 2', shortMessage: '' }, ]); @@ -3013,7 +2947,7 @@ describe('IndexPattern Data Source', () => { describe('#updateStateOnCloseDimension', () => { it('should not update when there are no incomplete columns', () => { expect( - indexPatternDatasource.updateStateOnCloseDimension!({ + FormBasedDatasource.updateStateOnCloseDimension!({ state: { layers: { first: { @@ -3055,7 +2989,7 @@ describe('IndexPattern Data Source', () => { currentIndexPatternId: '1', }; expect( - indexPatternDatasource.updateStateOnCloseDimension!({ + FormBasedDatasource.updateStateOnCloseDimension!({ state, layerId: 'first', columnId: 'col1', @@ -3127,9 +3061,9 @@ describe('IndexPattern Data Source', () => { }, }, }, - } as IndexPatternPrivateState; + } as FormBasedPrivateState; expect( - indexPatternDatasource.isTimeBased(state, { + FormBasedDatasource.isTimeBased(state, { ...indexPatterns, '1': { ...indexPatterns['1'], timeFieldName: undefined }, }) @@ -3189,9 +3123,9 @@ describe('IndexPattern Data Source', () => { }, }, }, - } as IndexPatternPrivateState; + } as FormBasedPrivateState; expect( - indexPatternDatasource.isTimeBased(state, { + FormBasedDatasource.isTimeBased(state, { ...indexPatterns, '1': { ...indexPatterns['1'], timeFieldName: undefined }, }) @@ -3215,9 +3149,9 @@ describe('IndexPattern Data Source', () => { }, }, }, - } as IndexPatternPrivateState; + } as FormBasedPrivateState; expect( - indexPatternDatasource.isTimeBased(state, { + FormBasedDatasource.isTimeBased(state, { ...indexPatterns, '1': { ...indexPatterns['1'], timeFieldName: undefined }, }) @@ -3241,8 +3175,8 @@ describe('IndexPattern Data Source', () => { }, }, }, - } as IndexPatternPrivateState; - expect(indexPatternDatasource.isTimeBased(state, indexPatterns)).toEqual(true); + } as FormBasedPrivateState; + expect(FormBasedDatasource.isTimeBased(state, indexPatterns)).toEqual(true); }); }); @@ -3265,9 +3199,9 @@ describe('IndexPattern Data Source', () => { }, }, }, - } as IndexPatternPrivateState; + } as FormBasedPrivateState; expect( - indexPatternDatasource.initializeDimension!(state, 'first', indexPatterns, { + FormBasedDatasource.initializeDimension!(state, 'first', indexPatterns, { columnId: 'newStatic', groupId: 'a', }) @@ -3292,9 +3226,9 @@ describe('IndexPattern Data Source', () => { }, }, }, - } as IndexPatternPrivateState; + } as FormBasedPrivateState; expect( - indexPatternDatasource.initializeDimension!(state, 'first', indexPatterns, { + FormBasedDatasource.initializeDimension!(state, 'first', indexPatterns, { columnId: 'newStatic', groupId: 'a', staticValue: 0, // use a falsy value to check also this corner case @@ -3329,7 +3263,7 @@ describe('IndexPattern Data Source', () => { describe('#isEqual', () => { const layerId = '8bd66b66-aba3-49fb-9ff2-4bf83f2be08e'; - const persistableState: IndexPatternPersistedState = { + const persistableState: FormBasedPersistedState = { layers: { [layerId]: { columns: { @@ -3366,7 +3300,7 @@ describe('IndexPattern Data Source', () => { it('should be false if datasource states are using different data views', () => { expect( - indexPatternDatasource.isEqual(persistableState, references1, persistableState, references2) + FormBasedDatasource.isEqual(persistableState, references1, persistableState, references2) ).toBe(false); }); @@ -3375,7 +3309,7 @@ describe('IndexPattern Data Source', () => { differentPersistableState.layers[layerId].columnOrder = ['something else']; expect( - indexPatternDatasource.isEqual( + FormBasedDatasource.isEqual( persistableState, references1, differentPersistableState, @@ -3386,7 +3320,7 @@ describe('IndexPattern Data Source', () => { it('should be true if datasource states are identical and they refer to the same data view', () => { expect( - indexPatternDatasource.isEqual(persistableState, references1, persistableState, references1) + FormBasedDatasource.isEqual(persistableState, references1, persistableState, references1) ).toBe(true); }); }); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx b/x-pack/plugins/lens/public/datasources/form_based/form_based.tsx similarity index 90% rename from x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx rename to x-pack/plugins/lens/public/datasources/form_based/form_based.tsx index fb31c3c1a9a71..984ce87dfefaf 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/form_based.tsx @@ -36,7 +36,7 @@ import type { IndexPatternField, IndexPattern, IndexPatternRef, -} from '../types'; +} from '../../types'; import { changeIndexPattern, changeLayerIndexPattern, @@ -49,18 +49,18 @@ import { } from './loader'; import { toExpression } from './to_expression'; import { - IndexPatternDimensionTrigger, - IndexPatternDimensionEditor, + FormBasedDimensionTrigger, + FormBasedDimensionEditor, getDropProps, onDrop, } from './dimension_panel'; -import { IndexPatternDataPanel } from './datapanel'; +import { FormBasedDataPanel } from './datapanel'; import { getDatasourceSuggestionsForField, getDatasourceSuggestionsFromCurrentState, getDatasourceSuggestionsForVisualizeField, getDatasourceSuggestionsForVisualizeCharts, -} from './indexpattern_suggestions'; +} from './form_based_suggestions'; import { getFiltersInLayer, @@ -69,7 +69,7 @@ import { isColumnInvalid, cloneLayer, } from './utils'; -import { isDraggedDataViewField } from '../utils'; +import { isDraggedDataViewField } from '../../utils'; import { normalizeOperationDataType } from './pure_utils'; import { LayerPanel } from './layerpanel'; import { @@ -81,15 +81,15 @@ import { TermsIndexPatternColumn, } from './operations'; import { getReferenceRoot } from './operations/layer_helpers'; -import { IndexPatternPrivateState, IndexPatternPersistedState } from './types'; +import { FormBasedPrivateState, FormBasedPersistedState } from './types'; import { mergeLayer } from './state_helpers'; -import { Datasource, VisualizeEditorContext } from '../types'; +import { Datasource, VisualizeEditorContext } from '../../types'; import { deleteColumn, isReferenced } from './operations'; -import { GeoFieldWorkspacePanel } from '../editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel'; -import { DraggingIdentifier } from '../drag_drop'; +import { GeoFieldWorkspacePanel } from '../../editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel'; +import { DraggingIdentifier } from '../../drag_drop'; import { getStateTimeShiftWarningMessages } from './time_shift_utils'; import { getPrecisionErrorWarningMessages } from './utils'; -import { DOCUMENT_FIELD_NAME } from '../../common/constants'; +import { DOCUMENT_FIELD_NAME } from '../../../common/constants'; import { isColumnOfType } from './operations/definitions/helpers'; export type { OperationType, GenericIndexPatternColumn } from './operations'; export { deleteColumn } from './operations'; @@ -119,15 +119,15 @@ export function columnToOperation( }; } -export type { FormatColumnArgs, TimeScaleArgs, CounterRateArgs } from '../../common/expressions'; +export type { FormatColumnArgs, TimeScaleArgs, CounterRateArgs } from '../../../common/expressions'; export { getSuffixFormatter, unitSuffixesLong, suffixFormatterId, -} from '../../common/suffix_formatter'; +} from '../../../common/suffix_formatter'; -export function getIndexPatternDatasource({ +export function getFormBasedDatasource({ core, storage, data, @@ -152,14 +152,14 @@ export function getIndexPatternDatasource({ }) { const uiSettings = core.uiSettings; - const DATASOURCE_ID = 'indexpattern'; + const DATASOURCE_ID = 'formBased'; // Not stateful. State is persisted to the frame - const indexPatternDatasource: Datasource = { + const formBasedDatasource: Datasource = { id: DATASOURCE_ID, initialize( - persistedState?: IndexPatternPersistedState, + persistedState?: FormBasedPersistedState, references?: SavedObjectReference[], initialContext?: VisualizeFieldContext | VisualizeEditorContext, indexPatternRefs?: IndexPatternRef[], @@ -176,11 +176,11 @@ export function getIndexPatternDatasource({ }); }, - getPersistableState(state: IndexPatternPrivateState) { + getPersistableState(state: FormBasedPrivateState) { return extractReferences(state); }, - insertLayer(state: IndexPatternPrivateState, newLayerId: string) { + insertLayer(state: FormBasedPrivateState, newLayerId: string) { return { ...state, layers: { @@ -204,7 +204,7 @@ export function getIndexPatternDatasource({ }; }, - removeLayer(state: IndexPatternPrivateState, layerId: string) { + removeLayer(state: FormBasedPrivateState, layerId: string) { const newLayers = { ...state.layers }; delete newLayers[layerId]; @@ -214,7 +214,7 @@ export function getIndexPatternDatasource({ }; }, - clearLayer(state: IndexPatternPrivateState, layerId: string) { + clearLayer(state: FormBasedPrivateState, layerId: string) { return { ...state, layers: { @@ -224,7 +224,7 @@ export function getIndexPatternDatasource({ }; }, - getLayers(state: IndexPatternPrivateState) { + getLayers(state: FormBasedPrivateState) { return Object.keys(state?.layers); }, @@ -266,10 +266,7 @@ export function getIndexPatternDatasource({ toExpression: (state, layerId, indexPatterns) => toExpression(state, layerId, indexPatterns, uiSettings), - renderDataPanel( - domElement: Element, - props: DatasourceDataPanelProps - ) { + renderDataPanel(domElement: Element, props: DatasourceDataPanelProps) { const { onChangeIndexPattern, ...otherProps } = props; render( @@ -285,7 +282,7 @@ export function getIndexPatternDatasource({ discover, }} > - ; const counts = {} as Record; @@ -342,9 +339,9 @@ export function getIndexPatternDatasource({ renderDimensionTrigger: ( domElement: Element, - props: DatasourceDimensionTriggerProps + props: DatasourceDimensionTriggerProps ) => { - const columnLabelMap = indexPatternDatasource.uniqueLabels(props.state); + const columnLabelMap = formBasedDatasource.uniqueLabels(props.state); render( @@ -361,10 +358,7 @@ export function getIndexPatternDatasource({ unifiedSearch, }} > - + , @@ -374,9 +368,9 @@ export function getIndexPatternDatasource({ renderDimensionEditor: ( domElement: Element, - props: DatasourceDimensionEditorProps + props: DatasourceDimensionEditorProps ) => { - const columnLabelMap = indexPatternDatasource.uniqueLabels(props.state); + const columnLabelMap = formBasedDatasource.uniqueLabels(props.state); render( @@ -394,7 +388,7 @@ export function getIndexPatternDatasource({ unifiedSearch, }} > - + props: DatasourceLayerPanelProps ) => { const { onChangeIndexPattern, ...otherProps } = props; render( @@ -445,7 +439,7 @@ export function getIndexPatternDatasource({ onDrop, getCustomWorkspaceRenderer: ( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, dragging: DraggingIdentifier, indexPatterns: Record ) => { @@ -501,7 +495,7 @@ export function getIndexPatternDatasource({ onIndexPatternRename: (state, oldIndexPatternId, newIndexPatternId) => { return renameIndexPattern({ state, oldIndexPatternId, newIndexPatternId }); }, - getRenderEventCounters(state: IndexPatternPrivateState): string[] { + getRenderEventCounters(state: FormBasedPrivateState): string[] { const additionalEvents = { time_shift: false, filter: false, @@ -545,8 +539,8 @@ export function getIndexPatternDatasource({ }); }, - getPublicAPI({ state, layerId, indexPatterns }: PublicAPIProps) { - const columnLabelMap = indexPatternDatasource.uniqueLabels(state); + getPublicAPI({ state, layerId, indexPatterns }: PublicAPIProps) { + const columnLabelMap = formBasedDatasource.uniqueLabels(state); const layer = state.layers[layerId]; const visibleColumnIds = layer.columnOrder.filter((colId) => !isReferenced(layer, colId)); @@ -766,16 +760,16 @@ export function getIndexPatternDatasource({ ); }, isEqual: ( - persistableState1: IndexPatternPersistedState, + persistableState1: FormBasedPersistedState, references1: SavedObjectReference[], - persistableState2: IndexPatternPersistedState, + persistableState2: FormBasedPersistedState, references2: SavedObjectReference[] ) => isEqual( injectReferences(persistableState1, references1), injectReferences(persistableState2, references2) ), - getUsedDataView: (state: IndexPatternPrivateState, layerId?: string) => { + getUsedDataView: (state: FormBasedPrivateState, layerId?: string) => { if (!layerId) { return state.currentIndexPatternId; } @@ -786,7 +780,7 @@ export function getIndexPatternDatasource({ }, }; - return indexPatternDatasource; + return formBasedDatasource; } function blankLayer(indexPatternId: string) { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/form_based_suggestions.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/form_based_suggestions.test.tsx index 382c11bda545a..d7a544a723e04 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/form_based_suggestions.test.tsx @@ -12,16 +12,16 @@ import type { StaticValueColumn, CountColumn, } from '@kbn/visualizations-plugin/common/convert_to_lens'; -import { DatasourceSuggestion } from '../types'; -import { generateId } from '../id_generator'; -import type { IndexPatternPrivateState } from './types'; +import { DatasourceSuggestion } from '../../types'; +import { generateId } from '../../id_generator'; +import type { FormBasedPrivateState } from './types'; import { getDatasourceSuggestionsForField, getDatasourceSuggestionsFromCurrentState, getDatasourceSuggestionsForVisualizeField, getDatasourceSuggestionsForVisualizeCharts, IndexPatternSuggestion, -} from './indexpattern_suggestions'; +} from './form_based_suggestions'; import { documentField } from './document_field'; import { getFieldByNameFactory } from './pure_helpers'; import { isEqual } from 'lodash'; @@ -33,7 +33,7 @@ import { } from './operations/definitions'; jest.mock('./loader'); -jest.mock('../id_generator'); +jest.mock('../../id_generator'); const fieldsOne = [ { @@ -171,7 +171,7 @@ const expectedIndexPatterns = { }, }; -function testInitialState(): IndexPatternPrivateState { +function testInitialState(): FormBasedPrivateState { return { currentIndexPatternId: '1', layers: { @@ -206,7 +206,7 @@ function getSuggestionSubset( ): Array> { return suggestions.map((s) => { const newSuggestion = { ...s } as Omit & { - state?: IndexPatternPrivateState; + state?: FormBasedPrivateState; }; delete newSuggestion.state; return newSuggestion; @@ -385,7 +385,7 @@ describe('IndexPattern Data Source suggestions', () => { }); it('should make a metric suggestion for a number field if there is no time field', async () => { - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -628,7 +628,7 @@ describe('IndexPattern Data Source suggestions', () => { }); it('should make a metric suggestion for a number field if there is no time field', async () => { - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { previousLayer: { @@ -764,7 +764,7 @@ describe('IndexPattern Data Source suggestions', () => { }); describe('suggesting extensions to non-empty tables', () => { - function stateWithNonEmptyTables(): IndexPatternPrivateState { + function stateWithNonEmptyTables(): FormBasedPrivateState { const state = testInitialState(); return { @@ -1036,7 +1036,7 @@ describe('IndexPattern Data Source suggestions', () => { it('adds a metric column on a number field if no other metrics set', () => { (generateId as jest.Mock).mockReturnValue('newid'); const initialState = stateWithNonEmptyTables(); - const modifiedState: IndexPatternPrivateState = { + const modifiedState: FormBasedPrivateState = { ...initialState, layers: { ...initialState.layers, @@ -1138,7 +1138,7 @@ describe('IndexPattern Data Source suggestions', () => { it('skips duplicates when the document-specific field is already in use', () => { const initialState = stateWithNonEmptyTables(); - const modifiedState: IndexPatternPrivateState = { + const modifiedState: FormBasedPrivateState = { ...initialState, layers: { ...initialState.layers, @@ -1170,7 +1170,7 @@ describe('IndexPattern Data Source suggestions', () => { it('hides any referenced metrics when adding new metrics', () => { (generateId as jest.Mock).mockReturnValue('newid'); const initialState = stateWithNonEmptyTables(); - const modifiedState: IndexPatternPrivateState = { + const modifiedState: FormBasedPrivateState = { ...initialState, layers: { currentLayer: { @@ -1239,7 +1239,7 @@ describe('IndexPattern Data Source suggestions', () => { it('makes a suggestion to extending from an invalid state with a new metric', () => { (generateId as jest.Mock).mockReturnValue('newid'); const initialState = stateWithNonEmptyTables(); - const modifiedState: IndexPatternPrivateState = { + const modifiedState: FormBasedPrivateState = { ...initialState, layers: { currentLayer: { @@ -1306,7 +1306,7 @@ describe('IndexPattern Data Source suggestions', () => { (generateId as jest.Mock).mockReturnValue('newid'); const initialState = stateWithNonEmptyTables(); - const modifiedState: IndexPatternPrivateState = { + const modifiedState: FormBasedPrivateState = { ...initialState, layers: { referenceLineLayer: { @@ -1394,7 +1394,7 @@ describe('IndexPattern Data Source suggestions', () => { }); describe('finding the layer that is using the current index pattern', () => { - function stateWithCurrentIndexPattern(): IndexPatternPrivateState { + function stateWithCurrentIndexPattern(): FormBasedPrivateState { const state = testInitialState(); return { @@ -2140,7 +2140,7 @@ describe('IndexPattern Data Source suggestions', () => { it('returns a single suggestion containing the current columns for each layer', async () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { ...initialState.layers, @@ -2233,7 +2233,7 @@ describe('IndexPattern Data Source suggestions', () => { it('returns a metric over time for single metric tables', async () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { first: { @@ -2296,7 +2296,7 @@ describe('IndexPattern Data Source suggestions', () => { it('adds date histogram over default time field for tables without time dimension', async () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { first: { @@ -2385,7 +2385,7 @@ describe('IndexPattern Data Source suggestions', () => { it('adds date histogram over default time field for tables without time dimension and a referenceLine', async () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { first: { @@ -2495,7 +2495,7 @@ describe('IndexPattern Data Source suggestions', () => { it('does not create an over time suggestion if tables with numeric buckets with time dimension', async () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { first: { @@ -2543,7 +2543,7 @@ describe('IndexPattern Data Source suggestions', () => { it('adds date histogram over default time field for custom range intervals', async () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { first: { @@ -2630,7 +2630,7 @@ describe('IndexPattern Data Source suggestions', () => { it('does not create an over time suggestion if there is no default time field', async () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { first: { @@ -2667,7 +2667,7 @@ describe('IndexPattern Data Source suggestions', () => { it('should not propose an over time suggestion if there are multiple bucket dimensions', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { first: { @@ -2751,7 +2751,7 @@ describe('IndexPattern Data Source suggestions', () => { searchable: true, }, ]; - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -2858,7 +2858,7 @@ describe('IndexPattern Data Source suggestions', () => { it('returns an only metric version of a given table, but does not include current state as reduced', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -2966,7 +2966,7 @@ describe('IndexPattern Data Source suggestions', () => { it('returns an alternative metric for an only-metric table', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -3032,7 +3032,7 @@ describe('IndexPattern Data Source suggestions', () => { it('contains a reordering suggestion when there are exactly 2 buckets', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -3084,7 +3084,7 @@ describe('IndexPattern Data Source suggestions', () => { it('will generate suggestions even if there are errors from missing fields', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -3148,7 +3148,7 @@ describe('IndexPattern Data Source suggestions', () => { describe('references', () => { it('will extend the table with a date when starting in an invalid state', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { ...initialState.layers, @@ -3237,7 +3237,7 @@ describe('IndexPattern Data Source suggestions', () => { it('will make an unchanged suggestion including incomplete references', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { ...initialState.layers, @@ -3327,7 +3327,7 @@ describe('IndexPattern Data Source suggestions', () => { it('will create reduced suggestions with all referenced children when handling references', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { ...initialState.layers, @@ -3473,7 +3473,7 @@ describe('IndexPattern Data Source suggestions', () => { it('will leave dangling references in place', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { ...initialState.layers, @@ -3521,7 +3521,7 @@ describe('IndexPattern Data Source suggestions', () => { it('will not suggest reduced tables if there is just a referenced top level metric', () => { const initialState = testInitialState(); - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { ...initialState, layers: { ...initialState.layers, @@ -3566,7 +3566,7 @@ describe('IndexPattern Data Source suggestions', () => { }); function isTableWithBucketColumns( - suggestion: DatasourceSuggestion, + suggestion: DatasourceSuggestion, columnIds: string[], numBuckets: number ) { @@ -3577,7 +3577,7 @@ function isTableWithBucketColumns( } function isTableWithMetricColumns( - suggestion: DatasourceSuggestion, + suggestion: DatasourceSuggestion, columnIds: string[] ) { expect(suggestion.table.isMultiRow).toEqual(false); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.ts b/x-pack/plugins/lens/public/datasources/form_based/form_based_suggestions.ts similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.ts rename to x-pack/plugins/lens/public/datasources/form_based/form_based_suggestions.ts index 8503c369f4ec2..52008f10bcdeb 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/form_based_suggestions.ts @@ -14,7 +14,7 @@ import type { AnyColumnWithSourceField, TermsColumn, } from '@kbn/visualizations-plugin/common/convert_to_lens'; -import { generateId } from '../id_generator'; +import { generateId } from '../../id_generator'; import type { DatasourceSuggestion, IndexPattern, @@ -22,8 +22,8 @@ import type { IndexPatternMap, TableChangeType, VisualizationDimensionGroupConfig, -} from '../types'; -import { columnToOperation } from './indexpattern'; +} from '../../types'; +import { columnToOperation } from './form_based'; import { insertNewColumn, replaceColumn, @@ -41,12 +41,12 @@ import { ColumnAdvancedParams, } from './operations'; import { hasField } from './pure_utils'; -import type { IndexPatternPrivateState, IndexPatternLayer } from './types'; +import type { FormBasedPrivateState, FormBasedLayer } from './types'; import { documentField } from './document_field'; import { OperationDefinition } from './operations/definitions'; import { insertOrReplaceFormulaColumn } from './operations/definitions/formula'; -export type IndexPatternSuggestion = DatasourceSuggestion; +export type IndexPatternSuggestion = DatasourceSuggestion; interface ColumnChange { op: OperationType; @@ -67,12 +67,12 @@ function buildSuggestion({ label, changeType, }: { - state: IndexPatternPrivateState; + state: FormBasedPrivateState; layerId: string; changeType: TableChangeType; - updatedLayer?: IndexPatternLayer; + updatedLayer?: FormBasedLayer; label?: string; -}): DatasourceSuggestion { +}): DatasourceSuggestion { const updatedState = updatedLayer ? { ...state, @@ -120,7 +120,7 @@ function buildSuggestion({ } export function getDatasourceSuggestionsForField( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, indexPatternId: string, field: IndexPatternField, indexPatterns: IndexPatternMap, @@ -176,7 +176,7 @@ export function getDatasourceSuggestionsForField( // Called when the user navigates from Visualize editor to Lens export function getDatasourceSuggestionsForVisualizeCharts( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, contextLayers: Layer[], indexPatterns: IndexPatternMap ): IndexPatternSuggestion[] { @@ -184,7 +184,7 @@ export function getDatasourceSuggestionsForVisualizeCharts( } function getEmptyLayersSuggestionsForVisualizeCharts( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, contextLayers: Layer[], indexPatterns: IndexPatternMap ): IndexPatternSuggestion[] { @@ -280,7 +280,7 @@ function convertToColumnChange(columns: Layer['columns'], indexPattern: IndexPat ) { const orderColumn = column.params.orderAgg; const operationDefinition = operationDefinitionMap[orderColumn.operationType]; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: indexPattern.id, columns: {}, columnOrder: [], @@ -311,7 +311,7 @@ function createNewLayerWithMetricAggregationFromVizEditor( layer: Layer ) { const columns = convertToColumnChange(layer.columns, indexPattern); - let newLayer: IndexPatternLayer = { + let newLayer: FormBasedLayer = { indexPatternId: indexPattern.id, columns: {}, columnOrder: [], @@ -360,7 +360,7 @@ function createNewLayerWithMetricAggregationFromVizEditor( // Called when the user navigates from Discover to Lens (Visualize button) export function getDatasourceSuggestionsForVisualizeField( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, indexPatternId: string, fieldName: string, indexPatterns: IndexPatternMap @@ -400,7 +400,7 @@ function getBucketOperation(field: IndexPatternField) { } function getExistingLayerSuggestionsForField( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, layerId: string, field: IndexPatternField, indexPatterns: IndexPatternMap @@ -514,14 +514,14 @@ function getExistingLayerSuggestionsForField( } function getEmptyLayerSuggestionsForField( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, layerId: string, indexPatternId: string, field: IndexPatternField, indexPatterns: IndexPatternMap ): IndexPatternSuggestion[] { const indexPattern = indexPatterns[indexPatternId]; - let newLayer: IndexPatternLayer | undefined; + let newLayer: FormBasedLayer | undefined; const bucketOperation = getBucketOperation(field); if (bucketOperation) { newLayer = createNewLayerWithBucketAggregation(indexPattern, field, bucketOperation); @@ -549,7 +549,7 @@ function createNewLayerWithBucketAggregation( indexPattern: IndexPattern, field: IndexPatternField, operation: OperationType -): IndexPatternLayer { +): FormBasedLayer { return insertNewColumn({ op: operation, layer: insertNewColumn({ @@ -570,7 +570,7 @@ function createNewLayerWithBucketAggregation( function createNewLayerWithMetricAggregation( indexPattern: IndexPattern, field: IndexPatternField -): IndexPatternLayer | undefined { +): FormBasedLayer | undefined { const dateField = indexPattern.getFieldByName(indexPattern.timeFieldName!); const [metricOperation] = getMetricOperationTypes(field); if (!metricOperation) { @@ -595,10 +595,10 @@ function createNewLayerWithMetricAggregation( } export function getDatasourceSuggestionsFromCurrentState( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, indexPatterns: IndexPatternMap, filterLayers: (layerId: string) => boolean = () => true -): Array> { +): Array> { const layers = Object.entries(state.layers || {}).filter(([layerId]) => filterLayers(layerId)); if (layers.length > 1) { @@ -658,7 +658,7 @@ export function getDatasourceSuggestionsFromCurrentState( buckets.length === 1 && buckets.some((columnId) => layer.columns[columnId].dataType === 'number'); - const suggestions: Array> = []; + const suggestions: Array> = []; // Always suggest an unchanged table, including during invalid states suggestions.push( @@ -708,7 +708,7 @@ export function getDatasourceSuggestionsFromCurrentState( } function createChangedNestingSuggestion( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, layerId: string, indexPatterns: IndexPatternMap ) { @@ -739,7 +739,7 @@ function createChangedNestingSuggestion( function createMetricSuggestion( indexPattern: IndexPattern, layerId: string, - state: IndexPatternPrivateState, + state: FormBasedPrivateState, field: IndexPatternField ) { const [operation] = getMetricOperationTypes(field); @@ -781,10 +781,10 @@ function getNestedTitle([outerBucketLabel, innerBucketLabel]: string[]) { function createAlternativeMetricSuggestions( indexPattern: IndexPattern, layerId: string, - state: IndexPatternPrivateState + state: FormBasedPrivateState ) { const layer = state.layers[layerId]; - const suggestions: Array> = []; + const suggestions: Array> = []; const topLevelMetricColumns = layer.columnOrder.filter( (columnId) => !isReferenced(layer, columnId) ); @@ -826,7 +826,7 @@ function createAlternativeMetricSuggestions( } function createSuggestionWithDefaultDateHistogram( - state: IndexPatternPrivateState, + state: FormBasedPrivateState, layerId: string, timeField: IndexPatternField, indexPatterns: IndexPatternMap @@ -852,7 +852,7 @@ function createSuggestionWithDefaultDateHistogram( }); } -function createSimplifiedTableSuggestions(state: IndexPatternPrivateState, layerId: string) { +function createSimplifiedTableSuggestions(state: FormBasedPrivateState, layerId: string) { const layer = state.layers[layerId]; const [availableBucketedColumns, availableMetricColumns] = partition( @@ -916,7 +916,7 @@ function createSimplifiedTableSuggestions(state: IndexPatternPrivateState, layer }); } -function getMetricSuggestionTitle(layer: IndexPatternLayer, onlySimpleMetric: boolean) { +function getMetricSuggestionTitle(layer: FormBasedLayer, onlySimpleMetric: boolean) { const { operationType, label } = layer.columns[layer.columnOrder[0]]; return i18n.translate('xpack.lens.indexpattern.suggestions.overallLabel', { defaultMessage: '{operation} overall', diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/help_popover.scss b/x-pack/plugins/lens/public/datasources/form_based/help_popover.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/help_popover.scss rename to x-pack/plugins/lens/public/datasources/form_based/help_popover.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/help_popover.tsx b/x-pack/plugins/lens/public/datasources/form_based/help_popover.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/help_popover.tsx rename to x-pack/plugins/lens/public/datasources/form_based/help_popover.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/index.ts b/x-pack/plugins/lens/public/datasources/form_based/index.ts similarity index 84% rename from x-pack/plugins/lens/public/indexpattern_datasource/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/index.ts index 6b1b052c90b14..3b1f62829fa46 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/index.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/index.ts @@ -16,11 +16,11 @@ import type { IndexPatternFieldEditorStart } from '@kbn/data-view-field-editor-p import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public'; import type { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import type { FieldFormatsStart, FieldFormatsSetup } from '@kbn/field-formats-plugin/public'; -import type { EditorFrameSetup } from '../types'; +import type { EditorFrameSetup } from '../../types'; export type { PersistedIndexPatternLayer, FormulaPublicApi } from './types'; -export interface IndexPatternDatasourceSetupPlugins { +export interface FormBasedDatasourceSetupPlugins { expressions: ExpressionsSetup; fieldFormats: FieldFormatsSetup; data: DataPublicPluginSetup; @@ -28,7 +28,7 @@ export interface IndexPatternDatasourceSetupPlugins { charts: ChartsPluginSetup; } -export interface IndexPatternDatasourceStartPlugins { +export interface FormBasedDatasourceStartPlugins { data: DataPublicPluginStart; unifiedSearch: UnifiedSearchPublicPluginStart; discover?: DiscoverStart; @@ -38,19 +38,19 @@ export interface IndexPatternDatasourceStartPlugins { uiActions: UiActionsStart; } -export class IndexPatternDatasource { +export class FormBasedDatasource { setup( - core: CoreSetup, + core: CoreSetup, { fieldFormats: fieldFormatsSetup, expressions, editorFrame, charts, - }: IndexPatternDatasourceSetupPlugins + }: FormBasedDatasourceSetupPlugins ) { editorFrame.registerDatasource(async () => { - const { getIndexPatternDatasource, getSuffixFormatter, suffixFormatterId } = await import( - '../async_services' + const { getFormBasedDatasource, getSuffixFormatter, suffixFormatterId } = await import( + '../../async_services' ); if (!fieldFormatsSetup.has(suffixFormatterId)) { @@ -67,7 +67,7 @@ export class IndexPatternDatasource { { dataViewFieldEditor, uiActions, data, fieldFormats, dataViews, unifiedSearch, discover }, ] = await core.getStartServices(); - return getIndexPatternDatasource({ + return getFormBasedDatasource({ core: coreStart, fieldFormats, storage: new Storage(localStorage), diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/layerpanel.test.tsx similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/layerpanel.test.tsx index 7dde02c6c2b61..defc505f1d9e1 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/layerpanel.test.tsx @@ -6,13 +6,13 @@ */ import React, { MouseEvent } from 'react'; -import { IndexPatternPrivateState } from './types'; -import { IndexPatternLayerPanelProps, LayerPanel } from './layerpanel'; +import { FormBasedPrivateState } from './types'; +import { FormBasedLayerPanelProps, LayerPanel } from './layerpanel'; import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { ShallowWrapper } from 'enzyme'; import { EuiSelectable } from '@elastic/eui'; import { DataViewsList } from '@kbn/unified-search-plugin/public'; -import { ChangeIndexPattern } from '../shared_components/dataview_picker/dataview_picker'; +import { ChangeIndexPattern } from '../../shared_components/dataview_picker/dataview_picker'; import { getFieldByNameFactory } from './pure_helpers'; import { TermsIndexPatternColumn } from './operations'; @@ -135,7 +135,7 @@ const fieldsThree = [ }, ]; -const initialState: IndexPatternPrivateState = { +const initialState: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { first: { @@ -168,7 +168,7 @@ const initialState: IndexPatternPrivateState = { }, }; describe('Layer Data Panel', () => { - let defaultProps: IndexPatternLayerPanelProps; + let defaultProps: FormBasedLayerPanelProps; beforeEach(() => { defaultProps = { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.tsx b/x-pack/plugins/lens/public/datasources/form_based/layerpanel.tsx similarity index 78% rename from x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.tsx rename to x-pack/plugins/lens/public/datasources/form_based/layerpanel.tsx index 9824f70eeddfc..c18b79b28c58c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/layerpanel.tsx @@ -8,13 +8,12 @@ import React from 'react'; import { I18nProvider } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; -import { DatasourceLayerPanelProps } from '../types'; -import { IndexPatternPrivateState } from './types'; -import { ChangeIndexPattern } from '../shared_components/dataview_picker/dataview_picker'; +import { DatasourceLayerPanelProps } from '../../types'; +import { FormBasedPrivateState } from './types'; +import { ChangeIndexPattern } from '../../shared_components/dataview_picker/dataview_picker'; -export interface IndexPatternLayerPanelProps - extends DatasourceLayerPanelProps { - state: IndexPatternPrivateState; +export interface FormBasedLayerPanelProps extends DatasourceLayerPanelProps { + state: FormBasedPrivateState; onChangeIndexPattern: (newId: string) => void; } @@ -23,7 +22,7 @@ export function LayerPanel({ layerId, onChangeIndexPattern, dataViews, -}: IndexPatternLayerPanelProps) { +}: FormBasedLayerPanelProps) { const layer = state.layers[layerId]; const indexPattern = dataViews.indexPatterns[layer.indexPatternId]; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/loader.test.ts b/x-pack/plugins/lens/public/datasources/form_based/loader.test.ts similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/loader.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/loader.test.ts index a3bc7a21143c4..896fbd0e6404f 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/loader.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/loader.test.ts @@ -12,9 +12,9 @@ import { extractReferences, injectReferences, } from './loader'; -import { IndexPatternPersistedState, IndexPatternPrivateState } from './types'; +import { FormBasedPersistedState, FormBasedPrivateState } from './types'; import { DateHistogramIndexPatternColumn, TermsIndexPatternColumn } from './operations'; -import { sampleIndexPatterns } from '../data_views_service/mocks'; +import { sampleIndexPatterns } from '../../data_views_service/mocks'; const createMockStorage = (lastData?: Record) => { return { @@ -141,7 +141,7 @@ describe('loader', () => { }); it('should initialize all the embeddable references without local storage', () => { - const savedState: IndexPatternPersistedState = { + const savedState: FormBasedPersistedState = { layers: { layerb: { columnOrder: ['col1', 'col2'], @@ -189,7 +189,7 @@ describe('loader', () => { }); it('should initialize from saved state', () => { - const savedState: IndexPatternPersistedState = { + const savedState: FormBasedPersistedState = { layers: { layerb: { columnOrder: ['col1', 'col2'], @@ -242,7 +242,7 @@ describe('loader', () => { }); describe('saved object references', () => { - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: 'b', layers: { a: { @@ -300,7 +300,7 @@ describe('loader', () => { describe('changeIndexPattern', () => { it('sets the given indexpattern as current', () => { - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '2', layers: {}, }; @@ -324,7 +324,7 @@ describe('loader', () => { }); it('should update an empty layer on indexpattern change', () => { - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '2', layers: { layerId: { columnOrder: [], columns: {}, indexPatternId: '2' } }, }; @@ -345,7 +345,7 @@ describe('loader', () => { }); it('should keep layer indexpattern on change if not empty', () => { - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '2', layers: { layerId: { @@ -402,7 +402,7 @@ describe('loader', () => { describe('changeLayerIndexPattern', () => { it('loads the index pattern and then changes the specified layer', async () => { - const state: IndexPatternPrivateState = { + const state: FormBasedPrivateState = { currentIndexPatternId: '1', layers: { l0: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/loader.ts b/x-pack/plugins/lens/public/datasources/form_based/loader.ts similarity index 89% rename from x-pack/plugins/lens/public/indexpattern_datasource/loader.ts rename to x-pack/plugins/lens/public/datasources/form_based/loader.ts index e26231995578e..6aa021a6f363f 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/loader.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/loader.ts @@ -17,12 +17,12 @@ import { UiActionsStart, VisualizeFieldContext, } from '@kbn/ui-actions-plugin/public'; -import type { VisualizeEditorContext } from '../types'; -import { IndexPatternPersistedState, IndexPatternPrivateState, IndexPatternLayer } from './types'; +import type { VisualizeEditorContext } from '../../types'; +import { FormBasedPersistedState, FormBasedPrivateState, FormBasedLayer } from './types'; import { memoizedGetAvailableOperationsByMetadata, updateLayerIndexPattern } from './operations'; -import { readFromStorage, writeToStorage } from '../settings_storage'; -import type { IndexPattern, IndexPatternRef } from '../types'; +import { readFromStorage, writeToStorage } from '../../settings_storage'; +import type { IndexPattern, IndexPatternRef } from '../../types'; export function onRefreshIndexPattern() { if (memoizedGetAvailableOperationsByMetadata.cache.clear) { @@ -47,9 +47,9 @@ function getLayerReferenceName(layerId: string) { return `indexpattern-datasource-layer-${layerId}`; } -export function extractReferences({ layers }: IndexPatternPrivateState) { +export function extractReferences({ layers }: FormBasedPrivateState) { const savedObjectReferences: SavedObjectReference[] = []; - const persistableState: IndexPatternPersistedState = { + const persistableState: FormBasedPersistedState = { layers: {}, }; Object.entries(layers).forEach(([layerId, { indexPatternId, ...persistableLayer }]) => { @@ -64,10 +64,10 @@ export function extractReferences({ layers }: IndexPatternPrivateState) { } export function injectReferences( - state: IndexPatternPersistedState, + state: FormBasedPersistedState, references: SavedObjectReference[] ) { - const layers: Record = {}; + const layers: Record = {}; Object.entries(state.layers).forEach(([layerId, persistedLayer]) => { layers[layerId] = { ...persistedLayer, @@ -83,7 +83,7 @@ function createStateFromPersisted({ persistedState, references, }: { - persistedState?: IndexPatternPersistedState; + persistedState?: FormBasedPersistedState; references?: SavedObjectReference[]; }) { return persistedState && references ? injectReferences(persistedState, references) : undefined; @@ -97,7 +97,7 @@ function getUsedIndexPatterns({ defaultIndexPatternId, }: { state?: { - layers: Record; + layers: Record; }; defaultIndexPatternId?: string; storage: IStorageWrapper; @@ -139,14 +139,14 @@ export function loadInitialState({ indexPatternRefs = [], indexPatterns = {}, }: { - persistedState?: IndexPatternPersistedState; + persistedState?: FormBasedPersistedState; references?: SavedObjectReference[]; defaultIndexPatternId?: string; storage: IStorageWrapper; initialContext?: VisualizeFieldContext | VisualizeEditorContext; indexPatternRefs?: IndexPatternRef[]; indexPatterns?: Record; -}): IndexPatternPrivateState { +}): FormBasedPrivateState { const state = createStateFromPersisted({ persistedState, references }); const { usedPatterns, allIndexPatternIds: indexPatternIds } = getUsedIndexPatterns({ state, @@ -186,7 +186,7 @@ export function changeIndexPattern({ indexPatterns, }: { indexPatternId: string; - state: IndexPatternPrivateState; + state: FormBasedPrivateState; storage: IStorageWrapper; indexPatterns: Record; }) { @@ -209,7 +209,7 @@ export function renameIndexPattern({ }: { oldIndexPatternId: string; newIndexPatternId: string; - state: IndexPatternPrivateState; + state: FormBasedPrivateState; }) { return { ...state, @@ -231,7 +231,7 @@ export function triggerActionOnIndexPatternChange({ }: { indexPatternId: string; layerId: string; - state: IndexPatternPrivateState; + state: FormBasedPrivateState; uiActions: UiActionsStart; }) { const fromDataView = state.layers[layerId]?.indexPatternId; @@ -260,7 +260,7 @@ export function changeLayerIndexPattern({ }: { indexPatternId: string; layerId: string; - state: IndexPatternPrivateState; + state: FormBasedPrivateState; replaceIfPossible?: boolean; storage: IStorageWrapper; indexPatterns: Record; @@ -276,7 +276,7 @@ export function changeLayerIndexPattern({ }; } -function isSingleEmptyLayer(layerMap: IndexPatternPrivateState['layers']) { +function isSingleEmptyLayer(layerMap: FormBasedPrivateState['layers']) { const layers = Object.values(layerMap); return layers.length === 1 && layers[0].columnOrder.length === 0; } diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/mocks.ts b/x-pack/plugins/lens/public/datasources/form_based/mocks.ts similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/mocks.ts rename to x-pack/plugins/lens/public/datasources/form_based/mocks.ts index 7cd3639547e14..c2a85fbf0bac4 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/mocks.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/mocks.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { DragContextState } from '../drag_drop'; +import { DragContextState } from '../../drag_drop'; import { getFieldByNameFactory } from './pure_helpers'; -import type { IndexPattern, IndexPatternField } from '../types'; +import type { IndexPattern, IndexPatternField } from '../../types'; export const createMockedIndexPattern = (someProps?: Partial): IndexPattern => { const fields = [ diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/no_fields_callout.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/no_fields_callout.test.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/no_fields_callout.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/no_fields_callout.test.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/no_fields_callout.tsx b/x-pack/plugins/lens/public/datasources/form_based/no_fields_callout.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/no_fields_callout.tsx rename to x-pack/plugins/lens/public/datasources/form_based/no_fields_callout.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/__mocks__/index.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/__mocks__/index.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/__mocks__/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/__mocks__/index.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions.test.ts similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions.test.ts index c9b3ae608ec76..3dc58b7f1ef6c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions.test.ts @@ -18,8 +18,8 @@ import { } from './definitions'; import { getFieldByNameFactory } from '../pure_helpers'; import { documentField } from '../document_field'; -import { IndexPatternLayer } from '../types'; -import { IndexPattern, IndexPatternField } from '../../types'; +import { FormBasedLayer } from '../types'; +import { IndexPattern, IndexPatternField } from '../../../types'; import { GenericIndexPatternColumn } from '.'; import { DateHistogramIndexPatternColumn } from './definitions/date_histogram'; @@ -83,7 +83,7 @@ const indexPattern = { const baseColumnArgs: { previousColumn: GenericIndexPatternColumn; indexPattern: IndexPattern; - layer: IndexPatternLayer; + layer: FormBasedLayer; field: IndexPatternField; } = { previousColumn: { @@ -105,7 +105,7 @@ const baseColumnArgs: { field: indexPattern.fields[2], }; -const layer: IndexPatternLayer = { +const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['date', 'metric', 'ref'], columns: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/counter_rate.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/counter_rate.tsx index f2c421946bafb..3b89de8e94c51 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/counter_rate.tsx @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedIndexPatternColumn, ReferenceBasedIndexPatternColumn } from '../column_types'; -import { IndexPatternLayer } from '../../../types'; +import { FormBasedLayer } from '../../../types'; import { buildLabelFunction, getErrorsForDateReference, @@ -106,7 +106,7 @@ export const counterRateOperation: OperationDefinition< isTransferable: (column, newIndexPattern) => { return hasDateField(newIndexPattern); }, - getErrorMessage: (layer: IndexPatternLayer, columnId: string) => { + getErrorMessage: (layer: FormBasedLayer, columnId: string) => { return combineErrorMessages([ getErrorsForDateReference( layer, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/cumulative_sum.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/cumulative_sum.tsx similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/cumulative_sum.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/cumulative_sum.tsx index 67260672fa66d..339f5e4bc4003 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/cumulative_sum.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/cumulative_sum.tsx @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedIndexPatternColumn, ReferenceBasedIndexPatternColumn } from '../column_types'; -import { IndexPatternLayer } from '../../../types'; +import { FormBasedLayer } from '../../../types'; import { checkForDateHistogram, getErrorsForDateReference, @@ -19,7 +19,7 @@ import { import { OperationDefinition } from '..'; import { getFormatFromPreviousColumn, getFilter, combineErrorMessages } from '../helpers'; import { getDisallowedPreviousShiftMessage } from '../../../time_shift_utils'; -import { DOCUMENT_FIELD_NAME } from '../../../../../common'; +import { DOCUMENT_FIELD_NAME } from '../../../../../../common'; const ofName = buildLabelFunction((name?: string) => { return i18n.translate('xpack.lens.indexPattern.cumulativeSumOf', { @@ -106,7 +106,7 @@ export const cumulativeSumOperation: OperationDefinition< isTransferable: () => { return true; }, - getErrorMessage: (layer: IndexPatternLayer, columnId: string) => { + getErrorMessage: (layer: FormBasedLayer, columnId: string) => { return combineErrorMessages([ getErrorsForDateReference( layer, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/differences.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/differences.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/differences.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/differences.tsx index 1d76667654cb3..f2c379b5af5c1 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/differences.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/differences.tsx @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedIndexPatternColumn, ReferenceBasedIndexPatternColumn } from '../column_types'; -import { IndexPatternLayer } from '../../../types'; +import { FormBasedLayer } from '../../../types'; import { buildLabelFunction, checkForDateHistogram, @@ -92,7 +92,7 @@ export const derivativeOperation: OperationDefinition< isTransferable: (column, newIndexPattern) => { return hasDateField(newIndexPattern); }, - getErrorMessage: (layer: IndexPatternLayer, columnId: string) => { + getErrorMessage: (layer: FormBasedLayer, columnId: string) => { return combineErrorMessages([ getErrorsForDateReference( layer, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/index.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/index.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/index.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/moving_average.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/moving_average.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/moving_average.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/moving_average.tsx index 0fbdd96153a0f..d7b46d09c0f1e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/moving_average.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/moving_average.tsx @@ -9,9 +9,9 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import React, { useState } from 'react'; import { EuiFieldNumber, EuiFormRow } from '@elastic/eui'; -import { useDebounceWithOptions } from '../../../../shared_components'; +import { useDebounceWithOptions } from '../../../../../shared_components'; import { FormattedIndexPatternColumn, ReferenceBasedIndexPatternColumn } from '../column_types'; -import { IndexPatternLayer } from '../../../types'; +import { FormBasedLayer } from '../../../types'; import { buildLabelFunction, checkForDateHistogram, @@ -114,7 +114,7 @@ export const movingAverageOperation: OperationDefinition< isTransferable: (column, newIndexPattern) => { return hasDateField(newIndexPattern); }, - getErrorMessage: (layer: IndexPatternLayer, columnId: string) => { + getErrorMessage: (layer: FormBasedLayer, columnId: string) => { return combineErrorMessages([ getErrorsForDateReference( layer, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/overall_metric.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/overall_metric.test.ts similarity index 93% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/overall_metric.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/overall_metric.test.ts index 178a98074ad8a..901600e90f034 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/overall_metric.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/overall_metric.test.ts @@ -6,7 +6,7 @@ */ import { createMockedIndexPattern } from '../../../mocks'; -import type { IndexPatternLayer } from '../../../types'; +import type { FormBasedLayer } from '../../../types'; import { overallAverageOperation, overallMaxOperation, @@ -16,7 +16,7 @@ import { describe('overall_metric', () => { const indexPattern = createMockedIndexPattern(); - let layer: IndexPatternLayer; + let layer: FormBasedLayer; beforeEach(() => { layer = { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/overall_metric.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/overall_metric.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/overall_metric.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/overall_metric.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/time_scale.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/time_scale.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/time_scale.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/time_scale.tsx index 68df34650794d..59eb7fea46233 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/time_scale.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/time_scale.tsx @@ -13,7 +13,7 @@ import type { import { getErrorsForDateReference } from './utils'; import type { OperationDefinition } from '..'; import { combineErrorMessages, getFormatFromPreviousColumn } from '../helpers'; -import { IndexPatternLayer } from '../../../types'; +import { FormBasedLayer } from '../../../types'; import { getDisallowedPreviousShiftMessage } from '../../../time_shift_utils'; type OverallMetricIndexPatternColumn = FormattedIndexPatternColumn & @@ -101,7 +101,7 @@ export const timeScaleOperation: OperationDefinition { return true; }, - getErrorMessage: (layer: IndexPatternLayer, columnId: string) => { + getErrorMessage: (layer: FormBasedLayer, columnId: string) => { return combineErrorMessages([ getErrorsForDateReference( layer, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/utils.test.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/utils.test.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/utils.ts similarity index 90% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/utils.ts index 5b33fb0717539..bac4a8940c689 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/calculations/utils.ts @@ -9,10 +9,10 @@ import { i18n } from '@kbn/i18n'; import type { AstFunction } from '@kbn/interpreter'; import memoizeOne from 'memoize-one'; import { LayerTypes } from '@kbn/expression-xy-plugin/public'; -import type { IndexPattern } from '../../../../types'; -import type { LayerType } from '../../../../../common'; -import type { TimeScaleUnit } from '../../../../../common/expressions'; -import type { IndexPatternLayer } from '../../../types'; +import type { IndexPattern } from '../../../../../types'; +import { LayerType } from '../../../../../../common'; +import type { TimeScaleUnit } from '../../../../../../common/expressions'; +import type { FormBasedLayer } from '../../../types'; import { adjustTimeScaleLabelSuffix } from '../../time_scale_utils'; import type { ReferenceBasedIndexPatternColumn } from '../column_types'; import { getManagedColumnsFrom, isColumnValidAsReference } from '../../layer_helpers'; @@ -49,7 +49,7 @@ export function checkForDataLayerType(layerType: LayerType, name: string) { /** * Checks whether the current layer includes a date histogram and returns an error otherwise */ -export function checkForDateHistogram(layer: IndexPatternLayer, name: string) { +export function checkForDateHistogram(layer: FormBasedLayer, name: string) { const buckets = layer.columnOrder.filter((colId) => layer.columns[colId].isBucketed); const hasDateHistogram = buckets.some( (colId) => layer.columns[colId].operationType === 'date_histogram' @@ -68,7 +68,7 @@ export function checkForDateHistogram(layer: IndexPatternLayer, name: string) { ]; } -const getFullyManagedColumnIds = memoizeOne((layer: IndexPatternLayer) => { +const getFullyManagedColumnIds = memoizeOne((layer: FormBasedLayer) => { const managedColumnIds = new Set(); Object.entries(layer.columns).forEach(([id, column]) => { if ( @@ -85,7 +85,7 @@ const getFullyManagedColumnIds = memoizeOne((layer: IndexPatternLayer) => { return managedColumnIds; }); -export function checkReferences(layer: IndexPatternLayer, columnId: string) { +export function checkReferences(layer: FormBasedLayer, columnId: string) { const column = layer.columns[columnId] as ReferenceBasedIndexPatternColumn; const errors: string[] = []; @@ -128,11 +128,7 @@ export function checkReferences(layer: IndexPatternLayer, columnId: string) { return errors.length ? errors : undefined; } -export function getErrorsForDateReference( - layer: IndexPatternLayer, - columnId: string, - name: string -) { +export function getErrorsForDateReference(layer: FormBasedLayer, columnId: string, name: string) { const dateErrors = checkForDateHistogram(layer, name) ?? []; const referenceErrors = checkReferences(layer, columnId) ?? []; if (dateErrors.length || referenceErrors.length) { @@ -149,7 +145,7 @@ export function hasDateField(indexPattern: IndexPattern) { * Creates an expression ast for a date based operation (cumulative sum, derivative, moving average, counter rate) */ export function dateBasedOperationToExpression( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, functionName: string, additionalArgs: Record = {} @@ -180,7 +176,7 @@ export function dateBasedOperationToExpression( * Creates an expression ast for a date based operation (cumulative sum, derivative, moving average, counter rate) */ export function optionallHistogramBasedOperationToExpression( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, functionName: string, additionalArgs: Record = {} diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/cardinality.test.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/cardinality.test.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/cardinality.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/cardinality.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/column_types.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/column_types.ts similarity index 91% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/column_types.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/column_types.ts index 8af67468f0ac1..a0931a23f4e5a 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/column_types.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/column_types.ts @@ -6,8 +6,8 @@ */ import type { Query } from '@kbn/es-query'; -import type { Operation } from '../../../types'; -import type { TimeScaleUnit } from '../../../../common/expressions'; +import type { Operation } from '../../../../types'; +import type { TimeScaleUnit } from '../../../../../common/expressions'; import type { OperationType } from '.'; export interface BaseIndexPatternColumn extends Operation { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/count.test.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/count.test.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/count.tsx similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/count.tsx index 1f67eebf3541a..c05b8d415de7e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/count.tsx @@ -11,10 +11,10 @@ import { euiThemeVars } from '@kbn/ui-theme'; import { EuiSwitch, EuiText } from '@elastic/eui'; import { AggFunctionsMapping } from '@kbn/data-plugin/public'; import { buildExpressionFunction } from '@kbn/expressions-plugin/public'; -import type { TimeScaleUnit } from '../../../../common/expressions'; -import type { OperationDefinition, ParamEditorProps } from '.'; -import type { FieldBasedIndexPatternColumn, ValueFormatConfig } from './column_types'; -import type { IndexPatternField } from '../../../types'; +import { TimeScaleUnit } from '../../../../../common/expressions'; +import { OperationDefinition, ParamEditorProps } from '.'; +import { FieldBasedIndexPatternColumn, ValueFormatConfig } from './column_types'; +import type { IndexPatternField } from '../../../../types'; import { getInvalidFieldMessage, getFilter, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/date_histogram.test.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/date_histogram.test.tsx index a437cf63fd873..c08f8703c723f 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/date_histogram.test.tsx @@ -18,8 +18,8 @@ import type { IStorageWrapper } from '@kbn/kibana-utils-plugin/public'; import { UI_SETTINGS } from '@kbn/data-plugin/public'; import { dataPluginMock, getCalculateAutoTimeExpression } from '@kbn/data-plugin/public/mocks'; import { createMockedIndexPattern } from '../../mocks'; -import type { IndexPatternLayer } from '../../types'; -import type { IndexPattern } from '../../../types'; +import type { FormBasedLayer } from '../../types'; +import type { IndexPattern } from '../../../../types'; import { getFieldByNameFactory } from '../../pure_helpers'; import { act } from 'react-dom/test-utils'; @@ -124,7 +124,7 @@ const defaultOptions = { }; describe('date_histogram', () => { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; const InlineOptions = dateHistogramOperation.paramEditor!; beforeEach(() => { @@ -160,7 +160,7 @@ describe('date_histogram', () => { }, }, }, - } as unknown as IndexPatternLayer; + } as unknown as FormBasedLayer; } describe('buildColumn', () => { @@ -339,7 +339,7 @@ describe('date_histogram', () => { it('should render current value for other index pattern', () => { const updateLayerSpy = jest.fn(); - const secondLayer: IndexPatternLayer = { + const secondLayer: FormBasedLayer = { indexPatternId: '2', columnOrder: ['col2'], columns: { @@ -374,7 +374,7 @@ describe('date_histogram', () => { }); it('should render time interval control set to auto for auto interval', () => { - const thirdLayer: IndexPatternLayer = { + const thirdLayer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -409,7 +409,7 @@ describe('date_histogram', () => { }); it('should allow switching to manual interval', () => { - const thirdLayer: IndexPatternLayer = { + const thirdLayer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -451,7 +451,7 @@ describe('date_histogram', () => { }); it('should allow turning off time range sync', () => { - const thirdLayer: IndexPatternLayer = { + const thirdLayer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -493,7 +493,7 @@ describe('date_histogram', () => { }); it('turns off time range ignore on switching to auto interval', () => { - const thirdLayer: IndexPatternLayer = { + const thirdLayer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -535,7 +535,7 @@ describe('date_histogram', () => { }); it('turns off drop partial bucket on tuning off time range ignore', () => { - const thirdLayer: IndexPatternLayer = { + const thirdLayer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -735,7 +735,7 @@ describe('date_histogram', () => { }); it('should allow the drop of partial buckets', () => { - const thirdLayer: IndexPatternLayer = { + const thirdLayer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/date_histogram.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/date_histogram.tsx index 8d6b201b2cc19..87261f41338d0 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/date_histogram.tsx @@ -33,8 +33,8 @@ import { updateColumnParam } from '../layer_helpers'; import { OperationDefinition, ParamEditorProps } from '.'; import { FieldBasedIndexPatternColumn } from './column_types'; import { getInvalidFieldMessage, getSafeName } from './helpers'; -import { IndexPatternLayer } from '../../types'; -import { TooltipWrapper } from '../../../shared_components'; +import { FormBasedLayer } from '../../types'; +import { TooltipWrapper } from '../../../../shared_components'; const { isValidInterval } = search.aggs; const autoInterval = 'auto'; @@ -50,7 +50,7 @@ export interface DateHistogramIndexPatternColumn extends FieldBasedIndexPatternC }; } -function getMultipleDateHistogramsErrorMessage(layer: IndexPatternLayer, columnId: string) { +function getMultipleDateHistogramsErrorMessage(layer: FormBasedLayer, columnId: string) { const usesTimeShift = Object.values(layer.columns).some( (col) => col.timeShift && col.timeShift !== '' ); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.scss b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.scss rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.test.tsx index 475761c94ec54..9fbc38732806c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.test.tsx @@ -13,7 +13,7 @@ import { createMockedIndexPattern } from '../../../mocks'; import { FilterPopover } from './filter_popover'; import { LabelInput } from '../shared_components'; import { QueryStringInput } from '@kbn/unified-search-plugin/public'; -import { QueryInput } from '../../../../shared_components'; +import { QueryInput } from '../../../../../shared_components'; jest.mock('.', () => ({ isQueryValid: () => true, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx similarity index 94% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx index 17314bbc991c0..21a52f46e5c58 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx @@ -12,8 +12,8 @@ import { EuiPopover, EuiSpacer } from '@elastic/eui'; import type { Query } from '@kbn/es-query'; // Need to keep it separate to make it work Jest mocks in dimension_panel tests // import { QueryInput } from '../../../../shared_components/query_input'; -import { isQueryValid, QueryInput } from '../../../../shared_components'; -import { IndexPattern } from '../../../../types'; +import { isQueryValid, QueryInput } from '../../../../../shared_components'; +import { IndexPattern } from '../../../../../types'; import { FilterValue, defaultLabel } from '.'; import { LabelInput } from '../shared_components'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.scss b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filters.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.scss rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filters.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filters.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filters.test.tsx index 2b227674c26e9..2264fa8f185fb 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filters.test.tsx @@ -16,7 +16,7 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import type { FiltersIndexPatternColumn } from '.'; import { filtersOperation } from '..'; -import type { IndexPatternLayer } from '../../../types'; +import type { FormBasedLayer } from '../../../types'; import { createMockedIndexPattern } from '../../../mocks'; import { FilterPopover } from './filter_popover'; @@ -62,7 +62,7 @@ jest.mock('@elastic/eui', () => { }); describe('filters', () => { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; const InlineOptions = filtersOperation.paramEditor!; beforeEach(() => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx index 434dbb092bdb0..67f3af575f7db 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx @@ -19,8 +19,8 @@ import { DraggableBucketContainer, isQueryValid, NewBucketButton, -} from '../../../../shared_components'; -import { IndexPattern } from '../../../../types'; +} from '../../../../../shared_components'; +import { IndexPattern } from '../../../../../types'; import { updateColumnParam } from '../../layer_helpers'; import type { OperationDefinition } from '..'; import type { BaseIndexPatternColumn } from '../column_types'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/index.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/index.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/index.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/filters/index.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/formula.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/formula.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_editor.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index 1e9a304ffa8a2..b390dd156dc56 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -27,7 +27,7 @@ import { monaco } from '@kbn/monaco'; import classNames from 'classnames'; import { CodeEditor } from '@kbn/kibana-react-plugin/public'; import type { CodeEditorProps } from '@kbn/kibana-react-plugin/public'; -import { TooltipWrapper, useDebounceWithOptions } from '../../../../../shared_components'; +import { TooltipWrapper, useDebounceWithOptions } from '../../../../../../shared_components'; import { ParamEditorProps } from '../..'; import { getManagedColumnsFrom } from '../../../layer_helpers'; import { ErrorWrapper, runASTValidation, tryToParse } from '../validation'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_help.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_help.tsx index 0a1cf746c19f8..c2bb8fe940a2c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_help.tsx @@ -21,7 +21,7 @@ import { EuiSpacer, } from '@elastic/eui'; import { Markdown } from '@kbn/kibana-react-plugin/public'; -import type { IndexPattern } from '../../../../../types'; +import type { IndexPattern } from '../../../../../../types'; import { tinymathFunctions } from '../util'; import { getPossibleFunctions } from './math_completion'; import { hasFunctionFieldArgument } from '../validation'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/index.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/index.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/index.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/math_completion.test.ts similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/math_completion.test.ts index 79e77c3275ea8..76b70ba9a471c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/math_completion.test.ts @@ -11,7 +11,7 @@ import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { createMockedIndexPattern } from '../../../../mocks'; import { GenericOperationDefinition } from '../..'; -import type { IndexPatternField, OperationMetadata } from '../../../../../types'; +import type { OperationMetadata, IndexPatternField } from '../../../../../../types'; import { tinymathFunctions } from '../util'; import { getSignatureHelp, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/math_completion.ts similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/math_completion.ts index 94b8dcc2a9681..8626accc8066f 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/math_completion.ts @@ -22,7 +22,7 @@ import type { } from '@kbn/unified-search-plugin/public'; import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; import { parseTimeShift } from '@kbn/data-plugin/common'; -import type { IndexPattern } from '../../../../../types'; +import type { IndexPattern } from '../../../../../../types'; import { memoizedGetAvailableOperationsByMetadata } from '../../../operations'; import { tinymathFunctions, groupArgsByType, unquotedStringRegex } from '../util'; import type { GenericOperationDefinition } from '../..'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_tokenization.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/math_tokenization.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_tokenization.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/editor/math_tokenization.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula.test.tsx index 9c5cf27e60a88..54811e16e5930 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula.test.tsx @@ -13,8 +13,8 @@ import { } from '..'; import type { FormulaIndexPatternColumn } from './formula'; import { insertOrReplaceFormulaColumn } from './parse'; -import type { IndexPatternLayer } from '../../../types'; -import { IndexPattern } from '../../../../types'; +import type { FormBasedLayer } from '../../../types'; +import { IndexPattern } from '../../../../../types'; import { tinymathFunctions } from './util'; import { TermsIndexPatternColumn } from '../terms'; import { MovingAverageIndexPatternColumn } from '../calculations'; @@ -69,7 +69,7 @@ const operationDefinitionMap: Record = { }; describe('formula', () => { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; beforeEach(() => { layer = { @@ -894,7 +894,7 @@ describe('formula', () => { formula: string, isBroken = true, columnParams: Partial> = {} - ): IndexPatternLayer { + ): FormBasedLayer { return { columns: { col1: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula.tsx index 2715ab96cef0c..d7958e9f4575f 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula.tsx @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n'; import type { BaseIndexPatternColumn, OperationDefinition } from '..'; import type { ReferenceBasedIndexPatternColumn } from '../column_types'; -import type { IndexPattern } from '../../../../types'; +import type { IndexPattern } from '../../../../../types'; import { runASTValidation, tryToParse } from './validation'; import { WrappedFormulaEditor } from './editor'; import { insertOrReplaceFormulaColumn } from './parse'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula_public_api.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula_public_api.test.ts similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula_public_api.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula_public_api.test.ts index c854595757a0c..4c1ba662d1861 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula_public_api.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula_public_api.test.ts @@ -10,13 +10,13 @@ import { createFormulaPublicApi, FormulaPublicApi } from './formula_public_api'; import type { DataView } from '@kbn/data-views-plugin/public'; import type { DateHistogramIndexPatternColumn, PersistedIndexPatternLayer } from '../../../types'; -import { convertDataViewIntoLensIndexPattern } from '../../../../data_views_service/loader'; +import { convertDataViewIntoLensIndexPattern } from '../../../../../data_views_service/loader'; jest.mock('./parse', () => ({ insertOrReplaceFormulaColumn: jest.fn().mockReturnValue({}), })); -jest.mock('../../../../data_views_service/loader', () => ({ +jest.mock('../../../../../data_views_service/loader', () => ({ convertDataViewIntoLensIndexPattern: jest.fn((v) => v), })); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula_public_api.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula_public_api.ts similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula_public_api.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula_public_api.ts index 4085ec931d3a6..231cd82804c8f 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula_public_api.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/formula_public_api.ts @@ -6,8 +6,8 @@ */ import type { DataView } from '@kbn/data-views-plugin/public'; -import { convertDataViewIntoLensIndexPattern } from '../../../../data_views_service/loader'; -import type { IndexPattern } from '../../../../types'; +import { convertDataViewIntoLensIndexPattern } from '../../../../../data_views_service/loader'; +import type { IndexPattern } from '../../../../../types'; import type { PersistedIndexPatternLayer } from '../../../types'; import { insertOrReplaceFormulaColumn } from './parse'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/generate.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/generate.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts index 189a8d342b903..2315d6d164fc8 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/generate.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts @@ -6,14 +6,14 @@ */ import { isObject } from 'lodash'; -import { DOCUMENT_FIELD_NAME } from '../../../../../common'; +import { DOCUMENT_FIELD_NAME } from '../../../../../../common'; import { FieldBasedIndexPatternColumn, GenericOperationDefinition, GenericIndexPatternColumn, } from '..'; import { BaseIndexPatternColumn, ReferenceBasedIndexPatternColumn } from '../column_types'; -import { IndexPatternLayer } from '../../../types'; +import { FormBasedLayer } from '../../../types'; import { unquotedStringRegex } from './util'; import { isColumnOfType } from '../helpers'; import { StaticValueIndexPatternColumn } from '../static_value'; @@ -37,7 +37,7 @@ export function getSafeFieldName({ export function generateFormula( previousColumn: ReferenceBasedIndexPatternColumn | GenericIndexPatternColumn, - layer: IndexPatternLayer, + layer: FormBasedLayer, previousFormula: string, operationDefinitionMap: Record | undefined ) { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/index.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/index.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/index.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/math.test.ts similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/math.test.ts index fdf4cc98c59d7..60fc7d5b72632 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/math.test.ts @@ -6,11 +6,11 @@ */ import { TinymathAST } from '@kbn/tinymath'; -import { IndexPattern } from '../../../../types'; -import { IndexPatternLayer } from '../../../types'; +import { IndexPattern } from '../../../../../types'; +import { FormBasedLayer } from '../../../types'; import { MathIndexPatternColumn, mathOperation } from './math'; -function createLayerWithMathColumn(tinymathAst: string | TinymathAST): IndexPatternLayer { +function createLayerWithMathColumn(tinymathAst: string | TinymathAST): FormBasedLayer { return { columnOrder: ['myColumnId'], columns: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/math.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/math.tsx index c4e0cbed627f2..de197c2de8189 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/math.tsx @@ -8,7 +8,7 @@ import type { TinymathAST } from '@kbn/tinymath'; import { OperationDefinition } from '..'; import { ValueFormatConfig, ReferenceBasedIndexPatternColumn } from '../column_types'; -import { IndexPattern } from '../../../../types'; +import { IndexPattern } from '../../../../../types'; export interface MathIndexPatternColumn extends ReferenceBasedIndexPatternColumn { operationType: 'math'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/math_examples.md similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/math_examples.md diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/mocks/operation_mocks.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/mocks/operation_mocks.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/mocks/operation_mocks.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/mocks/operation_mocks.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/parse.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/parse.ts similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/parse.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/parse.ts index 10789e181dcb9..a195cf98f77b2 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/parse.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/parse.ts @@ -8,14 +8,14 @@ import { i18n } from '@kbn/i18n'; import { isObject } from 'lodash'; import type { TinymathAST, TinymathVariable, TinymathLocation } from '@kbn/tinymath'; -import type { IndexPattern } from '../../../../types'; +import type { IndexPattern } from '../../../../../types'; import { OperationDefinition, GenericOperationDefinition, GenericIndexPatternColumn, operationDefinitionMap, } from '..'; -import type { IndexPatternLayer } from '../../../types'; +import type { FormBasedLayer } from '../../../types'; import { mathOperation } from './math'; import { documentField } from '../../../document_field'; import { runASTValidation, shouldHaveFieldArgument, tryToParse } from './validation'; @@ -36,7 +36,7 @@ export function getManagedId(mainId: string, index: number) { function parseAndExtract( text: string, - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, indexPattern: IndexPattern, operations: Record, @@ -72,7 +72,7 @@ function extractColumns( idPrefix: string, operations: Record, ast: TinymathAST, - layer: IndexPatternLayer, + layer: FormBasedLayer, indexPattern: IndexPattern, label: string ): Array<{ column: GenericIndexPatternColumn; location?: TinymathLocation }> { @@ -226,7 +226,7 @@ const getEmptyColumnsWithFormulaMeta = (): { function generateFormulaColumns( id: string, column: FormulaIndexPatternColumn, - layer: IndexPatternLayer, + layer: FormBasedLayer, { indexPattern, operations = operationDefinitionMap }: ExpandColumnProperties ) { const { columns, meta } = getEmptyColumnsWithFormulaMeta(); @@ -273,7 +273,7 @@ function generateFormulaColumns( export function insertOrReplaceFormulaColumn( id: string, column: FormulaIndexPatternColumn, - baseLayer: IndexPatternLayer, + baseLayer: FormBasedLayer, params: ExpandColumnProperties ) { const layer = { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/types.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/types.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/types.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/types.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/util.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/util.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/util.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/util.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/validation.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/validation.ts similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/validation.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/validation.ts index a7ffc57a2361e..6189166de43f8 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/validation.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/validation.ts @@ -27,8 +27,8 @@ import type { GenericIndexPatternColumn, GenericOperationDefinition, } from '..'; -import type { IndexPatternLayer } from '../../../types'; -import type { IndexPattern } from '../../../../types'; +import type { FormBasedLayer } from '../../../types'; +import type { IndexPattern } from '../../../../../types'; import type { TinymathNodeTypes } from './types'; interface ValidationErrors { @@ -397,7 +397,7 @@ export function tryToParse( export function runASTValidation( ast: TinymathAST, - layer: IndexPatternLayer, + layer: FormBasedLayer, indexPattern: IndexPattern, operations: Record, currentColumn: GenericIndexPatternColumn @@ -426,7 +426,7 @@ function checkVariableEdgeCases(ast: TinymathAST, missingVariables: Set) function checkMissingVariableOrFunctions( ast: TinymathAST, - layer: IndexPatternLayer, + layer: FormBasedLayer, indexPattern: IndexPattern, operations: Record ): ErrorWrapper[] { @@ -623,7 +623,7 @@ function validateNameArguments( function runFullASTValidation( ast: TinymathAST, - layer: IndexPatternLayer, + layer: FormBasedLayer, indexPattern: IndexPattern, operations: Record, currentColumn?: GenericIndexPatternColumn diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/get_group_by_key.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/get_group_by_key.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/get_group_by_key.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/get_group_by_key.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/helpers.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/helpers.test.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/helpers.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/helpers.test.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/helpers.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/helpers.tsx similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/helpers.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/helpers.tsx index 868d5e2557e49..32d39f9527ef4 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/helpers.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/helpers.tsx @@ -6,14 +6,14 @@ */ import { i18n } from '@kbn/i18n'; -import type { IndexPattern, IndexPatternField } from '../../../types'; +import type { IndexPattern, IndexPatternField } from '../../../../types'; import { GenericIndexPatternColumn, operationDefinitionMap } from '.'; import { FieldBasedIndexPatternColumn, FormattedIndexPatternColumn, ReferenceBasedIndexPatternColumn, } from './column_types'; -import type { IndexPatternLayer } from '../../types'; +import type { FormBasedLayer } from '../../types'; import { hasField } from '../../pure_utils'; export function getInvalidFieldMessage( @@ -132,8 +132,8 @@ export function isColumnOfType( export const isColumn = ( setter: | GenericIndexPatternColumn - | IndexPatternLayer - | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) + | FormBasedLayer + | ((prevLayer: FormBasedLayer) => FormBasedLayer) ): setter is GenericIndexPatternColumn => { return 'operationType' in setter; }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/index.ts similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/index.ts index bde67ea14a488..5253267b286cd 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/index.ts @@ -55,17 +55,17 @@ import { IndexPatternField, OperationMetadata, ParamEditorCustomProps, -} from '../../../types'; +} from '../../../../types'; import type { BaseIndexPatternColumn, IncompleteColumn, GenericIndexPatternColumn, ReferenceBasedIndexPatternColumn, } from './column_types'; -import { DataViewDragDropOperation, IndexPatternLayer } from '../../types'; -import { DateRange, LayerType } from '../../../../common'; +import { DataViewDragDropOperation, FormBasedLayer } from '../../types'; +import { DateRange, LayerType } from '../../../../../common'; import { rangeOperation } from './ranges'; -import { IndexPatternDimensionEditorProps, OperationSupportMatrix } from '../../dimension_panel'; +import { FormBasedDimensionEditorProps, OperationSupportMatrix } from '../../dimension_panel'; import type { OriginalColumn } from '../../to_expression'; import { ReferenceEditorProps } from '../../dimension_panel/reference_editor'; @@ -174,10 +174,10 @@ export { staticValueOperation } from './static_value'; */ export interface ParamEditorProps< C, - U = IndexPatternLayer | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) + U = FormBasedLayer | ((prevLayer: FormBasedLayer) => FormBasedLayer) > { currentColumn: C; - layer: IndexPatternLayer; + layer: FormBasedLayer; paramEditorUpdater: (setter: U) => void; ReferenceEditor?: (props: ReferenceEditorProps) => JSX.Element | null; toggleFullscreen: () => void; @@ -195,7 +195,7 @@ export interface ParamEditorProps< fieldFormats: FieldFormatsStart; unifiedSearch: UnifiedSearchPublicPluginStart; dataViews: DataViewsPublicPluginStart; - activeData?: IndexPatternDimensionEditorProps['activeData']; + activeData?: FormBasedDimensionEditorProps['activeData']; operationDefinitionMap: Record; paramEditorCustomProps?: ParamEditorCustomProps; existingFields: Record>; @@ -203,20 +203,18 @@ export interface ParamEditorProps< } export interface FieldInputProps { - layer: IndexPatternLayer; + layer: FormBasedLayer; selectedColumn?: C; columnId: string; indexPattern: IndexPattern; - updateLayer: ( - setter: IndexPatternLayer | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) - ) => void; + updateLayer: (setter: FormBasedLayer | ((prevLayer: FormBasedLayer) => FormBasedLayer)) => void; onDeleteColumn?: () => void; currentFieldIsInvalid: boolean; incompleteField: IncompleteColumn['sourceField'] | null; incompleteOperation: IncompleteColumn['operationType']; incompleteParams: Omit; - dimensionGroups: IndexPatternDimensionEditorProps['dimensionGroups']; - groupId: IndexPatternDimensionEditorProps['groupId']; + dimensionGroups: FormBasedDimensionEditorProps['dimensionGroups']; + groupId: FormBasedDimensionEditorProps['groupId']; /** * indexPatternId -> fieldName -> boolean */ @@ -271,7 +269,7 @@ interface BaseOperationDefinitionProps< * Based on the current column and the other updated columns, this function has to * return an updated column. If not implemented, the `id` function is used instead. */ - onOtherColumnChanged?: (layer: IndexPatternLayer, thisColumnId: string) => C; + onOtherColumnChanged?: (layer: FormBasedLayer, thisColumnId: string) => C; /** * React component for operation specific settings shown in the flyout editor */ @@ -303,7 +301,7 @@ interface BaseOperationDefinitionProps< */ getDisabledStatus?: ( indexPattern: IndexPattern, - layer: IndexPatternLayer, + layer: FormBasedLayer, layerType?: LayerType ) => string | undefined; /** @@ -313,7 +311,7 @@ interface BaseOperationDefinitionProps< * - Missing references */ getErrorMessage?: ( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, indexPattern: IndexPattern, operationDefinitionMap?: Record @@ -329,7 +327,7 @@ interface BaseOperationDefinitionProps< core: CoreStart, frame: FrameDatasourceAPI, layerId: string - ) => Promise; + ) => Promise; }; } > @@ -453,7 +451,7 @@ interface BaseOperationDefinitionProps< } interface BaseBuildColumnArgs { - layer: IndexPatternLayer; + layer: FormBasedLayer; indexPattern: IndexPattern; } @@ -499,7 +497,7 @@ interface FieldlessOperationDefinition column: C, columnId: string, indexPattern: IndexPattern, - layer: IndexPatternLayer, + layer: FormBasedLayer, uiSettings: IUiSettingsClient ) => ExpressionAstFunction; } @@ -556,7 +554,7 @@ interface FieldBasedOperationDefinition @@ -568,7 +566,7 @@ interface FieldBasedOperationDefinition @@ -584,7 +582,7 @@ interface FieldBasedOperationDefinition Promise; + ) => Promise; }; } > @@ -652,7 +650,7 @@ interface FullReferenceOperationDefinition { * A chain of expression functions which will transform the table */ toExpression: ( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, indexPattern: IndexPattern ) => ExpressionAstFunction[]; @@ -680,7 +678,7 @@ interface ManagedReferenceOperationDefinition * A chain of expression functions which will transform the table */ toExpression: ( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, indexPattern: IndexPattern ) => ExpressionAstFunction[]; @@ -689,11 +687,11 @@ interface ManagedReferenceOperationDefinition * root level */ createCopy: ( - layers: Record, + layers: Record, source: DataViewDragDropOperation, target: DataViewDragDropOperation, operationDefinitionMap: Record - ) => Record; + ) => Record; } interface OperationDefinitionMap { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/last_value.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/last_value.test.tsx index 05386492544f4..16c6f2727ea50 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/last_value.test.tsx @@ -17,8 +17,8 @@ import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { createMockedIndexPattern } from '../../mocks'; import { LastValueIndexPatternColumn } from './last_value'; import { lastValueOperation } from '.'; -import type { IndexPatternLayer } from '../../types'; -import type { IndexPattern } from '../../../types'; +import type { FormBasedLayer } from '../../types'; +import type { IndexPattern } from '../../../../types'; import { TermsIndexPatternColumn } from './terms'; import { EuiSwitch, EuiSwitchEvent } from '@elastic/eui'; import { buildExpression, parseExpression } from '@kbn/expressions-plugin/common'; @@ -55,7 +55,7 @@ const defaultProps = { }; describe('last_value', () => { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; const InlineOptions = lastValueOperation.paramEditor!; beforeEach(() => { @@ -506,7 +506,7 @@ describe('last_value', () => { }, columnOrder: [], indexPatternId: '', - } as IndexPatternLayer; + } as FormBasedLayer; expect( lastValueOperation.buildColumn({ @@ -829,7 +829,7 @@ describe('last_value', () => { describe('getErrorMessage', () => { let indexPattern: IndexPattern; - let errorLayer: IndexPatternLayer; + let errorLayer: FormBasedLayer; beforeEach(() => { indexPattern = createMockedIndexPattern(); errorLayer = { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/last_value.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/last_value.tsx index 4206cd8109760..59b77cd73fc9d 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/last_value.tsx @@ -20,8 +20,8 @@ import { AggFunctionsMapping } from '@kbn/data-plugin/public'; import { buildExpressionFunction } from '@kbn/expressions-plugin/public'; import { OperationDefinition } from '.'; import { FieldBasedIndexPatternColumn, ValueFormatConfig } from './column_types'; -import type { IndexPatternField, IndexPattern } from '../../../types'; -import { DataType } from '../../../types'; +import type { IndexPatternField, IndexPattern } from '../../../../types'; +import { DataType } from '../../../../types'; import { getFormatFromPreviousColumn, getInvalidFieldMessage, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/metrics.test.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/metrics.test.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/metrics.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/metrics.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.test.tsx index 77434d7ecc7ad..e78ac9e9360da 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.test.tsx @@ -18,7 +18,7 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { createMockedIndexPattern } from '../../mocks'; import { percentileOperation } from '.'; -import { IndexPatternLayer } from '../../types'; +import { FormBasedLayer } from '../../types'; import { PercentileIndexPatternColumn } from './percentile'; import { TermsIndexPatternColumn } from './terms'; import { @@ -27,7 +27,7 @@ import { ExpressionAstExpressionBuilder, } from '@kbn/expressions-plugin/public'; import type { OriginalColumn } from '../../to_expression'; -import { IndexPattern } from '../../../types'; +import { IndexPattern } from '../../../../types'; import faker from 'faker'; jest.mock('lodash', () => { @@ -71,7 +71,7 @@ const defaultProps = { }; describe('percentile', () => { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; const InlineOptions = percentileOperation.paramEditor!; beforeEach(() => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.tsx index ec4a3d569e7da..f391e3a6f9a2f 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile.tsx @@ -28,7 +28,7 @@ import { } from './helpers'; import { FieldBasedIndexPatternColumn } from './column_types'; import { adjustTimeScaleLabelSuffix } from '../time_scale_utils'; -import { useDebouncedValue } from '../../../shared_components'; +import { useDebouncedValue } from '../../../../shared_components'; import { getDisallowedPreviousShiftMessage } from '../../time_shift_utils'; import { FormRow } from './shared_components'; import { getColumnReducedTimeRangeError } from '../../reduced_time_range_utils'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.test.tsx index a0c69a7354849..adb0d8e491fd7 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.test.tsx @@ -18,10 +18,10 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { createMockedIndexPattern } from '../../mocks'; import { percentileRanksOperation } from '.'; -import { IndexPatternLayer } from '../../types'; +import { FormBasedLayer } from '../../types'; import type { PercentileRanksIndexPatternColumn } from './percentile_ranks'; import { TermsIndexPatternColumn } from './terms'; -import { IndexPattern } from '../../../types'; +import { IndexPattern } from '../../../../types'; jest.mock('lodash', () => { const original = jest.requireActual('lodash'); @@ -64,7 +64,7 @@ const defaultProps = { }; describe('percentile ranks', () => { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; const InlineOptions = percentileRanksOperation.paramEditor!; beforeEach(() => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.tsx index 45bd05f37372f..3d7b12802858c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/percentile_ranks.tsx @@ -22,7 +22,7 @@ import { } from './helpers'; import { FieldBasedIndexPatternColumn } from './column_types'; import { adjustTimeScaleLabelSuffix } from '../time_scale_utils'; -import { useDebouncedValue } from '../../../shared_components'; +import { useDebouncedValue } from '../../../../shared_components'; import { getDisallowedPreviousShiftMessage } from '../../time_shift_utils'; import { FormRow } from './shared_components'; import { getColumnReducedTimeRangeError } from '../../reduced_time_range_utils'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.scss b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.scss rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx index d3f5000646bc9..c3212642e0064 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx @@ -28,7 +28,7 @@ import { DraggableBucketContainer, NewBucketButton, useDebounceWithOptions, -} from '../../../../shared_components'; +} from '../../../../../shared_components'; import { RangeTypeLens, isValidRange } from './ranges'; import { FROM_PLACEHOLDER, TO_PLACEHOLDER, TYPING_DEBOUNCE_TIME } from './constants'; import { LabelInput } from '../shared_components'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/constants.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/constants.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/constants.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/constants.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/index.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/index.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/index.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/range_editor.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/range_editor.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/range_editor.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/range_editor.tsx index 92f0196b9cbb5..1f7565c9d31d6 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/range_editor.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/range_editor.tsx @@ -26,7 +26,7 @@ import { UI_SETTINGS } from '@kbn/data-plugin/public'; import { RangeColumnParams, UpdateParamsFnType, MODES_TYPES } from './ranges'; import { AdvancedRangeEditor } from './advanced_editor'; import { TYPING_DEBOUNCE_TIME, MODES, MIN_HISTOGRAM_BARS } from './constants'; -import { useDebounceWithOptions } from '../../../../shared_components'; +import { useDebounceWithOptions } from '../../../../../shared_components'; import { HelpPopover, HelpPopoverButton } from '../../../help_popover'; const GranularityHelpPopover = () => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/ranges.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/ranges.test.tsx index 874559ae66c19..d0dd9f6458612 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/ranges.test.tsx @@ -15,7 +15,7 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks'; -import type { IndexPatternLayer } from '../../../types'; +import type { FormBasedLayer } from '../../../types'; import { rangeOperation } from '..'; import { RangeIndexPatternColumn } from './ranges'; import { @@ -26,9 +26,9 @@ import { SLICES, } from './constants'; import { RangePopover } from './advanced_editor'; -import { DragDropBuckets } from '../../../../shared_components'; +import { DragDropBuckets } from '../../../../../shared_components'; import { getFieldByNameFactory } from '../../../pure_helpers'; -import { IndexPattern } from '../../../../types'; +import { IndexPattern } from '../../../../../types'; // mocking random id generator function jest.mock('@elastic/eui', () => { @@ -136,7 +136,7 @@ const defaultOptions = { }; describe('ranges', () => { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; const InlineOptions = rangeOperation.paramEditor!; const MAX_HISTOGRAM_VALUE = 100; const GRANULARITY_DEFAULT_VALUE = (MAX_HISTOGRAM_VALUE - MIN_HISTOGRAM_BARS) / 2; @@ -156,7 +156,7 @@ describe('ranges', () => { column.params.type = MODES.Range; } - function getDefaultLayer(): IndexPatternLayer { + function getDefaultLayer(): FormBasedLayer { return { indexPatternId: '1', columnOrder: ['col1', 'col2'], diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/ranges.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/ranges.tsx index 52c9471aefe0e..2dab571dcfc39 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/ranges/ranges.tsx @@ -15,9 +15,9 @@ import { RangeEditor } from './range_editor'; import { OperationDefinition } from '..'; import { FieldBasedIndexPatternColumn } from '../column_types'; import { updateColumnParam } from '../../layer_helpers'; -import { supportedFormats } from '../../../../../common/expressions/format_column/supported_formats'; +import { supportedFormats } from '../../../../../../common/expressions/format_column/supported_formats'; import { MODES, AUTO_BARS, DEFAULT_INTERVAL, MIN_HISTOGRAM_BARS, SLICES } from './constants'; -import { IndexPattern, IndexPatternField } from '../../../../types'; +import { IndexPattern, IndexPatternField } from '../../../../../types'; import { getInvalidFieldMessage, isValidNumber } from '../helpers'; type RangeType = Omit; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/form_row.scss b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.scss similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/form_row.scss rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.scss diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/form_row.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/form_row.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/index.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/index.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/index.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/index.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/label_input.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/label_input.tsx similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/label_input.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/label_input.tsx index 4bc461aaa319b..9d8730d38216a 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/shared_components/label_input.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/shared_components/label_input.tsx @@ -8,7 +8,7 @@ import React, { useRef } from 'react'; import { EuiFieldText, keys } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { useDebouncedValue } from '../../../../shared_components'; +import { useDebouncedValue } from '../../../../../shared_components'; export const LabelInput = ({ value, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/static_value.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/static_value.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/static_value.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/static_value.test.tsx index a93b1ece5e13f..0ed6a60677f73 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/static_value.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/static_value.test.tsx @@ -17,8 +17,8 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { createMockedIndexPattern } from '../../mocks'; import { staticValueOperation } from '.'; -import { IndexPatternLayer } from '../../types'; -import { IndexPattern } from '../../../types'; +import { FormBasedLayer } from '../../types'; +import { IndexPattern } from '../../../../types'; import { StaticValueIndexPatternColumn } from './static_value'; import { TermsIndexPatternColumn } from './terms'; @@ -63,7 +63,7 @@ const defaultProps = { }; describe('static_value', () => { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; beforeEach(() => { layer = { @@ -97,7 +97,7 @@ describe('static_value', () => { }; }); - function getLayerWithStaticValue(newValue: string | null | undefined): IndexPatternLayer { + function getLayerWithStaticValue(newValue: string | null | undefined): FormBasedLayer { return { ...layer, columns: { @@ -377,7 +377,7 @@ describe('static_value', () => { }, } as StaticValueIndexPatternColumn, }, - } as IndexPatternLayer; + } as FormBasedLayer; const instance = shallow( { - let layer: IndexPatternLayer; + let layer: FormBasedLayer; const InlineOptions = termsOperation.paramEditor!; const InlineFieldInput = termsOperation.renderFieldInput!; @@ -1187,7 +1187,7 @@ describe('terms', () => { return getOperationSupportMatrix({ state: { layers: { layer1: layer }, - } as unknown as IndexPatternPrivateState, + } as unknown as FormBasedPrivateState, layerId: 'layer1', filterOperations: () => true, columnId, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/types.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/types.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/types.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/types.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/values_input.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/values_input.test.tsx similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/values_input.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/values_input.test.tsx diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/values_input.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/values_input.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/values_input.tsx rename to x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/values_input.tsx index 9e86ea8525adc..33dd5b7206008 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/values_input.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/values_input.tsx @@ -8,7 +8,7 @@ import React, { useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFieldNumber, EuiFormRow } from '@elastic/eui'; -import { useDebounceWithOptions } from '../../../../shared_components'; +import { useDebounceWithOptions } from '../../../../../shared_components'; export const ValuesInput = ({ value, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/index.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/index.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/index.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/index.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/layer_helpers.test.ts similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/layer_helpers.test.ts index 1a77cd253424f..65b11c2605cc3 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/layer_helpers.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { OperationMetadata } from '../../types'; +import type { OperationMetadata } from '../../../types'; import { copyColumn, insertNewColumn, @@ -23,10 +23,10 @@ import { operationDefinitionMap, OperationType } from '.'; import { TermsIndexPatternColumn } from './definitions/terms'; import { DateHistogramIndexPatternColumn } from './definitions/date_histogram'; import { AvgIndexPatternColumn } from './definitions/metrics'; -import type { IndexPatternLayer, IndexPatternPrivateState } from '../types'; +import type { FormBasedLayer, FormBasedPrivateState } from '../types'; import { documentField } from '../document_field'; import { getFieldByNameFactory } from '../pure_helpers'; -import { generateId } from '../../id_generator'; +import { generateId } from '../../../id_generator'; import { createMockedFullReference, createMockedManagedReference } from './mocks'; import { FiltersIndexPatternColumn, @@ -38,13 +38,13 @@ import { } from './definitions'; import { TinymathAST } from '@kbn/tinymath'; import { CoreStart } from '@kbn/core/public'; -import { IndexPattern } from '../../types'; +import { IndexPattern } from '../../../types'; import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; const dataMock = dataPluginMock.createStartContract(); jest.mock('.'); -jest.mock('../../id_generator'); +jest.mock('../../../id_generator'); jest.mock('../dimension_panel/reference_editor', () => ({ ReferenceEditor: () => null, })); @@ -257,7 +257,7 @@ describe('state_helpers', () => { }); it('should update order on inserting a bucketed fieldless operation', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -284,7 +284,7 @@ describe('state_helpers', () => { }); it('should update order on inserting a bucketed field-based operation', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -312,7 +312,7 @@ describe('state_helpers', () => { }); it('should insert a metric after buckets', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -343,7 +343,7 @@ describe('state_helpers', () => { }); it('should insert a metric after references', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -382,7 +382,7 @@ describe('state_helpers', () => { }); it('should insert new buckets at the end of previous buckets', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col3'], columns: { @@ -421,7 +421,7 @@ describe('state_helpers', () => { }); it('should not change order of metrics and references on inserting new buckets', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col2'], columns: { @@ -665,7 +665,7 @@ describe('state_helpers', () => { specificOperations: [], }, ]; - const layer: IndexPatternLayer = { indexPatternId: '1', columnOrder: [], columns: {} }; + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: [], columns: {} }; expect(() => { insertNewColumn({ layer, @@ -678,7 +678,7 @@ describe('state_helpers', () => { }); it('should leave the references empty if too ambiguous', () => { - const layer: IndexPatternLayer = { indexPatternId: '1', columnOrder: [], columns: {} }; + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: [], columns: {} }; const result = insertNewColumn({ layer, indexPattern, @@ -710,7 +710,7 @@ describe('state_helpers', () => { validateMetadata: () => true, }, ]; - const layer: IndexPatternLayer = { indexPatternId: '1', columnOrder: [], columns: {} }; + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: [], columns: {} }; const result = insertNewColumn({ layer, indexPattern, @@ -728,7 +728,7 @@ describe('state_helpers', () => { }); it('should create a referenced column if the ID is being used as a reference', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -825,7 +825,7 @@ describe('state_helpers', () => { }); it('should update order on changing the column', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col2'], columns: { @@ -1498,7 +1498,7 @@ describe('state_helpers', () => { operationType: 'count' as const, }; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { col1: expectedColumn }, @@ -1526,7 +1526,7 @@ describe('state_helpers', () => { }); it('should not wrap around the previous operation as a reference if excluded by validateMetadata (case new1)', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -1573,7 +1573,7 @@ describe('state_helpers', () => { const testFilter = { language: 'kuery', query: '' }; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { col1: { ...expectedColumn, filter: testFilter } }, @@ -1612,7 +1612,7 @@ describe('state_helpers', () => { validateMetadata: () => true, }, ]; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -1653,7 +1653,7 @@ describe('state_helpers', () => { specificOperations: ['unique_count', 'sum', 'average'], // this order is ignored }, ]; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -1694,7 +1694,7 @@ describe('state_helpers', () => { specificOperations: ['unique_count'], }, ]; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -1734,7 +1734,7 @@ describe('state_helpers', () => { specificOperations: [], }, ]; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1'], columns: { @@ -1804,7 +1804,7 @@ describe('state_helpers', () => { }); it('should use existing references, delete invalid, when switching from one reference to another (case ref1)', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['ref1', 'invalid', 'output'], columns: { @@ -1856,7 +1856,7 @@ describe('state_helpers', () => { }); it('should modify a copied object, not the original layer', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['ref1', 'invalid', 'output'], columns: { @@ -1907,7 +1907,7 @@ describe('state_helpers', () => { label: 'math', operationType: 'math' as const, }; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '', columnOrder: [], columns: { @@ -1977,7 +1977,7 @@ describe('state_helpers', () => { }); it('should transition by using the field from the previous reference if nothing else works (case new5)', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['fieldReused', 'output'], columns: { @@ -2045,7 +2045,7 @@ describe('state_helpers', () => { ], }, }; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col2'], columns: { @@ -2089,7 +2089,7 @@ describe('state_helpers', () => { filter: { language: 'kuery', query: 'bytes > 4000' }, timeShift: '3h', }; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col2'], columns: { @@ -2135,7 +2135,7 @@ describe('state_helpers', () => { timeShift: '3h', }; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['metric', 'ref'], columns: { @@ -2168,7 +2168,7 @@ describe('state_helpers', () => { }); it('should keep state and set incomplete column on incompatible switch', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['metric', 'ref'], columns: { @@ -2272,7 +2272,7 @@ describe('state_helpers', () => { }, ]; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col2'], columns: { @@ -2439,7 +2439,7 @@ describe('state_helpers', () => { }); it('should delete the column and all of its references', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col2'], columns: { @@ -2467,7 +2467,7 @@ describe('state_helpers', () => { }); it('should update the labels when deleting columns', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col2'], columns: { @@ -2512,7 +2512,7 @@ describe('state_helpers', () => { }); it('should recursively delete references', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: ['col1', 'col2', 'col3'], columns: { @@ -2837,7 +2837,7 @@ describe('state_helpers', () => { }); it('should remove operations referencing unavailable fields', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1', 'col2'], columns: { col1: { @@ -2870,7 +2870,7 @@ describe('state_helpers', () => { }); it('should remove operations indirectly referencing unavailable fields', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1', 'col2'], columns: { col1: { @@ -2902,7 +2902,7 @@ describe('state_helpers', () => { }); it('should remove operations referencing fields with insufficient capabilities', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1', 'col2'], columns: { col1: { @@ -2941,7 +2941,7 @@ describe('state_helpers', () => { interval: 'w', }, })) as OperationDefinition['transfer']; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1', 'col2'], columns: { col1: { @@ -2971,7 +2971,7 @@ describe('state_helpers', () => { }); it('should remove operations referencing fields with wrong field types', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1', 'col2'], columns: { col1: { @@ -3004,7 +3004,7 @@ describe('state_helpers', () => { }); it('should remove operations referencing fields with incompatible restrictions', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1', 'col2'], columns: { col1: { @@ -3078,7 +3078,7 @@ describe('state_helpers', () => { }, }, indexPattern, - {} as IndexPatternPrivateState, + {} as FormBasedPrivateState, '1', {} as CoreStart, dataMock @@ -3114,7 +3114,7 @@ describe('state_helpers', () => { }, }, indexPattern, - {} as IndexPatternPrivateState, + {} as FormBasedPrivateState, '1', {} as CoreStart, dataMock @@ -3151,7 +3151,7 @@ describe('state_helpers', () => { }, }, indexPattern, - {} as IndexPatternPrivateState, + {} as FormBasedPrivateState, '1', {} as CoreStart, dataMock @@ -3181,7 +3181,7 @@ describe('state_helpers', () => { }, }, indexPattern, - {} as IndexPatternPrivateState, + {} as FormBasedPrivateState, '1', {} as CoreStart, dataMock @@ -3209,7 +3209,7 @@ describe('state_helpers', () => { describe('hasTermsWithManyBuckets', () => { it('should return false for a bucketed non terms operation', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1'], columns: { col1: { @@ -3230,7 +3230,7 @@ describe('state_helpers', () => { }); it('should return false if all terms operation have a lower size', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1'], columns: { col1: { @@ -3256,7 +3256,7 @@ describe('state_helpers', () => { }); it('should return true if the size is high', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { columnOrder: ['col1'], columns: { col1: { @@ -3284,7 +3284,7 @@ describe('state_helpers', () => { describe('isReferenced', () => { it('should return false for top column which has references', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: [], columns: { @@ -3308,7 +3308,7 @@ describe('state_helpers', () => { }); it('should return true for referenced column', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: [], columns: { @@ -3334,7 +3334,7 @@ describe('state_helpers', () => { describe('getReferenceRoot', () => { it("should just return the column id itself if it's not a referenced column", () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: [], columns: { @@ -3358,7 +3358,7 @@ describe('state_helpers', () => { }); it('should return the top column if a referenced column is passed', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '1', columnOrder: [], columns: { @@ -3389,7 +3389,7 @@ describe('state_helpers', () => { label: 'math', operationType: 'math' as const, }; - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '', columnOrder: [], columns: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/layer_helpers.ts similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/layer_helpers.ts index eb0f39262874b..db9b744cd43b2 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/layer_helpers.ts @@ -17,7 +17,7 @@ import type { IndexPatternField, OperationMetadata, VisualizationDimensionGroupConfig, -} from '../../types'; +} from '../../../types'; import { operationDefinitionMap, operationDefinitions, @@ -27,23 +27,19 @@ import { GenericOperationDefinition, TermsIndexPatternColumn, } from './definitions'; -import type { - DataViewDragDropOperation, - IndexPatternLayer, - IndexPatternPrivateState, -} from '../types'; +import type { DataViewDragDropOperation, FormBasedLayer, FormBasedPrivateState } from '../types'; import { getSortScoreByPriorityForField } from './operations'; -import { generateId } from '../../id_generator'; +import { generateId } from '../../../id_generator'; import { GenericIndexPatternColumn, ReferenceBasedIndexPatternColumn, BaseIndexPatternColumn, } from './definitions/column_types'; import { FormulaIndexPatternColumn, insertOrReplaceFormulaColumn } from './definitions/formula'; -import type { TimeScaleUnit } from '../../../common/expressions'; +import type { TimeScaleUnit } from '../../../../common/expressions'; import { documentField } from '../document_field'; import { isColumnOfType } from './definitions/helpers'; -import type { DataType } from '../..'; +import type { DataType } from '../../..'; export interface ColumnAdvancedParams { filter?: Query | undefined; @@ -54,7 +50,7 @@ export interface ColumnAdvancedParams { interface ColumnChange { op: OperationType; - layer: IndexPatternLayer; + layer: FormBasedLayer; columnId: string; indexPattern: IndexPattern; field?: IndexPatternField; @@ -72,7 +68,7 @@ interface ColumnChange { } interface ColumnCopy { - layers: Record; + layers: Record; target: DataViewDragDropOperation; source: DataViewDragDropOperation; shouldDeleteSource?: boolean; @@ -82,7 +78,7 @@ export const deleteColumnInLayers = ({ layers, source, }: { - layers: Record; + layers: Record; source: DataViewDragDropOperation; }) => ({ ...layers, @@ -98,7 +94,7 @@ export function copyColumn({ source, target, shouldDeleteSource, -}: ColumnCopy): Record { +}: ColumnCopy): Record { const outputLayers = createCopiedColumn(layers, target, source); return shouldDeleteSource ? deleteColumnInLayers({ @@ -109,10 +105,10 @@ export function copyColumn({ } function createCopiedColumn( - layers: Record, + layers: Record, target: DataViewDragDropOperation, source: DataViewDragDropOperation -): Record { +): Record { const sourceLayer = layers[source.layerId]; const sourceColumn = sourceLayer.columns[source.columnId]; const targetLayer = layers[target.layerId]; @@ -152,7 +148,7 @@ function createCopiedColumn( }; } -export function insertOrReplaceColumn(args: ColumnChange): IndexPatternLayer { +export function insertOrReplaceColumn(args: ColumnChange): FormBasedLayer { if (args.layer.columns[args.columnId]) { return replaceColumn(args); } @@ -185,7 +181,7 @@ const insertReferences = ({ visualizationGroups, targetGroup, }: { - layer: IndexPatternLayer; + layer: FormBasedLayer; references: Exclude; requiredReferences: RequiredReference[]; indexPattern: IndexPattern; @@ -269,7 +265,7 @@ const generateNewReferences = ({ incompleteFieldName?: string; incompleteFieldOperation?: OperationType; columnParams?: Record; - layer: IndexPatternLayer; + layer: FormBasedLayer; requiredReferences: RequiredReference[]; indexPattern: IndexPattern; visualizationGroups: VisualizationDimensionGroupConfig[]; @@ -364,7 +360,7 @@ export function insertNewColumn({ initialParams, references, respectOrder, -}: ColumnChange): IndexPatternLayer { +}: ColumnChange): FormBasedLayer { const operationDefinition = operationDefinitionMap[op]; if (!operationDefinition) { @@ -541,8 +537,8 @@ function replaceFormulaColumn( }: { operationDefinition: Extract; previousDefinition: GenericOperationDefinition; - layer: IndexPatternLayer; - previousColumn: IndexPatternLayer['columns'][number]; + layer: FormBasedLayer; + previousColumn: FormBasedLayer['columns'][number]; indexPattern: IndexPattern; columnId: string; }, @@ -615,7 +611,7 @@ export function replaceColumn({ initialParams, shouldResetLabel, shouldCombineField, -}: ColumnChange): IndexPatternLayer { +}: ColumnChange): FormBasedLayer { const previousColumn = layer.columns[columnId]; if (!previousColumn) { throw new Error(`Can't replace column because there is no prior column`); @@ -901,10 +897,10 @@ function removeOrphanedColumns( | OperationDefinition | OperationDefinition, previousColumn: GenericIndexPatternColumn, - tempLayer: IndexPatternLayer, + tempLayer: FormBasedLayer, indexPattern: IndexPattern ) { - let newLayer: IndexPatternLayer = tempLayer; + let newLayer: FormBasedLayer = tempLayer; if (previousDefinition.input === 'managedReference') { const [columnId] = Object.entries(tempLayer.columns).find(([_, currColumn]) => currColumn === previousColumn) || @@ -994,13 +990,13 @@ function applyReferenceTransition({ indexPattern, visualizationGroups, }: { - layer: IndexPatternLayer; + layer: FormBasedLayer; columnId: string; previousColumn: GenericIndexPatternColumn; op: OperationType; indexPattern: IndexPattern; visualizationGroups: VisualizationDimensionGroupConfig[]; -}): IndexPatternLayer { +}): FormBasedLayer { const operationDefinition = operationDefinitionMap[op]; if (operationDefinition.input !== 'fullReference') { @@ -1218,13 +1214,13 @@ function copyCustomLabel( } function addBucket( - layer: IndexPatternLayer, + layer: FormBasedLayer, column: BaseIndexPatternColumn, addedColumnId: string, visualizationGroups: VisualizationDimensionGroupConfig[], targetGroup?: string, respectOrder?: boolean -): IndexPatternLayer { +): FormBasedLayer { const [buckets, metrics] = partition( layer.columnOrder, (colId) => layer.columns[colId].isBucketed @@ -1314,10 +1310,10 @@ export function reorderByGroups( } function addMetric( - layer: IndexPatternLayer, + layer: FormBasedLayer, column: BaseIndexPatternColumn, addedColumnId: string -): IndexPatternLayer { +): FormBasedLayer { const tempLayer = { ...resetIncomplete(layer, addedColumnId), columns: { @@ -1347,10 +1343,10 @@ export function updateColumnLabel({ columnId, customLabel, }: { - layer: IndexPatternLayer; + layer: FormBasedLayer; columnId: string; customLabel?: string; -}): IndexPatternLayer { +}): FormBasedLayer { const oldColumn = layer.columns[columnId]; return { ...layer, @@ -1371,11 +1367,11 @@ export function updateColumnParam({ paramName, value, }: { - layer: IndexPatternLayer; + layer: FormBasedLayer; columnId: string; paramName: string; value: unknown; -}): IndexPatternLayer { +}): FormBasedLayer { const currentColumn = layer.columns[columnId]; return { ...layer, @@ -1392,7 +1388,7 @@ export function updateColumnParam({ }; } -export function adjustColumnReferences(layer: IndexPatternLayer) { +export function adjustColumnReferences(layer: FormBasedLayer) { const newColumns = { ...layer.columns }; Object.keys(newColumns).forEach((currentColumnId) => { const currentColumn = newColumns[currentColumnId]; @@ -1413,7 +1409,7 @@ export function adjustColumnReferences(layer: IndexPatternLayer) { } export function adjustColumnReferencesForChangedColumn( - layer: IndexPatternLayer, + layer: FormBasedLayer, changedColumnId: string ) { const newColumns = { ...layer.columns }; @@ -1440,10 +1436,10 @@ export function deleteColumn({ columnId, indexPattern, }: { - layer: IndexPatternLayer; + layer: FormBasedLayer; columnId: string; indexPattern: IndexPattern; -}): IndexPatternLayer { +}): FormBasedLayer { const column = layer.columns[columnId]; if (!column) { const newIncomplete = { ...(layer.incompleteColumns || {}) }; @@ -1491,7 +1487,7 @@ export function deleteColumn({ // // This does NOT topologically sort references, as this would cause the order in the UI // to change. Reference order is determined before creating the pipeline in to_expression -export function getColumnOrder(layer: IndexPatternLayer): string[] { +export function getColumnOrder(layer: FormBasedLayer): string[] { const entries = Object.entries(layer.columns); entries.sort(([idA], [idB]) => { const indexA = layer.columnOrder.indexOf(idA); @@ -1511,7 +1507,7 @@ export function getColumnOrder(layer: IndexPatternLayer): string[] { } // Splits existing columnOrder into the three categories -export function getExistingColumnGroups(layer: IndexPatternLayer): [string[], string[], string[]] { +export function getExistingColumnGroups(layer: FormBasedLayer): [string[], string[], string[]] { const [direct, referenced] = partition( layer.columnOrder, (columnId) => layer.columns[columnId] && !('references' in layer.columns[columnId]) @@ -1525,7 +1521,7 @@ export function getExistingColumnGroups(layer: IndexPatternLayer): [string[], st export function isColumnTransferable( column: GenericIndexPatternColumn, newIndexPattern: IndexPattern, - layer: IndexPatternLayer + layer: FormBasedLayer ): boolean { return ( operationDefinitionMap[column.operationType].isTransferable( @@ -1541,13 +1537,13 @@ export function isColumnTransferable( } export function updateLayerIndexPattern( - layer: IndexPatternLayer, + layer: FormBasedLayer, newIndexPattern: IndexPattern -): IndexPatternLayer { - const keptColumns: IndexPatternLayer['columns'] = pickBy(layer.columns, (column) => { +): FormBasedLayer { + const keptColumns: FormBasedLayer['columns'] = pickBy(layer.columns, (column) => { return isColumnTransferable(column, newIndexPattern, layer); }); - const newColumns: IndexPatternLayer['columns'] = mapValues(keptColumns, (column) => { + const newColumns: FormBasedLayer['columns'] = mapValues(keptColumns, (column) => { const operationDefinition = operationDefinitionMap[column.operationType]; return operationDefinition.transfer ? operationDefinition.transfer(column, newIndexPattern) @@ -1573,9 +1569,9 @@ export function updateLayerIndexPattern( * - If timeshift is used, only a single date histogram can be used */ export function getErrorMessages( - layer: IndexPatternLayer, + layer: FormBasedLayer, indexPattern: IndexPattern, - state: IndexPatternPrivateState, + state: FormBasedPrivateState, layerId: string, core: CoreStart, data: DataPublicPluginStart @@ -1584,7 +1580,7 @@ export function getErrorMessages( | string | { message: string; - fixAction?: DatasourceFixAction; + fixAction?: DatasourceFixAction; } > | undefined { @@ -1632,21 +1628,21 @@ export function getErrorMessages( | string | { message: string; - fixAction?: DatasourceFixAction; + fixAction?: DatasourceFixAction; } >; return errors.length ? errors : undefined; } -export function isReferenced(layer: IndexPatternLayer, columnId: string): boolean { +export function isReferenced(layer: FormBasedLayer, columnId: string): boolean { const allReferences = Object.values(layer.columns).flatMap((col) => 'references' in col ? col.references : [] ); return allReferences.includes(columnId); } -const computeReferenceLookup = memoizeOne((layer: IndexPatternLayer): Record => { +const computeReferenceLookup = memoizeOne((layer: FormBasedLayer): Record => { // speed up things for deep chains as in formula const refLookup: Record = {}; for (const [parentId, col] of Object.entries(layer.columns)) { @@ -1666,7 +1662,7 @@ const computeReferenceLookup = memoizeOne((layer: IndexPatternLayer): Record { const column = layer.columns[columnId]; if (column) { @@ -1740,9 +1736,9 @@ export function isOperationAllowedAsReference({ // Labels need to be updated when columns are added because reference-based column labels // are sometimes copied into the parents export function updateDefaultLabels( - layer: IndexPatternLayer, + layer: FormBasedLayer, indexPattern: IndexPattern -): IndexPatternLayer { +): FormBasedLayer { const copiedColumns = { ...layer.columns }; layer.columnOrder.forEach((id) => { const col = copiedColumns[id]; @@ -1760,7 +1756,7 @@ export function updateDefaultLabels( return { ...layer, columns: copiedColumns }; } -export function resetIncomplete(layer: IndexPatternLayer, columnId: string): IndexPatternLayer { +export function resetIncomplete(layer: FormBasedLayer, columnId: string): FormBasedLayer { const incompleteColumns = { ...(layer.incompleteColumns ?? {}) }; delete incompleteColumns[columnId]; return { ...layer, incompleteColumns }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/mocks.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/mocks.ts similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/mocks.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/mocks.ts index 2d7e70179fb3f..3884bab02f200 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/mocks.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/mocks.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { OperationMetadata } from '../../types'; +import type { OperationMetadata } from '../../../types'; import type { OperationType } from './definitions'; export const createMockedFullReference = () => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/operations.test.ts similarity index 100% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/operations.test.ts diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/operations.ts similarity index 99% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/operations.ts index 27071e5f0ee74..b44c0a0e4cc55 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/operations.ts @@ -6,7 +6,7 @@ */ import { memoize } from 'lodash'; -import type { IndexPattern, IndexPatternField, OperationMetadata } from '../../types'; +import type { IndexPattern, IndexPatternField, OperationMetadata } from '../../../types'; import { operationDefinitionMap, operationDefinitions, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/time_scale_utils.test.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/time_scale_utils.test.ts similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/time_scale_utils.test.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/time_scale_utils.test.ts index 559086cf69b84..e249be575aac2 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/time_scale_utils.test.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/time_scale_utils.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TimeScaleUnit } from '../../../common/expressions'; +import type { TimeScaleUnit } from '../../../../common/expressions'; import { adjustTimeScaleLabelSuffix } from './time_scale_utils'; export const DEFAULT_TIME_SCALE = 's' as TimeScaleUnit; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/time_scale_utils.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/time_scale_utils.ts similarity index 92% rename from x-pack/plugins/lens/public/indexpattern_datasource/operations/time_scale_utils.ts rename to x-pack/plugins/lens/public/datasources/form_based/operations/time_scale_utils.ts index 1ebf4ccc76a36..08dfa147bf88e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/time_scale_utils.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/time_scale_utils.ts @@ -6,8 +6,8 @@ */ import { i18n } from '@kbn/i18n'; -import { unitSuffixesLong } from '../../../common/suffix_formatter'; -import type { TimeScaleUnit } from '../../../common/expressions'; +import { unitSuffixesLong } from '../../../../common/suffix_formatter'; +import type { TimeScaleUnit } from '../../../../common/expressions'; export const DEFAULT_TIME_SCALE = 's' as TimeScaleUnit; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/pure_helpers.ts b/x-pack/plugins/lens/public/datasources/form_based/pure_helpers.ts similarity index 92% rename from x-pack/plugins/lens/public/indexpattern_datasource/pure_helpers.ts rename to x-pack/plugins/lens/public/datasources/form_based/pure_helpers.ts index ba3ba9bbb824f..6355809369804 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/pure_helpers.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/pure_helpers.ts @@ -6,7 +6,7 @@ */ import { keyBy } from 'lodash'; -import { IndexPatternField } from '../types'; +import { IndexPatternField } from '../../types'; import { documentField } from './document_field'; export function getFieldByNameFactory( diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/pure_utils.ts b/x-pack/plugins/lens/public/datasources/form_based/pure_utils.ts similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/pure_utils.ts rename to x-pack/plugins/lens/public/datasources/form_based/pure_utils.ts index 39b4bcdf49229..5d8d823c30ab4 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/pure_utils.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/pure_utils.ts @@ -5,8 +5,8 @@ * 2.0. */ -import type { DataType, IndexPattern, IndexPatternField } from '../types'; -import type { IndexPatternLayer } from './types'; +import type { DataType, IndexPattern, IndexPatternField } from '../../types'; +import type { FormBasedLayer } from './types'; import type { BaseIndexPatternColumn, FieldBasedIndexPatternColumn, @@ -36,7 +36,7 @@ export function getFieldType(field: IndexPatternField) { export function getReferencedField( column: GenericIndexPatternColumn | undefined, indexPattern: IndexPattern, - layer: IndexPatternLayer + layer: FormBasedLayer ) { if (!column) return; if (!('references' in column)) return; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/reduced_time_range_utils.tsx b/x-pack/plugins/lens/public/datasources/form_based/reduced_time_range_utils.tsx similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/reduced_time_range_utils.tsx rename to x-pack/plugins/lens/public/datasources/form_based/reduced_time_range_utils.tsx index 04984a1c782bf..69e0fb4f07a5e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/reduced_time_range_utils.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/reduced_time_range_utils.tsx @@ -6,8 +6,8 @@ */ import { i18n } from '@kbn/i18n'; -import type { IndexPatternLayer } from './types'; -import type { IndexPattern } from '../types'; +import type { FormBasedLayer } from './types'; +import type { IndexPattern } from '../../types'; export const reducedTimeRangeOptions = [ { @@ -53,7 +53,7 @@ export const reducedTimeRangeOptionOrder = reducedTimeRangeOptions.reduce<{ ); export function getColumnReducedTimeRangeError( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, indexPattern: IndexPattern ): string[] | undefined { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/state_helpers.ts b/x-pack/plugins/lens/public/datasources/form_based/state_helpers.ts similarity index 73% rename from x-pack/plugins/lens/public/indexpattern_datasource/state_helpers.ts rename to x-pack/plugins/lens/public/datasources/form_based/state_helpers.ts index 6e16ebe5e8d53..0120c29713a83 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/state_helpers.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/state_helpers.ts @@ -5,16 +5,16 @@ * 2.0. */ -import { IndexPatternPrivateState, IndexPatternLayer } from './types'; +import { FormBasedPrivateState, FormBasedLayer } from './types'; export function mergeLayer({ state, layerId, newLayer, }: { - state: IndexPatternPrivateState; + state: FormBasedPrivateState; layerId: string; - newLayer: Partial; + newLayer: Partial; }) { return { ...state, @@ -29,8 +29,8 @@ export function mergeLayers({ state, newLayers, }: { - state: IndexPatternPrivateState; - newLayers: Record; + state: FormBasedPrivateState; + newLayers: Record; }) { return { ...state, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/time_shift_utils.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/time_shift_utils.test.tsx similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/time_shift_utils.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/time_shift_utils.test.tsx index 4cb251e3820be..a0ff29a684150 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/time_shift_utils.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/time_shift_utils.test.tsx @@ -6,11 +6,11 @@ */ import { getDisallowedPreviousShiftMessage } from './time_shift_utils'; -import { IndexPatternLayer } from './types'; +import { FormBasedLayer } from './types'; describe('time_shift_utils', () => { describe('getDisallowedPreviousShiftMessage', () => { - const layer: IndexPatternLayer = { + const layer: FormBasedLayer = { indexPatternId: '', columnOrder: [], columns: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/time_shift_utils.tsx b/x-pack/plugins/lens/public/datasources/form_based/time_shift_utils.tsx similarity index 97% rename from x-pack/plugins/lens/public/indexpattern_datasource/time_shift_utils.tsx rename to x-pack/plugins/lens/public/datasources/form_based/time_shift_utils.tsx index 51f389e69a4f0..6dd4b88d3422a 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/time_shift_utils.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/time_shift_utils.tsx @@ -13,12 +13,8 @@ import type { DatatableUtilitiesService } from '@kbn/data-plugin/common'; import { Datatable } from '@kbn/expressions-plugin/common'; import { search } from '@kbn/data-plugin/public'; import { parseTimeShift } from '@kbn/data-plugin/common'; -import type { - GenericIndexPatternColumn, - IndexPatternLayer, - IndexPatternPrivateState, -} from './types'; -import type { FramePublicAPI, IndexPattern } from '../types'; +import type { GenericIndexPatternColumn, FormBasedLayer, FormBasedPrivateState } from './types'; +import type { FramePublicAPI, IndexPattern } from '../../types'; export const timeShiftOptions = [ { @@ -105,7 +101,7 @@ export const timeShiftOptionOrder = timeShiftOptions.reduce<{ [key: string]: num export function getDateHistogramInterval( datatableUtilities: DatatableUtilitiesService, - layer: IndexPatternLayer, + layer: FormBasedLayer, indexPattern: IndexPattern, activeData: Record | undefined, layerId: string @@ -163,7 +159,7 @@ export function getLayerTimeShiftChecks({ } export function getDisallowedPreviousShiftMessage( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string ): string[] | undefined { const currentColumn = layer.columns[columnId]; @@ -191,7 +187,7 @@ export function getDisallowedPreviousShiftMessage( export function getStateTimeShiftWarningMessages( datatableUtilities: DatatableUtilitiesService, - state: IndexPatternPrivateState, + state: FormBasedPrivateState, { activeData, dataViews }: FramePublicAPI ) { if (!state) return; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts b/x-pack/plugins/lens/public/datasources/form_based/to_expression.ts similarity index 98% rename from x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts rename to x-pack/plugins/lens/public/datasources/form_based/to_expression.ts index 72cb2a2ab729e..fc77aa6520bd0 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/to_expression.ts @@ -20,13 +20,13 @@ import { ExpressionAstExpressionBuilder, ExpressionAstFunction, } from '@kbn/expressions-plugin/public'; -import { GenericIndexPatternColumn } from './indexpattern'; +import { GenericIndexPatternColumn } from './form_based'; import { operationDefinitionMap } from './operations'; -import { IndexPatternPrivateState, IndexPatternLayer } from './types'; +import { FormBasedPrivateState, FormBasedLayer } from './types'; import { DateHistogramIndexPatternColumn, RangeIndexPatternColumn } from './operations/definitions'; import { FormattedIndexPatternColumn } from './operations/definitions/column_types'; import { isColumnFormatted, isColumnOfType } from './operations/definitions/helpers'; -import type { IndexPattern, IndexPatternMap } from '../types'; +import type { IndexPattern, IndexPatternMap } from '../../types'; import { dedupeAggs } from './dedupe_aggs'; export type OriginalColumn = { id: string } & GenericIndexPatternColumn; @@ -50,7 +50,7 @@ const updatePositionIndex = (currentId: string, newIndex: number) => { }; function getExpressionForLayer( - layer: IndexPatternLayer, + layer: FormBasedLayer, indexPattern: IndexPattern, uiSettings: IUiSettingsClient ): ExpressionAstExpression | null { @@ -438,7 +438,7 @@ function sortedReferences(columns: Array; // Each layer is tied to the index pattern that created it @@ -56,15 +55,15 @@ export interface IndexPatternLayer { incompleteColumns?: Record; } -export interface IndexPatternPersistedState { - layers: Record>; +export interface FormBasedPersistedState { + layers: Record>; } -export type PersistedIndexPatternLayer = Omit; +export type PersistedIndexPatternLayer = Omit; -export interface IndexPatternPrivateState { +export interface FormBasedPrivateState { currentIndexPatternId: string; - layers: Record; + layers: Record; isDimensionClosePrevented?: boolean; } diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/utils.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/utils.test.tsx similarity index 95% rename from x-pack/plugins/lens/public/indexpattern_datasource/utils.test.tsx rename to x-pack/plugins/lens/public/datasources/form_based/utils.test.tsx index 2d7a6334adaf6..5349e433f3cac 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/utils.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/utils.test.tsx @@ -9,19 +9,19 @@ import React from 'react'; import { shallow } from 'enzyme'; import { createDatatableUtilitiesMock } from '@kbn/data-plugin/common/mocks'; import { getPrecisionErrorWarningMessages, cloneLayer } from './utils'; -import type { IndexPatternPrivateState, GenericIndexPatternColumn } from './types'; -import type { FramePublicAPI } from '../types'; +import type { FormBasedPrivateState, GenericIndexPatternColumn } from './types'; +import type { FramePublicAPI } from '../../types'; import type { DocLinksStart } from '@kbn/core/public'; import { EuiButton } from '@elastic/eui'; import { TermsIndexPatternColumn } from './operations'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { FormattedMessage } from '@kbn/i18n-react'; -import { IndexPatternLayer } from './types'; +import { FormBasedLayer } from './types'; describe('indexpattern_datasource utils', () => { describe('getPrecisionErrorWarningMessages', () => { const datatableUtilitites = createDatatableUtilitiesMock(); - let state: IndexPatternPrivateState; + let state: FormBasedPrivateState; let framePublicAPI: FramePublicAPI; let docLinks: DocLinksStart; @@ -42,7 +42,7 @@ describe('indexpattern_datasource utils', () => { }, }, }, - } as unknown as IndexPatternPrivateState; + } as unknown as FormBasedPrivateState; framePublicAPI = { activeData: { id: { @@ -227,7 +227,7 @@ describe('indexpattern_datasource utils', () => { incompleteColumns: {}, indexPatternId: 'ff959d40-b880-11e8-a6d9-e546fe2bba5f', }, - } as unknown as Record, + } as unknown as Record, 'a', 'b', (id) => id + 'C' diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx b/x-pack/plugins/lens/public/datasources/form_based/utils.tsx similarity index 96% rename from x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx rename to x-pack/plugins/lens/public/datasources/form_based/utils.tsx index 612719967161c..dfec3c723d189 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/utils.tsx @@ -17,13 +17,9 @@ import type { DatatableColumn } from '@kbn/expressions-plugin/common'; import { groupBy, escape, uniq } from 'lodash'; import type { Query } from '@kbn/data-plugin/common'; import { SearchResponseWarning } from '@kbn/data-plugin/public/search/types'; -import type { FramePublicAPI, IndexPattern, StateSetter } from '../types'; -import { renewIDs } from '../utils'; -import type { - IndexPatternLayer, - IndexPatternPersistedState, - IndexPatternPrivateState, -} from './types'; +import type { FramePublicAPI, IndexPattern, StateSetter } from '../../types'; +import { renewIDs } from '../../utils'; +import type { FormBasedLayer, FormBasedPersistedState, FormBasedPrivateState } from './types'; import type { ReferenceBasedIndexPatternColumn } from './operations/definitions/column_types'; import { @@ -44,11 +40,11 @@ import { hasField } from './pure_utils'; import { mergeLayer } from './state_helpers'; import { supportsRarityRanking } from './operations/definitions/terms'; import { DEFAULT_MAX_DOC_COUNT } from './operations/definitions/terms/constants'; -import { getOriginalId } from '../../common/expressions/datatable/transpose_helpers'; -import { isQueryValid } from '../shared_components'; +import { getOriginalId } from '../../../common/expressions/datatable/transpose_helpers'; +import { isQueryValid } from '../../shared_components'; export function isColumnInvalid( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnId: string, indexPattern: IndexPattern ) { @@ -76,7 +72,7 @@ export function isColumnInvalid( } function getReferencesErrors( - layer: IndexPatternLayer, + layer: FormBasedLayer, column: ReferenceBasedIndexPatternColumn, indexPattern: IndexPattern ) { @@ -167,7 +163,7 @@ const accuracyModeEnabledWarning = (columnName: string, docLink: string) => ( ); export function getTSDBRollupWarningMessages( - state: IndexPatternPersistedState, + state: FormBasedPersistedState, warning: SearchResponseWarning ) { if (state) { @@ -208,10 +204,10 @@ export function getTSDBRollupWarningMessages( export function getPrecisionErrorWarningMessages( datatableUtilities: DatatableUtilitiesService, - state: IndexPatternPrivateState, + state: FormBasedPrivateState, { activeData, dataViews }: FramePublicAPI, docLinks: DocLinksStart, - setState: StateSetter + setState: StateSetter ) { const warningMessages: React.ReactNode[] = []; @@ -338,7 +334,7 @@ export function getPrecisionErrorWarningMessages( return warningMessages; } -export function getVisualDefaultsForLayer(layer: IndexPatternLayer) { +export function getVisualDefaultsForLayer(layer: FormBasedLayer) { return Object.keys(layer.columns).reduce>>( (memo, columnId) => { const column = layer.columns[columnId]; @@ -461,7 +457,7 @@ function shouldUseTermsFallback( * * if there's at least one unfiltered metric, then just return an empty list of filters * * otherwise get all the filters, with the only exception of those from formula (referenced columns will have it anyway) */ -function collectFiltersFromMetrics(layer: IndexPatternLayer, columnIds: string[]) { +function collectFiltersFromMetrics(layer: FormBasedLayer, columnIds: string[]) { // Isolate filtered metrics first // mind to ignore non-filterable columns and formula columns const metricColumns = Object.keys(layer.columns).filter((colId) => { @@ -506,7 +502,7 @@ function collectOnlyValidQueries( } export function getFiltersInLayer( - layer: IndexPatternLayer, + layer: FormBasedLayer, columnIds: string[], layerData: NonNullable[string] | undefined, indexPattern: IndexPattern, @@ -617,7 +613,7 @@ export function getFiltersInLayer( } export const cloneLayer = ( - layers: Record, + layers: Record, layerId: string, newLayerId: string, getNewId: (id: string) => string diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/datapanel.test.tsx b/x-pack/plugins/lens/public/datasources/text_based/datapanel.test.tsx similarity index 88% rename from x-pack/plugins/lens/public/text_based_languages_datasource/datapanel.test.tsx rename to x-pack/plugins/lens/public/datasources/text_based/datapanel.test.tsx index 51ba02c1cdc6f..781b6547f8e15 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/datapanel.test.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/datapanel.test.tsx @@ -19,18 +19,18 @@ import { import type { DatatableColumn } from '@kbn/expressions-plugin/public'; import { FieldButton } from '@kbn/react-field'; -import { type TextBasedLanguagesDataPanelProps, TextBasedLanguagesDataPanel } from './datapanel'; +import { type TextBasedDataPanelProps, TextBasedDataPanel } from './datapanel'; import { coreMock } from '@kbn/core/public/mocks'; -import type { TextBasedLanguagesPrivateState } from './types'; +import type { TextBasedPrivateState } from './types'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; -import { createIndexPatternServiceMock } from '../mocks/data_views_service_mock'; -import { createMockFramePublicAPI } from '../mocks'; +import { createIndexPatternServiceMock } from '../../mocks/data_views_service_mock'; +import { createMockFramePublicAPI } from '../../mocks'; import { createMockedDragDropContext } from './mocks'; -import { DataViewsState } from '../state_management'; -import { ExistingFieldsMap, IndexPattern } from '../types'; +import { DataViewsState } from '../../state_management'; +import { ExistingFieldsMap, IndexPattern } from '../../types'; const fieldsFromQuery = [ { @@ -113,7 +113,7 @@ function getExistingFields(indexPatterns: Record) { return existingFields; } -const initialState: TextBasedLanguagesPrivateState = { +const initialState: TextBasedPrivateState = { layers: { first: { index: '1', @@ -163,7 +163,7 @@ describe('TextBased Query Languages Data Panel', () => { let core: ReturnType; let dataViews: DataViewPublicStart; - let defaultProps: TextBasedLanguagesDataPanelProps; + let defaultProps: TextBasedDataPanelProps; const dataViewsMock = dataViewPluginMocks.createStartContract(); beforeEach(() => { core = coreMock.createStart(); @@ -202,12 +202,12 @@ describe('TextBased Query Languages Data Panel', () => { }); it('should render a search box', async () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); expect(wrapper.find('[data-test-subj="lnsTextBasedLangugesFieldSearch"]').length).toEqual(1); }); it('should list all supported fields in the pattern', async () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); expect( wrapper .find('[data-test-subj="lnsTextBasedLanguagesPanelFields"]') @@ -217,7 +217,7 @@ describe('TextBased Query Languages Data Panel', () => { }); it('should list all supported fields in the pattern that match the search input', async () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl(); const searchBox = wrapper.find('[data-test-subj="lnsTextBasedLangugesFieldSearch"]'); act(() => { diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/datapanel.tsx b/x-pack/plugins/lens/public/datasources/text_based/datapanel.tsx similarity index 90% rename from x-pack/plugins/lens/public/text_based_languages_datasource/datapanel.tsx rename to x-pack/plugins/lens/public/datasources/text_based/datapanel.tsx index 9e15db381549d..925d92be5aa99 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/datapanel.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/datapanel.tsx @@ -17,23 +17,22 @@ import { isOfAggregateQueryType } from '@kbn/es-query'; import { ExpressionsStart } from '@kbn/expressions-plugin/public'; import { FieldButton } from '@kbn/react-field'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; -import { DatasourceDataPanelProps, DataType } from '../types'; -import type { TextBasedLanguagesPrivateState } from './types'; +import { DatasourceDataPanelProps, DataType } from '../../types'; +import type { TextBasedPrivateState } from './types'; import { getStateFromAggregateQuery } from './utils'; -import { DragDrop } from '../drag_drop'; -import { LensFieldIcon } from '../shared_components'; -import { ChildDragDropProvider } from '../drag_drop'; +import { DragDrop } from '../../drag_drop'; +import { LensFieldIcon } from '../../shared_components'; +import { ChildDragDropProvider } from '../../drag_drop'; -export type TextBasedLanguagesDataPanelProps = - DatasourceDataPanelProps & { - data: DataPublicPluginStart; - expressions: ExpressionsStart; - dataViews: DataViewsPublicPluginStart; - }; +export type TextBasedDataPanelProps = DatasourceDataPanelProps & { + data: DataPublicPluginStart; + expressions: ExpressionsStart; + dataViews: DataViewsPublicPluginStart; +}; const htmlId = htmlIdGenerator('datapanel-text-based-languages'); const fieldSearchDescriptionId = htmlId(); -export function TextBasedLanguagesDataPanel({ +export function TextBasedDataPanel({ setState, state, dragDropContext, @@ -44,7 +43,7 @@ export function TextBasedLanguagesDataPanel({ dateRange, expressions, dataViews, -}: TextBasedLanguagesDataPanelProps) { +}: TextBasedDataPanelProps) { const prevQuery = usePrevious(query); const [localState, setLocalState] = useState({ nameFilter: '' }); const clearLocalState = () => setLocalState((s) => ({ ...s, nameFilter: '' })); diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/fetch_data_from_aggregate_query.ts b/x-pack/plugins/lens/public/datasources/text_based/fetch_data_from_aggregate_query.ts similarity index 100% rename from x-pack/plugins/lens/public/text_based_languages_datasource/fetch_data_from_aggregate_query.ts rename to x-pack/plugins/lens/public/datasources/text_based/fetch_data_from_aggregate_query.ts diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/field_select.test.tsx b/x-pack/plugins/lens/public/datasources/text_based/field_select.test.tsx similarity index 96% rename from x-pack/plugins/lens/public/text_based_languages_datasource/field_select.test.tsx rename to x-pack/plugins/lens/public/datasources/text_based/field_select.test.tsx index f1051f3b8f61d..b344131747b1b 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/field_select.test.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/field_select.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import type { DatatableColumn } from '@kbn/expressions-plugin/public'; -import { FieldPicker, FieldOptionValue } from '../shared_components/field_picker'; +import { FieldPicker, FieldOptionValue } from '../../shared_components/field_picker'; import { FieldSelect, FieldSelectProps } from './field_select'; import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/field_select.tsx b/x-pack/plugins/lens/public/datasources/text_based/field_select.tsx similarity index 89% rename from x-pack/plugins/lens/public/text_based_languages_datasource/field_select.tsx rename to x-pack/plugins/lens/public/datasources/text_based/field_select.tsx index 63153bc87d59e..e7cb5451d31ab 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/field_select.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/field_select.tsx @@ -9,12 +9,12 @@ import React, { useMemo } from 'react'; import { EuiComboBoxOptionOption, EuiComboBoxProps } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import type { DatatableColumn } from '@kbn/expressions-plugin/public'; -import { FieldPicker, FieldOptionValue, FieldOption } from '../shared_components/field_picker'; -import type { TextBasedLanguagesLayerColumn } from './types'; -import type { DataType } from '../types'; +import { FieldPicker, FieldOptionValue, FieldOption } from '../../shared_components/field_picker'; +import type { TextBasedLayerColumn } from './types'; +import type { DataType } from '../../types'; export interface FieldSelectProps extends EuiComboBoxProps { - selectedField?: TextBasedLanguagesLayerColumn; + selectedField?: TextBasedLayerColumn; onChoose: (choice: FieldOptionValue) => void; existingFields: DatatableColumn[]; } diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/index.ts b/x-pack/plugins/lens/public/datasources/text_based/index.ts similarity index 71% rename from x-pack/plugins/lens/public/text_based_languages_datasource/index.ts rename to x-pack/plugins/lens/public/datasources/text_based/index.ts index b2cffc5659dbf..1041e94eb7c61 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/index.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/index.ts @@ -10,31 +10,28 @@ import { Storage } from '@kbn/kibana-utils-plugin/public'; import { ExpressionsStart } from '@kbn/expressions-plugin/public'; import { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public'; import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; -import { EditorFrameSetup } from '../types'; +import { EditorFrameSetup } from '../../types'; -export interface TextBasedLanguageSetupPlugins { +export interface TextBasedSetupPlugins { data: DataPublicPluginSetup; editorFrame: EditorFrameSetup; } -export interface TextBasedLanguageStartPlugins { +export interface TextBasedStartPlugins { data: DataPublicPluginStart; dataViews: DataViewsPublicPluginStart; expressions: ExpressionsStart; } -export class TextBasedLanguagesDatasource { +export class TextBasedDatasource { constructor() {} - setup( - core: CoreSetup, - { editorFrame }: TextBasedLanguageSetupPlugins - ) { + setup(core: CoreSetup, { editorFrame }: TextBasedSetupPlugins) { editorFrame.registerDatasource(async () => { - const { getTextBasedLanguagesDatasource } = await import('../async_services'); + const { getTextBasedDatasource } = await import('../../async_services'); const [coreStart, { data, dataViews, expressions }] = await core.getStartServices(); - return getTextBasedLanguagesDatasource({ + return getTextBasedDatasource({ core: coreStart, storage: new Storage(localStorage), data, diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/layerpanel.test.tsx b/x-pack/plugins/lens/public/datasources/text_based/layerpanel.test.tsx similarity index 83% rename from x-pack/plugins/lens/public/text_based_languages_datasource/layerpanel.test.tsx rename to x-pack/plugins/lens/public/datasources/text_based/layerpanel.test.tsx index 7a3bf25b5e9e6..f0a9d147ddfd6 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/layerpanel.test.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/layerpanel.test.tsx @@ -7,12 +7,12 @@ import React from 'react'; import type { DatatableColumn } from '@kbn/expressions-plugin/public'; -import { TextBasedLanguagesPrivateState } from './types'; -import type { DataViewsState } from '../state_management/types'; +import { TextBasedPrivateState } from './types'; +import type { DataViewsState } from '../../state_management/types'; -import { TextBasedLanguageLayerPanelProps, LayerPanel } from './layerpanel'; +import { TextBasedLayerPanelProps, LayerPanel } from './layerpanel'; import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; -import { ChangeIndexPattern } from '../shared_components/dataview_picker/dataview_picker'; +import { ChangeIndexPattern } from '../../shared_components/dataview_picker/dataview_picker'; const fields = [ { @@ -38,7 +38,7 @@ const fields = [ }, ] as DatatableColumn[]; -const initialState: TextBasedLanguagesPrivateState = { +const initialState: TextBasedPrivateState = { layers: { first: { index: '1', @@ -55,7 +55,7 @@ const initialState: TextBasedLanguagesPrivateState = { fieldList: fields, }; describe('Layer Data Panel', () => { - let defaultProps: TextBasedLanguageLayerPanelProps; + let defaultProps: TextBasedLayerPanelProps; beforeEach(() => { defaultProps = { diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/layerpanel.tsx b/x-pack/plugins/lens/public/datasources/text_based/layerpanel.tsx similarity index 75% rename from x-pack/plugins/lens/public/text_based_languages_datasource/layerpanel.tsx rename to x-pack/plugins/lens/public/datasources/text_based/layerpanel.tsx index 8f8e4a91242b1..879d28a607c7f 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/layerpanel.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/layerpanel.tsx @@ -8,16 +8,15 @@ import React from 'react'; import { I18nProvider } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; -import { DatasourceLayerPanelProps } from '../types'; -import { TextBasedLanguagesPrivateState } from './types'; -import { ChangeIndexPattern } from '../shared_components/dataview_picker/dataview_picker'; +import { DatasourceLayerPanelProps } from '../../types'; +import { TextBasedPrivateState } from './types'; +import { ChangeIndexPattern } from '../../shared_components/dataview_picker/dataview_picker'; -export interface TextBasedLanguageLayerPanelProps - extends DatasourceLayerPanelProps { - state: TextBasedLanguagesPrivateState; +export interface TextBasedLayerPanelProps extends DatasourceLayerPanelProps { + state: TextBasedPrivateState; } -export function LayerPanel({ state, layerId, dataViews }: TextBasedLanguageLayerPanelProps) { +export function LayerPanel({ state, layerId, dataViews }: TextBasedLayerPanelProps) { const layer = state.layers[layerId]; const dataView = dataViews.indexPatternRefs.find((ref) => ref.id === layer.index); const notFoundTitleLabel = i18n.translate('xpack.lens.layerPanel.missingDataView', { diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/mocks.ts b/x-pack/plugins/lens/public/datasources/text_based/mocks.ts similarity index 92% rename from x-pack/plugins/lens/public/text_based_languages_datasource/mocks.ts rename to x-pack/plugins/lens/public/datasources/text_based/mocks.ts index adca02ab2299d..8b191b815100e 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/mocks.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/mocks.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { DragContextState } from '../drag_drop'; +import { DragContextState } from '../../drag_drop'; export function createMockedDragDropContext(): jest.Mocked { return { diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/text_based_languages.test.ts b/x-pack/plugins/lens/public/datasources/text_based/text_based_languages.test.ts similarity index 88% rename from x-pack/plugins/lens/public/text_based_languages_datasource/text_based_languages.test.ts rename to x-pack/plugins/lens/public/datasources/text_based/text_based_languages.test.ts index ae7e84c61b3c5..5f4df8492c9b3 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/text_based_languages.test.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/text_based_languages.test.ts @@ -8,14 +8,14 @@ import { coreMock } from '@kbn/core/public/mocks'; import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public'; import { expressionsPluginMock } from '@kbn/expressions-plugin/public/mocks'; -import { TextBasedLanguagesPersistedState, TextBasedLanguagesPrivateState } from './types'; +import { TextBasedPersistedState, TextBasedPrivateState } from './types'; import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; -import { getTextBasedLanguagesDatasource } from './text_based_languages'; -import { generateId } from '../id_generator'; -import { DatasourcePublicAPI, Datasource } from '../types'; +import { getTextBasedDatasource } from './text_based_languages'; +import { generateId } from '../../id_generator'; +import { DatasourcePublicAPI, Datasource } from '../../types'; -jest.mock('../id_generator'); +jest.mock('../../id_generator'); const fieldsOne = [ { @@ -78,14 +78,11 @@ const expectedIndexPatterns = { const indexPatterns = expectedIndexPatterns; describe('IndexPattern Data Source', () => { - let baseState: TextBasedLanguagesPrivateState; - let textBasedLanguagesDatasource: Datasource< - TextBasedLanguagesPrivateState, - TextBasedLanguagesPersistedState - >; + let baseState: TextBasedPrivateState; + let TextBasedDatasource: Datasource; beforeEach(() => { - textBasedLanguagesDatasource = getTextBasedLanguagesDatasource({ + TextBasedDatasource = getTextBasedDatasource({ storage: {} as IStorageWrapper, core: coreMock.createStart(), data: dataPluginMock.createStartContract(), @@ -127,12 +124,12 @@ describe('IndexPattern Data Source', () => { }, }, ], - } as unknown as TextBasedLanguagesPrivateState; + } as unknown as TextBasedPrivateState; }); describe('uniqueLabels', () => { it('appends a suffix to duplicates', () => { - const map = textBasedLanguagesDatasource.uniqueLabels({ + const map = TextBasedDatasource.uniqueLabels({ layers: { a: { columns: [ @@ -154,7 +151,7 @@ describe('IndexPattern Data Source', () => { index: 'foo', }, }, - } as unknown as TextBasedLanguagesPrivateState); + } as unknown as TextBasedPrivateState); expect(map).toMatchInlineSnapshot(` Object { @@ -167,7 +164,7 @@ describe('IndexPattern Data Source', () => { describe('#getPersistedState', () => { it('should persist from saved state', async () => { - expect(textBasedLanguagesDatasource.getPersistableState(baseState)).toEqual({ + expect(TextBasedDatasource.getPersistableState(baseState)).toEqual({ state: { layers: baseState.layers, }, @@ -180,7 +177,7 @@ describe('IndexPattern Data Source', () => { describe('#insertLayer', () => { it('should insert an empty layer into the previous state', () => { - expect(textBasedLanguagesDatasource.insertLayer(baseState, 'newLayer')).toEqual({ + expect(TextBasedDatasource.insertLayer(baseState, 'newLayer')).toEqual({ ...baseState, layers: { ...baseState.layers, @@ -205,7 +202,7 @@ describe('IndexPattern Data Source', () => { describe('#removeLayer', () => { it('should remove a layer', () => { - expect(textBasedLanguagesDatasource.removeLayer(baseState, 'a')).toEqual({ + expect(TextBasedDatasource.removeLayer(baseState, 'a')).toEqual({ ...baseState, layers: { a: { @@ -229,7 +226,7 @@ describe('IndexPattern Data Source', () => { describe('#createEmptyLayer', () => { it('creates state with empty layers', () => { - expect(textBasedLanguagesDatasource.createEmptyLayer('index-pattern-id')).toEqual({ + expect(TextBasedDatasource.createEmptyLayer('index-pattern-id')).toEqual({ fieldList: [], layers: {}, indexPatternRefs: [], @@ -240,7 +237,7 @@ describe('IndexPattern Data Source', () => { describe('#getLayers', () => { it('should list the current layers', () => { expect( - textBasedLanguagesDatasource.getLayers({ + TextBasedDatasource.getLayers({ layers: { a: { columns: [ @@ -279,7 +276,7 @@ describe('IndexPattern Data Source', () => { index: 'foo', }, }, - } as unknown as TextBasedLanguagesPrivateState) + } as unknown as TextBasedPrivateState) ).toEqual(['a']); }); }); @@ -298,8 +295,8 @@ describe('IndexPattern Data Source', () => { name: 'Foo', }, }, - } as unknown as TextBasedLanguagesPrivateState; - const suggestions = textBasedLanguagesDatasource.getDatasourceSuggestionsForVisualizeField( + } as unknown as TextBasedPrivateState; + const suggestions = TextBasedDatasource.getDatasourceSuggestionsForVisualizeField( state, '1', '', @@ -417,8 +414,8 @@ describe('IndexPattern Data Source', () => { index: 'foo', }, }, - } as unknown as TextBasedLanguagesPrivateState; - expect(textBasedLanguagesDatasource.getErrorMessages(state, indexPatterns)).toEqual([ + } as unknown as TextBasedPrivateState; + expect(TextBasedDatasource.getErrorMessages(state, indexPatterns)).toEqual([ { longMessage: 'error 1', shortMessage: 'error 1' }, { longMessage: 'error 2', shortMessage: 'error 2' }, ]); @@ -466,9 +463,9 @@ describe('IndexPattern Data Source', () => { index: '1', }, }, - } as unknown as TextBasedLanguagesPrivateState; + } as unknown as TextBasedPrivateState; expect( - textBasedLanguagesDatasource.isTimeBased(state, { + TextBasedDatasource.isTimeBased(state, { ...indexPatterns, }) ).toEqual(true); @@ -513,9 +510,9 @@ describe('IndexPattern Data Source', () => { index: '1', }, }, - } as unknown as TextBasedLanguagesPrivateState; + } as unknown as TextBasedPrivateState; expect( - textBasedLanguagesDatasource.isTimeBased(state, { + TextBasedDatasource.isTimeBased(state, { ...indexPatterns, '1': { ...indexPatterns['1'], timeFieldName: undefined }, }) @@ -525,10 +522,8 @@ describe('IndexPattern Data Source', () => { describe('#toExpression', () => { it('should generate an empty expression when no columns are selected', async () => { - const state = textBasedLanguagesDatasource.initialize(); - expect(textBasedLanguagesDatasource.toExpression(state, 'first', indexPatterns)).toEqual( - null - ); + const state = TextBasedDatasource.initialize(); + expect(TextBasedDatasource.toExpression(state, 'first', indexPatterns)).toEqual(null); }); it('should generate an expression for an SQL query', async () => { @@ -576,9 +571,9 @@ describe('IndexPattern Data Source', () => { { id: '2', title: 'my-fake-restricted-pattern' }, { id: '3', title: 'my-compatible-pattern' }, ], - } as unknown as TextBasedLanguagesPrivateState; + } as unknown as TextBasedPrivateState; - expect(textBasedLanguagesDatasource.toExpression(queryBaseState, 'a', indexPatterns)) + expect(TextBasedDatasource.toExpression(queryBaseState, 'a', indexPatterns)) .toMatchInlineSnapshot(` Object { "chain": Array [ @@ -621,7 +616,7 @@ describe('IndexPattern Data Source', () => { let publicAPI: DatasourcePublicAPI; beforeEach(async () => { - publicAPI = textBasedLanguagesDatasource.getPublicAPI({ + publicAPI = TextBasedDatasource.getPublicAPI({ state: baseState, layerId: 'a', indexPatterns, @@ -676,9 +671,9 @@ describe('IndexPattern Data Source', () => { }, }, ], - } as unknown as TextBasedLanguagesPrivateState; + } as unknown as TextBasedPrivateState; - publicAPI = textBasedLanguagesDatasource.getPublicAPI({ + publicAPI = TextBasedDatasource.getPublicAPI({ state, layerId: 'a', indexPatterns, @@ -701,9 +696,9 @@ describe('IndexPattern Data Source', () => { }, }, ], - } as unknown as TextBasedLanguagesPrivateState; + } as unknown as TextBasedPrivateState; - publicAPI = textBasedLanguagesDatasource.getPublicAPI({ + publicAPI = TextBasedDatasource.getPublicAPI({ state, layerId: 'a', indexPatterns, diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/text_based_languages.tsx b/x-pack/plugins/lens/public/datasources/text_based/text_based_languages.tsx similarity index 89% rename from x-pack/plugins/lens/public/text_based_languages_datasource/text_based_languages.tsx rename to x-pack/plugins/lens/public/datasources/text_based/text_based_languages.tsx index 7157f643c6e8c..d7897362e86c4 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/text_based_languages.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/text_based_languages.tsx @@ -25,25 +25,25 @@ import { DataType, TableChangeType, DatasourceDimensionTriggerProps, -} from '../types'; -import { generateId } from '../id_generator'; +} from '../../types'; +import { generateId } from '../../id_generator'; import { toExpression } from './to_expression'; -import { TextBasedLanguagesDataPanel } from './datapanel'; +import { TextBasedDataPanel } from './datapanel'; import type { - TextBasedLanguagesPrivateState, - TextBasedLanguagesPersistedState, - TextBasedLanguagesLayerColumn, - TextBasedLanguageField, + TextBasedPrivateState, + TextBasedPersistedState, + TextBasedLayerColumn, + TextBasedField, } from './types'; import { FieldSelect } from './field_select'; -import type { Datasource, IndexPatternMap } from '../types'; +import type { Datasource, IndexPatternMap } from '../../types'; import { LayerPanel } from './layerpanel'; function getLayerReferenceName(layerId: string) { return `textBasedLanguages-datasource-layer-${layerId}`; } -export function getTextBasedLanguagesDatasource({ +export function getTextBasedDatasource({ core, storage, data, @@ -56,7 +56,7 @@ export function getTextBasedLanguagesDatasource({ expressions: ExpressionsStart; dataViews: DataViewsPublicPluginStart; }) { - const getSuggestionsForState = (state: TextBasedLanguagesPrivateState) => { + const getSuggestionsForState = (state: TextBasedPrivateState) => { return Object.entries(state.layers)?.map(([id, layer]) => { return { state: { @@ -83,7 +83,7 @@ export function getTextBasedLanguagesDatasource({ }); }; const getSuggestionsForVisualizeField = ( - state: TextBasedLanguagesPrivateState, + state: TextBasedPrivateState, indexPatternId: string, fieldName: string, indexPatterns: IndexPatternMap @@ -153,11 +153,8 @@ export function getTextBasedLanguagesDatasource({ return []; }; - const TextBasedLanguagesDatasource: Datasource< - TextBasedLanguagesPrivateState, - TextBasedLanguagesPersistedState - > = { - id: 'textBasedLanguages', + const TextBasedDatasource: Datasource = { + id: 'textBased', checkIntegrity: () => { return []; @@ -188,7 +185,7 @@ export function getTextBasedLanguagesDatasource({ return errors; }, initialize( - state?: TextBasedLanguagesPersistedState, + state?: TextBasedPersistedState, savedObjectReferences?, context?, indexPatternRefs?, @@ -217,7 +214,7 @@ export function getTextBasedLanguagesDatasource({ return Object.values(state.layers).map(({ index }) => index); }, - getPersistableState({ layers }: TextBasedLanguagesPrivateState) { + getPersistableState({ layers }: TextBasedPrivateState) { const savedObjectReferences: SavedObjectReference[] = []; Object.entries(layers).forEach(([layerId, { index, ...persistableLayer }]) => { if (index) { @@ -237,7 +234,7 @@ export function getTextBasedLanguagesDatasource({ if (!column || !indexPattern) return false; return true; }, - insertLayer(state: TextBasedLanguagesPrivateState, newLayerId: string) { + insertLayer(state: TextBasedPrivateState, newLayerId: string) { const layer = Object.values(state?.layers)?.[0]; const query = layer?.query; const columns = layer?.allColumns ?? []; @@ -267,7 +264,7 @@ export function getTextBasedLanguagesDatasource({ }; }, - removeLayer(state: TextBasedLanguagesPrivateState, layerId: string) { + removeLayer(state: TextBasedPrivateState, layerId: string) { const newLayers = { ...state.layers, [layerId]: { @@ -283,7 +280,7 @@ export function getTextBasedLanguagesDatasource({ }; }, - clearLayer(state: TextBasedLanguagesPrivateState, layerId: string) { + clearLayer(state: TextBasedPrivateState, layerId: string) { return { ...state, layers: { @@ -293,7 +290,7 @@ export function getTextBasedLanguagesDatasource({ }; }, - getLayers(state: TextBasedLanguagesPrivateState) { + getLayers(state: TextBasedPrivateState) { return state && state.layers ? Object.keys(state?.layers) : []; }, isTimeBased: (state, indexPatterns) => { @@ -306,7 +303,7 @@ export function getTextBasedLanguagesDatasource({ }) ); }, - getUsedDataView: (state: TextBasedLanguagesPrivateState, layerId?: string) => { + getUsedDataView: (state: TextBasedPrivateState, layerId?: string) => { if (!layerId) { const layers = Object.values(state.layers); return layers?.[0]?.index; @@ -331,13 +328,10 @@ export function getTextBasedLanguagesDatasource({ return toExpression(state, layerId); }, - renderDataPanel( - domElement: Element, - props: DatasourceDataPanelProps - ) { + renderDataPanel(domElement: Element, props: DatasourceDataPanelProps) { render( - + props: DatasourceDimensionTriggerProps ) => { - const columnLabelMap = TextBasedLanguagesDatasource.uniqueLabels(props.state); + const columnLabelMap = TextBasedDatasource.uniqueLabels(props.state); const layer = props.state.layers[props.layerId]; const selectedField = layer?.allColumns?.find((column) => column.columnId === props.columnId); let customLabel: string | undefined = columnLabelMap[props.columnId]; @@ -377,13 +371,13 @@ export function getTextBasedLanguagesDatasource({ ); }, - getRenderEventCounters(state: TextBasedLanguagesPrivateState): string[] { + getRenderEventCounters(state: TextBasedPrivateState): string[] { return []; }, renderDimensionEditor: ( domElement: Element, - props: DatasourceDimensionEditorProps + props: DatasourceDimensionEditorProps ) => { const fields = props.state.fieldList; const selectedField = props.state.layers[props.layerId]?.allColumns?.find( @@ -450,7 +444,7 @@ export function getTextBasedLanguagesDatasource({ renderLayerPanel: ( domElement: Element, - props: DatasourceLayerPanelProps + props: DatasourceLayerPanelProps ) => { render( @@ -460,7 +454,7 @@ export function getTextBasedLanguagesDatasource({ ); }, - uniqueLabels(state: TextBasedLanguagesPrivateState) { + uniqueLabels(state: TextBasedPrivateState) { const layers = state.layers; const columnLabelMap = {} as Record; const counts = {} as Record; @@ -536,9 +530,9 @@ export function getTextBasedLanguagesDatasource({ return false; }, - getPublicAPI({ state, layerId }: PublicAPIProps) { + getPublicAPI({ state, layerId }: PublicAPIProps) { return { - datasourceId: 'textBasedLanguages', + datasourceId: 'textBased', getTableSpec: () => { const columns = state.layers[layerId]?.columns.filter((c) => { @@ -555,7 +549,7 @@ export function getTextBasedLanguagesDatasource({ getOperationForColumnId: (columnId: string) => { const layer = state.layers[layerId]; const column = layer?.allColumns?.find((c) => c.columnId === columnId); - const columnLabelMap = TextBasedLanguagesDatasource.uniqueLabels(state); + const columnLabelMap = TextBasedDatasource.uniqueLabels(state); if (column) { return { @@ -591,9 +585,7 @@ export function getTextBasedLanguagesDatasource({ }; }, getDatasourceSuggestionsForField(state, draggedField) { - const field = state.fieldList.find( - (f) => f.id === (draggedField as TextBasedLanguageField).id - ); + const field = state.fieldList.find((f) => f.id === (draggedField as TextBasedField).id); if (!field) return []; return Object.entries(state.layers)?.map(([id, layer]) => { const newId = generateId(); @@ -650,14 +642,10 @@ export function getTextBasedLanguagesDatasource({ isEqual: () => true, }; - return TextBasedLanguagesDatasource; + return TextBasedDatasource; } -function blankLayer( - index: string, - query?: AggregateQuery, - columns?: TextBasedLanguagesLayerColumn[] -) { +function blankLayer(index: string, query?: AggregateQuery, columns?: TextBasedLayerColumn[]) { return { index, query, diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/to_expression.ts b/x-pack/plugins/lens/public/datasources/text_based/to_expression.ts similarity index 80% rename from x-pack/plugins/lens/public/text_based_languages_datasource/to_expression.ts rename to x-pack/plugins/lens/public/datasources/text_based/to_expression.ts index aa7a264673a3e..dba9a93555ce2 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/to_expression.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/to_expression.ts @@ -7,13 +7,10 @@ import { Ast } from '@kbn/interpreter'; import { textBasedQueryStateToExpressionAst } from '@kbn/data-plugin/common'; -import type { OriginalColumn } from '../../common/types'; -import { TextBasedLanguagesPrivateState, TextBasedLanguagesLayer, IndexPatternRef } from './types'; +import type { OriginalColumn } from '../../../common/types'; +import { TextBasedPrivateState, TextBasedLayer, IndexPatternRef } from './types'; -function getExpressionForLayer( - layer: TextBasedLanguagesLayer, - refs: IndexPatternRef[] -): Ast | null { +function getExpressionForLayer(layer: TextBasedLayer, refs: IndexPatternRef[]): Ast | null { if (!layer.columns || layer.columns?.length === 0) { return null; } @@ -53,7 +50,7 @@ function getExpressionForLayer( return textBasedQueryToAst; } -export function toExpression(state: TextBasedLanguagesPrivateState, layerId: string) { +export function toExpression(state: TextBasedPrivateState, layerId: string) { if (state.layers[layerId]) { return getExpressionForLayer(state.layers[layerId], state.indexPatternRefs); } diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/types.ts b/x-pack/plugins/lens/public/datasources/text_based/types.ts similarity index 65% rename from x-pack/plugins/lens/public/text_based_languages_datasource/types.ts rename to x-pack/plugins/lens/public/datasources/text_based/types.ts index 11b9612624efd..0e30e0d517054 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/types.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/types.ts @@ -7,33 +7,33 @@ import type { DatatableColumn } from '@kbn/expressions-plugin/public'; import type { AggregateQuery } from '@kbn/es-query'; import type { VisualizeFieldContext } from '@kbn/ui-actions-plugin/public'; -import type { VisualizeEditorContext } from '../types'; +import type { VisualizeEditorContext } from '../../types'; -export interface TextBasedLanguagesLayerColumn { +export interface TextBasedLayerColumn { columnId: string; fieldName: string; meta?: DatatableColumn['meta']; } -export interface TextBasedLanguageField { +export interface TextBasedField { id: string; field: string; } -export interface TextBasedLanguagesLayer { +export interface TextBasedLayer { index: string; query: AggregateQuery | undefined; - columns: TextBasedLanguagesLayerColumn[]; - allColumns: TextBasedLanguagesLayerColumn[]; + columns: TextBasedLayerColumn[]; + allColumns: TextBasedLayerColumn[]; timeField?: string; errors?: Error[]; } -export interface TextBasedLanguagesPersistedState { - layers: Record; +export interface TextBasedPersistedState { + layers: Record; } -export type TextBasedLanguagesPrivateState = TextBasedLanguagesPersistedState & { +export type TextBasedPrivateState = TextBasedPersistedState & { indexPatternRefs: IndexPatternRef[]; fieldList: DatatableColumn[]; initialContext?: VisualizeFieldContext | VisualizeEditorContext; diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/utils.test.ts b/x-pack/plugins/lens/public/datasources/text_based/utils.test.ts similarity index 97% rename from x-pack/plugins/lens/public/text_based_languages_datasource/utils.test.ts rename to x-pack/plugins/lens/public/datasources/text_based/utils.test.ts index 1e7096414d19e..1698ae536f44f 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/utils.test.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/utils.test.ts @@ -9,14 +9,14 @@ import type { DatatableColumn } from '@kbn/expressions-plugin/public'; import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { expressionsPluginMock } from '@kbn/expressions-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; -import { mockDataViewsService } from '../data_views_service/mocks'; +import { mockDataViewsService } from '../../data_views_service/mocks'; import { getIndexPatternFromTextBasedQuery, loadIndexPatternRefs, getStateFromAggregateQuery, getAllColumns, } from './utils'; -import type { TextBasedLanguagesLayerColumn } from './types'; +import type { TextBasedLayerColumn } from './types'; import { type AggregateQuery } from '@kbn/es-query'; jest.mock('./fetch_data_from_aggregate_query', () => ({ @@ -92,7 +92,7 @@ describe('Text based languages utils', () => { type: 'number', }, }, - ] as TextBasedLanguagesLayerColumn[]; + ] as TextBasedLayerColumn[]; const columnsFromQuery = [ { name: 'timestamp', diff --git a/x-pack/plugins/lens/public/text_based_languages_datasource/utils.ts b/x-pack/plugins/lens/public/datasources/text_based/utils.ts similarity index 92% rename from x-pack/plugins/lens/public/text_based_languages_datasource/utils.ts rename to x-pack/plugins/lens/public/datasources/text_based/utils.ts index 5504cd39bd6a1..5078c967ff9e8 100644 --- a/x-pack/plugins/lens/public/text_based_languages_datasource/utils.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/utils.ts @@ -10,14 +10,10 @@ import type { ExpressionsStart } from '@kbn/expressions-plugin/public'; import { type AggregateQuery, getIndexPatternFromSQLQuery } from '@kbn/es-query'; import type { DatatableColumn } from '@kbn/expressions-plugin/public'; -import { generateId } from '../id_generator'; +import { generateId } from '../../id_generator'; import { fetchDataFromAggregateQuery } from './fetch_data_from_aggregate_query'; -import type { - IndexPatternRef, - TextBasedLanguagesPrivateState, - TextBasedLanguagesLayerColumn, -} from './types'; +import type { IndexPatternRef, TextBasedPrivateState, TextBasedLayerColumn } from './types'; export async function loadIndexPatternRefs( indexPatternsService: DataViewsPublicPluginStart @@ -36,7 +32,7 @@ export async function loadIndexPatternRefs( } export const getAllColumns = ( - existingColumns: TextBasedLanguagesLayerColumn[], + existingColumns: TextBasedLayerColumn[], columnsFromQuery: DatatableColumn[] ) => { // filter out columns that do not exist on the query @@ -64,7 +60,7 @@ export const getAllColumns = ( }; export async function getStateFromAggregateQuery( - state: TextBasedLanguagesPrivateState, + state: TextBasedPrivateState, query: AggregateQuery, dataViews: DataViewsPublicPluginStart, data: DataPublicPluginStart, @@ -80,7 +76,7 @@ export async function getStateFromAggregateQuery( // get the id of the dataview const index = indexPatternRefs.find((r) => r.title === indexPattern)?.id ?? ''; let columnsFromQuery: DatatableColumn[] = []; - let allColumns: TextBasedLanguagesLayerColumn[] = []; + let allColumns: TextBasedLayerColumn[] = []; let timeFieldName; try { const table = await fetchDataFromAggregateQuery(query, dataViews, data, expressions); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_helpers.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_helpers.ts index c96a022f4aed2..81298a97f650e 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_helpers.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_helpers.ts @@ -209,7 +209,7 @@ export function getVisualizeFieldSuggestions({ // suggestions for visualizing textbased languages if (visualizeTriggerFieldContext && 'query' in visualizeTriggerFieldContext) { if (visualizeTriggerFieldContext.query) { - return suggestions.find((s) => s.datasourceId === 'textBasedLanguages'); + return suggestions.find((s) => s.datasourceId === 'textBased'); } } diff --git a/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx b/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx index 98c8d363a45b7..56939b54299ce 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx @@ -22,7 +22,7 @@ import { } from '@kbn/embeddable-plugin/public'; import type { LensByReferenceInput, LensByValueInput } from './embeddable'; import type { Document } from '../persistence'; -import type { IndexPatternPersistedState } from '../indexpattern_datasource/types'; +import type { FormBasedPersistedState } from '../datasources/form_based/types'; import type { XYState } from '../visualizations/xy/types'; import type { PieVisualizationState, LegacyMetricState } from '../../common'; import type { DatatableVisualizationState } from '../visualizations/datatable/visualization'; @@ -37,7 +37,7 @@ type LensAttributes = Omit< visualizationType: TVisType; state: Omit & { datasourceStates: { - indexpattern: IndexPatternPersistedState; + formBased: FormBasedPersistedState; }; visualization: TVisState; }; diff --git a/x-pack/plugins/lens/public/index.ts b/x-pack/plugins/lens/public/index.ts index 9efe67c4283e3..54380bd7eec63 100644 --- a/x-pack/plugins/lens/public/index.ts +++ b/x-pack/plugins/lens/public/index.ts @@ -44,7 +44,7 @@ export type { DatatableVisualizationState } from './visualizations/datatable/vis export type { HeatmapVisualizationState } from './visualizations/heatmap/types'; export type { GaugeVisualizationState } from './visualizations/gauge/constants'; export type { - IndexPatternPersistedState, + FormBasedPersistedState, PersistedIndexPatternLayer, OperationType, IncompleteColumn, @@ -75,8 +75,8 @@ export type { FormulaPublicApi, StaticValueIndexPatternColumn, TimeScaleIndexPatternColumn, - IndexPatternLayer, -} from './indexpattern_datasource/types'; + FormBasedLayer, +} from './datasources/form_based/types'; export type { XYArgs, XYRender, diff --git a/x-pack/plugins/lens/public/plugin.ts b/x-pack/plugins/lens/public/plugin.ts index 6b06978befea7..c4d4cf9bfab9f 100644 --- a/x-pack/plugins/lens/public/plugin.ts +++ b/x-pack/plugins/lens/public/plugin.ts @@ -52,11 +52,11 @@ import type { AdvancedUiActionsSetup } from '@kbn/ui-actions-enhanced-plugin/pub import type { DocLinksStart } from '@kbn/core-doc-links-browser'; import type { EditorFrameService as EditorFrameServiceType } from './editor_frame_service'; import type { - IndexPatternDatasource as IndexPatternDatasourceType, - IndexPatternDatasourceSetupPlugins, + FormBasedDatasource as FormBasedDatasourceType, + FormBasedDatasourceSetupPlugins, FormulaPublicApi, -} from './indexpattern_datasource'; -import type { TextBasedLanguagesDatasource as TextBasedLanguagesDatasourceType } from './text_based_languages_datasource'; +} from './datasources/form_based'; +import type { TextBasedDatasource as TextBasedDatasourceType } from './datasources/text_based'; import type { XyVisualization as XyVisualizationType, @@ -231,8 +231,8 @@ export class LensPlugin { private editorFrameService: EditorFrameServiceType | undefined; private editorFrameSetup: EditorFrameSetup | undefined; private queuedVisualizations: Array Promise)> = []; - private indexpatternDatasource: IndexPatternDatasourceType | undefined; - private textBasedLanguagesDatasource: TextBasedLanguagesDatasourceType | undefined; + private FormBasedDatasource: FormBasedDatasourceType | undefined; + private TextBasedDatasource: TextBasedDatasourceType | undefined; private xyVisualization: XyVisualizationType | undefined; private legacyMetricVisualization: LegacyMetricVisualizationType | undefined; private metricVisualization: MetricVisualizationType | undefined; @@ -423,19 +423,19 @@ export class LensPlugin { const { DatatableVisualization, EditorFrameService, - IndexPatternDatasource, + FormBasedDatasource, XyVisualization, LegacyMetricVisualization, MetricVisualization, PieVisualization, HeatmapVisualization, GaugeVisualization, - TextBasedLanguagesDatasource, + TextBasedDatasource, } = await import('./async_services'); this.datatableVisualization = new DatatableVisualization(); this.editorFrameService = new EditorFrameService(); - this.indexpatternDatasource = new IndexPatternDatasource(); - this.textBasedLanguagesDatasource = new TextBasedLanguagesDatasource(); + this.FormBasedDatasource = new FormBasedDatasource(); + this.TextBasedDatasource = new TextBasedDatasource(); this.xyVisualization = new XyVisualization(); this.legacyMetricVisualization = new LegacyMetricVisualization(); this.metricVisualization = new MetricVisualization(); @@ -445,7 +445,7 @@ export class LensPlugin { const editorFrameSetupInterface = this.editorFrameService.setup(); - const dependencies: IndexPatternDatasourceSetupPlugins & + const dependencies: FormBasedDatasourceSetupPlugins & XyVisualizationPluginSetupPlugins & DatatableVisualizationPluginSetupPlugins & LegacyMetricVisualizationPluginSetupPlugins & @@ -458,8 +458,8 @@ export class LensPlugin { formatFactory, eventAnnotation, }; - this.indexpatternDatasource.setup(core, dependencies); - this.textBasedLanguagesDatasource.setup(core, dependencies); + this.FormBasedDatasource.setup(core, dependencies); + this.TextBasedDatasource.setup(core, dependencies); this.xyVisualization.setup(core, dependencies); this.datatableVisualization.setup(core, dependencies); this.legacyMetricVisualization.setup(core, dependencies); diff --git a/x-pack/plugins/lens/public/shared_components/field_picker/lens_field_icon.tsx b/x-pack/plugins/lens/public/shared_components/field_picker/lens_field_icon.tsx index fabb8cab6fd0e..e3be012647e8c 100644 --- a/x-pack/plugins/lens/public/shared_components/field_picker/lens_field_icon.tsx +++ b/x-pack/plugins/lens/public/shared_components/field_picker/lens_field_icon.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { FieldIcon, FieldIconProps } from '@kbn/react-field'; import { DataType } from '../../types'; -import { normalizeOperationDataType } from '../../indexpattern_datasource/pure_utils'; +import { normalizeOperationDataType } from '../../datasources/form_based/pure_utils'; export function LensFieldIcon({ type, ...rest }: FieldIconProps & { type: DataType }) { return ( diff --git a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts index 5b942eff4a683..69e93f7a763a3 100644 --- a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts +++ b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts @@ -117,7 +117,7 @@ export function loadInitial( let activeDatasourceId: string | undefined; if (initialContext && 'query' in initialContext) { - activeDatasourceId = 'textBasedLanguages'; + activeDatasourceId = 'textBased'; } if ( diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts index 29aff3d428690..bed1acfad574f 100644 --- a/x-pack/plugins/lens/public/types.ts +++ b/x-pack/plugins/lens/public/types.ts @@ -47,7 +47,7 @@ import { LENS_EDIT_PAGESIZE_ACTION, } from './visualizations/datatable/components/constants'; import type { LensInspector } from './lens_inspector_service'; -import type { FormatSelectorOptions } from './indexpattern_datasource/dimension_panel/format_selector'; +import type { FormatSelectorOptions } from './datasources/form_based/dimension_panel/format_selector'; import type { DataViewsState } from './state_management/types'; import type { IndexPatternServiceAPI } from './data_views_service/service'; import type { Document } from './persistence/saved_object_store'; diff --git a/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx b/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx index ad5e8118c5226..27ac3d5b092b9 100644 --- a/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx @@ -29,7 +29,7 @@ import type { LayerType } from '../../../common'; import { getDefaultSummaryLabel } from '../../../common/expressions/datatable/summary'; import type { ColumnState, SortingState, PagingState } from '../../../common/expressions'; import { DataTableToolbar } from './components/toolbar'; -import type { IndexPatternLayer } from '../../indexpattern_datasource/types'; +import type { FormBasedLayer } from '../../datasources/form_based/types'; export interface DatatableVisualizationState { columns: ColumnState[]; @@ -45,7 +45,7 @@ export interface DatatableVisualizationState { interface DatatableDatasourceState { [prop: string]: unknown; - layers: IndexPatternLayer[]; + layers: FormBasedLayer[]; } export interface DatatableSuggestion extends Suggestion { diff --git a/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx b/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx index 99120c90942d4..f78529a17c8f4 100644 --- a/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx @@ -37,7 +37,7 @@ import { applyPaletteParams } from '../../shared_components'; import { GaugeDimensionEditor } from './dimension_editor'; import { generateId } from '../../id_generator'; import { getAccessorsFromState } from './utils'; -import { IndexPatternLayer } from '../..'; +import { FormBasedLayer } from '../..'; const groupLabelForGauge = i18n.translate('xpack.lens.metric.groupLabel', { defaultMessage: 'Goal and single value', @@ -50,7 +50,7 @@ interface GaugeVisualizationDeps { interface GaugeDatasourceState { [prop: string]: unknown; - layers: IndexPatternLayer[]; + layers: FormBasedLayer[]; } export interface GaugeSuggestion extends Suggestion { diff --git a/x-pack/plugins/lens/public/visualizations/metric/visualization.tsx b/x-pack/plugins/lens/public/visualizations/metric/visualization.tsx index e3b42fedc45e4..5fe14fb58cc21 100644 --- a/x-pack/plugins/lens/public/visualizations/metric/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/metric/visualization.tsx @@ -31,8 +31,8 @@ import { GROUP_ID, LENS_METRIC_ID } from './constants'; import { DimensionEditor } from './dimension_editor'; import { Toolbar } from './toolbar'; import { generateId } from '../../id_generator'; -import { FormatSelectorOptions } from '../../indexpattern_datasource/dimension_panel/format_selector'; -import { IndexPatternLayer } from '../../indexpattern_datasource/types'; +import { FormatSelectorOptions } from '../../datasources/form_based/dimension_panel/format_selector'; +import { FormBasedLayer } from '../../datasources/form_based/types'; export const DEFAULT_MAX_COLUMNS = 3; @@ -59,7 +59,7 @@ export interface MetricVisualizationState { interface MetricDatasourceState { [prop: string]: unknown; - layers: IndexPatternLayer[]; + layers: FormBasedLayer[]; } export interface MetricSuggestion extends Suggestion { diff --git a/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx b/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx index 49a485debcf27..cf30fbcc1ceff 100644 --- a/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx @@ -37,11 +37,11 @@ import { suggestions } from './suggestions'; import { PartitionChartsMeta } from './partition_charts_meta'; import { DimensionEditor, PieToolbar } from './toolbar'; import { checkTableForContainsSmallValues } from './render_helpers'; -import type { IndexPatternLayer } from '../..'; +import type { FormBasedLayer } from '../..'; interface DatatableDatasourceState { [prop: string]: unknown; - layers: IndexPatternLayer[]; + layers: FormBasedLayer[]; } export interface PartitionSuggestion extends Suggestion { diff --git a/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts b/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts index 6c2d61d7bb869..8c6da8bf95a6b 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts @@ -28,7 +28,7 @@ import { EventAnnotationConfig } from '@kbn/event-annotation-plugin/common'; import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public'; import { DataViewsState } from '../../state_management'; -import { createMockedIndexPattern } from '../../indexpattern_datasource/mocks'; +import { createMockedIndexPattern } from '../../datasources/form_based/mocks'; import { createMockDataViewsState } from '../../data_views_service/mocks'; import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks'; diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.test.tsx index 7d581d50d0859..185a73c64d4e6 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.test.tsx @@ -18,7 +18,7 @@ import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import moment from 'moment'; import { EventAnnotationConfig } from '@kbn/event-annotation-plugin/common'; import { createMockDataViewsState } from '../../../../data_views_service/mocks'; -import { createMockedIndexPattern } from '../../../../indexpattern_datasource/mocks'; +import { createMockedIndexPattern } from '../../../../datasources/form_based/mocks'; import { act } from 'react-dom/test-utils'; import { EuiButtonGroup } from '@elastic/eui'; diff --git a/x-pack/plugins/lens/readme.md b/x-pack/plugins/lens/readme.md index d8b80e864be58..d276a45eb00ac 100644 --- a/x-pack/plugins/lens/readme.md +++ b/x-pack/plugins/lens/readme.md @@ -82,7 +82,7 @@ References (`references`) are regular saved object references forming a graph of ### Datasource state -The data source state (`state.datasourceStates.indexPattern.layers`) contains the configuration state of the data fetching and processing part of Lens. It's not specific to a certain representation (xy, pie, gauge, ...), but instead it defines a data table per layer made out of columns with various properties. This data table is passed over to the visualization state which maps it to various dimensions of the specific visualization. Layer and columns have unique ids which are shared amongst visualization and datasource - it's important to make sure they are always in sync. The keys of the `state.datasourceStates.indexPattern.layers` object are the layer ids. Lens editor chooses uuids for these, but when programmatically generating Lens attributes, any string can be used for them. The `layers[].columns` object is constructed in a similar way (keys represent the column ids). The `operationType` property defines the type of the column, other properties depend on the specific operation. Types for individual parts of the datasource state are provided (check the `lens/public` export, e.g. there's the `MaxIndexPatternColumn` for a column of operation type `max`) +The data source state (`state.datasourceStates.formBased.layers`) contains the configuration state of the data fetching and processing part of Lens. It's not specific to a certain representation (xy, pie, gauge, ...), but instead it defines a data table per layer made out of columns with various properties. This data table is passed over to the visualization state which maps it to various dimensions of the specific visualization. Layer and columns have unique ids which are shared amongst visualization and datasource - it's important to make sure they are always in sync. The keys of the `state.datasourceStates.formBased.layers` object are the layer ids. Lens editor chooses uuids for these, but when programmatically generating Lens attributes, any string can be used for them. The `layers[].columns` object is constructed in a similar way (keys represent the column ids). The `operationType` property defines the type of the column, other properties depend on the specific operation. Types for individual parts of the datasource state are provided (check the `lens/public` export, e.g. there's the `MaxIndexPatternColumn` for a column of operation type `max`) ### Visualization state diff --git a/x-pack/plugins/lens/server/embeddable/make_lens_embeddable_factory.ts b/x-pack/plugins/lens/server/embeddable/make_lens_embeddable_factory.ts index 8b977fbce5742..42846e84377dd 100644 --- a/x-pack/plugins/lens/server/embeddable/make_lens_embeddable_factory.ts +++ b/x-pack/plugins/lens/server/embeddable/make_lens_embeddable_factory.ts @@ -7,6 +7,7 @@ import { EmbeddableRegistryDefinition } from '@kbn/embeddable-plugin/server'; import type { SerializableRecord } from '@kbn/utility-types'; +import type { SavedObject } from '@kbn/core-saved-objects-common'; import { mergeMigrationFunctionMaps, MigrateFunctionsObject, @@ -31,6 +32,7 @@ import { getLensDataViewMigrations, commonMigrateMetricIds, commonMigratePartitionChartGroups, + commonMigrateIndexPatternDatasource, } from '../migrations/common_migrations'; import { CustomVisualizationMigrations, @@ -155,6 +157,15 @@ export const makeLensEmbeddableFactory = attributes: migratedLensState, } as unknown as SerializableRecord; }, + '8.6.0': (state) => { + const lensState = state as unknown as SavedObject>; + + const migratedLensState = commonMigrateIndexPatternDatasource(lensState.attributes); + return { + ...lensState, + attributes: migratedLensState, + } as unknown as SerializableRecord; + }, }), getLensCustomVisualizationMigrations(customVisualizationMigrations) ), diff --git a/x-pack/plugins/lens/server/migrations/common_migrations.ts b/x-pack/plugins/lens/server/migrations/common_migrations.ts index 4afe60729920f..b56f4b691911b 100644 --- a/x-pack/plugins/lens/server/migrations/common_migrations.ts +++ b/x-pack/plugins/lens/server/migrations/common_migrations.ts @@ -34,6 +34,7 @@ import { XYVisStatePre850, VisState850, LensDocShape850, + LensDocShape860, } from './types'; import { DOCUMENT_FIELD_NAME, LegacyMetricState } from '../../common'; import { isPartitionShape } from '../../common/visualizations'; @@ -477,6 +478,22 @@ export const commonMigrateMetricIds = ( return newAttributes; }; +export const commonMigrateIndexPatternDatasource = ( + attributes: LensDocShape850 +): LensDocShape860 => { + const newAttrs = { + ...attributes, + state: { + ...attributes.state, + datasourceStates: { + formBased: attributes.state.datasourceStates.indexpattern, + }, + }, + }; + + return newAttrs; +}; + export const commonMigratePartitionChartGroups = ( attributes: LensDocShape850<{ shape: string; diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts index fcb1e2a5722f1..54504b9201f67 100644 --- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts +++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts @@ -2363,4 +2363,100 @@ describe('Lens migrations', () => { expect(result.attributes.visualizationType).toBe('lnsMetric'); }); }); + + describe('8.6.0 migrates indexpattern datasource', () => { + const context = { log: { warn: () => {} } } as unknown as SavedObjectMigrationContext; + const example = { + type: 'lens', + id: 'mock-saved-object-id', + attributes: { + state: { + datasourceMetaData: { + filterableIndexPatterns: [ + { + id: 'logstash-*', + title: 'logstash-*', + }, + ], + }, + datasourceStates: { + indexpattern: { + currentIndexPatternId: 'logstash-*', + layers: { + 'c61a8afb-a185-4fae-a064-fb3846f6c451': { + columnOrder: ['2cd09808-3915-49f4-b3b0-82767eba23f7'], + columns: { + '2cd09808-3915-49f4-b3b0-82767eba23f7': { + dataType: 'number', + isBucketed: false, + label: 'Maximum of bytes', + operationType: 'max', + scale: 'ratio', + sourceField: 'bytes', + }, + 'd3e62a7a-c259-4fff-a2fc-eebf20b7008a': { + dataType: 'number', + isBucketed: false, + label: 'Minimum of bytes', + operationType: 'min', + scale: 'ratio', + sourceField: 'bytes', + }, + 'd6e40cea-6299-43b4-9c9d-b4ee305a2ce8': { + dataType: 'date', + isBucketed: true, + label: 'Date Histogram of @timestamp', + operationType: 'date_histogram', + params: { + interval: 'auto', + }, + scale: 'interval', + sourceField: '@timestamp', + }, + }, + indexPatternId: 'logstash-*', + }, + }, + }, + }, + filters: [], + query: { + language: 'kuery', + query: '', + }, + visualization: { + accessor: '2cd09808-3915-49f4-b3b0-82767eba23f7', + isHorizontal: false, + layerId: 'c61a8afb-a185-4fae-a064-fb3846f6c451', + layers: [ + { + accessors: [ + 'd3e62a7a-c259-4fff-a2fc-eebf20b7008a', + '26ef70a9-c837-444c-886e-6bd905ee7335', + ], + layerId: 'c61a8afb-a185-4fae-a064-fb3846f6c451', + seriesType: 'area', + splitAccessor: '54cd64ed-2a44-4591-af84-b2624504569a', + xAccessor: 'd6e40cea-6299-43b4-9c9d-b4ee305a2ce8', + }, + ], + legend: { + isVisible: true, + position: 'right', + }, + preferredSeriesType: 'area', + }, + }, + title: 'Artistpreviouslyknownaslens', + visualizationType: 'lnsXY', + }, + }; + + it('migrates the indexpattern datasource to formBased', () => { + const result = migrations['8.6.0'](example, context); + expect(result.attributes.state.datasourceStates.formBased).toBe( + example.attributes.state.datasourceStates.indexpattern + ); + }); + }); }); diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts index 2f02ca358fcc0..8e4914b94fe83 100644 --- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts +++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts @@ -38,6 +38,7 @@ import { LensDocShape850, LensDocShape840, VisState850, + LensDocShape860, } from './types'; import { commonRenameOperationsForFormula, @@ -59,6 +60,7 @@ import { getLensDataViewMigrations, commonMigrateMetricIds, commonMigratePartitionChartGroups, + commonMigrateIndexPatternDatasource, } from './common_migrations'; interface LensDocShapePre710 { @@ -533,6 +535,13 @@ const migrateMetricIds: SavedObjectMigrationFn attributes: commonMigrateMetricIds(doc.attributes), }); +const migrateIndexPatternDatasource: SavedObjectMigrationFn = ( + doc +) => ({ + ...doc, + attributes: commonMigrateIndexPatternDatasource(doc.attributes), +}); + const migratePartitionChartGroups: SavedObjectMigrationFn = ( doc ) => ({ @@ -566,6 +575,7 @@ const lensMigrations: SavedObjectMigrationMap = { ), '8.3.0': flow(lockOldMetricVisSettings, preserveOldLegendSizeDefault, fixValueLabelsInXY), '8.5.0': flow(migrateMetricIds, enrichAnnotationLayers, migratePartitionChartGroups), + '8.6.0': flow(migrateIndexPatternDatasource), }; export const getAllMigrations = ( diff --git a/x-pack/plugins/lens/server/migrations/types.ts b/x-pack/plugins/lens/server/migrations/types.ts index 87c993a712e01..061ba113f734a 100644 --- a/x-pack/plugins/lens/server/migrations/types.ts +++ b/x-pack/plugins/lens/server/migrations/types.ts @@ -303,3 +303,24 @@ export type VisState840 = VisState830; export type LensDocShape840 = LensDocShape830; export type LensDocShape850 = LensDocShape840; + +export type LensDocShape860 = Omit< + LensDocShape850, + 'state' +> & { + state: Omit['state'], 'datasourceStates'> & { + datasourceStates: { + // This is hardcoded as our only datasource + formBased: { + currentIndexPatternId: string; + layers: Record< + string, + { + columnOrder: string[]; + columns: Record>; + } + >; + }; + }; + }; +}; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/job_from_lens/visualization_extractor.ts b/x-pack/plugins/ml/public/application/jobs/new_job/job_from_lens/visualization_extractor.ts index d3fe88a390c1e..31cec1635968f 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/job_from_lens/visualization_extractor.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/job_from_lens/visualization_extractor.ts @@ -14,8 +14,8 @@ import type { LensSavedObjectAttributes, FieldBasedIndexPatternColumn, XYDataLayerConfig, - IndexPatternPersistedState, - IndexPatternLayer, + FormBasedPersistedState, + FormBasedLayer, XYLayerConfig, } from '@kbn/lens-plugin/public'; import { layerTypes } from '@kbn/lens-plugin/public'; @@ -68,7 +68,7 @@ export class VisualizationExtractor { ); } - const indexpattern = vis.state.datasourceStates.indexpattern as IndexPatternPersistedState; + const indexpattern = vis.state.datasourceStates.formBased as FormBasedPersistedState; const compatibleIndexPatternLayer = Object.entries(indexpattern.layers).find( ([id]) => layer.layerId === id ); @@ -192,10 +192,7 @@ export class VisualizationExtractor { } } -function getColumns( - { columns }: Omit, - layer: XYDataLayerConfig -) { +function getColumns({ columns }: Omit, layer: XYDataLayerConfig) { layer.accessors.forEach((a) => { const col = columns[a]; // fail early if any of the cols being used as accessors diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts index 8f2953a45834e..a21684bd0d08c 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts @@ -118,7 +118,7 @@ describe('Lens Attribute', () => { ReportTypes.KPI ); - expect(lnsAttrKpi.getJSON().state.datasourceStates.indexpattern.layers.layer0.columns).toEqual({ + expect(lnsAttrKpi.getJSON().state.datasourceStates.formBased.layers.layer0.columns).toEqual({ 'x-axis-column-layer0': { dataType: 'date', isBucketed: true, @@ -352,7 +352,7 @@ describe('Lens Attribute', () => { }); it('should return first layer', function () { - expect(lnsAttr.getLayers()).toEqual(sampleAttribute.state.datasourceStates.indexpattern.layers); + expect(lnsAttr.getLayers()).toEqual(sampleAttribute.state.datasourceStates.formBased.layers); }); it('should return expected XYState', function () { diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.ts index 3c8c2e5d4bffb..50701e12f94be 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.ts @@ -1100,7 +1100,7 @@ export class LensAttributes { references: this.getReferences(), state: { datasourceStates: { - indexpattern: { + formBased: { layers: this.layers, }, }, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/sample_formula_metric_attribute.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/sample_formula_metric_attribute.ts index d6f572fcacde6..c70d0ee031451 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/sample_formula_metric_attribute.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/sample_formula_metric_attribute.ts @@ -21,7 +21,7 @@ export const sampleMetricFormulaAttribute = { ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer0: { columnOrder: [ diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/single_metric_attributes.test.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/single_metric_attributes.test.ts index 2f06db3ae144a..d6c5bfea5f1d6 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/single_metric_attributes.test.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/single_metric_attributes.test.ts @@ -74,7 +74,7 @@ describe('SingleMetricAttributes', () => { ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer0: { columnOrder: ['layer-0-column-1'], @@ -136,7 +136,7 @@ describe('SingleMetricAttributes', () => { ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer0: { columnOrder: ['layer-0-column-1'], diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/single_metric_attributes.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/single_metric_attributes.ts index 4dbc2dd86740a..f674ab1f9914f 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/single_metric_attributes.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes/single_metric_attributes.ts @@ -188,7 +188,7 @@ export class SingleMetricLensAttributes extends LensAttributes { state: { visualization, datasourceStates: { - indexpattern: { + formBased: { layers: this.layers, }, }, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/mobile_test_attribute.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/mobile_test_attribute.ts index 02678ad91ba12..874d6e45b2234 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/mobile_test_attribute.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/mobile_test_attribute.ts @@ -23,7 +23,7 @@ export const testMobileKPIAttr = { visualizationType: 'lnsXY', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer0: { columnOrder: ['x-axis-column-layer0', 'y-axis-column-layer0'], diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts index dcc2775a54871..5302078d372ce 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts @@ -27,7 +27,7 @@ export const sampleAttribute = { ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer0: { columnOrder: [ diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_cwv.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_cwv.ts index a688962459a24..108112e43ae35 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_cwv.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_cwv.ts @@ -22,7 +22,7 @@ export const sampleAttributeCoreWebVital = { ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer0: { columnOrder: [ diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_kpi.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_kpi.ts index c5b62ce3f14b4..c1bd53c85b760 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_kpi.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_kpi.ts @@ -22,7 +22,7 @@ export const sampleAttributeKpi = { ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer0: { columnOrder: ['x-axis-column-layer0', 'y-axis-column-layer0'], diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_with_reference_lines.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_with_reference_lines.ts index 32d3d480e777d..2cf6cdc8a6054 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_with_reference_lines.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_with_reference_lines.ts @@ -27,7 +27,7 @@ export const sampleAttributeWithReferenceLines = { ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer0: { columnOrder: [ diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/embeddable/embeddable.test.tsx b/x-pack/plugins/observability/public/components/shared/exploratory_view/embeddable/embeddable.test.tsx index fecb9e7172cc6..a6c3cd1777ec5 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/embeddable/embeddable.test.tsx +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/embeddable/embeddable.test.tsx @@ -32,7 +32,7 @@ const mockLensAttrs = { }, filters: [], datasourceStates: { - indexpattern: { + formBased: { layers: { '416b6fad-1923-4f6a-a2df-b223bb287e30': { columnOrder: ['b00c65ea-32be-4163-bfc8-f795b1ef9d06'], diff --git a/x-pack/plugins/osquery/public/lens/view_results_in_lens.tsx b/x-pack/plugins/osquery/public/lens/view_results_in_lens.tsx index 080c078f6a290..a61e986fd1201 100644 --- a/x-pack/plugins/osquery/public/lens/view_results_in_lens.tsx +++ b/x-pack/plugins/osquery/public/lens/view_results_in_lens.tsx @@ -174,7 +174,7 @@ function getLensAttributes( ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer1: dataLayer, }, diff --git a/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx b/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx index 2ba4a76c48515..df08fa6d1bf9b 100644 --- a/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx +++ b/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx @@ -151,7 +151,7 @@ function getLensAttributes( ], state: { datasourceStates: { - indexpattern: { + formBased: { layers: { layer1: dataLayer, }, diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/__snapshots__/authentication.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/__snapshots__/authentication.test.ts.snap index 747487203066b..f683d2828bae3 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/__snapshots__/authentication.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/__snapshots__/authentication.test.ts.snap @@ -27,7 +27,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "3fd0c5d5-f762-4a27-8c56-14eee0223e13": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/__snapshots__/external_alert.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/__snapshots__/external_alert.test.ts.snap index ac42b228012fe..425f545129ee6 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/__snapshots__/external_alert.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/__snapshots__/external_alert.test.ts.snap @@ -27,7 +27,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "a3c54471-615f-4ff9-9fda-69b5b2ea3eef": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/authentication.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/authentication.ts index 15d7f029ae612..4e69bac6287ec 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/authentication.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/authentication.ts @@ -98,7 +98,7 @@ export const authenticationLensAttributes: LensAttributes = { }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { '3fd0c5d5-f762-4a27-8c56-14eee0223e13': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/external_alert.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/external_alert.ts index a815d442b043e..f5a664b98161b 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/external_alert.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/common/external_alert.ts @@ -71,7 +71,7 @@ export const getExternalAlertLensAttributes: GetLensAttributes = ( }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { 'a3c54471-615f-4ff9-9fda-69b5b2ea3eef': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/event.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/event.test.ts.snap index 7f3fdb6c66107..129a82aa1692c 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/event.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/event.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "0039eb0c-9a1a-4687-ae54-0f4e239bec75": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_host_area.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_host_area.test.ts.snap index c5e4e272ec9c4..b9165ea5c38a8 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_host_area.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_host_area.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "416b6fad-1923-4f6a-a2df-b223bb287e30": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_host_metric.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_host_metric.test.ts.snap index 3669de2d30109..ea37bec0d1976 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_host_metric.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_host_metric.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "416b6fad-1923-4f6a-a2df-b223bb287e30": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_area.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_area.test.ts.snap index acaf78556269f..f45cd86c70ed2 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_area.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_area.test.ts.snap @@ -22,7 +22,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "8be0156b-d423-4a39-adf1-f54d4c9f2e69": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_bar.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_bar.test.ts.snap index 9f702ecb06412..0a66d46f9a7db 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_bar.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_bar.test.ts.snap @@ -22,7 +22,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "8be0156b-d423-4a39-adf1-f54d4c9f2e69": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_destination_metric.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_destination_metric.test.ts.snap index ebeb85e27a44f..3ca56d9f020b2 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_destination_metric.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_destination_metric.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "8be0156b-d423-4a39-adf1-f54d4c9f2e69": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_source_metric.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_source_metric.test.ts.snap index f8ec7bb8c70d7..2972842a6f419 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_source_metric.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/__snapshots__/kpi_unique_ips_source_metric.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "8be0156b-d423-4a39-adf1-f54d4c9f2e69": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/events.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/events.ts index da244d40565fb..f07716f8c4bd7 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/events.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/events.ts @@ -53,7 +53,7 @@ export const getEventsHistogramLensAttributes: GetLensAttributes = ( }, filters: [], datasourceStates: { - indexpattern: { + formBased: { layers: { '0039eb0c-9a1a-4687-ae54-0f4e239bec75': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_host_area.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_host_area.ts index 64f62133e9406..6eb400734ebe0 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_host_area.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_host_area.ts @@ -12,7 +12,7 @@ export const kpiHostAreaLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { '416b6fad-1923-4f6a-a2df-b223bb287e30': { columnOrder: [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_host_metric.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_host_metric.ts index 00ab0239acb40..66b6b63a69321 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_host_metric.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_host_metric.ts @@ -11,7 +11,7 @@ export const kpiHostMetricLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { '416b6fad-1923-4f6a-a2df-b223bb287e30': { columnOrder: ['b00c65ea-32be-4163-bfc8-f795b1ef9d06'], diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_area.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_area.ts index ac0d102a5f03c..79539f40390af 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_area.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_area.ts @@ -12,7 +12,7 @@ export const kpiUniqueIpsAreaLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { '8be0156b-d423-4a39-adf1-f54d4c9f2e69': { columnOrder: [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_bar.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_bar.ts index cf7dbf21913b5..862eb64b44eeb 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_bar.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_bar.ts @@ -12,7 +12,7 @@ export const kpiUniqueIpsBarLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { '8be0156b-d423-4a39-adf1-f54d4c9f2e69': { columnOrder: [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_destination_metric.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_destination_metric.ts index 5c4aa31f65833..094bc189f1ac7 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_destination_metric.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_destination_metric.ts @@ -11,7 +11,7 @@ export const kpiUniqueIpsDestinationMetricLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { '8be0156b-d423-4a39-adf1-f54d4c9f2e69': { columnOrder: ['d9a6eb6b-8b78-439e-98e7-a718f8ffbebe'], diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_source_metric.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_source_metric.ts index 4d308b95d796d..388f5ef53b301 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_source_metric.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/hosts/kpi_unique_ips_source_metric.ts @@ -11,7 +11,7 @@ export const kpiUniqueIpsSourceMetricLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { '8be0156b-d423-4a39-adf1-f54d4c9f2e69': { columnOrder: ['d9a6eb6b-8b78-439e-98e7-a718f8ffbebe'], diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/dns_top_domains.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/dns_top_domains.test.ts.snap index 6e0f9c2bbd516..392d68b512b41 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/dns_top_domains.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/dns_top_domains.test.ts.snap @@ -22,7 +22,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "b1c3efc6-c886-4fba-978f-3b6bb5e7948a": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_dns_queries.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_dns_queries.test.ts.snap index 39f16779abaf4..173a1229e1282 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_dns_queries.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_dns_queries.test.ts.snap @@ -22,7 +22,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "cea37c70-8f91-43bf-b9fe-72d8c049f6a3": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_network_events.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_network_events.test.ts.snap index 03bacfac49ad7..c9b0441a25a4b 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_network_events.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_network_events.test.ts.snap @@ -27,7 +27,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "eaadfec7-deaa-4aeb-a403-3b4e516416d2": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_tls_handshakes.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_tls_handshakes.test.ts.snap index 6e695484fdc0f..532d81001ab06 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_tls_handshakes.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_tls_handshakes.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "1f48a633-8eee-45ae-9471-861227e9ca03": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_flow_ids.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_flow_ids.test.ts.snap index 1e3f1f63c40c8..60a52f4f5b4a9 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_flow_ids.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_flow_ids.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "5d46d48f-6ce8-46be-a797-17ad50642564": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_area.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_area.test.ts.snap index 2415dcc6c750c..11e3f62d0cd4c 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_area.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_area.test.ts.snap @@ -22,7 +22,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "38aa6532-6bf9-4c8f-b2a6-da8d32f7d0d7": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_bar.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_bar.test.ts.snap index 2ea658869183c..2a702bb87f3fd 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_bar.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_bar.test.ts.snap @@ -22,7 +22,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "38aa6532-6bf9-4c8f-b2a6-da8d32f7d0d7": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_destination_metric.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_destination_metric.test.ts.snap index 37311a980c6b4..9f205c5c23c07 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_destination_metric.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_destination_metric.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "cea37c70-8f91-43bf-b9fe-72d8c049f6a3": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_source_metric.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_source_metric.test.ts.snap index 2f7ba7d2997b1..b7e25a6ceb8f4 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_source_metric.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/__snapshots__/kpi_unique_private_ips_source_metric.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "cea37c70-8f91-43bf-b9fe-72d8c049f6a3": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/dns_top_domains.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/dns_top_domains.ts index ef75bea77c3e0..0f195bdeaa8d4 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/dns_top_domains.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/dns_top_domains.ts @@ -89,7 +89,7 @@ export const dnsTopDomainsLensAttributes: LensAttributes = { }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { 'b1c3efc6-c886-4fba-978f-3b6bb5e7948a': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_dns_queries.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_dns_queries.ts index 681cd278214b1..c4691a4797b5b 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_dns_queries.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_dns_queries.ts @@ -64,7 +64,7 @@ export const kpiDnsQueriesLensAttributes: LensAttributes = { }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { 'cea37c70-8f91-43bf-b9fe-72d8c049f6a3': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_network_events.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_network_events.ts index 534ffeb2024e6..bb88ceb732c66 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_network_events.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_network_events.ts @@ -62,7 +62,7 @@ export const kpiNetworkEventsLensAttributes: LensAttributes = { }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { 'eaadfec7-deaa-4aeb-a403-3b4e516416d2': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_tls_handshakes.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_tls_handshakes.ts index 367fe6fd40f6f..b7b651bf56362 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_tls_handshakes.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_tls_handshakes.ts @@ -93,7 +93,7 @@ export const kpiTlsHandshakesLensAttributes: LensAttributes = { }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { '1f48a633-8eee-45ae-9471-861227e9ca03': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_flow_ids.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_flow_ids.ts index 5f31645c75eca..3660f2ff6ad06 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_flow_ids.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_flow_ids.ts @@ -56,7 +56,7 @@ export const kpiUniqueFlowIdsLensAttributes: LensAttributes = { }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { '5d46d48f-6ce8-46be-a797-17ad50642564': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_area.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_area.ts index 394bc227e871c..86e9f21d7ffef 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_area.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_area.ts @@ -82,7 +82,7 @@ export const kpiUniquePrivateIpsAreaLensAttributes: LensAttributes = { }, filters: [], datasourceStates: { - indexpattern: { + formBased: { layers: { '38aa6532-6bf9-4c8f-b2a6-da8d32f7d0d7': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_bar.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_bar.ts index fe4a698aedf5e..07a81a273e2b5 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_bar.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_bar.ts @@ -85,7 +85,7 @@ export const kpiUniquePrivateIpsBarLensAttributes: LensAttributes = { }, filters: [], datasourceStates: { - indexpattern: { + formBased: { layers: { 'e406bf4f-942b-41ac-b516-edb5cef06ec8': { columns: { diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_destination_metric.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_destination_metric.ts index 6e3d440619e76..bcdd7d377b82b 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_destination_metric.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_destination_metric.ts @@ -11,7 +11,7 @@ export const kpiUniquePrivateIpsDestinationMetricLensAttributes: LensAttributes description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { 'cea37c70-8f91-43bf-b9fe-72d8c049f6a3': { columnOrder: ['bd17c23e-4f83-4108-8005-2669170d064b'], diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_source_metric.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_source_metric.ts index 3f1110d706300..411dd90828a7b 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_source_metric.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/network/kpi_unique_private_ips_source_metric.ts @@ -10,7 +10,7 @@ export const kpiUniquePrivateIpsSourceMetricLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { 'cea37c70-8f91-43bf-b9fe-72d8c049f6a3': { columnOrder: ['bd17c23e-4f83-4108-8005-2669170d064b'], diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_total_users_area.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_total_users_area.test.ts.snap index 11df964f2eca1..f474a4c9d6e10 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_total_users_area.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_total_users_area.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "416b6fad-1923-4f6a-a2df-b223bb287e30": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_total_users_metric.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_total_users_metric.test.ts.snap index b53e1bd24d303..eef74c94537d4 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_total_users_metric.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_total_users_metric.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "416b6fad-1923-4f6a-a2df-b223bb287e30": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentication_metric_failure.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentication_metric_failure.test.ts.snap index 37c20b7e80265..b87fad1faa055 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentication_metric_failure.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentication_metric_failure.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "4590dafb-4ac7-45aa-8641-47a3ff0b817c": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_area.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_area.test.ts.snap index 1954bccfaffbe..1dcaab239de8e 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_area.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_area.test.ts.snap @@ -22,7 +22,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "31213ae3-905b-4e88-b987-0cccb1f3209f": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_bar.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_bar.test.ts.snap index 5335dca6057a6..ac7c883ca71b7 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_bar.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_bar.test.ts.snap @@ -22,7 +22,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "31213ae3-905b-4e88-b987-0cccb1f3209f": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_metric_success.test.ts.snap b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_metric_success.test.ts.snap index 4cadcaf19e91e..0b652257864c0 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_metric_success.test.ts.snap +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/__snapshots__/kpi_user_authentications_metric_success.test.ts.snap @@ -17,7 +17,7 @@ Object { ], "state": Object { "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "4590dafb-4ac7-45aa-8641-47a3ff0b817c": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_total_users_area.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_total_users_area.ts index c97748077a6be..c241d03266cc3 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_total_users_area.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_total_users_area.ts @@ -12,7 +12,7 @@ export const kpiTotalUsersAreaLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { '416b6fad-1923-4f6a-a2df-b223bb287e30': { columnOrder: [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_total_users_metric.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_total_users_metric.ts index faa6b62e18b65..08cfed0cb91f7 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_total_users_metric.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_total_users_metric.ts @@ -11,7 +11,7 @@ export const kpiTotalUsersMetricLensAttributes: LensAttributes = { description: '', state: { datasourceStates: { - indexpattern: { + formBased: { layers: { '416b6fad-1923-4f6a-a2df-b223bb287e30': { columnOrder: ['3e51b035-872c-4b44-824b-fe069c222e91'], diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentication_metric_failure.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentication_metric_failure.ts index 3f421f8a1c30a..238a8b95e35d9 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentication_metric_failure.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentication_metric_failure.ts @@ -49,7 +49,7 @@ export const kpiUserAuthenticationsMetricFailureLensAttributes: LensAttributes = }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { '4590dafb-4ac7-45aa-8641-47a3ff0b817c': { columnOrder: ['0eb97c09-a351-4280-97da-944e4bd30dd7'], diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_area.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_area.ts index d96ea21489bb2..da6bdf139a1ca 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_area.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_area.ts @@ -109,7 +109,7 @@ export const kpiUserAuthenticationsAreaLensAttributes: LensAttributes = { }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { '31213ae3-905b-4e88-b987-0cccb1f3209f': { columnOrder: [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_bar.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_bar.ts index 4727c6010b751..a4a1629e360de 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_bar.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_bar.ts @@ -104,7 +104,7 @@ export const kpiUserAuthenticationsBarLensAttributes: LensAttributes = { }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { '31213ae3-905b-4e88-b987-0cccb1f3209f': { columnOrder: [ diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_metric_success.ts b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_metric_success.ts index 3af6f5734d458..58ee89ac81b42 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_metric_success.ts +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/lens_attributes/users/kpi_user_authentications_metric_success.ts @@ -49,7 +49,7 @@ export const kpiUserAuthenticationsMetricSuccessLensAttributes: LensAttributes = }, ], datasourceStates: { - indexpattern: { + formBased: { layers: { '4590dafb-4ac7-45aa-8641-47a3ff0b817c': { columnOrder: ['0eb97c09-a351-4280-97da-944e4bd30dd7'], diff --git a/x-pack/plugins/ux/public/components/app/rum_dashboard/charts/__snapshots__/visitor_breakdown_chart.test.tsx.snap b/x-pack/plugins/ux/public/components/app/rum_dashboard/charts/__snapshots__/visitor_breakdown_chart.test.tsx.snap index 0ff461bc8ff77..1e7d3ca13e43c 100644 --- a/x-pack/plugins/ux/public/components/app/rum_dashboard/charts/__snapshots__/visitor_breakdown_chart.test.tsx.snap +++ b/x-pack/plugins/ux/public/components/app/rum_dashboard/charts/__snapshots__/visitor_breakdown_chart.test.tsx.snap @@ -10,7 +10,7 @@ Object { }, }, "datasourceStates": Object { - "indexpattern": Object { + "formBased": Object { "layers": Object { "layer1": Object { "columnOrder": Array [ diff --git a/x-pack/plugins/ux/public/components/app/rum_dashboard/charts/visitor_breakdown_chart.tsx b/x-pack/plugins/ux/public/components/app/rum_dashboard/charts/visitor_breakdown_chart.tsx index 9b3ee489c934c..e20e9b1f89f7e 100644 --- a/x-pack/plugins/ux/public/components/app/rum_dashboard/charts/visitor_breakdown_chart.tsx +++ b/x-pack/plugins/ux/public/components/app/rum_dashboard/charts/visitor_breakdown_chart.tsx @@ -188,7 +188,7 @@ export function getVisitorBreakdownLensAttributes({ [localDataView.id]: localDataView, }, datasourceStates: { - indexpattern: { + formBased: { layers: { layer1: dataLayer, }, diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/attachment_framework.ts b/x-pack/test/functional_with_es_ssl/apps/cases/attachment_framework.ts index f9bcd5946d400..2d16926b47660 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/attachment_framework.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/attachment_framework.ts @@ -145,7 +145,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { query: { query: '', language: 'kuery' }, filters: [], datasourceStates: { - indexpattern: { + formBased: { layers: { '85863a23-73a0-4e11-9774-70f77b9a5898': { columns: {