adjust apply
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
sceneGraph,
|
sceneGraph,
|
||||||
SceneObjectBase,
|
SceneObjectBase,
|
||||||
VariableValueOption,
|
VariableValueOption,
|
||||||
|
VariableValueSingle,
|
||||||
VizPanel,
|
VizPanel,
|
||||||
} from '@grafana/scenes';
|
} from '@grafana/scenes';
|
||||||
import { Button, Icon, Input, useStyles2, Checkbox, Dropdown, Stack } from '@grafana/ui';
|
import { Button, Icon, Input, useStyles2, Checkbox, Dropdown, Stack } from '@grafana/ui';
|
||||||
@@ -107,15 +108,21 @@ function PanelGroupByActionRenderer({ model }: SceneComponentProps<PanelGroupByA
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleApply = useCallback(() => {
|
const handleApply = useCallback(() => {
|
||||||
const checkedOptions = options.filter((opt) => opt.checked);
|
const selectedValues: VariableValueSingle[] = [];
|
||||||
|
const selectedLabels: string[] = [];
|
||||||
|
|
||||||
if (!checkedOptions.length) {
|
for (const option of options) {
|
||||||
|
if (option.checked) {
|
||||||
|
selectedValues.push(option.value);
|
||||||
|
selectedLabels.push(option.label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedValues.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const groupByVariable = model.getGroupByVariable();
|
const groupByVariable = model.getGroupByVariable();
|
||||||
const selectedValues = checkedOptions.map((item) => item.value);
|
|
||||||
const selectedLabels = checkedOptions.map((item) => item.label);
|
|
||||||
|
|
||||||
if (groupByVariable) {
|
if (groupByVariable) {
|
||||||
groupByVariable.changeValueTo(selectedValues, selectedLabels, true);
|
groupByVariable.changeValueTo(selectedValues, selectedLabels, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user