adjust apply

This commit is contained in:
Sergej-Vlasov
2025-11-12 10:49:11 +00:00
parent dcd0152e4b
commit f4e3964edf
@@ -10,6 +10,7 @@ import {
sceneGraph,
SceneObjectBase,
VariableValueOption,
VariableValueSingle,
VizPanel,
} from '@grafana/scenes';
import { Button, Icon, Input, useStyles2, Checkbox, Dropdown, Stack } from '@grafana/ui';
@@ -107,15 +108,21 @@ function PanelGroupByActionRenderer({ model }: SceneComponentProps<PanelGroupByA
}, []);
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;
}
const groupByVariable = model.getGroupByVariable();
const selectedValues = checkedOptions.map((item) => item.value);
const selectedLabels = checkedOptions.map((item) => item.label);
if (groupByVariable) {
groupByVariable.changeValueTo(selectedValues, selectedLabels, true);