Routing NG: Fix time range zoom not working when refresh enabled (#32023)

* Fix time range zoom not working when refresh enabled

* Review update
This commit is contained in:
Dominik Prokop 2021-03-16 14:25:40 +01:00 committed by GitHub
parent bb8a703428
commit e967ad9ca9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,6 +42,9 @@ type DashboardPageRouteSearchParams = {
editview?: string;
inspect?: string;
kiosk?: UrlQueryValue;
from?: string;
to?: string;
refresh?: string;
};
export interface Props extends GrafanaRouteComponentProps<DashboardPageRouteParams, DashboardPageRouteSearchParams> {
@ -138,9 +141,19 @@ export class DashboardPage extends PureComponent<Props, State> {
}
if (prevProps.location.search !== this.props.location.search) {
getTimeSrv().updateTimeRangeFromUrl();
const prevUrlParams = prevProps.queryParams;
const urlParams = this.props.queryParams;
if (urlParams?.from !== prevUrlParams?.from && urlParams?.to !== prevUrlParams?.to) {
getTimeSrv().updateTimeRangeFromUrl();
}
if (!prevUrlParams?.refresh && urlParams?.refresh) {
getTimeSrv().setAutoRefresh(urlParams.refresh);
}
const templateVarChanges = findTemplateVarChanges(this.props.queryParams, prevProps.queryParams);
if (templateVarChanges) {
templateVarsChangedInUrl(templateVarChanges);
}