UX: move wiki button in post wrench

This commit is contained in:
Arpit Jalan 2016-03-23 23:36:04 +05:30
parent e0347b18da
commit df565da3b3
3 changed files with 25 additions and 41 deletions
app/assets/javascripts/discourse/widgets
config

View file

@ -23,7 +23,6 @@ export default createWidget('post-admin-menu', {
const contents = []; const contents = [];
contents.push(h('h3', I18n.t('admin_title'))); contents.push(h('h3', I18n.t('admin_title')));
if (!attrs.isWhisper && this.currentUser.staff) { if (!attrs.isWhisper && this.currentUser.staff) {
const buttonAtts = { action: 'togglePostType', icon: 'shield', className: 'toggle-post-type' }; const buttonAtts = { action: 'togglePostType', icon: 'shield', className: 'toggle-post-type' };
@ -35,25 +34,32 @@ export default createWidget('post-admin-menu', {
contents.push(this.attach('post-admin-menu-button', buttonAtts)); contents.push(this.attach('post-admin-menu-button', buttonAtts));
} }
contents.push(this.attach('post-admin-menu-button', { if (attrs.canManage) {
icon: 'cog', label: 'post.controls.rebake', action: 'rebakePost', className: 'rebuild-html'
}));
if (attrs.hidden) {
contents.push(this.attach('post-admin-menu-button', { contents.push(this.attach('post-admin-menu-button', {
icon: 'eye', icon: 'cog', label: 'post.controls.rebake', action: 'rebakePost', className: 'rebuild-html'
label: 'post.controls.unhide',
action: 'unhidePost',
className: 'unhide-post'
})); }));
if (attrs.hidden) {
contents.push(this.attach('post-admin-menu-button', {
icon: 'eye', label: 'post.controls.unhide', action: 'unhidePost', className: 'unhide-post'
}));
}
} }
if (this.currentUser.admin) { if (this.currentUser.admin) {
contents.push(this.attach('post-admin-menu-button', { contents.push(this.attach('post-admin-menu-button', {
icon: 'user', icon: 'user', label: 'post.controls.change_owner', action: 'changePostOwner', className: 'change-owner'
label: 'post.controls.change_owner', }));
action: 'changePostOwner', }
className: 'change-owner'
// toggle Wiki button
if (attrs.wiki) {
contents.push(this.attach('post-admin-menu-button', {
action: 'toggleWiki', label: 'post.controls.unwiki', icon: 'pencil-square-o', className: 'wiki wikied'
}));
} else {
contents.push(this.attach('post-admin-menu-button', {
action: 'toggleWiki', label: 'post.controls.wiki', icon: 'pencil-square-o', className: 'wiki'
})); }));
} }
@ -64,4 +70,3 @@ export default createWidget('post-admin-menu', {
this.sendWidgetAction('closeAdminMenu'); this.sendWidgetAction('closeAdminMenu');
} }
}); });

View file

@ -81,8 +81,7 @@ registerButton('edit', attrs => {
className: 'edit', className: 'edit',
title: 'post.controls.edit', title: 'post.controls.edit',
icon: 'pencil', icon: 'pencil',
alwaysShowYours: true, alwaysShowYours: true
alwaysShowWiki: true
}; };
} }
}); });
@ -161,7 +160,7 @@ registerButton('bookmark', attrs => {
}); });
registerButton('admin', attrs => { registerButton('admin', attrs => {
if (!attrs.canManage) { return; } if (!attrs.canManage && !attrs.canWiki) { return; }
return { action: 'openAdminMenu', return { action: 'openAdminMenu',
title: 'post.controls.admin', title: 'post.controls.admin',
className: 'show-post-admin-menu', className: 'show-post-admin-menu',
@ -180,22 +179,6 @@ registerButton('delete', attrs => {
} }
}); });
registerButton('wiki', attrs => {
if (!attrs.canWiki) { return; }
if (attrs.wiki) {
return { action: 'toggleWiki',
title: 'post.controls.unwiki',
icon: 'pencil-square-o',
className: 'wiki wikied' };
} else {
return { action: 'toggleWiki',
title: 'post.controls.wiki',
icon: 'pencil-square-o',
className: 'wiki' };
}
});
export default createWidget('post-menu', { export default createWidget('post-menu', {
tagName: 'section.post-menu-area.clearfix', tagName: 'section.post-menu-area.clearfix',
@ -229,9 +212,7 @@ export default createWidget('post-menu', {
const button = this.attachButton(i, attrs); const button = this.attachButton(i, attrs);
if (button) { if (button) {
allButtons.push(button); allButtons.push(button);
if ((attrs.yours && button.attrs.alwaysShowYours) || if ((attrs.yours && button.attrs.alwaysShowYours) || (hiddenButtons.indexOf(i) === -1)) {
(attrs.wiki && button.attrs.alwaysShowWiki) ||
(hiddenButtons.indexOf(i) === -1)) {
visibleButtons.push(button); visibleButtons.push(button);
} }
} }

View file

@ -108,7 +108,7 @@ basic:
post_menu: post_menu:
client: true client: true
type: list type: list
default: 'like-count|like|share|flag|edit|bookmark|wiki|delete|admin|reply' default: 'like-count|like|share|flag|edit|bookmark|delete|admin|reply'
choices: choices:
- like-count - like-count
- like - like
@ -119,11 +119,10 @@ basic:
- bookmark - bookmark
- admin - admin
- reply - reply
- wiki
post_menu_hidden_items: post_menu_hidden_items:
client: true client: true
type: list type: list
default: 'bookmark|edit|wiki|delete|admin' default: 'bookmark|edit|delete|admin'
choices: choices:
- like - like
- edit - edit
@ -133,7 +132,6 @@ basic:
- bookmark - bookmark
- admin - admin
- reply - reply
- wiki
share_links: share_links:
client: true client: true
type: list type: list