Skip to content

Commit

Permalink
[Lens] Rename datasources (#142553)
Browse files Browse the repository at this point in the history
* Rename to textBased instead of textBasedLanguages

* [Lens] Rename datasources to textBased and formBased

* Fix css

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

* Move datasources under a common foler

* Fix types

* Revert css classes

* Add migration script

* Fix lens embeddable functional tests

* Fix types

* Fixes cases test

* Adds migration script test

* Revert

* Update jest integration test

* Fix security solution tests

* Fix jest test

* Address type nit

* Fix types

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
stratoula and kibanamachine authored Oct 12, 2022
1 parent 005a6ea commit 8c4976f
Show file tree
Hide file tree
Showing 271 changed files with 1,309 additions and 1,282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion x-pack/examples/embedded_lens_example/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function getLensAttributes(
],
state: {
datasourceStates: {
indexpattern: {
formBased: {
layers: {
layer1: dataLayer!,
},
Expand Down
2 changes: 1 addition & 1 deletion x-pack/examples/testing_embedded_lens/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function getBaseAttributes(
],
state: {
datasourceStates: {
indexpattern: {
formBased: {
layers: {
layer1: finalDataLayer,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function getLensAttributes(defaultDataView: DataView): TypedLensByValueInput['at
],
state: {
datasourceStates: {
indexpattern: {
formBased: {
layers: {
layer1: dataLayer,
},
Expand Down
2 changes: 1 addition & 1 deletion x-pack/examples/third_party_vis_lens_example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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":[]}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function getLensAttributes(defaultDataView: DataView): TypedLensByValueInput['at
],
state: {
datasourceStates: {
indexpattern: {
formBased: {
layers: {
layer1: dataLayer,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export function getLensAttributes(
],
state: {
datasourceStates: {
indexpattern: {
formBased: {
layers: {
layer1: {
columnOrder: ['col1', 'col2'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const getLensHostsTable = (
],
state: {
datasourceStates: {
indexpattern: {
formBased: {
layers: {
'cbe5d8a0-381d-49bf-b8ac-f8f312ec7129': {
columns: {
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export const LensTopNavMenu = ({
setIsOnTextBasedMode(true);
dispatch(
switchAndCleanDatasource({
newDatasourceId: 'textBasedLanguages',
newDatasourceId: 'textBased',
visualizationId: visualization?.activeId,
currentIndexPatternId: currentIndexPattern?.id,
})
Expand Down Expand Up @@ -764,7 +764,7 @@ export const LensTopNavMenu = ({
if (isOnTextBasedMode) {
dispatch(
switchAndCleanDatasource({
newDatasourceId: 'indexpattern',
newDatasourceId: 'formBased',
visualizationId: visualization?.activeId,
currentIndexPatternId: dataView?.id,
})
Expand Down Expand Up @@ -795,7 +795,7 @@ export const LensTopNavMenu = ({
if (isOnTextBasedMode) {
dispatch(
switchAndCleanDatasource({
newDatasourceId: 'indexpattern',
newDatasourceId: 'formBased',
visualizationId: visualization?.activeId,
currentIndexPatternId: dataView?.id,
})
Expand Down Expand Up @@ -838,7 +838,7 @@ export const LensTopNavMenu = ({
if (isOnTextBasedMode) {
dispatch(
switchAndCleanDatasource({
newDatasourceId: 'indexpattern',
newDatasourceId: 'formBased',
visualizationId: visualization?.activeId,
currentIndexPatternId: newIndexPatternId,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/lens/public/async_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/data_views_service/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/lens/public/data_views_service/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
};
Expand Down
Loading

0 comments on commit 8c4976f

Please sign in to comment.