From 8342c477a7c40c3bec3c310cf23230bb9b64e12c Mon Sep 17 00:00:00 2001 From: Christopher Davies Date: Wed, 27 Nov 2019 13:41:44 -0500 Subject: [PATCH 1/2] Remove unused datasource methods --- .../lens/public/editor_frame_plugin/mocks.tsx | 3 - .../indexpattern_plugin/indexpattern.test.ts | 55 ------------------- .../indexpattern_plugin/indexpattern.tsx | 16 ------ x-pack/legacy/plugins/lens/public/types.ts | 4 -- 4 files changed, 78 deletions(-) diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/mocks.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/mocks.tsx index 79dff5bddb882..456951e7d2d26 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/mocks.tsx +++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/mocks.tsx @@ -48,9 +48,6 @@ export function createMockDatasource(): DatasourceMock { getOperationForColumnId: jest.fn(), renderDimensionPanel: jest.fn(), renderLayerPanel: jest.fn(), - removeColumnInTableSpec: jest.fn(), - moveColumnTo: jest.fn(), - duplicateColumn: jest.fn(), }; return { diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.ts b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.ts index d998437f3e492..e7def3b9dbf2c 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.ts +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.ts @@ -433,61 +433,6 @@ describe('IndexPattern Data Source', () => { }); }); - describe('removeColumnInTableSpec', () => { - it('should remove the specified column', async () => { - const initialState = await indexPatternDatasource.initialize(persistedState); - const setState = jest.fn(); - const sampleColumn: IndexPatternColumn = { - dataType: 'number', - isBucketed: false, - label: 'foo', - operationType: 'max', - sourceField: 'baz', - suggestedPriority: 0, - }; - const columns: Record = { - a: { - ...sampleColumn, - suggestedPriority: 0, - }, - b: { - ...sampleColumn, - suggestedPriority: 1, - }, - c: { - ...sampleColumn, - suggestedPriority: 2, - }, - }; - const api = indexPatternDatasource.getPublicAPI({ - state: { - ...initialState, - layers: { - first: { - ...initialState.layers.first, - columns, - columnOrder: ['a', 'b', 'c'], - }, - }, - }, - setState, - layerId: 'first', - dateRange: { - fromDate: 'now-1y', - toDate: 'now', - }, - }); - - api.removeColumnInTableSpec('b'); - - expect(setState.mock.calls[0][0].layers.first.columnOrder).toEqual(['a', 'c']); - expect(setState.mock.calls[0][0].layers.first.columns).toEqual({ - a: columns.a, - c: columns.c, - }); - }); - }); - describe('getOperationForColumnId', () => { it('should get an operation for col1', () => { expect(publicAPI.getOperationForColumnId('col1')).toEqual({ 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 443667ab64476..16614a7d52ae1 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx @@ -268,22 +268,6 @@ export function getIndexPatternDatasource({ domElement ); }, - - removeColumnInTableSpec: (columnId: string) => { - setState({ - ...state, - layers: { - ...state.layers, - [layerId]: { - ...state.layers[layerId], - columnOrder: state.layers[layerId].columnOrder.filter(id => id !== columnId), - columns: removeProperty(columnId, state.layers[layerId].columns), - }, - }, - }); - }, - moveColumnTo: () => {}, - duplicateColumn: () => [], }; }, getDatasourceSuggestionsForField(state, draggedField) { diff --git a/x-pack/legacy/plugins/lens/public/types.ts b/x-pack/legacy/plugins/lens/public/types.ts index 36d30fa1a6d48..8c1e90643ca7a 100644 --- a/x-pack/legacy/plugins/lens/public/types.ts +++ b/x-pack/legacy/plugins/lens/public/types.ts @@ -157,10 +157,6 @@ export interface DatasourcePublicAPI { // Render can be called many times renderDimensionPanel: (domElement: Element, props: DatasourceDimensionPanelProps) => void; renderLayerPanel: (domElement: Element, props: DatasourceLayerPanelProps) => void; - - removeColumnInTableSpec: (columnId: string) => void; - moveColumnTo: (columnId: string, targetIndex: number) => void; - duplicateColumn: (columnId: string) => TableSpec; } export interface TableSpecColumn { From 2fb0fa9a4ea957f3119752eb98170625f65b8ced Mon Sep 17 00:00:00 2001 From: Christopher Davies Date: Tue, 3 Dec 2019 16:25:55 -0500 Subject: [PATCH 2/2] Remove unused function --- .../lens/public/indexpattern_plugin/indexpattern.tsx | 6 ------ 1 file changed, 6 deletions(-) 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 16614a7d52ae1..7a413f24f243a 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx @@ -89,12 +89,6 @@ export function uniqueLabels(layers: Record) { return columnLabelMap; } -function removeProperty(prop: string, object: Record): Record { - const result = { ...object }; - delete result[prop]; - return result; -} - export function getIndexPatternDatasource({ chrome, core,