Merge "Add WEBROOT to ngdetails navigation" into stable/ussuri

This commit is contained in:
Zuul 2021-02-12 19:07:04 +00:00 committed by Gerrit Code Review
commit 664c6ec28e
3 changed files with 23 additions and 2 deletions

View File

@ -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;

View File

@ -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/');

View File

@ -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")) {