diff --git a/app/assets/javascripts/discourse/components/group-membership-button.js.es6 b/app/assets/javascripts/discourse/components/group-membership-button.js.es6 index 3b722da4cc4..7c808bc3eb3 100644 --- a/app/assets/javascripts/discourse/components/group-membership-button.js.es6 +++ b/app/assets/javascripts/discourse/components/group-membership-button.js.es6 @@ -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() { diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 07f788fad0e..697ae7fb80f 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -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: