Skip to content

Commit

Permalink
Fix based on the review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaroslav Kuznietsov committed May 31, 2021
1 parent b0058e1 commit 3d9d1d8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ColorRulesOperator {
label: string;
method: Operator;
value?: unknown;
isValueConstant?: boolean;
hideValueSelector?: boolean;
}

const defaultSecondaryName = i18n.translate(
Expand Down Expand Up @@ -92,7 +92,7 @@ export const colorRulesOperatorsList: ColorRulesOperator[] = [
defaultMessage: 'empty',
}),
method: Operator.Empty,
isValueConstant: true,
hideValueSelector: true,
},
];

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
commonAddSupportOfDualIndexSelectionModeInTSVB,
commonHideTSVBLastValueIndicator,
commonRemoveDefaultIndexPatternAndTimeFieldFromTSVBModel,
commonAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules,
commonAddEmptyValueColorRule,
} from '../migrations/visualization_common_migrations';

const byValueAddSupportOfDualIndexSelectionModeInTSVB = (state: SerializableState) => {
Expand All @@ -37,12 +37,10 @@ const byValueRemoveDefaultIndexPatternAndTimeFieldFromTSVBModel = (state: Serial
};
};

const byValueAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRule = (
state: SerializableState
) => {
const byValueAddEmptyValueColorRule = (state: SerializableState) => {
return {
...state,
savedVis: commonAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules(state.savedVis),
savedVis: commonAddEmptyValueColorRule(state.savedVis),
};
};

Expand All @@ -57,8 +55,7 @@ export const visualizeEmbeddableFactory = (): EmbeddableRegistryDefinition => {
byValueHideTSVBLastValueIndicator,
byValueRemoveDefaultIndexPatternAndTimeFieldFromTSVBModel
)(state),
'7.14.0': (state) =>
flow(byValueAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRule)(state),
'7.14.0': (state) => flow(byValueAddEmptyValueColorRule)(state),
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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') || {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
commonAddSupportOfDualIndexSelectionModeInTSVB,
commonHideTSVBLastValueIndicator,
commonRemoveDefaultIndexPatternAndTimeFieldFromTSVBModel,
commonAddEmptyValueRuleForSavedObjectsWithLessAndGreaterThenZeroRules,
commonAddEmptyValueColorRule,
} from './visualization_common_migrations';

const migrateIndexPattern: SavedObjectMigrationFn<any, any> = (doc) => {
Expand Down Expand Up @@ -980,9 +980,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,
Expand Down

0 comments on commit 3d9d1d8

Please sign in to comment.