disable missing switch for non-string fields (#102865)
This commit is contained in:
parent
498df213fa
commit
2ab5d6bc46
|
@ -497,7 +497,10 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
|
|||
defaultMessage: 'Include documents without this field',
|
||||
})}
|
||||
compressed
|
||||
disabled={!currentColumn.params.otherBucket}
|
||||
disabled={
|
||||
!currentColumn.params.otherBucket ||
|
||||
indexPattern.getFieldByName(currentColumn.sourceField)?.type !== 'string'
|
||||
}
|
||||
data-test-subj="indexPattern-terms-missing-bucket"
|
||||
checked={Boolean(currentColumn.params.missingBucket)}
|
||||
onChange={(e: EuiSwitchEvent) =>
|
||||
|
|
|
@ -60,7 +60,7 @@ describe('terms', () => {
|
|||
size: 3,
|
||||
orderDirection: 'asc',
|
||||
},
|
||||
sourceField: 'category',
|
||||
sourceField: 'source',
|
||||
},
|
||||
col2: {
|
||||
label: 'Count',
|
||||
|
@ -88,7 +88,7 @@ describe('terms', () => {
|
|||
expect.objectContaining({
|
||||
arguments: expect.objectContaining({
|
||||
orderBy: ['_key'],
|
||||
field: ['category'],
|
||||
field: ['source'],
|
||||
size: [3],
|
||||
otherBucket: [true],
|
||||
}),
|
||||
|
@ -770,6 +770,34 @@ describe('terms', () => {
|
|||
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', () => {
|
||||
const updateLayerSpy = jest.fn();
|
||||
const instance = shallow(
|
||||
|
|
Loading…
Reference in a new issue