From 77921c4dcd43f9b8b1a1a392e13cda998456a4d5 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Mon, 13 Mar 2017 09:31:59 +0100 Subject: [PATCH] renderpng: fixes invalid image link (#7797) Closes #7770 --- .../app/features/dashboard/shareModalCtrl.js | 7 +++--- public/test/specs/shareModalCtrl-specs.js | 25 ++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard/shareModalCtrl.js b/public/app/features/dashboard/shareModalCtrl.js index d4075c1e641..6f3cb320bef 100644 --- a/public/app/features/dashboard/shareModalCtrl.js +++ b/public/app/features/dashboard/shareModalCtrl.js @@ -76,9 +76,10 @@ function (angular, _, $, moment, require, config) { $scope.shareUrl = linkSrv.addParamsToUrl(baseUrl, params); - var soloUrl = $scope.shareUrl; - soloUrl = soloUrl.replace(config.appSubUrl + '/dashboard/', config.appSubUrl + '/dashboard-solo/'); - soloUrl = soloUrl.replace("&fullscreen", "").replace("&edit", ""); + var soloUrl = baseUrl.replace(config.appSubUrl + '/dashboard/', config.appSubUrl + '/dashboard-solo/'); + delete params.fullscreen; + delete params.edit; + soloUrl = linkSrv.addParamsToUrl(soloUrl, params); $scope.iframeHtml = ''; diff --git a/public/test/specs/shareModalCtrl-specs.js b/public/test/specs/shareModalCtrl-specs.js index f23dcb61f3a..9d3e7f941d0 100644 --- a/public/test/specs/shareModalCtrl-specs.js +++ b/public/test/specs/shareModalCtrl-specs.js @@ -71,6 +71,30 @@ define([ expect(ctx.scope.shareUrl).to.be('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', function() { + ctx.$location.url('/test?fullscreen&edit'); + ctx.scope.modeSharePanel = true; + ctx.scope.panel = { id: 1 }; + + ctx.scope.buildUrl(); + + expect(ctx.scope.shareUrl).to.contain('?fullscreen&edit&from=1000&to=2000&orgId=1&panelId=1'); + expect(ctx.scope.imageUrl).to.contain('?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', function() { + ctx.$location.url('/test?edit&fullscreen'); + ctx.scope.modeSharePanel = true; + ctx.scope.panel = { id: 1 }; + + ctx.scope.buildUrl(); + + expect(ctx.scope.shareUrl).to.contain('?edit&fullscreen&from=1000&to=2000&orgId=1&panelId=1'); + expect(ctx.scope.imageUrl).to.contain('?from=1000&to=2000&orgId=1&panelId=1&width=1000&height=500&tz=UTC'); + + }); + it('should include template variables in url', function() { ctx.$location.path('/test'); ctx.scope.options.includeTemplateVars = true; @@ -83,7 +107,6 @@ define([ ctx.scope.buildUrl(); expect(ctx.scope.shareUrl).to.be('http://server/#!/test?from=1000&to=2000&orgId=1&var-app=mupp&var-server=srv-01'); }); - }); });