From 67b4c84399654438575b4fab2b86a619a98ee124 Mon Sep 17 00:00:00 2001 From: Marcus Andersson Date: Wed, 6 May 2020 09:48:30 +0200 Subject: [PATCH] Panel: will fix so the correct links is generated to the panel view. (#24301) * fixed a couple of bad links. * adjusted so we use the correct type of links. * cleaning up links regarding edit/viewing panels. * fixing edit link. * reverted back to panelId for the image urls. * reverted back. * remvoed the editPanel: null since it is obsolete. --- .../dashboard/components/DashNav/DashNav.tsx | 2 +- .../components/ShareModal/ShareLink.test.tsx | 19 ++++--------------- .../dashboard/components/ShareModal/utils.ts | 15 ++++++++------- .../dashboard/containers/DashboardPage.tsx | 5 ++--- .../dashboard/DashboardQueryEditor.tsx | 2 +- .../app/plugins/panel/alertlist/module.html | 2 +- .../plugins/panel/annolist/AnnoListPanel.tsx | 3 +-- 7 files changed, 18 insertions(+), 30 deletions(-) diff --git a/public/app/features/dashboard/components/DashNav/DashNav.tsx b/public/app/features/dashboard/components/DashNav/DashNav.tsx index 38a29c8eb58..c100415aaa4 100644 --- a/public/app/features/dashboard/components/DashNav/DashNav.tsx +++ b/public/app/features/dashboard/components/DashNav/DashNav.tsx @@ -67,7 +67,7 @@ class DashNav extends PureComponent { onClose = () => { this.props.updateLocation({ - query: { edit: null, viewPanel: null }, + query: { viewPanel: null }, partial: true, }); }; diff --git a/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx b/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx index 10caf5aeb5e..03583c717ae 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx @@ -95,7 +95,7 @@ describe('ShareModal', () => { it('should generate share url absolute time', () => { const state = ctx.wrapper?.state(); - expect(state?.shareUrl).toBe('http://server/#!/test?from=1000&to=2000&orgId=1&panelId=22&fullscreen'); + expect(state?.shareUrl).toBe('http://server/#!/test?from=1000&to=2000&orgId=1&viewPanel=22'); }); it('should generate render url', () => { @@ -139,25 +139,14 @@ describe('ShareModal', () => { expect(state?.shareUrl).toBe('http://server/#!/test?from=1000&to=2000&orgId=1&theme=light'); }); - it('should remove fullscreen from image url when is first param in querystring and modeSharePanel is true', () => { - mockLocationHref('http://server/#!/test?fullscreen&edit'); + it('should remove editPanel from image url when is first param in querystring', () => { + mockLocationHref('http://server/#!/test?editPanel=1'); ctx.mount({ panel: { id: 1, options: {}, fieldConfig: { defaults: {}, overrides: [] } }, }); const state = ctx.wrapper?.state(); - expect(state?.shareUrl).toContain('?fullscreen&edit&from=1000&to=2000&orgId=1&panelId=1'); - expect(state?.imageUrl).toContain('?from=1000&to=2000&orgId=1&panelId=1&width=1000&height=500&tz=UTC'); - }); - - it('should remove edit from image url when is first param in querystring and modeSharePanel is true', () => { - mockLocationHref('http://server/#!/test?edit&fullscreen'); - ctx.mount({ - panel: { id: 1, options: {}, fieldConfig: { defaults: {}, overrides: [] } }, - }); - - const state = ctx.wrapper?.state(); - expect(state?.shareUrl).toContain('?edit&fullscreen&from=1000&to=2000&orgId=1&panelId=1'); + expect(state?.shareUrl).toContain('?editPanel=1&from=1000&to=2000&orgId=1'); expect(state?.imageUrl).toContain('?from=1000&to=2000&orgId=1&panelId=1&width=1000&height=500&tz=UTC'); }); diff --git a/public/app/features/dashboard/components/ShareModal/utils.ts b/public/app/features/dashboard/components/ShareModal/utils.ts index dacc19d530b..00aec7d7fb2 100644 --- a/public/app/features/dashboard/components/ShareModal/utils.ts +++ b/public/app/features/dashboard/components/ShareModal/utils.ts @@ -29,12 +29,10 @@ export function buildParams( params.theme = selectedTheme; } - if (panel) { - params.panelId = panel.id; - params.fullscreen = true; + if (panel && !params.editPanel) { + params.viewPanel = panel.id; } else { - delete params.panelId; - delete params.fullscreen; + delete params.viewPanel; } return params; @@ -74,8 +72,11 @@ export function buildSoloUrl( let soloUrl = baseUrl.replace(config.appSubUrl + '/dashboard/', config.appSubUrl + '/dashboard-solo/'); soloUrl = soloUrl.replace(config.appSubUrl + '/d/', config.appSubUrl + '/d-solo/'); - delete params.fullscreen; - delete params.edit; + + params.panelId = params.editPanel ?? params.viewPanel; + delete params.editPanel; + delete params.viewPanel; + return urlUtil.appendQueryToUrl(soloUrl, urlUtil.toUrlParams(params)); } diff --git a/public/app/features/dashboard/containers/DashboardPage.tsx b/public/app/features/dashboard/containers/DashboardPage.tsx index ed840e350dd..36158cc4d67 100644 --- a/public/app/features/dashboard/containers/DashboardPage.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.tsx @@ -162,9 +162,8 @@ export class DashboardPage extends PureComponent { // Clear url state this.props.updateLocation({ query: { - edit: null, - fullscreen: null, - panelId: null, + editPanel: null, + viewPanel: null, }, partial: true, }); diff --git a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx index 1b1b0424ce8..5ed265b61a0 100644 --- a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx +++ b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx @@ -177,7 +177,7 @@ export class DashboardQueryEditor extends PureComponent { } // Same as current URL, but different panelId - const editURL = `d/${dashboard.uid}/${dashboard.title}?&fullscreen&edit&panelId=${query.panelId}`; + const editURL = `d/${dashboard.uid}/${dashboard.title}?&editPanel=${query.panelId}`; return (
diff --git a/public/app/plugins/panel/alertlist/module.html b/public/app/plugins/panel/alertlist/module.html index 0d2232153bf..ad964056ac7 100644 --- a/public/app/plugins/panel/alertlist/module.html +++ b/public/app/plugins/panel/alertlist/module.html @@ -12,7 +12,7 @@

- + {{alert.name}}

diff --git a/public/app/plugins/panel/annolist/AnnoListPanel.tsx b/public/app/plugins/panel/annolist/AnnoListPanel.tsx index f51b4043d5e..5f7e9b31510 100644 --- a/public/app/plugins/panel/annolist/AnnoListPanel.tsx +++ b/public/app/plugins/panel/annolist/AnnoListPanel.tsx @@ -118,8 +118,7 @@ export class AnnoListPanel extends PureComponent { }; if (options.navigateToPanel) { - params.panelId = anno.panelId; - params.fullscreen = true; + params.viewPanel = anno.panelId; } if (current.id === anno.dashboardId) {