From 5c052684fbbaec12d78ccf4d4e69b4e48557c2cd Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 10 May 2023 12:32:18 +0100 Subject: [PATCH] [v10.0.x] Nested folders: Redo search query when actions complete (#68193) Nested folders: Redo search query when actions complete (#68102) redo search query if searching when actions complete (cherry picked from commit 135b0a25aa14ee670f5e9979fba3fff876690fbd) Co-authored-by: Ashley Harrison --- .../components/BrowseActions/BrowseActions.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx b/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx index 68479753977..07b607d1c7f 100644 --- a/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx +++ b/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx @@ -4,6 +4,7 @@ import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, useStyles2 } from '@grafana/ui'; import appEvents from 'app/core/app_events'; +import { useSearchStateManager } from 'app/features/search/state/SearchStateManager'; import { useDispatch, useSelector } from 'app/types'; import { ShowModalReactEvent } from 'app/types/events'; @@ -33,6 +34,8 @@ export function BrowseActions() { const selectedFolders = Object.keys(selectedItems.folder).filter((uid) => selectedItems.folder[uid]); const rootItems = useSelector(rootItemsSelector); const childrenByParentUID = useSelector(childrenByParentUIDSelector); + const [, stateManager] = useSearchStateManager(); + const isSearching = stateManager.hasSearchFilters(); const onActionComplete = (parentsToRefresh: Set) => { dispatch( @@ -40,8 +43,14 @@ export function BrowseActions() { isSelected: false, }) ); - for (const parentUID of parentsToRefresh) { - dispatch(fetchChildren(parentUID)); + if (isSearching) { + // Redo search query + stateManager.doSearchWithDebounce(); + } else { + // Refetch parents + for (const parentUID of parentsToRefresh) { + dispatch(fetchChildren(parentUID)); + } } };