disable missing switch for non-string fields (#102865)
This commit is contained in:
parent
498df213fa
commit
2ab5d6bc46
2 changed files with 34 additions and 3 deletions
|
@ -497,7 +497,10 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
|
||||||
defaultMessage: 'Include documents without this field',
|
defaultMessage: 'Include documents without this field',
|
||||||
})}
|
})}
|
||||||
compressed
|
compressed
|
||||||
disabled={!currentColumn.params.otherBucket}
|
disabled={
|
||||||
|
!currentColumn.params.otherBucket ||
|
||||||
|
indexPattern.getFieldByName(currentColumn.sourceField)?.type !== 'string'
|
||||||
|
}
|
||||||
data-test-subj="indexPattern-terms-missing-bucket"
|
data-test-subj="indexPattern-terms-missing-bucket"
|
||||||
checked={Boolean(currentColumn.params.missingBucket)}
|
checked={Boolean(currentColumn.params.missingBucket)}
|
||||||
onChange={(e: EuiSwitchEvent) =>
|
onChange={(e: EuiSwitchEvent) =>
|
||||||
|
|
|
@ -60,7 +60,7 @@ describe('terms', () => {
|
||||||
size: 3,
|
size: 3,
|
||||||
orderDirection: 'asc',
|
orderDirection: 'asc',
|
||||||
},
|
},
|
||||||
sourceField: 'category',
|
sourceField: 'source',
|
||||||
},
|
},
|
||||||
col2: {
|
col2: {
|
||||||
label: 'Count',
|
label: 'Count',
|
||||||
|
@ -88,7 +88,7 @@ describe('terms', () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
arguments: expect.objectContaining({
|
arguments: expect.objectContaining({
|
||||||
orderBy: ['_key'],
|
orderBy: ['_key'],
|
||||||
field: ['category'],
|
field: ['source'],
|
||||||
size: [3],
|
size: [3],
|
||||||
otherBucket: [true],
|
otherBucket: [true],
|
||||||
}),
|
}),
|
||||||
|
@ -770,6 +770,34 @@ describe('terms', () => {
|
||||||
expect(select.prop('disabled')).toEqual(false);
|
expect(select.prop('disabled')).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should disable missing bucket setting if field is not a string', () => {
|
||||||
|
const updateLayerSpy = jest.fn();
|
||||||
|
const instance = shallow(
|
||||||
|
<InlineOptions
|
||||||
|
{...defaultProps}
|
||||||
|
layer={layer}
|
||||||
|
updateLayer={updateLayerSpy}
|
||||||
|
columnId="col1"
|
||||||
|
currentColumn={
|
||||||
|
{
|
||||||
|
...layer.columns.col1,
|
||||||
|
sourceField: 'bytes',
|
||||||
|
params: {
|
||||||
|
...layer.columns.col1.params,
|
||||||
|
otherBucket: true,
|
||||||
|
},
|
||||||
|
} as TermsIndexPatternColumn
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const select = instance
|
||||||
|
.find('[data-test-subj="indexPattern-terms-missing-bucket"]')
|
||||||
|
.find(EuiSwitch);
|
||||||
|
|
||||||
|
expect(select.prop('disabled')).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('should update state when clicking other bucket toggle', () => {
|
it('should update state when clicking other bucket toggle', () => {
|
||||||
const updateLayerSpy = jest.fn();
|
const updateLayerSpy = jest.fn();
|
||||||
const instance = shallow(
|
const instance = shallow(
|
||||||
|
|
Loading…
Reference in a new issue