Merge "Move to 404 page if specified navigation not found"

This commit is contained in:
Zuul 2018-09-28 10:43:25 +00:00 committed by Gerrit Code Review
commit 7094da9ae3
3 changed files with 23 additions and 1 deletions

View File

@ -24,7 +24,8 @@
getActivePanelUrl: getActivePanelUrl,
collapseAllNavigation: collapseAllNavigation,
expandNavigationByUrl: expandNavigationByUrl,
setBreadcrumb: setBreadcrumb
setBreadcrumb: setBreadcrumb,
isNavigationExists: isNavigationExists
};
/* get URL for active panel on navigation side bar */
@ -105,5 +106,10 @@
breadcrumb.append(newItem);
});
}
/* 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,18 @@
});
});
describe('isNavigationExists', function() {
it('returns true if navigation for specified URL exists', function() {
var result = service.isNavigationExists('/project/images/');
expect(result).toEqual(true);
});
it('returns false if navigation for specified URL does not exist', function() {
var result = service.isNavigationExists('/not/found/');
expect(result).toEqual(false);
});
});
});
})();

View File

@ -74,6 +74,10 @@
if (query.hasOwnProperty("nav")) {
url = query.nav;
}
// check navigation from url
if (!navigationsService.isNavigationExists(url)) {
pageNotFound();
}
// set navigations (side bar and breadcrumb)
var labels = navigationsService.expandNavigationByUrl(url);
navigationsService.setBreadcrumb(labels);