Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
This commit is contained in:
parent
ef5da0fa6c
commit
0e04be09f9
3 changed files with 8 additions and 6 deletions
|
@ -194,14 +194,16 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
|
|||
return { dataType: type as DataType, isBucketed: true, scale: 'ordinal' };
|
||||
}
|
||||
},
|
||||
getErrorMessage: (layer, columnId, indexPattern) =>
|
||||
[
|
||||
getErrorMessage: (layer, columnId, indexPattern) => {
|
||||
const messages = [
|
||||
...(getInvalidFieldMessage(
|
||||
layer.columns[columnId] as FieldBasedIndexPatternColumn,
|
||||
indexPattern
|
||||
) || []),
|
||||
getDisallowedTermsMessage(layer, columnId, indexPattern) || '',
|
||||
].filter(Boolean),
|
||||
].filter(Boolean);
|
||||
return messages.length ? messages : undefined;
|
||||
},
|
||||
isTransferable: (column, newIndexPattern) => {
|
||||
const newField = newIndexPattern.getFieldByName(column.sourceField);
|
||||
|
||||
|
|
|
@ -996,8 +996,8 @@ describe('terms', () => {
|
|||
indexPatternId: '',
|
||||
};
|
||||
});
|
||||
it('returns empty array', () => {
|
||||
expect(termsOperation.getErrorMessage!(layer, 'col1', indexPattern)).toEqual([]);
|
||||
it('returns undefined for no errors found', () => {
|
||||
expect(termsOperation.getErrorMessage!(layer, 'col1', indexPattern)).toEqual(undefined);
|
||||
});
|
||||
it('returns error message if the sourceField does not exist in index pattern', () => {
|
||||
layer = {
|
||||
|
|
|
@ -627,7 +627,7 @@ export function canTransition({
|
|||
Boolean(newColumn) &&
|
||||
!newLayer.incompleteColumns?.[columnId] &&
|
||||
filterOperations(newColumn) &&
|
||||
!newDefinition.getErrorMessage?.(newLayer, columnId, indexPattern)
|
||||
!newDefinition.getErrorMessage?.(newLayer, columnId, indexPattern)?.length
|
||||
);
|
||||
} catch (e) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue