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

This commit is contained in:
yinjialu 2022-10-28 00:00:14 +08:00 committed by GitHub
parent bff9671b81
commit 9aac0d32f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,8 +36,8 @@ export function LabelFilterItem({
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[] => {
@ -94,7 +94,11 @@ export function LabelFilterItem({
width="auto"
onChange={(change) => {
if (change.value != null) {
onChange({ ...item, op: change.value } as unknown as QueryBuilderLabelFilter);
onChange({
...item,
op: change.value,
value: isMultiSelect(change.value) ? item.value : getSelectOptionsFromString(item?.value)[0],
} as unknown as QueryBuilderLabelFilter);
}
}}
/>