A platform for community discussion. Free, open, simple.
FIX: Reintroduce add group user by email (#13581)
Dan Ungureanu6ba28cbed728
diff --git a/app/assets/javascripts/discourse/app/controllers/group-add-members.js b/app/assets/javascripts/discourse/app/controllers/group-add-members.jsindex 6528f103a11..b6bd5e51a4f 100644--- a/app/assets/javascripts/discourse/app/controllers/group-add-members.js+++ b/app/assets/javascripts/discourse/app/controllers/group-add-members.js@@ -3,13 +3,14 @@ import { action } from "@ember/object";import { isEmpty } from "@ember/utils";import discourseComputed from "discourse-common/utils/decorators";import { extractError } from "discourse/lib/ajax-error";+import { emailValid } from "discourse/lib/utilities";import ModalFunctionality from "discourse/mixins/modal-functionality";import I18n from "I18n";export default Controller.extend(ModalFunctionality, {loading: false,- usernames: null,+ usernamesAndEmails: null,setOwner: false,notifyUsers: false,@@ -18,7 +19,7 @@ export default Controller.extend(ModalFunctionality, {loading: false,setOwner: false,notifyUsers: false,- usernames: [],+ usernamesAndEmails: [],});},@@ -27,23 +28,50 @@ export default Controller.extend(ModalFunctionality, {return I18n.t("groups.add_members.title", { group_name: fullName || name });},+ @discourseComputed("usernamesAndEmails.[]")+ usernames(usernamesAndEmails) {+ return usernamesAndEmails.reject(emailValid).join(",");+ },++ @discourseComputed("usernamesAndEmails.[]")+ emails(usernamesAndEmails) {+ return usernamesAndEmails.filter(emailValid).join(",");+ },++ @action+ setUsernamesAndEmails(usernamesAndEmails) {+ this.set("usernamesAndEmails", usernamesAndEmails);++ if (this.emails) {+ if (!this.usernames) {+ this.set("notifyUsers", false);+ }++ this.set("setOwner", false);+ }+ },+@actionaddMembers() {- if (isEmpty(this.usernames)) {+ if (isEmpty(this.usernamesAndEmails)) {return;}this.set("loading", true);- const usernames = this.usernames.join(",");const promise = this.setOwner- ? this.model.addOwners(usernames, true, this.notifyUsers)- : this.model.addMembers(usernames, true, this.notifyUsers);+ ? this.model.addOwners(this.usernames, true, this.notifyUsers)+ : this.model.addMembers(+ this.usernames,+ true,+ this.notifyUsers,+ this.emails+ );promise.then(() => {this.transitionToRoute("group.members", this.get("model.name"), {- queryParams: usernames ? { filter: usernames } : {},+ queryParams: this.usernames ? { filter: this.usernames } : {},});this.send("closeModal");diff --git a/app/assets/javascripts/discourse/app/templates/modal/group-add-members.hbs b/app/assets/javascripts/discourse/app/templates/modal/group-add-members.hbsindex 873e20fb396..8769840814e 100644--- a/app/assets/javascripts/discourse/app/templates/modal/group-add-members.hbs+++ b/app/assets/javascripts/discourse/app/templates/modal/group-add-members.hbs@@ -4,15 +4,22 @@<div class="input-group">{{email-group-user-chooser- value=usernames- onChange=(action (mut usernames))+ value=usernamesAndEmails+ onChange=(action "setUsernamesAndEmails")+ options=(hash+ allowEmails=currentUser.can_invite_to_forum+ filterPlaceholder=(if currentUser.can_invite_to_forum+ "groups.add_members.usernames_or_emails_placeholder"+ "groups.add_members.usernames_placeholder"+ )+ )}}</div>{{#if model.can_admin_group}}<div class="input-group"><label>- {{input id="set-owner" type="checkbox" checked=setOwner disabled=emailsPresent}}+ {{input id="set-owner" type="checkbox" checked=setOwner disabled=emails}}{{i18n "groups.add_members.set_owner"}}</label></div>@@ -20,7 +27,7 @@<div class="input-group"><label>- {{input type="checkbox" checked=notifyUsers}}+ {{input type="checkbox" checked=notifyUsers disabled=(and (not usernames) emails)}}{{i18n "groups.add_members.notify_users"}}</label></div>@@ -31,6 +38,6 @@{{d-button action=(action "addMembers")class="add btn-primary"icon="plus"- disabled=(or loading (not usernames))+ disabled=(or loading (not usernamesAndEmails))label="groups.add"}}</div>diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 87a5cc185ee..56aba8372d8 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -668,6 +668,8 @@ en:add_members:title: "Add Users to %{group_name}"description: "Enter a list of users you want to invite to the group or paste in a comma separated list:"+ usernames_placeholder: "usernames"+ usernames_or_emails_placeholder: "usernames or emails"notify_users: "Notify users"set_owner: "Set users as owners of this group"requests: