More customization for menu items

This commit is contained in:
Robin Ward 2017-10-05 17:00:23 -04:00
parent 0c84352386
commit 2ae06e6fd0
3 changed files with 25 additions and 20 deletions

View File

@ -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));
});

View File

@ -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) {

View File

@ -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) {