diff --git a/public/app/features/dashboard-scene/pages/DashboardScenePage.test.tsx b/public/app/features/dashboard-scene/pages/DashboardScenePage.test.tsx index e6953c5e135..3b8e8699882 100644 --- a/public/app/features/dashboard-scene/pages/DashboardScenePage.test.tsx +++ b/public/app/features/dashboard-scene/pages/DashboardScenePage.test.tsx @@ -124,7 +124,7 @@ describe('DashboardScenePage', () => { locationService.push('/'); getDashboardScenePageStateManager().clearDashboardCache(); loadDashboardMock.mockClear(); - loadDashboardMock.mockResolvedValue({ dashboard: simpleDashboard, meta: {} }); + loadDashboardMock.mockResolvedValue({ dashboard: simpleDashboard, meta: { slug: '123' } }); // hacky way because mocking autosizer does not work Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { configurable: true, value: 1000 }); Object.defineProperty(HTMLElement.prototype, 'offsetWidth', { configurable: true, value: 1000 }); @@ -241,7 +241,7 @@ describe('DashboardScenePage', () => { }); it('is in edit mode when coming from explore to an existing dashboard', async () => { - store.setObject(DASHBOARD_FROM_LS_KEY, { dashboard: simpleDashboard }); + store.setObject(DASHBOARD_FROM_LS_KEY, { dashboard: simpleDashboard, meta: { slug: '123' } }); setup(); diff --git a/public/app/features/dashboard-scene/scene/DashboardScene.tsx b/public/app/features/dashboard-scene/scene/DashboardScene.tsx index eebc3be983e..3358f3f696c 100644 --- a/public/app/features/dashboard-scene/scene/DashboardScene.tsx +++ b/public/app/features/dashboard-scene/scene/DashboardScene.tsx @@ -396,6 +396,7 @@ export class DashboardScene extends SceneObjectBase { slug: meta.slug, currentQueryParams: location.search, updateQuery: { viewPanel: null, inspect: null, editview: null, editPanel: null, tab: null }, + isHomeDashboard: !meta.url && !meta.slug && !meta.isNew, }), }; diff --git a/public/app/features/dashboard-scene/scene/DashboardSceneRenderer.tsx b/public/app/features/dashboard-scene/scene/DashboardSceneRenderer.tsx index 7a0ab70610e..694c002720b 100644 --- a/public/app/features/dashboard-scene/scene/DashboardSceneRenderer.tsx +++ b/public/app/features/dashboard-scene/scene/DashboardSceneRenderer.tsx @@ -14,7 +14,7 @@ import { DashboardScene } from './DashboardScene'; import { NavToolbarActions } from './NavToolbarActions'; export function DashboardSceneRenderer({ model }: SceneComponentProps) { - const { controls, overlay, editview, editPanel, isEmpty, scopes } = model.useState(); + const { controls, overlay, editview, editPanel, isEmpty, scopes, meta } = model.useState(); const { isExpanded: isScopesExpanded } = scopes?.useState() ?? {}; const styles = useStyles2(getStyles); const location = useLocation(); @@ -22,6 +22,7 @@ export function DashboardSceneRenderer({ model }: SceneComponentProps {scopes && } - {controls && ( + {!isHomePage && controls && (
@@ -62,7 +63,7 @@ export function DashboardSceneRenderer({ model }: SceneComponentProps )} -
+
<>{isEmpty && emptyState} {withPanels}
@@ -115,6 +116,9 @@ function getStyles(theme: GrafanaTheme2) { controlsWrapperWithScopes: css({ padding: theme.spacing(2, 2, 2, 0), }), + homePagePadding: css({ + padding: theme.spacing(2, 2), + }), canvasContent: css({ label: 'canvas-content', display: 'flex', diff --git a/public/app/features/dashboard-scene/utils/urlBuilders.ts b/public/app/features/dashboard-scene/utils/urlBuilders.ts index e3e7ae8331c..fc334be29fb 100644 --- a/public/app/features/dashboard-scene/utils/urlBuilders.ts +++ b/public/app/features/dashboard-scene/utils/urlBuilders.ts @@ -22,6 +22,8 @@ export interface DashboardUrlOptions { absolute?: boolean; // Add tz to query params timeZone?: string; + // Check if we are on the home dashboard + isHomeDashboard?: boolean; } export function getDashboardUrl(options: DashboardUrlOptions) { @@ -54,6 +56,10 @@ export function getDashboardUrl(options: DashboardUrlOptions) { }; } + if (options.isHomeDashboard) { + path = '/'; + } + const params = options.currentQueryParams ? locationSearchToObject(options.currentQueryParams) : {}; if (options.updateQuery) {