From 80e32594e25d1bb1d1918aa26f79af718b307ea5 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Fri, 24 Apr 2020 16:29:16 -0400 Subject: [PATCH] Disable "Start Discussion" button for restricted tags (#74) Also, change the label when the button is disabled. --- extensions/tags/js/src/forum/addTagFilter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/tags/js/src/forum/addTagFilter.js b/extensions/tags/js/src/forum/addTagFilter.js index 95ed7c78d..b141e841d 100644 --- a/extensions/tags/js/src/forum/addTagFilter.js +++ b/extensions/tags/js/src/forum/addTagFilter.js @@ -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'); + } });