Skip to content

Commit 0f7c9e5

Browse files
committed
Add time range selector to the dashboard
1 parent 3e77535 commit 0f7c9e5

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

packages/grafana-ui/src/components/ToolbarButton/ToolbarButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ const getStyles = (theme: GrafanaTheme2) => {
188188
}),
189189
default: css({
190190
color: theme.colors.text.secondary,
191-
background: 'transparent',
191+
background: theme.colors.background.primary,
192192
border: `1px solid transparent`,
193193

194194
'&:hover': {

public/app/features/dashboard/containers/DashboardPage.tsx

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { cx } from '@emotion/css';
2+
import { Box } from '@mui/material';
23
import React, { PureComponent } from 'react';
34
import { connect, ConnectedProps, MapDispatchToProps, MapStateToProps } from 'react-redux';
45

56
import { NavModel, NavModelItem, TimeRange, PageLayoutType, locationUtil } from '@grafana/data';
67
import { selectors } from '@grafana/e2e-selectors';
78
import { config, locationService } from '@grafana/runtime';
8-
import { Themeable2, withTheme2 } from '@grafana/ui';
9+
import { Themeable2, withTheme2, ToolbarButtonRow } from '@grafana/ui';
910
import { notifyApp } from 'app/core/actions';
1011
import { Page } from 'app/core/components/Page/Page';
1112
import { EntityNotFound } from 'app/core/components/PageNotFound/EntityNotFound';
@@ -17,6 +18,7 @@ import { FnGlobalState } from 'app/core/reducers/fn-slice';
1718
import { getNavModel } from 'app/core/selectors/navModel';
1819
import { PanelModel } from 'app/features/dashboard/state';
1920
import { dashboardWatcher } from 'app/features/live/dashboard/dashboardWatcher';
21+
import { updateTimeZoneForSession } from 'app/features/profile/state/reducers';
2022
import { getPageNavFromSlug, getRootContentNavModel } from 'app/features/storage/StorageFolderPage';
2123
import { FNDashboardProps } from 'app/fn-app/types';
2224
import { DashboardRoutes, DashboardState, KioskMode, StoreState } from 'app/types';
@@ -25,7 +27,7 @@ import { PanelEditEnteredEvent, PanelEditExitedEvent } from 'app/types/events';
2527
import { cancelVariables, templateVarsChangedInUrl } from '../../variables/state/actions';
2628
import { findTemplateVarChanges } from '../../variables/utils';
2729
import { AddWidgetModal } from '../components/AddWidgetModal/AddWidgetModal';
28-
import { DashNav } from '../components/DashNav';
30+
import { DashNavTimeControls } from '../components/DashNav/DashNavTimeControls';
2931
import { DashboardFailed } from '../components/DashboardLoading/DashboardFailed';
3032
import { DashboardLoading } from '../components/DashboardLoading/DashboardLoading';
3133
import { FnLoader } from '../components/DashboardLoading/FnLoader';
@@ -409,19 +411,28 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
409411
scrollRef={this.setScrollRef}
410412
scrollTop={updateScrollTop}
411413
>
412-
{showToolbar && (
413-
<header data-testid={selectors.pages.Dashboard.DashNav.navV2}>
414-
<DashNav
414+
{/* {showToolbar && ( */}
415+
<header data-testid={selectors.pages.Dashboard.DashNav.navV2}>
416+
<Box mb={4}>
417+
<ToolbarButtonRow alignment="right">
418+
<DashNavTimeControls
419+
dashboard={dashboard}
420+
onChangeTimeZone={updateTimeZoneForSession}
421+
key="time-controls"
422+
/>
423+
</ToolbarButtonRow>
424+
</Box>
425+
{/* <DashNav
415426
dashboard={dashboard}
416427
title={dashboard.title}
417428
folderTitle={dashboard.meta.folderTitle}
418429
isFullscreen={!!viewPanel}
419430
onAddPanel={this.onAddPanel}
420431
kioskMode={kioskMode}
421432
hideTimePicker={dashboard.timepicker.hidden}
422-
/>
423-
</header>
424-
)}
433+
/> */}
434+
</header>
435+
{/* )} */}
425436
{!FNDashboard && <DashboardPrompt dashboard={dashboard} />}
426437
{initError && <DashboardFailed />}
427438
{showSubMenu && !FNDashboard && (

0 commit comments

Comments
 (0)