Skip to content

Commit

Permalink
[Lens] Remove unused datasource methods (#51840)
Browse files Browse the repository at this point in the history
* Remove unused datasource methods

* Remove unused function
  • Loading branch information
chrisdavies committed Dec 4, 2019
1 parent d625417 commit c4af5f0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, IndexPatternColumn> = {
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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ export function uniqueLabels(layers: Record<string, IndexPatternLayer>) {
return columnLabelMap;
}

function removeProperty<T>(prop: string, object: Record<string, T>): Record<string, T> {
const result = { ...object };
delete result[prop];
return result;
}

export function getIndexPatternDatasource({
chrome,
core,
Expand Down Expand Up @@ -268,22 +262,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) {
Expand Down
4 changes: 0 additions & 4 deletions x-pack/legacy/plugins/lens/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c4af5f0

Please sign in to comment.