From c6e9ffb1689ccf991346e3bcb8bd1faf5f751107 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Tue, 17 Jul 2018 12:56:05 +0200 Subject: [PATCH] Use url params for explore state - putting state in the path components led to 400 on reload - use `/explore?state=JSON` instead --- pkg/api/api.go | 3 +-- public/app/containers/Explore/Explore.tsx | 2 +- public/app/core/services/keybindingSrv.ts | 2 +- public/app/features/panel/metrics_panel_ctrl.ts | 2 +- public/app/routes/routes.ts | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 8870b9b095e..84425fdae3d 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -73,8 +73,7 @@ func (hs *HTTPServer) registerRoutes() { r.Get("/dashboards/", reqSignedIn, Index) r.Get("/dashboards/*", reqSignedIn, Index) - r.Get("/explore/", reqEditorRole, Index) - r.Get("/explore/*", reqEditorRole, Index) + r.Get("/explore", reqEditorRole, Index) r.Get("/playlists/", reqSignedIn, Index) r.Get("/playlists/*", reqSignedIn, Index) diff --git a/public/app/containers/Explore/Explore.tsx b/public/app/containers/Explore/Explore.tsx index 81e1922d2cd..6486a3a58c9 100644 --- a/public/app/containers/Explore/Explore.tsx +++ b/public/app/containers/Explore/Explore.tsx @@ -67,7 +67,7 @@ interface IExploreState { export class Explore extends React.Component { constructor(props) { super(props); - const { datasource, queries, range } = parseInitialState(props.routeParams.initial); + const { datasource, queries, range } = parseInitialState(props.routeParams.state); this.state = { datasource: null, datasourceError: null, diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index cbc7871fbbd..672ae29740b 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -191,7 +191,7 @@ export class KeybindingSrv { range, }; const exploreState = encodePathComponent(JSON.stringify(state)); - this.$location.url(`/explore/${exploreState}`); + this.$location.url(`/explore?state=${exploreState}`); } } }); diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index 6eb6d3b3b00..3567abf948b 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -332,7 +332,7 @@ class MetricsPanelCtrl extends PanelCtrl { range, }; const exploreState = encodePathComponent(JSON.stringify(state)); - this.$location.url(`/explore/${exploreState}`); + this.$location.url(`/explore?state=${exploreState}`); } addQuery(target) { diff --git a/public/app/routes/routes.ts b/public/app/routes/routes.ts index cd1aed549e0..d12711aca5b 100644 --- a/public/app/routes/routes.ts +++ b/public/app/routes/routes.ts @@ -112,7 +112,7 @@ export function setupAngularRoutes($routeProvider, $locationProvider) { controller: 'FolderDashboardsCtrl', controllerAs: 'ctrl', }) - .when('/explore/:initial?', { + .when('/explore', { template: '', resolve: { roles: () => ['Editor', 'Admin'],