This commit is contained in:
JC Brand 2021-06-22 12:35:51 +02:00
parent 8de6e78729
commit afd737f965
6 changed files with 23 additions and 17 deletions

View File

@ -79,6 +79,7 @@ module.exports = function(config) {
{ pattern: "src/plugins/muc-views/tests/rai.js", type: 'module' },
{ pattern: "src/plugins/muc-views/tests/retractions.js", type: 'module' },
{ pattern: "src/plugins/muc-views/tests/styling.js", type: 'module' },
{ pattern: "src/plugins/muc-views/tests/toolbar.js", type: 'module' },
{ pattern: "src/plugins/muc-views/tests/unfurls.js", type: 'module' },
{ pattern: "src/plugins/muc-views/tests/xss.js", type: 'module' },
{ pattern: "src/plugins/notifications/tests/notification.js", type: 'module' },

View File

@ -52,10 +52,6 @@ export default class ChatBottomPanel extends ElementView {
_converse.chatboxviews.get(this.getAttribute('jid'))?.emitBlurred(ev);
}
getToolbarOptions () { // eslint-disable-line class-methods-use-this
return {};
}
onDrop (evt) {
if (evt.dataTransfer.files.length == 0) {
// There are no files to be dropped, so this isnt a file

View File

@ -2,7 +2,6 @@ import 'shared/autocomplete/index.js';
import BottomPanel from 'plugins/chatview/bottom-panel.js';
import debounce from 'lodash-es/debounce';
import tpl_muc_bottom_panel from './templates/muc-bottom-panel.js';
import { __ } from 'i18n';
import { _converse, api, converse } from "@converse/headless/core";
import { render } from 'lit';
@ -35,6 +34,7 @@ export default class MUCBottomPanel extends BottomPanel {
render(tpl_muc_bottom_panel({
can_edit, entered,
'model': this.model,
'is_groupchat': true,
'viewUnreadMessages': ev => this.viewUnreadMessages(ev)
}), this);
}
@ -47,14 +47,6 @@ export default class MUCBottomPanel extends BottomPanel {
this.querySelector('converse-message-form')?.onFormSubmitted(ev);
}
getToolbarOptions () {
return Object.assign(super.getToolbarOptions(), {
'is_groupchat': true,
'label_hide_occupants': __('Hide the list of participants'),
'show_occupants_toggle': api.settings.get('visible_toolbar_buttons').toggle_occupants
});
}
hideOccupants (ev) {
ev?.preventDefault?.();
ev?.stopPropagation?.();

View File

@ -23,10 +23,9 @@ const tpl_can_edit = (o) => {
.model=${o.model}
?composing_spoiler="${o.model.get('composing_spoiler')}"
?hidden_occupants="${o.model.get('hidden_occupants')}"
?is_groupchat="${o.model.get('is_groupchat')}"
?is_groupchat="${o.is_groupchat}"
?show_call_button="${show_call_button}"
?show_emoji_button="${show_emoji_button}"
?show_occupants_toggle="${o.model.get('show_occupants_toggle')}"
?show_send_button="${show_send_button}"
?show_spoiler_button="${show_spoiler_button}"
?show_toolbar="${show_toolbar}"

View File

@ -0,0 +1,19 @@
/*global mock, converse */
const { u } = converse.env;
describe('The visible_toolbar_buttons configuration setting', function () {
it("can be used to show a participants toggle in a MUC's toolbar",
mock.initConverse([], { 'visible_toolbar_buttons': { 'toggle_occupants': true } },
async (done, _converse) => {
const muc_jid = 'lounge@montague.lit';
await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo');
const view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => view.querySelector('converse-chat-toolbar .toggle_occupants'));
expect(1).toBe(1);
done();
})
);
});

View File

@ -22,7 +22,6 @@ export class ChatToolbar extends CustomElement {
model: { type: Object },
show_call_button: { type: Boolean },
show_emoji_button: { type: Boolean },
show_occupants_toggle: { type: Boolean },
show_send_button: { type: Boolean },
show_spoiler_button: { type: Boolean },
}
@ -83,7 +82,7 @@ export class ChatToolbar extends CustomElement {
const http_upload_promise = api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain);
buttons.push(html`${until(http_upload_promise.then(is_supported => this.getHTTPUploadButton(is_supported)),'')}`);
if (this.show_occupants_toggle) {
if (this.is_groupchat && api.settings.get('visible_toolbar_buttons')?.toggle_occupants) {
const i18n_hide_occupants = __('Hide participants');
const i18n_show_occupants = __('Show participants');
buttons.push(html`