FIX: handles different cases of canInvite/canRemove states in PM (#10607)

This commit is contained in:
Joffrey JAFFEUX 2020-09-08 16:35:59 +02:00 committed by GitHub
parent 2c66698470
commit 8413d27cf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View File

@ -158,15 +158,25 @@ export default createWidget("private-message-map", {
const result = [h(`div.participants${hideNamesClass}`, participants)];
const controls = [];
if (
attrs.canInvite ||
attrs.canRemoveAllowedUsers ||
attrs.canRemoveSelfId
) {
const canRemove = attrs.canRemoveAllowedUsers || attrs.canRemoveSelfId;
if (attrs.canInvite || canRemove) {
let key;
let action = "toggleEditing";
if (attrs.canInvite && canRemove) {
key = "edit";
} else if (!attrs.canInvite && canRemove) {
key = "remove";
} else {
key = "add";
action = "showInvite";
}
controls.push(
this.attach("button", {
action: "toggleEditing",
label: "private_message_info.edit",
action,
label: `private_message_info.${key}`,
className: "btn btn-default add-remove-participant-btn",
})
);

View File

@ -1586,6 +1586,8 @@ en:
title: "Message"
invite: "Invite Others ..."
edit: "Add or Remove ..."
remove: "Remove ..."
add: "Add ..."
leave_message: "Do you really want to leave this message?"
remove_allowed_user: "Do you really want to remove %{name} from this message?"
remove_allowed_group: "Do you really want to remove %{name} from this message?"