summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-02-12 19:07:04 +0000
committerGerrit Code Review <review@openstack.org>2021-02-12 19:07:04 +0000
commit664c6ec28ec56ffd7474fba7ebce43dbdcf65543 (patch)
treefd9e8b3f0a53e461ddb3f2f2693d1e9bff8a88d1
parent885ce37cc6ea11c15d833db88d86943d6273a0ae (diff)
parentcd4d3aa1a6db93305d88387e1ea163947a6b62f6 (diff)
downloadhorizon-664c6ec28ec56ffd7474fba7ebce43dbdcf65543.tar.gz
Merge "Add WEBROOT to ngdetails navigation" into stable/ussuri18.3.3
-rw-r--r--horizon/static/framework/util/navigations/navigations.service.js9
-rw-r--r--horizon/static/framework/util/navigations/navigations.service.spec.js7
-rw-r--r--horizon/static/framework/widgets/details/routed-details-view.controller.js9
3 files changed, 23 insertions, 2 deletions
diff --git a/horizon/static/framework/util/navigations/navigations.service.js b/horizon/static/framework/util/navigations/navigations.service.js
index 8da8746c0..5d7a3571f 100644
--- a/horizon/static/framework/util/navigations/navigations.service.js
+++ b/horizon/static/framework/util/navigations/navigations.service.js
@@ -25,6 +25,7 @@
collapseAllNavigation: collapseAllNavigation,
expandNavigationByUrl: expandNavigationByUrl,
setBreadcrumb: setBreadcrumb,
+ setAbsoluteURI: setAbsoluteURI,
isNavigationExists: isNavigationExists
};
@@ -107,6 +108,14 @@
});
}
+ /* set absolute uri */
+ function setAbsoluteURI(webroot, url) {
+ if (webroot.endsWith("/") && url.startsWith("/")) {
+ webroot = webroot.slice(0, -1);
+ }
+ return webroot + url;
+ }
+
/* check whether navigation exists from url */
function isNavigationExists(url) {
return angular.element("a.openstack-panel[href='" + url + "']").length ? true : false;
diff --git a/horizon/static/framework/util/navigations/navigations.service.spec.js b/horizon/static/framework/util/navigations/navigations.service.spec.js
index 44c3e3bfd..3326374af 100644
--- a/horizon/static/framework/util/navigations/navigations.service.spec.js
+++ b/horizon/static/framework/util/navigations/navigations.service.spec.js
@@ -158,6 +158,13 @@
});
});
+ describe('setAbsoluteURI', function() {
+ it('sets absolute uri', function() {
+ var url = service.setAbsoluteURI('/dashboard/', '/project/images/');
+ expect(url).toBe('/dashboard/project/images/');
+ });
+ });
+
describe('isNavigationExists', function() {
it('returns true if navigation for specified URL exists', function() {
var result = service.isNavigationExists('/project/images/');
diff --git a/horizon/static/framework/widgets/details/routed-details-view.controller.js b/horizon/static/framework/widgets/details/routed-details-view.controller.js
index 739dc5d7e..cea3e4102 100644
--- a/horizon/static/framework/widgets/details/routed-details-view.controller.js
+++ b/horizon/static/framework/widgets/details/routed-details-view.controller.js
@@ -28,7 +28,8 @@
'horizon.framework.widgets.modal-wait-spinner.service',
'$location',
'$q',
- '$routeParams'
+ '$routeParams',
+ '$window'
];
function controller(
@@ -39,7 +40,8 @@
spinnerService,
$location,
$q,
- $routeParams
+ $routeParams,
+ $window
) {
var ctrl = this;
@@ -69,6 +71,9 @@
// get defaultIndexUrl
var url = resourceType.getDefaultIndexUrl();
+ // add webroot
+ var webroot = $window.WEBROOT;
+ url = navigationsService.setAbsoluteURI(webroot, url);
// if querystring has 'nav' parameter, overwrite the url
var query = $location.search();
if (query.hasOwnProperty("nav")) {