From f58d44dc67e5feb4e97adae4328e435333dc271f Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 23 Nov 2022 12:42:21 +0100 Subject: [PATCH] [v9.3.x] Solo Panel: Configurable timezone (#59202) Solo Panel: Configurable timezone (#59153) * Allow to set timezone in query * Use optional timestamp * Update timeZone (cherry picked from commit a0334a92f52178da4d01b81f9704e523b3336bbe) Co-authored-by: Selene --- public/app/features/dashboard/containers/SoloPanelPage.tsx | 7 +++++-- public/app/features/dashboard/dashgrid/DashboardPanel.tsx | 4 +++- .../app/features/dashboard/dashgrid/PanelStateWrapper.tsx | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard/containers/SoloPanelPage.tsx b/public/app/features/dashboard/containers/SoloPanelPage.tsx index 3573aeeee315..f81bcfcb5e31 100644 --- a/public/app/features/dashboard/containers/SoloPanelPage.tsx +++ b/public/app/features/dashboard/containers/SoloPanelPage.tsx @@ -26,7 +26,7 @@ const mapDispatchToProps = { const connector = connect(mapStateToProps, mapDispatchToProps); -export type Props = GrafanaRouteComponentProps & +export type Props = GrafanaRouteComponentProps & ConnectedProps; export interface State { @@ -87,6 +87,7 @@ export class SoloPanelPage extends Component { notFound={this.state.notFound} panel={this.state.panel} panelId={this.getPanelId()} + timezone={this.props.queryParams.timezone} /> ); } @@ -95,9 +96,10 @@ export class SoloPanelPage extends Component { export interface SoloPanelProps extends State { dashboard: DashboardModel | null; panelId: number; + timezone?: string; } -export const SoloPanel = ({ dashboard, notFound, panel, panelId }: SoloPanelProps) => { +export const SoloPanel = ({ dashboard, notFound, panel, panelId, timezone }: SoloPanelProps) => { if (notFound) { return
Panel with id {panelId} not found
; } @@ -123,6 +125,7 @@ export const SoloPanel = ({ dashboard, notFound, panel, panelId }: SoloPanelProp isEditing={false} isViewing={false} lazy={false} + timezone={timezone} /> ); }} diff --git a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx index f6b6a0cf367d..4f76e07a792c 100644 --- a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx @@ -20,6 +20,7 @@ export interface OwnProps { width: number; height: number; lazy?: boolean; + timezone?: string; } const mapStateToProps = (state: StoreState, props: OwnProps) => { @@ -70,7 +71,7 @@ export class DashboardPanelUnconnected extends PureComponent { }; renderPanel = (isInView: boolean) => { - const { dashboard, panel, isViewing, isEditing, width, height, plugin } = this.props; + const { dashboard, panel, isViewing, isEditing, width, height, plugin, timezone } = this.props; if (!plugin) { return null; @@ -102,6 +103,7 @@ export class DashboardPanelUnconnected extends PureComponent { width={width} height={height} onInstanceStateChange={this.onInstanceStateChange} + timezone={timezone} /> ); }; diff --git a/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx b/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx index c296384eec0a..bcd7ebbef261 100644 --- a/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx +++ b/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx @@ -61,6 +61,7 @@ export interface Props { width: number; height: number; onInstanceStateChange: (value: any) => void; + timezone?: string; } export interface State { @@ -521,6 +522,8 @@ export class PanelStateWrapper extends PureComponent { // Yes this is called ever render for a function that is triggered on every mouse move this.eventFilter.onlyLocal = dashboard.graphTooltip === 0; + const timeZone = this.props.timezone || this.props.dashboard.getTimezone(); + return ( <>
@@ -531,7 +534,7 @@ export class PanelStateWrapper extends PureComponent { data={data} title={panel.title} timeRange={timeRange} - timeZone={this.props.dashboard.getTimezone()} + timeZone={timeZone} options={panelOptions} fieldConfig={panel.fieldConfig} transparent={panel.transparent}