From 2ecc1bb6465a816c5801510fe4d3b204e8d366b5 Mon Sep 17 00:00:00 2001 From: Darren Janeczek <38694490+darrenjaneczek@users.noreply.github.com> Date: Wed, 27 Mar 2024 10:33:21 -0400 Subject: [PATCH] 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 --- .../trails/ActionTabs/AddToFiltersGraphAction.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/app/features/trails/ActionTabs/AddToFiltersGraphAction.tsx b/public/app/features/trails/ActionTabs/AddToFiltersGraphAction.tsx index b41e81f3473..d3a3d6d59f3 100644 --- a/public/app/features/trails/ActionTabs/AddToFiltersGraphAction.tsx +++ b/public/app/features/trails/ActionTabs/AddToFiltersGraphAction.tsx @@ -41,6 +41,15 @@ export class AddToFiltersGraphAction extends SceneObjectBase) => { + const state = model.useState(); + const labels = state.frame.fields[1]?.labels || {}; + + const canAddToFilters = Object.keys(labels).length !== 0; + + if (!canAddToFilters) { + return null; + } + return (