Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
59ea19e0
Commit
59ea19e0
authored
Dec 13, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:grafana/grafana into develop
parents
1eeb421d
fa29ff0d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
2 deletions
+49
-2
public/app/core/components/org_switcher.ts
+11
-2
public/app/core/specs/org_switcher.jest.ts
+38
-0
No files found.
public/app/core/components/org_switcher.ts
View file @
59ea19e0
...
...
@@ -61,10 +61,19 @@ export class OrgSwitchCtrl {
}
setUsingOrg
(
org
)
{
this
.
backendSrv
.
post
(
'/api/user/using/'
+
org
.
orgId
).
then
(()
=>
{
window
.
location
.
href
=
window
.
location
.
href
;
return
this
.
backendSrv
.
post
(
'/api/user/using/'
+
org
.
orgId
).
then
(()
=>
{
const
re
=
/orgId=
\d
+/gi
;
this
.
setWindowLocationHref
(
this
.
getWindowLocationHref
().
replace
(
re
,
'orgId='
+
org
.
orgId
));
});
}
getWindowLocationHref
()
{
return
window
.
location
.
href
;
}
setWindowLocationHref
(
href
:
string
)
{
window
.
location
.
href
=
href
;
}
}
export
function
orgSwitcher
()
{
...
...
public/app/core/specs/org_switcher.jest.ts
0 → 100644
View file @
59ea19e0
import
{
OrgSwitchCtrl
}
from
'../components/org_switcher'
;
import
q
from
'q'
;
jest
.
mock
(
'app/core/services/context_srv'
,
()
=>
({
contextSrv
:
{
user
:
{
orgId
:
1
}
}
}));
describe
(
'OrgSwitcher'
,
()
=>
{
describe
(
'when switching org'
,
()
=>
{
let
expectedHref
;
let
expectedUsingUrl
;
beforeEach
(()
=>
{
const
backendSrvStub
:
any
=
{
get
:
(
url
)
=>
{
return
q
.
resolve
([]);
},
post
:
(
url
)
=>
{
expectedUsingUrl
=
url
;
return
q
.
resolve
({});
}
};
const
orgSwitcherCtrl
=
new
OrgSwitchCtrl
(
backendSrvStub
);
orgSwitcherCtrl
.
getWindowLocationHref
=
()
=>
'http://localhost:3000?orgId=1'
;
orgSwitcherCtrl
.
setWindowLocationHref
=
(
href
)
=>
expectedHref
=
href
;
return
orgSwitcherCtrl
.
setUsingOrg
({
orgId
:
2
});
});
it
(
'should switch orgId in call to backend'
,
()
=>
{
expect
(
expectedUsingUrl
).
toBe
(
'/api/user/using/2'
);
});
it
(
'should switch orgId in url'
,
()
=>
{
expect
(
expectedHref
).
toBe
(
'http://localhost:3000?orgId=2'
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment