mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -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", {
|
createWidget("user-menu-links", {
|
||||||
tagName: "div.menu-links-header",
|
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) {
|
html(attrs) {
|
||||||
const { currentUser, siteSettings } = this;
|
const { currentUser, siteSettings } = this;
|
||||||
|
|
||||||
@ -37,20 +59,10 @@ createWidget("user-menu-links", {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
glyphs.push({
|
glyphs.push(this.bookmarksGlyph());
|
||||||
label: "user.bookmarks",
|
|
||||||
className: "user-bookmarks-link",
|
|
||||||
icon: "bookmark",
|
|
||||||
href: `${path}/activity/bookmarks`
|
|
||||||
});
|
|
||||||
|
|
||||||
if (siteSettings.enable_personal_messages) {
|
if (siteSettings.enable_personal_messages) {
|
||||||
glyphs.push({
|
glyphs.push(this.messagesGlyph());
|
||||||
label: "user.private_messages",
|
|
||||||
className: "user-pms-link",
|
|
||||||
icon: "envelope",
|
|
||||||
href: `${path}/messages`
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileLink = {
|
const profileLink = {
|
||||||
@ -95,10 +107,7 @@ createWidget("user-menu-links", {
|
|||||||
|
|
||||||
return h("ul.menu-links-row", [
|
return h("ul.menu-links-row", [
|
||||||
links.map(l => h("li.user", this.attach("link", l))),
|
links.map(l => h("li.user", this.attach("link", l))),
|
||||||
h(
|
h("li.glyphs", glyphs.map(l => this.glyphHtml(l)))
|
||||||
"li.glyphs",
|
|
||||||
glyphs.map(l => this.attach("link", $.extend(l, { hideLabel: true })))
|
|
||||||
)
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user