UX: Users must confirm when leaving a private group

This commit is contained in:
romanrizzi 2020-01-17 17:58:10 -03:00
parent 4089607b40
commit 0d08eac1c7
2 changed files with 23 additions and 10 deletions

View File

@ -31,6 +31,14 @@ export default Component.extend({
$.cookie("destination_url", window.location.href);
},
removeFromGroup() {
this.model
.removeMember(this.currentUser)
.then(() => this.model.set("is_group_user", false))
.catch(popupAjaxError)
.finally(() => this.set("updatingMembership", false));
},
actions: {
joinGroup() {
if (this.currentUser) {
@ -53,17 +61,21 @@ export default Component.extend({
leaveGroup() {
this.set("updatingMembership", true);
const model = this.model;
model
.removeMember(this.currentUser)
.then(() => {
model.set("is_group_user", false);
})
.catch(popupAjaxError)
.finally(() => {
this.set("updatingMembership", false);
});
if (this.model.public_admission) {
this.removeFromGroup();
} else {
return bootbox.confirm(
I18n.t("groups.confirm_leave"),
I18n.t("no_value"),
I18n.t("yes_value"),
result => {
result
? this.removeFromGroup()
: this.set("updatingMembership", false);
}
);
}
},
showRequestMembershipForm() {

View File

@ -646,6 +646,7 @@ en:
leave: "Leave"
request: "Request"
message: "Message"
confirm_leave: "Are you sure you want to leave this group?"
allow_membership_requests: "Allow users to send membership requests to group owners"
membership_request_template: "Custom template to display to users when sending a membership request"
membership_request: