mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Co-authored-by: Tim Roes <tim.roes@elastic.co>
This commit is contained in:
parent
009a6d02be
commit
e4a251d043
2 changed files with 11 additions and 1 deletions
|
@ -43,4 +43,9 @@ describe('getDisplayedColumns', () => {
|
|||
]
|
||||
`);
|
||||
});
|
||||
test('returns the same instance of ["_source"] over multiple calls', async () => {
|
||||
const result = getDisplayedColumns([], indexPatternWithTimefieldMock);
|
||||
const result2 = getDisplayedColumns([], indexPatternWithTimefieldMock);
|
||||
expect(result).toBe(result2);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
|
||||
import { IndexPattern } from '../../../../data/common';
|
||||
|
||||
// We store this outside the function as a constant, so we're not creating a new array every time
|
||||
// the function is returning this. A changing array might cause the data grid to think it got
|
||||
// new columns, and thus performing worse than using the same array over multiple renders.
|
||||
const SOURCE_ONLY = ['_source'];
|
||||
|
||||
/**
|
||||
* Function to provide fallback when
|
||||
* 1) no columns are given
|
||||
|
@ -19,5 +24,5 @@ export function getDisplayedColumns(stateColumns: string[] = [], indexPattern: I
|
|||
// check if all columns where removed except the configured timeField (this can't be removed)
|
||||
!(stateColumns.length === 1 && stateColumns[0] === indexPattern.timeFieldName)
|
||||
? stateColumns
|
||||
: ['_source'];
|
||||
: SOURCE_ONLY;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue