Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: uses simpler patternj for custom href on extra nav items #8015

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 7 additions & 12 deletions app/assets/javascripts/discourse/models/nav-item.js.es6
Expand Up @@ -101,18 +101,8 @@ const NavItem = Discourse.Model.extend({
});

const ExtraNavItem = NavItem.extend({
href: Ember.computed({
set(key, value) {
let customHref;
NavItem.customNavItemHrefs.forEach(function(cb) {
customHref = cb.call(this, this);
if (customHref) {
return false;
}
}, this);
return customHref || value;
}
}),
@computed("href")
href: href => href,

customFilter: null
});
Expand Down Expand Up @@ -189,6 +179,11 @@ NavItem.reopenClass({
return item.customFilter.call(this, category, args);
});

extraItems.forEach(item => {
if (!item.customHref) return;
item.set("href", item.customHref.call(this, category, args));
});

return items.concat(extraItems);
}
});
Expand Down