Fixes based on review.

This commit is contained in:
Yaroslav Kuznietsov 2021-05-31 10:40:57 +03:00
parent 4618802457
commit 35af7b2b6a
4 changed files with 10 additions and 17 deletions

View file

@ -49,7 +49,7 @@ export interface ColorRulesOperator {
label: string;
method: Operator;
value?: unknown;
isValueConstant?: boolean;
hideValueSelector?: boolean;
}
const defaultSecondaryName = i18n.translate(
@ -92,7 +92,7 @@ export const colorRulesOperatorsList: ColorRulesOperator[] = [
defaultMessage: 'empty',
}),
method: Operator.Empty,
isValueConstant: true,
hideValueSelector: true,
},
];
@ -148,7 +148,7 @@ export class ColorRules extends Component<ColorRulesProps> {
(operator) => model.operator === operator.method
);
const hideValueSelectorField = selectedOperator?.isValueConstant ?? false;
const hideValueSelectorField = selectedOperator?.hideValueSelector ?? false;
const labelStyle = { marginBottom: 0 };
let secondary;

View file

@ -13,7 +13,7 @@ import {
commonAddSupportOfDualIndexSelectionModeInTSVB,
commonHideTSVBLastValueIndicator,
commonRemoveDefaultIndexPatternAndTimeFieldFromTSVBModel,
commonAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules,
commonAddEmptyValueColorRule,
} from '../migrations/visualization_common_migrations';
const byValueAddSupportOfDualIndexSelectionModeInTSVB = (state: SerializableState) => {
@ -42,7 +42,7 @@ const byValueAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRule = (
) => {
return {
...state,
savedVis: commonAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules(state.savedVis),
savedVis: commonAddEmptyValueColorRule(state.savedVis),
};
};

View file

@ -46,9 +46,7 @@ export const commonRemoveDefaultIndexPatternAndTimeFieldFromTSVBModel = (visStat
return visState;
};
export const commonAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules = (
visState: any
) => {
export const commonAddEmptyValueColorRule = (visState: any) => {
if (visState && visState.type === 'metrics') {
const params: any = get(visState, 'params') || {};

View file

@ -15,7 +15,7 @@ import {
commonAddSupportOfDualIndexSelectionModeInTSVB,
commonHideTSVBLastValueIndicator,
commonRemoveDefaultIndexPatternAndTimeFieldFromTSVBModel,
commonAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules,
commonAddEmptyValueColorRule,
} from './visualization_common_migrations';
const migrateIndexPattern: SavedObjectMigrationFn<any, any> = (doc) => {
@ -967,10 +967,7 @@ const removeDefaultIndexPatternAndTimeFieldFromTSVBModel: SavedObjectMigrationFn
};
};
const addEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules: SavedObjectMigrationFn<
any,
any
> = (doc) => {
const addEmptyValueColorRule: SavedObjectMigrationFn<any, any> = (doc) => {
const visStateJSON = get(doc, 'attributes.visState');
let visState;
@ -980,9 +977,7 @@ const addEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules: SavedObje
} catch (e) {
// Let it go, the data is invalid and we'll leave it as is
}
const newVisState = commonAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules(
visState
);
const newVisState = commonAddEmptyValueColorRule(visState);
return {
...doc,
@ -1041,5 +1036,5 @@ export const visualizationSavedObjectTypeMigrations = {
hideTSVBLastValueIndicator,
removeDefaultIndexPatternAndTimeFieldFromTSVBModel
),
'7.14.0': flow(addEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules),
'7.14.0': flow(addEmptyValueColorRule),
};