Move to 404 page if specified navigation not found
When refresh or link directly to ngdetails without correct navigation to be set, ngdetails view can not reproduce navigations, i.e. sidebar and breadcrumb. e.g. when the ordinary user try to open the URL specified as admin side. In this situation, ngdetails view should show 404 page. So this patch move to 404 page if the navigation does not exist. Change-Id: I7aeeddf838923d110703bfd7a04699b056c2abd5 Closes-Bug: #1761036
This commit is contained in:
parent
872ae60c76
commit
8c03ce0bcc
|
@ -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;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue