mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 09:32:48 +08:00
FIX: Reintroduce add group user by email (#13581)
This feature was removed when the modal for adding and inviting members was split in two modals.
This commit is contained in:
parent
79e850ba19
commit
6ba28cbed7
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
@action
|
||||
addMembers() {
|
||||
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");
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user