From c4a31390efc756d7a95dbf110d75c90761c37f1e Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Tue, 2 May 2023 16:25:03 +0000 Subject: [PATCH] NestedFolders: Use new Browse Dashboards UI behind feature flag (#67416) NestedFolders: Put feature flagged new Browse Dashboards UI at main route --- pkg/api/api.go | 6 ---- .../browse-dashboards/components/NameCell.tsx | 13 ++++---- .../search/components/DashboardListPage.tsx | 33 ++++++++----------- public/app/routes/routes.tsx | 22 ------------- 4 files changed, 21 insertions(+), 53 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index f8aff7dd331..2577fbfd854 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -152,12 +152,6 @@ func (hs *HTTPServer) registerRoutes() { r.Get("/dashboards/*", reqSignedIn, hs.Index) r.Get("/goto/:uid", reqSignedIn, hs.redirectFromShortURL, hs.Index) - // Temporary routes for the work-in-progress new Browse Dashboards views - if hs.Features.IsEnabled(featuremgmt.FlagNestedFolders) { - r.Get("/nested-dashboards/", reqSignedIn, hs.Index) - r.Get("/nested-dashboards/*", reqSignedIn, hs.Index) - } - if hs.Features.IsEnabled(featuremgmt.FlagPublicDashboards) { // list public dashboards r.Get("/public-dashboards/list", reqSignedIn, hs.Index) diff --git a/public/app/features/browse-dashboards/components/NameCell.tsx b/public/app/features/browse-dashboards/components/NameCell.tsx index 4765b7042a1..5b86405934b 100644 --- a/public/app/features/browse-dashboards/components/NameCell.tsx +++ b/public/app/features/browse-dashboards/components/NameCell.tsx @@ -45,12 +45,13 @@ export function NameCell({ row: { original: data }, onFolderClick }: NameCellPro )} - - {item.title} - + {item.url ? ( + + {item.title} + + ) : ( + item.title + )} ); } diff --git a/public/app/features/search/components/DashboardListPage.tsx b/public/app/features/search/components/DashboardListPage.tsx index 5f018a14708..986c3f54452 100644 --- a/public/app/features/search/components/DashboardListPage.tsx +++ b/public/app/features/search/components/DashboardListPage.tsx @@ -4,11 +4,11 @@ import { useAsync } from 'react-use'; import { locationUtil, NavModelItem } from '@grafana/data'; import { config, locationService } from '@grafana/runtime'; -import { Badge, Link, Tooltip } from '@grafana/ui'; import { Page } from 'app/core/components/Page/Page'; +import { GrafanaRouteComponentProps } from 'app/core/navigation/types'; +import NewBrowseDashboardsPage from 'app/features/browse-dashboards/BrowseDashboardsPage'; import { FolderDTO } from 'app/types'; -import { GrafanaRouteComponentProps } from '../../../core/navigation/types'; import { loadFolderPage } from '../loaders'; import ManageDashboardsNew from './ManageDashboardsNew'; @@ -20,7 +20,16 @@ export interface DashboardListPageRouteParams { interface Props extends GrafanaRouteComponentProps {} -export const DashboardListPage = memo(({ match, location }: Props) => { +export const DashboardListPageFeatureToggle = memo((props: Props) => { + if (config.featureToggles.nestedFolders) { + return ; + } + + return ; +}); +DashboardListPageFeatureToggle.displayName = 'DashboardListPageFeatureToggle'; + +const DashboardListPage = memo(({ match, location }: Props) => { const { loading, value } = useAsync<() => Promise<{ folder?: FolderDTO; pageNav?: NavModelItem }>>(() => { const uid = match.params.uid; const url = location.pathname; @@ -41,21 +50,7 @@ export const DashboardListPage = memo(({ match, location }: Props) => { }, [match.params.uid]); return ( - - - - - - - - ) - } - > + { DashboardListPage.displayName = 'DashboardListPage'; -export default DashboardListPage; +export default DashboardListPageFeatureToggle; diff --git a/public/app/routes/routes.tsx b/public/app/routes/routes.tsx index edcbe8488bd..b8b466801f4 100644 --- a/public/app/routes/routes.tsx +++ b/public/app/routes/routes.tsx @@ -140,9 +140,6 @@ export function getAppRoutes(): RouteDescriptor[] { ) ), }, - - ...(config.featureToggles.nestedFolders ? getNestedFoldersRoutes() : []), - { path: '/dashboards', component: SafeDynamicImport( @@ -567,22 +564,3 @@ export function getDynamicDashboardRoutes(cfg = config): RouteDescriptor[] { }, ]; } - -function getNestedFoldersRoutes(): RouteDescriptor[] { - return [ - { - path: '/nested-dashboards', - component: SafeDynamicImport(() => import('app/features/browse-dashboards/BrowseDashboardsPage')), - }, - - { - path: '/nested-dashboards/f/:uid', - component: SafeDynamicImport(() => import('app/features/browse-dashboards/BrowseDashboardsPage')), - }, - - { - path: '/nested-dashboards/f/:uid/:slug', - component: SafeDynamicImport(() => import('app/features/browse-dashboards/BrowseDashboardsPage')), - }, - ]; -}