From 343a0d5fe21d0c83662cf1f148a8f785b7a71c0b Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 11:15:03 -0400 Subject: [PATCH] [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 2ecc1bb6465a816c5801510fe4d3b204e8d366b5) Co-authored-by: Darren Janeczek <38694490+darrenjaneczek@users.noreply.github.com> --- .../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 (