mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
datatrails: hide "add to filter" button when there is no label value to add to filter (#85270)
fix: hide add to filters button when it won't work
This commit is contained in:
parent
d4953f4a1f
commit
2ecc1bb646
@ -41,6 +41,15 @@ export class AddToFiltersGraphAction extends SceneObjectBase<AddToFiltersGraphAc
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static Component = ({ model }: SceneComponentProps<AddToFiltersGraphAction>) => {
|
public static Component = ({ model }: SceneComponentProps<AddToFiltersGraphAction>) => {
|
||||||
|
const state = model.useState();
|
||||||
|
const labels = state.frame.fields[1]?.labels || {};
|
||||||
|
|
||||||
|
const canAddToFilters = Object.keys(labels).length !== 0;
|
||||||
|
|
||||||
|
if (!canAddToFilters) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button variant="secondary" size="sm" fill="solid" onClick={model.onClick}>
|
<Button variant="secondary" size="sm" fill="solid" onClick={model.onClick}>
|
||||||
Add to filters
|
Add to filters
|
||||||
|
Loading…
Reference in New Issue
Block a user