Prometheus: fix Raw query is not updated when label op change. (#57492) (#57493) (#57780)

(cherry picked from commit 9aac0d32f9)

Co-authored-by: yinjialu <37073056+yinjialu@users.noreply.github.com>
This commit is contained in:
ismail simsek
2022-10-27 14:24:07 -04:00
committed by GitHub
co-authored by yinjialu
parent 2576f05029
commit e71e6ae07e
@@ -25,8 +25,8 @@ export function LabelFilterItem({ item, defaultOp, onChange, onDelete, onGetLabe
isLoadingLabelValues?: boolean;
}>({});
const isMultiSelect = () => {
return operators.find((op) => op.label === item.op)?.isMultiValue;
const isMultiSelect = (operator = item.op) => {
return operators.find((op) => op.label === operator)?.isMultiValue;
};
const getSelectOptionsFromString = (item?: string): string[] => {
@@ -82,7 +82,11 @@ export function LabelFilterItem({ item, defaultOp, onChange, onDelete, onGetLabe
width="auto"
onChange={(change) => {
if (change.value != null) {
onChange({ ...item, op: change.value } as any as QueryBuilderLabelFilter);
onChange({
...item,
op: change.value,
value: isMultiSelect(change.value) ? item.value : getSelectOptionsFromString(item?.value)[0],
} as any as QueryBuilderLabelFilter);
}
}}
/>