mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
DEV: injects router in customHref/customFilter of addNavigationBarItem (#8018)
This commit is contained in:
@ -734,7 +734,8 @@ class PluginApi {
|
|||||||
* name: "link-to-bugs-category",
|
* name: "link-to-bugs-category",
|
||||||
* displayName: "bugs"
|
* displayName: "bugs"
|
||||||
* href: "/c/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) {
|
addNavigationBarItem(item) {
|
||||||
@ -745,6 +746,22 @@ class PluginApi {
|
|||||||
item
|
item
|
||||||
);
|
);
|
||||||
} else {
|
} 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);
|
addNavItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user