mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:24:52 -06:00
More customization for menu items
This commit is contained in:
parent
0c84352386
commit
2ae06e6fd0
@ -10,9 +10,7 @@ createWidget('post-admin-menu-button', jQuery.extend(ButtonClass, {
|
||||
}
|
||||
}));
|
||||
|
||||
export function buildManageButtons(widget) {
|
||||
let { attrs, currentUser } = widget;
|
||||
|
||||
export function buildManageButtons(attrs, currentUser) {
|
||||
if (!currentUser) {
|
||||
return [];
|
||||
}
|
||||
@ -60,20 +58,22 @@ export function buildManageButtons(widget) {
|
||||
});
|
||||
}
|
||||
|
||||
if (attrs.wiki) {
|
||||
contents.push({
|
||||
action: 'toggleWiki',
|
||||
label: 'post.controls.unwiki',
|
||||
icon: 'pencil-square-o',
|
||||
className: 'wiki wikied'
|
||||
});
|
||||
} else {
|
||||
contents.push({
|
||||
action: 'toggleWiki',
|
||||
label: 'post.controls.wiki',
|
||||
icon: 'pencil-square-o',
|
||||
className: 'wiki'
|
||||
});
|
||||
if (attrs.canWiki) {
|
||||
if (attrs.wiki) {
|
||||
contents.push({
|
||||
action: 'toggleWiki',
|
||||
label: 'post.controls.unwiki',
|
||||
icon: 'pencil-square-o',
|
||||
className: 'wiki wikied'
|
||||
});
|
||||
} else {
|
||||
contents.push({
|
||||
action: 'toggleWiki',
|
||||
label: 'post.controls.wiki',
|
||||
icon: 'pencil-square-o',
|
||||
className: 'wiki'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return contents;
|
||||
@ -86,7 +86,7 @@ export default createWidget('post-admin-menu', {
|
||||
const contents = [];
|
||||
contents.push(h('h3', I18n.t('admin_title')));
|
||||
|
||||
buildManageButtons(this).forEach(b => {
|
||||
buildManageButtons(this.attrs, this.currentUser).forEach(b => {
|
||||
contents.push(this.attach('post-admin-menu-button', b));
|
||||
});
|
||||
|
||||
|
@ -249,6 +249,11 @@ export default createWidget('post-menu', {
|
||||
}
|
||||
},
|
||||
|
||||
menuItems() {
|
||||
let result = this.siteSettings.post_menu.split('|');
|
||||
return result;
|
||||
},
|
||||
|
||||
html(attrs, state) {
|
||||
const { siteSettings } = this;
|
||||
|
||||
@ -260,7 +265,7 @@ export default createWidget('post-menu', {
|
||||
const allButtons = [];
|
||||
let visibleButtons = [];
|
||||
|
||||
const orderedButtons = siteSettings.post_menu.split('|');
|
||||
const orderedButtons = this.menuItems();
|
||||
|
||||
// If the post is a wiki, make Edit more prominent
|
||||
if (attrs.wiki) {
|
||||
|
@ -91,7 +91,7 @@ function drawWidget(builder, attrs, state) {
|
||||
}
|
||||
}
|
||||
|
||||
this.transformed = this.transform();
|
||||
this.transformed = this.transform(this.attrs, this.state);
|
||||
|
||||
let contents = this.html(attrs, state);
|
||||
if (this.name) {
|
||||
|
Loading…
Reference in New Issue
Block a user