From d88286ab810cbfdf3455849aaa2376f42d86ca09 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 23 Feb 2017 11:03:37 +0100 Subject: [PATCH] orgs: set orgId as query param on load ref #1613 --- public/app/features/dashboard/viewStateSrv.js | 4 +++- .../test/specs/dashboardViewStateSrv-specs.js | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/public/app/features/dashboard/viewStateSrv.js b/public/app/features/dashboard/viewStateSrv.js index 681e1377bad..70590e3c497 100644 --- a/public/app/features/dashboard/viewStateSrv.js +++ b/public/app/features/dashboard/viewStateSrv.js @@ -2,8 +2,9 @@ define([ 'angular', 'lodash', 'jquery', + 'app/core/config' ], -function (angular, _, $) { +function (angular, _, $, config) { 'use strict'; var module = angular.module('grafana.services'); @@ -63,6 +64,7 @@ function (angular, _, $) { state.fullscreen = state.fullscreen ? true : null; state.edit = (state.edit === "true" || state.edit === true) || null; state.editview = state.editview || null; + state.orgId = config.bootData.user.orgId; return state; }; diff --git a/public/test/specs/dashboardViewStateSrv-specs.js b/public/test/specs/dashboardViewStateSrv-specs.js index 90e35810ac0..42bbf709655 100644 --- a/public/test/specs/dashboardViewStateSrv-specs.js +++ b/public/test/specs/dashboardViewStateSrv-specs.js @@ -1,6 +1,7 @@ define([ - 'app/features/dashboard/viewStateSrv' -], function() { + 'app/features/dashboard/viewStateSrv', + 'app/core/config' +], function(viewStateSrv, config) { 'use strict'; describe('when updating view state', function() { @@ -12,7 +13,13 @@ define([ orgId: 19 } }; - + beforeEach(function() { + config.bootData = { + user: { + orgId: 1 + } + }; + }); beforeEach(module('grafana.services')); beforeEach(module(function($provide) { $provide.value('timeSrv', timeSrv); @@ -31,7 +38,7 @@ define([ it('should update querystring and view state', function() { var updateState = {fullscreen: true, edit: true, panelId: 1}; viewState.update(updateState); - expect(location.search()).to.eql({fullscreen: true, edit: true, panelId: 1}); + expect(location.search()).to.eql({fullscreen: true, edit: true, panelId: 1, orgId: 1}); expect(viewState.dashboard.meta.fullscreen).to.be(true); expect(viewState.state.fullscreen).to.be(true); }); @@ -45,7 +52,5 @@ define([ expect(viewState.state.fullscreen).to.be(null); }); }); - }); - });