mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 21:11:55 +08:00
Disable "Start Discussion" button for restricted tags (#74)
Also, change the label when the button is disabled.
This commit is contained in:
parent
649f71d25a
commit
80e32594e2
|
@ -35,16 +35,21 @@ export default function() {
|
|||
});
|
||||
|
||||
// If currently viewing a tag, restyle the 'new discussion' button to use
|
||||
// the tag's color.
|
||||
// the tag's color, and disable if the user isn't allowed to edit.
|
||||
extend(IndexPage.prototype, 'sidebarItems', function(items) {
|
||||
const tag = this.currentTag();
|
||||
|
||||
if (tag) {
|
||||
const color = tag.color();
|
||||
const canStartDiscussion = tag.canStartDiscussion();
|
||||
|
||||
if (color) {
|
||||
items.get('newDiscussion').props.style = {backgroundColor: color};
|
||||
}
|
||||
|
||||
items.get('newDiscussion').props.disabled = !canStartDiscussion;
|
||||
items.get('newDiscussion').props.children = app.translator.trans(canStartDiscussion ? 'core.forum.index.start_discussion_button' : 'core.forum.index.cannot_start_discussion_button');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user