From 8b44c7ceee9b23981dac054ae4b7348eb520e6a0 Mon Sep 17 00:00:00 2001 From: Dan Hodgson Date: Thu, 12 Dec 2024 10:02:00 +0000 Subject: [PATCH] fix(scopes): add missing dashboards toggle button --- .../scopes/internal/ScopesDashboardsScene.tsx | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/public/app/features/scopes/internal/ScopesDashboardsScene.tsx b/public/app/features/scopes/internal/ScopesDashboardsScene.tsx index e838286df3..acf5e7d872 100644 --- a/public/app/features/scopes/internal/ScopesDashboardsScene.tsx +++ b/public/app/features/scopes/internal/ScopesDashboardsScene.tsx @@ -3,7 +3,7 @@ import { isEqual } from 'lodash'; import { GrafanaTheme2, ScopeDashboardBinding } from '@grafana/data'; import { SceneComponentProps, SceneObjectBase, SceneObjectRef, SceneObjectState } from '@grafana/scenes'; -import { Button, CustomScrollbar, LoadingPlaceholder, useStyles2 } from '@grafana/ui'; +import { Button, CustomScrollbar, IconButton, LoadingPlaceholder, useStyles2 } from '@grafana/ui'; import { t, Trans } from 'app/core/internationalization'; import { ScopesDashboardsTree } from './ScopesDashboardsTree'; @@ -16,11 +16,8 @@ import { filterFolders, getScopeNamesFromSelectedScopes, groupDashboards } from export interface ScopesDashboardsSceneState extends SceneObjectState { selector: SceneObjectRef | null; - // by keeping a track of the raw response, it's much easier to check if we got any dashboards for the currently selected scopes dashboards: ScopeDashboardBinding[]; - // this is a grouping in folders of the `dashboards` property. it is used for filtering the dashboards and folders when the search query changes folders: SuggestedDashboardsFoldersMap; - // a filtered version of the `folders` property. this prevents a lot of unnecessary parsings in React renders filteredFolders: SuggestedDashboardsFoldersMap; forScopeNames: string[]; isLoading: boolean; @@ -173,10 +170,23 @@ export function ScopesDashboardsSceneRenderer({ model }: SceneComponentProps model.togglePanel()} + /> + ); + + if (!isEnabled) { return null; } + if (!isPanelOpened) { + return toggleButton; + } + if (!isLoading) { if (!scopesSelected) { return ( @@ -184,6 +194,7 @@ export function ScopesDashboardsSceneRenderer({ model }: SceneComponentProps + {toggleButton} No scopes selected ); @@ -193,6 +204,7 @@ export function ScopesDashboardsSceneRenderer({ model }: SceneComponentProps + {toggleButton} No dashboards found for the selected scopes ); @@ -201,11 +213,14 @@ export function ScopesDashboardsSceneRenderer({ model }: SceneComponentProps - model.changeSearchQuery(value)} - /> +
+ {toggleButton} + model.changeSearchQuery(value)} + /> +
{isLoading ? ( { loadingIndicator: css({ alignSelf: 'center', }), + header: css({ + display: 'flex', + alignItems: 'center', + gap: theme.spacing(1), + }), }; };