Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens] Remove unused datasource methods #51840

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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) {
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