Occupant modal: Only show role/affiliation forms for moderators

This commit is contained in:
JC Brand 2023-02-22 09:32:20 +01:00
parent 0122bd7bab
commit 16b442ac19
3 changed files with 15 additions and 11 deletions

View File

@ -1,5 +1,4 @@
{ {
"arrowParens": "avoid",
"printWidth": 120, "printWidth": 120,
"quoteProps": "preserve", "quoteProps": "preserve",
"singleQuote": true, "singleQuote": true,

View File

@ -5,7 +5,6 @@
- Add the ability to set roles and affiliations via the MUC occupant modal - Add the ability to set roles and affiliations via the MUC occupant modal
- Fix `isOnlyEmojis is not a function` when using only `@converse/headless` - Fix `isOnlyEmojis is not a function` when using only `@converse/headless`
## 10.1.2 (2023-02-17) ## 10.1.2 (2023-02-17)
- #1490: Busy-loop when fetching registration form fails - #1490: Busy-loop when fetching registration form fails

View File

@ -16,6 +16,9 @@ export default (el) => {
const hats = el.model?.get('hats')?.length ? el.model.get('hats') : null; const hats = el.model?.get('hats')?.length ? el.model.get('hats') : null;
const muc = el.model.collection.chatroom; 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 i18n_add_to_contacts = __('Add to Contacts');
const can_see_real_jids = muc.features.get('nonanonymous') || muc.getOwnRole() === 'moderator'; const can_see_real_jids = muc.features.get('nonanonymous') || muc.getOwnRole() === 'moderator';
@ -45,26 +48,29 @@ export default (el) => {
<li> <li>
<div class="row"><strong>${__('Affiliation')}:</strong></div> <div class="row"><strong>${__('Affiliation')}:</strong></div>
<div class="row">${affiliation}&nbsp; <div class="row">${affiliation}&nbsp;
<a href="#" ${ may_moderate ? html`
data-form="affiliation-form" <a href="#"
class="toggle-form right" data-form="affiliation-form"
color="var(--subdued-color)" class="toggle-form right"
@click=${(ev) => el.toggleForm(ev)}><converse-icon class="fa fa-wrench" size="1em"></converse-icon> color="var(--subdued-color)"
</a> @click=${(ev) => el.toggleForm(ev)}><converse-icon class="fa fa-wrench" size="1em"></converse-icon>
${ el.show_affiliation_form ? html`<converse-muc-affiliation-form jid=${jid} .muc=${muc} affiliation=${affiliation}></converse-muc-affiliation-form>` : '' } </a>
${ el.show_affiliation_form ? html`<converse-muc-affiliation-form jid=${jid} .muc=${muc} affiliation=${affiliation}></converse-muc-affiliation-form>` : '' }` : ''
}
</div> </div>
</li> </li>
<li> <li>
<div class="row"><strong>${__('Role')}:</strong></div> <div class="row"><strong>${__('Role')}:</strong></div>
<div class="row">${role}&nbsp; <div class="row">${role}&nbsp;
${ role ? html` ${ may_moderate && role ? html`
<a href="#" <a href="#"
data-form="row-form" data-form="row-form"
class="toggle-form right" class="toggle-form right"
color="var(--subdued-color)" color="var(--subdued-color)"
@click=${(ev) => el.toggleForm(ev)}><converse-icon class="fa fa-wrench" size="1em"></converse-icon> @click=${(ev) => el.toggleForm(ev)}><converse-icon class="fa fa-wrench" size="1em"></converse-icon>
</a> </a>
${ el.show_role_form ? html`<converse-muc-role-form jid=${jid} .muc=${muc} role=${role}></converse-muc-role-form>` : '' }` : '' } ${ el.show_role_form ? html`<converse-muc-role-form jid=${jid} .muc=${muc} role=${role}></converse-muc-role-form>` : '' }` : ''
}
</div> </div>
</li> </li>
<li> <li>