[v11.0.x] datatrails: hide "add to filter" button when there is no label value to add to filter (#85502)
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
(cherry picked from commit 2ecc1bb646)
Co-authored-by: Darren Janeczek <38694490+darrenjaneczek@users.noreply.github.com>
This commit is contained in:
co-authored by
Darren Janeczek
parent
159719ba2a
commit
343a0d5fe2
@@ -41,6 +41,15 @@ export class AddToFiltersGraphAction extends SceneObjectBase<AddToFiltersGraphAc
|
||||
};
|
||||
|
||||
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 (
|
||||
<Button variant="secondary" size="sm" fill="solid" onClick={model.onClick}>
|
||||
Add to filters
|
||||
|
||||
Reference in New Issue
Block a user