From eeeb08515ccf034cac875259aacc1d9bad189441 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Thu, 1 Aug 2019 11:06:59 +0200 Subject: [PATCH 1/2] remove unused property on column --- .../indexpattern_plugin/datapanel.test.tsx | 1 - .../dimension_panel/dimension_panel.test.tsx | 7 ------- .../indexpattern_plugin/indexpattern.test.tsx | 4 ---- .../indexpattern_plugin/indexpattern.tsx | 1 - .../operation_definitions/count.tsx | 3 +-- .../date_histogram.test.tsx | 4 ---- .../operation_definitions/date_histogram.tsx | 3 --- .../filter_ratio.test.tsx | 2 -- .../operation_definitions/filter_ratio.tsx | 3 +-- .../operation_definitions/metrics.tsx | 3 +-- .../operation_definitions/terms.test.tsx | 10 ---------- .../operation_definitions/terms.tsx | 3 +-- .../indexpattern_plugin/operations.test.ts | 1 - .../public/indexpattern_plugin/operations.ts | 2 -- .../indexpattern_plugin/state_helpers.test.ts | 20 ------------------- 15 files changed, 4 insertions(+), 63 deletions(-) diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.test.tsx index da6d567d971d9..6e37f736d738d 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.test.tsx @@ -35,7 +35,6 @@ const initialState: IndexPatternPrivateState = { type: 'alphabetical', }, }, - indexPatternId: '1', }, }, }, diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.test.tsx index 70bed5f41f0a7..bee8db0e4d1d8 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.test.tsx @@ -96,7 +96,6 @@ describe('IndexPatternDimensionPanel', () => { interval: '1d', }, sourceField: 'timestamp', - indexPatternId: '1', }, }, }, @@ -207,7 +206,6 @@ describe('IndexPatternDimensionPanel', () => { // Private operationType: 'max', sourceField: 'bytes', - indexPatternId: '1', }, }, }, @@ -249,7 +247,6 @@ describe('IndexPatternDimensionPanel', () => { // Private operationType: 'max', sourceField: 'bytes', - indexPatternId: '1', }, }, }, @@ -288,7 +285,6 @@ describe('IndexPatternDimensionPanel', () => { // Private operationType: 'max', sourceField: 'bytes', - indexPatternId: '1', }, }, }, @@ -373,7 +369,6 @@ describe('IndexPatternDimensionPanel', () => { // Private operationType: 'max', sourceField: 'bytes', - indexPatternId: '1', }, }, }, @@ -713,7 +708,6 @@ describe('IndexPatternDimensionPanel', () => { // Private operationType: 'max', sourceField: 'bytes', - indexPatternId: '1', }, }, }, @@ -819,7 +813,6 @@ describe('IndexPatternDimensionPanel', () => { interval: '1d', }, sourceField: 'timestamp', - indexPatternId: 'foo', }, }, }, diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx index 9ea076b3795a0..d7af534322c1e 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx @@ -146,7 +146,6 @@ describe('IndexPattern Data Source', () => { orderBy: { type: 'alphabetical' }, orderDirection: 'asc', }, - indexPatternId: '1', }, }, }, @@ -202,7 +201,6 @@ describe('IndexPattern Data Source', () => { // Private operationType: 'count', - indexPatternId: '1', }, col2: { label: 'Date', @@ -215,7 +213,6 @@ describe('IndexPattern Data Source', () => { params: { interval: '1d', }, - indexPatternId: '1', }, }, }, @@ -863,7 +860,6 @@ describe('IndexPattern Data Source', () => { operationType: 'max', sourceField: 'baz', suggestedPriority: 0, - indexPatternId: '1', }; const columns: Record = { a: { diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx index 913d51acc763d..1a309934af710 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx @@ -47,7 +47,6 @@ export interface BaseIndexPatternColumn { // Private operationType: OperationType; suggestedPriority?: DimensionPriority; - indexPatternId: string; } type Omit = Pick>; diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/count.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/count.tsx index c9437d6427985..8006af3ccc38d 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/count.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/count.tsx @@ -22,7 +22,7 @@ export const countOperation: OperationDefinition = { }, ]; }, - buildColumn({ suggestedPriority, indexPatternId }) { + buildColumn({ suggestedPriority }) { return { label: i18n.translate('xpack.lens.indexPattern.countOf', { defaultMessage: 'Count of documents', @@ -31,7 +31,6 @@ export const countOperation: OperationDefinition = { operationType: 'count', suggestedPriority, isBucketed: false, - indexPatternId, }; }, toEsAggsConfig: (column, columnId) => ({ diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/date_histogram.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/date_histogram.test.tsx index 3a7d1814bb9fe..36e54224f1854 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/date_histogram.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/date_histogram.test.tsx @@ -61,7 +61,6 @@ describe('date_histogram', () => { interval: 'w', }, sourceField: 'timestamp', - indexPatternId: '1', }, }, }, @@ -80,7 +79,6 @@ describe('date_histogram', () => { interval: 'd', }, sourceField: 'other_timestamp', - indexPatternId: '2', }, }, }, @@ -94,7 +92,6 @@ describe('date_histogram', () => { columns: {}, suggestedPriority: 0, layerId: 'first', - indexPatternId: '1', field: { name: 'timestamp', type: 'date', @@ -111,7 +108,6 @@ describe('date_histogram', () => { columns: {}, suggestedPriority: 0, layerId: 'first', - indexPatternId: '1', field: { name: 'timestamp', type: 'date', diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/date_histogram.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/date_histogram.tsx index 0f3cf60fa2ca9..ed81f4656711e 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/date_histogram.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/date_histogram.tsx @@ -51,11 +51,9 @@ export const dateHistogramOperation: OperationDefinition { numerator: { query: '', language: 'kuery' }, denominator: { query: '', language: 'kuery' }, }, - indexPatternId: '1', }, }, }, @@ -70,7 +69,6 @@ describe('filter_ratio', () => { describe('buildColumn', () => { it('should create column object with default params', () => { const column = filterRatioOperation.buildColumn({ - indexPatternId: '1', layerId: 'first', columns: {}, suggestedPriority: undefined, diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/filter_ratio.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/filter_ratio.tsx index f7e1ac68ebea3..724bb7fd620ae 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/filter_ratio.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/filter_ratio.tsx @@ -27,7 +27,7 @@ export const filterRatioOperation: OperationDefinition( } return []; }, - buildColumn({ suggestedPriority, field, indexPatternId }): T { + buildColumn({ suggestedPriority, field }): T { if (!field) { throw new Error(`Invariant: A ${type} operation can only be built with a field`); } @@ -45,7 +45,6 @@ function buildMetricOperation( suggestedPriority, sourceField: field ? field.name : '', isBucketed: false, - indexPatternId, } as T; }, toEsAggsConfig: (column, columnId) => ({ diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/terms.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/terms.test.tsx index 94411e13fb63c..68d70959480a5 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/terms.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/terms.test.tsx @@ -36,7 +36,6 @@ describe('terms', () => { orderDirection: 'asc', }, sourceField: 'category', - indexPatternId: '1', }, col2: { label: 'Count', @@ -45,7 +44,6 @@ describe('terms', () => { // Private operationType: 'count', - indexPatternId: '1', }, }, }, @@ -75,7 +73,6 @@ describe('terms', () => { it('should use existing metric column as order column', () => { const termsColumn = termsOperation.buildColumn({ layerId: 'first', - indexPatternId: '1', suggestedPriority: undefined, columns: { col1: { @@ -85,7 +82,6 @@ describe('terms', () => { // Private operationType: 'count', - indexPatternId: '1', }, }, }); @@ -112,7 +108,6 @@ describe('terms', () => { orderDirection: 'asc', }, sourceField: 'category', - indexPatternId: '1', }; const updatedColumn = termsOperation.onOtherColumnChanged!(initialColumn, { col1: { @@ -122,7 +117,6 @@ describe('terms', () => { // Private operationType: 'count', - indexPatternId: '1', }, }); expect(updatedColumn).toBe(initialColumn); @@ -143,7 +137,6 @@ describe('terms', () => { orderDirection: 'asc', }, sourceField: 'category', - indexPatternId: '1', }, {} ); @@ -169,7 +162,6 @@ describe('terms', () => { orderDirection: 'asc', }, sourceField: 'category', - indexPatternId: '1', }, { col1: { @@ -183,7 +175,6 @@ describe('terms', () => { interval: 'w', }, sourceField: 'timestamp', - indexPatternId: '1', }, } ); @@ -234,7 +225,6 @@ describe('terms', () => { numerator: { query: '', language: 'kuery' }, denominator: { query: '', language: 'kuery' }, }, - indexPatternId: '1', }, }, }, diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/terms.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/terms.tsx index 912a532621d43..2f9863547bf84 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/terms.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/terms.tsx @@ -53,7 +53,7 @@ export const termsOperation: OperationDefinition = { } return []; }, - buildColumn({ suggestedPriority, columns, field, indexPatternId }) { + buildColumn({ suggestedPriority, columns, field }) { const existingMetricColumn = Object.entries(columns) .filter(([_columnId, column]) => column && isSortableByColumn(column)) .map(([id]) => id)[0]; @@ -65,7 +65,6 @@ export const termsOperation: OperationDefinition = { suggestedPriority, sourceField: field ? field.name : '', isBucketed: true, - indexPatternId, params: { size: DEFAULT_SIZE, orderBy: existingMetricColumn diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations.test.ts b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations.test.ts index 9fff0e0fdb7e3..cdc3b040beb05 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations.test.ts +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations.test.ts @@ -169,7 +169,6 @@ describe('getOperationTypesForField', () => { interval: '1d', }, sourceField: 'timestamp', - indexPatternId: '1', }, }, }, diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations.ts b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations.ts index e5823aa92f0cc..843fd804a01f6 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations.ts +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations.ts @@ -75,7 +75,6 @@ export interface OperationDefinition { buildColumn: (arg: { suggestedPriority: DimensionPriority | undefined; layerId: string; - indexPatternId: string; columns: Partial>; field?: IndexPatternField; }) => C; @@ -189,6 +188,5 @@ export function buildColumn({ suggestedPriority, field, layerId, - indexPatternId: indexPattern.id, }); } diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/state_helpers.test.ts b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/state_helpers.test.ts index 43b59298d0f86..b90ba469518d4 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/state_helpers.test.ts +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/state_helpers.test.ts @@ -31,7 +31,6 @@ describe('state_helpers', () => { orderDirection: 'asc', size: 5, }, - indexPatternId: '', }; const state: IndexPatternPrivateState = { @@ -50,7 +49,6 @@ describe('state_helpers', () => { // Private operationType: 'count', - indexPatternId: '1', }, }, }, @@ -78,7 +76,6 @@ describe('state_helpers', () => { orderDirection: 'asc', size: 5, }, - indexPatternId: '', }; const state: IndexPatternPrivateState = { @@ -97,7 +94,6 @@ describe('state_helpers', () => { // Private operationType: 'count', - indexPatternId: '1', }, }, }, @@ -129,7 +125,6 @@ describe('state_helpers', () => { interval: '1d', }, sourceField: 'timestamp', - indexPatternId: '1', }; const state: IndexPatternPrivateState = { @@ -173,7 +168,6 @@ describe('state_helpers', () => { // Private operationType: 'avg', sourceField: 'bytes', - indexPatternId: '1', }, col2: { label: 'Max of bytes', @@ -183,7 +177,6 @@ describe('state_helpers', () => { // Private operationType: 'max', sourceField: 'bytes', - indexPatternId: '1', }, }, }, @@ -205,7 +198,6 @@ describe('state_helpers', () => { interval: '1d', }, sourceField: 'timestamp', - indexPatternId: '1', }, }) ).toEqual({ @@ -238,7 +230,6 @@ describe('state_helpers', () => { params: { interval: 'h', }, - indexPatternId: '1', }, }, }, @@ -260,7 +251,6 @@ describe('state_helpers', () => { params: { interval: 'w', }, - indexPatternId: '1', }, }).layers.first.columns.col1 ).toEqual( @@ -284,7 +274,6 @@ describe('state_helpers', () => { orderDirection: 'asc', size: 5, }, - indexPatternId: '1', }; const newColumn: AvgIndexPatternColumn = { @@ -295,7 +284,6 @@ describe('state_helpers', () => { // Private operationType: 'avg', sourceField: 'bytes', - indexPatternId: '1', }; const state: IndexPatternPrivateState = { @@ -314,7 +302,6 @@ describe('state_helpers', () => { // Private operationType: 'count', - indexPatternId: '1', }, }, }, @@ -354,7 +341,6 @@ describe('state_helpers', () => { params: { interval: 'h', }, - indexPatternId: '1', }, }) ).toEqual(['col1']); @@ -378,7 +364,6 @@ describe('state_helpers', () => { }, orderDirection: 'asc', }, - indexPatternId: '1', }, col2: { label: 'Average of bytes', @@ -388,7 +373,6 @@ describe('state_helpers', () => { // Private operationType: 'avg', sourceField: 'bytes', - indexPatternId: '1', }, col3: { label: 'Date Histogram of timestamp', @@ -401,7 +385,6 @@ describe('state_helpers', () => { params: { interval: '1d', }, - indexPatternId: '1', }, }) ).toEqual(['col1', 'col3', 'col2']); @@ -426,7 +409,6 @@ describe('state_helpers', () => { orderDirection: 'asc', }, suggestedPriority: 2, - indexPatternId: '1', }, col2: { label: 'Average of bytes', @@ -437,7 +419,6 @@ describe('state_helpers', () => { operationType: 'avg', sourceField: 'bytes', suggestedPriority: 0, - indexPatternId: '1', }, col3: { label: 'Date Histogram of timestamp', @@ -451,7 +432,6 @@ describe('state_helpers', () => { params: { interval: '1d', }, - indexPatternId: '1', }, }) ).toEqual(['col3', 'col1', 'col2']); From 6343a73ee1ecdd8a65dea35c9caf8cbc1e21d600 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Mon, 5 Aug 2019 13:13:08 +0200 Subject: [PATCH 2/2] fix type errors --- .../lens/public/indexpattern_plugin/indexpattern.test.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx index 7917ea986c500..ea1be14b39e06 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx @@ -607,7 +607,6 @@ describe('IndexPattern Data Source', () => { columns: { col1: { dataType: 'string', - indexPatternId: '1', isBucketed: true, sourceField: 'source', label: 'values of source', @@ -620,7 +619,6 @@ describe('IndexPattern Data Source', () => { }, col2: { dataType: 'number', - indexPatternId: '1', isBucketed: false, sourceField: 'bytes', label: 'Min of bytes', @@ -644,7 +642,6 @@ describe('IndexPattern Data Source', () => { columns: { col1: { dataType: 'date', - indexPatternId: '1', isBucketed: true, sourceField: 'timestamp', label: 'date histogram of timestamp', @@ -655,7 +652,6 @@ describe('IndexPattern Data Source', () => { }, col2: { dataType: 'number', - indexPatternId: '1', isBucketed: false, sourceField: 'bytes', label: 'Min of bytes',