mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
only allow sorting by date and number fields (#128111)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
de02c2da65
commit
ee4f521b43
2 changed files with 43 additions and 2 deletions
|
@ -474,7 +474,28 @@ describe('isSortableByColumn()', () => {
|
||||||
).toBeFalsy();
|
).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('SHOULD be sortable when NOT using top-hit agg', () => {
|
it('should NOT be sortable when NOT using date or number source field', () => {
|
||||||
|
expect(
|
||||||
|
isSortableByColumn(
|
||||||
|
getLayer(getStringBasedOperationColumn(), [
|
||||||
|
{
|
||||||
|
label: 'Last Value',
|
||||||
|
dataType: 'string',
|
||||||
|
isBucketed: false,
|
||||||
|
sourceField: 'some_string_field',
|
||||||
|
operationType: 'last_value',
|
||||||
|
params: {
|
||||||
|
sortField: 'time',
|
||||||
|
showArrayValues: false,
|
||||||
|
},
|
||||||
|
} as GenericIndexPatternColumn,
|
||||||
|
]),
|
||||||
|
'col2'
|
||||||
|
)
|
||||||
|
).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('SHOULD be sortable when NOT using top-hit agg and source field is date or number', () => {
|
||||||
expect(
|
expect(
|
||||||
isSortableByColumn(
|
isSortableByColumn(
|
||||||
getLayer(getStringBasedOperationColumn(), [
|
getLayer(getStringBasedOperationColumn(), [
|
||||||
|
@ -493,6 +514,25 @@ describe('isSortableByColumn()', () => {
|
||||||
'col2'
|
'col2'
|
||||||
)
|
)
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
isSortableByColumn(
|
||||||
|
getLayer(getStringBasedOperationColumn(), [
|
||||||
|
{
|
||||||
|
label: 'Last Value',
|
||||||
|
dataType: 'date',
|
||||||
|
isBucketed: false,
|
||||||
|
sourceField: 'order_date',
|
||||||
|
operationType: 'last_value',
|
||||||
|
params: {
|
||||||
|
sortField: 'time',
|
||||||
|
showArrayValues: false,
|
||||||
|
},
|
||||||
|
} as GenericIndexPatternColumn,
|
||||||
|
]),
|
||||||
|
'col2'
|
||||||
|
)
|
||||||
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -208,7 +208,8 @@ export function getDisallowedTermsMessage(
|
||||||
function checkLastValue(column: GenericIndexPatternColumn) {
|
function checkLastValue(column: GenericIndexPatternColumn) {
|
||||||
return (
|
return (
|
||||||
column.operationType !== 'last_value' ||
|
column.operationType !== 'last_value' ||
|
||||||
!(column as LastValueIndexPatternColumn).params.showArrayValues
|
(['number', 'date'].includes(column.dataType) &&
|
||||||
|
!(column as LastValueIndexPatternColumn).params.showArrayValues)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue