DEV: injects router in customHref/customFilter of addNavigationBarItem (#8018)

This commit is contained in:
Joffrey JAFFEUX 2019-08-19 18:33:12 +02:00 committed by GitHub
parent f27564a0a0
commit 6f70138f4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -734,7 +734,8 @@ class PluginApi {
* name: "link-to-bugs-category",
* displayName: "bugs"
* href: "/c/bugs",
* customFilter: (category, args) => { category && category.get('name') !== 'bug' }
* customFilter: (category, args, router) => { category && category.name !== 'bug' }
* customHref: (category, args, router) => { if (category && category.name) === 'not-a-bug') "/a-feature"; }
* })
*/
addNavigationBarItem(item) {
@ -745,6 +746,22 @@ class PluginApi {
item
);
} else {
const customHref = item.customHref;
if (customHref) {
const router = this.container.lookup("service:router");
item.customHref = function(category, args) {
return customHref(category, args, router);
};
}
const customFilter = item.customFilter;
if (customFilter) {
const router = this.container.lookup("service:router");
item.customFilter = function(category, args) {
return customFilter(category, args, router);
};
}
addNavItem(item);
}
}