mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
REFACTOR: user-menu-links widget for extensibility (#7996)
This commit is contained in:
parent
d686318133
commit
ca7f1dabbf
@ -13,6 +13,28 @@ export function addUserMenuGlyph(glyph) {
|
||||
createWidget("user-menu-links", {
|
||||
tagName: "div.menu-links-header",
|
||||
|
||||
bookmarksGlyph() {
|
||||
return {
|
||||
label: "user.bookmarks",
|
||||
className: "user-bookmarks-link",
|
||||
icon: "bookmark",
|
||||
href: `${this.attrs.path}/activity/bookmarks`
|
||||
};
|
||||
},
|
||||
|
||||
messagesGlyph() {
|
||||
return {
|
||||
label: "user.private_messages",
|
||||
className: "user-pms-link",
|
||||
icon: "envelope",
|
||||
href: `${this.attrs.path}/messages`
|
||||
};
|
||||
},
|
||||
|
||||
glyphHtml(glyph) {
|
||||
return this.attach("link", $.extend(glyph, { hideLabel: true }));
|
||||
},
|
||||
|
||||
html(attrs) {
|
||||
const { currentUser, siteSettings } = this;
|
||||
|
||||
@ -37,20 +59,10 @@ createWidget("user-menu-links", {
|
||||
});
|
||||
}
|
||||
|
||||
glyphs.push({
|
||||
label: "user.bookmarks",
|
||||
className: "user-bookmarks-link",
|
||||
icon: "bookmark",
|
||||
href: `${path}/activity/bookmarks`
|
||||
});
|
||||
glyphs.push(this.bookmarksGlyph());
|
||||
|
||||
if (siteSettings.enable_personal_messages) {
|
||||
glyphs.push({
|
||||
label: "user.private_messages",
|
||||
className: "user-pms-link",
|
||||
icon: "envelope",
|
||||
href: `${path}/messages`
|
||||
});
|
||||
glyphs.push(this.messagesGlyph());
|
||||
}
|
||||
|
||||
const profileLink = {
|
||||
@ -95,10 +107,7 @@ createWidget("user-menu-links", {
|
||||
|
||||
return h("ul.menu-links-row", [
|
||||
links.map(l => h("li.user", this.attach("link", l))),
|
||||
h(
|
||||
"li.glyphs",
|
||||
glyphs.map(l => this.attach("link", $.extend(l, { hideLabel: true })))
|
||||
)
|
||||
h("li.glyphs", glyphs.map(l => this.glyphHtml(l)))
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user