mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 01:46:39 +08:00
DEV: injects router in customHref/customFilter of addNavigationBarItem (#8018)
This commit is contained in:
parent
f27564a0a0
commit
6f70138f4a
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user