From 16b442ac19fbb2028166bf67c65b9a8eef45f970 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Wed, 22 Feb 2023 09:32:20 +0100 Subject: [PATCH] Occupant modal: Only show role/affiliation forms for moderators --- .prettierrc | 1 - CHANGES.md | 1 - .../muc-views/modals/templates/occupant.js | 24 ++++++++++++------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.prettierrc b/.prettierrc index 2a06a05d6..e0e638036 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,4 @@ { - "arrowParens": "avoid", "printWidth": 120, "quoteProps": "preserve", "singleQuote": true, diff --git a/CHANGES.md b/CHANGES.md index 93fd8bb6f..0ae90f269 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,6 @@ - Add the ability to set roles and affiliations via the MUC occupant modal - Fix `isOnlyEmojis is not a function` when using only `@converse/headless` - ## 10.1.2 (2023-02-17) - #1490: Busy-loop when fetching registration form fails diff --git a/src/plugins/muc-views/modals/templates/occupant.js b/src/plugins/muc-views/modals/templates/occupant.js index f728c3873..3ccc87a98 100644 --- a/src/plugins/muc-views/modals/templates/occupant.js +++ b/src/plugins/muc-views/modals/templates/occupant.js @@ -16,6 +16,9 @@ export default (el) => { const hats = el.model?.get('hats')?.length ? el.model.get('hats') : null; const muc = el.model.collection.chatroom; + const allowed_commands = muc.getAllowedCommands(); + const may_moderate = allowed_commands.includes('modtools'); + const i18n_add_to_contacts = __('Add to Contacts'); const can_see_real_jids = muc.features.get('nonanonymous') || muc.getOwnRole() === 'moderator'; @@ -45,26 +48,29 @@ export default (el) => {
  • ${__('Affiliation')}:
    ${affiliation}  - el.toggleForm(ev)}> - - ${ el.show_affiliation_form ? html`` : '' } + ${ may_moderate ? html` + el.toggleForm(ev)}> + + ${ el.show_affiliation_form ? html`` : '' }` : '' + }
  • ${__('Role')}:
    ${role}  - ${ role ? html` + ${ may_moderate && role ? html` el.toggleForm(ev)}> - ${ el.show_role_form ? html`` : '' }` : '' } + ${ el.show_role_form ? html`` : '' }` : '' + }