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
5ca03972
Commit
5ca03972
authored
Feb 06, 2018
by
Daniel Lee
Committed by
Torkel Ödegaard
Feb 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
org-switcher: should redirect to home page (#10782)
Fixes #10776
parent
45d66e4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
public/app/core/components/org_switcher.ts
+3
-7
public/app/core/specs/org_switcher.jest.ts
+9
-4
No files found.
public/app/core/components/org_switcher.ts
View file @
5ca03972
import
coreModule
from
'app/core/core_module'
;
import
{
contextSrv
}
from
'app/core/services/context_srv'
;
import
config
from
'app/core/config'
;
const
template
=
`
<div class="modal-body">
...
...
@@ -60,16 +61,11 @@ export class OrgSwitchCtrl {
setUsingOrg
(
org
)
{
return
this
.
backendSrv
.
post
(
'/api/user/using/'
+
org
.
orgId
).
then
(()
=>
{
const
re
=
/orgId=
\d
+/gi
;
this
.
setWindowLocationHref
(
this
.
getWindowLocationHref
().
replace
(
re
,
'orgId='
+
org
.
orgId
));
this
.
setWindowLocation
(
config
.
appSubUrl
+
(
config
.
appSubUrl
.
endsWith
(
'/'
)
?
''
:
'/'
)
+
'?orgId='
+
org
.
orgId
);
});
}
getWindowLocationHref
()
{
return
window
.
location
.
href
;
}
setWindowLocationHref
(
href
:
string
)
{
setWindowLocation
(
href
:
string
)
{
window
.
location
.
href
=
href
;
}
}
...
...
public/app/core/specs/org_switcher.jest.ts
View file @
5ca03972
...
...
@@ -7,6 +7,12 @@ jest.mock('app/core/services/context_srv', () => ({
},
}));
jest
.
mock
(
'app/core/config'
,
()
=>
{
return
{
appSubUrl
:
'/subUrl'
,
};
});
describe
(
'OrgSwitcher'
,
()
=>
{
describe
(
'when switching org'
,
()
=>
{
let
expectedHref
;
...
...
@@ -25,8 +31,7 @@ describe('OrgSwitcher', () => {
const
orgSwitcherCtrl
=
new
OrgSwitchCtrl
(
backendSrvStub
);
orgSwitcherCtrl
.
getWindowLocationHref
=
()
=>
'http://localhost:3000?orgId=1&from=now-3h&to=now'
;
orgSwitcherCtrl
.
setWindowLocationHref
=
href
=>
(
expectedHref
=
href
);
orgSwitcherCtrl
.
setWindowLocation
=
href
=>
(
expectedHref
=
href
);
return
orgSwitcherCtrl
.
setUsingOrg
({
orgId
:
2
});
});
...
...
@@ -35,8 +40,8 @@ describe('OrgSwitcher', () => {
expect
(
expectedUsingUrl
).
toBe
(
'/api/user/using/2'
);
});
it
(
'should switch orgId in url'
,
()
=>
{
expect
(
expectedHref
).
toBe
(
'
http://localhost:3000?orgId=2&from=now-3h&to=now
'
);
it
(
'should switch orgId in url
and redirect to home page
'
,
()
=>
{
expect
(
expectedHref
).
toBe
(
'
/subUrl/?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