[lens] Only allow aggregated dimensions

This commit is contained in:
Wylie Conlon 2019-06-12 15:04:57 -04:00
parent 307cb1262a
commit 9ea8b9a041
4 changed files with 23 additions and 42 deletions

View file

@ -55,12 +55,12 @@ describe('IndexPatternDimensionPanel', () => {
columns: {
col1: {
operationId: 'op1',
label: 'Value of timestamp',
label: 'Date Histogram of timestamp',
dataType: 'date',
isBucketed: false,
isBucketed: true,
// Private
operationType: 'value',
operationType: 'date_histogram',
sourceField: 'timestamp',
},
},
@ -169,17 +169,14 @@ describe('IndexPatternDimensionPanel', () => {
);
expect(
wrapper.find('[data-test-subj="lns-indexPatternDimension-value"]').prop('color')
wrapper.find('[data-test-subj="lns-indexPatternDimension-date_histogram"]').prop('color')
).toEqual('primary');
expect(
wrapper.find('[data-test-subj="lns-indexPatternDimension-value"]').prop('isDisabled')
wrapper.find('[data-test-subj="lns-indexPatternDimension-date_histogram"]').prop('isDisabled')
).toEqual(false);
expect(
wrapper.find('[data-test-subj="lns-indexPatternDimension-terms"]').prop('isDisabled')
).toEqual(true);
expect(
wrapper.find('[data-test-subj="lns-indexPatternDimension-date_histogram"]').prop('isDisabled')
).toEqual(false);
expect(
wrapper.find('[data-test-subj="lns-indexPatternDimension-sum"]').prop('isDisabled')
).toEqual(true);
@ -271,11 +268,6 @@ describe('IndexPatternDimensionPanel', () => {
...state.columns,
col2: expect.objectContaining({
operationId: firstField.value,
label: 'Value of bytes',
dataType: 'number',
isBucketed: false,
operationType: 'value',
sourceField: 'bytes',
}),
},
columnOrder: ['col1', 'col2'],

View file

@ -119,10 +119,10 @@ describe('IndexPattern Data Source', () => {
operationId: 'op1',
label: 'My Op',
dataType: 'string',
isBucketed: false,
isBucketed: true,
// Private
operationType: 'value',
operationType: 'terms',
sourceField: 'op',
},
},
@ -303,7 +303,7 @@ describe('IndexPattern Data Source', () => {
id: 'op1',
label: 'My Op',
dataType: 'string',
isBucketed: false,
isBucketed: true,
} as Operation);
});
});

View file

@ -45,7 +45,7 @@ describe('getOperationTypesForField', () => {
aggregatable: true,
searchable: true,
})
).toEqual(expect.arrayContaining(['value', 'terms']));
).toEqual(expect.arrayContaining(['terms']));
});
it('should return operations on numbers', () => {
@ -56,7 +56,7 @@ describe('getOperationTypesForField', () => {
aggregatable: true,
searchable: true,
})
).toEqual(expect.arrayContaining(['value', 'avg', 'sum', 'min', 'max']));
).toEqual(expect.arrayContaining(['avg', 'sum', 'min', 'max']));
});
it('should return operations on dates', () => {
@ -67,7 +67,7 @@ describe('getOperationTypesForField', () => {
aggregatable: true,
searchable: true,
})
).toEqual(expect.arrayContaining(['value', 'date_histogram']));
).toEqual(expect.arrayContaining(['date_histogram']));
});
it('should return no operations on unknown types', () => {
@ -149,12 +149,12 @@ describe('getOperationTypesForField', () => {
columns: {
col1: {
operationId: 'op1',
label: 'Value of timestamp',
label: 'Date Histogram of timestamp',
dataType: 'date',
isBucketed: false,
isBucketed: true,
// Private
operationType: 'value',
operationType: 'date_histogram',
sourceField: 'timestamp',
},
},
@ -172,10 +172,6 @@ describe('getOperationTypesForField', () => {
expect(columns.map(col => [col.sourceField, col.operationType])).toMatchInlineSnapshot(`
Array [
Array [
"bytes",
"value",
],
Array [
"bytes",
"sum",
@ -196,18 +192,10 @@ Array [
"documents",
"count",
],
Array [
"source",
"value",
],
Array [
"source",
"terms",
],
Array [
"timestamp",
"value",
],
Array [
"timestamp",
"date_histogram",
@ -228,12 +216,12 @@ describe('getColumnOrder', () => {
getColumnOrder({
col1: {
operationId: 'op1',
label: 'Value of timestamp',
dataType: 'string',
isBucketed: false,
label: 'Date Histogram of timestamp',
dataType: 'date',
isBucketed: true,
// Private
operationType: 'value',
operationType: 'date_histogram',
sourceField: 'timestamp',
},
})

View file

@ -15,7 +15,8 @@ import {
} from './indexpattern';
export function getOperations(): OperationType[] {
return ['value', 'terms', 'date_histogram', 'sum', 'avg', 'min', 'max', 'count'];
// Raw value is not listed in the MVP
return ['terms', 'date_histogram', 'sum', 'avg', 'min', 'max', 'count'];
}
export function getOperationDisplay(): Record<
@ -132,11 +133,11 @@ export function getOperationTypesForField({
switch (type) {
case 'date':
return ['value', 'date_histogram'];
return ['date_histogram'];
case 'number':
return ['value', 'sum', 'avg', 'min', 'max'];
return ['sum', 'avg', 'min', 'max'];
case 'string':
return ['value', 'terms'];
return ['terms'];
}
return [];
}