mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 04:23:01 +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 { isEmpty } from "@ember/utils";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { extractError } from "discourse/lib/ajax-error";
|
import { extractError } from "discourse/lib/ajax-error";
|
||||||
|
import { emailValid } from "discourse/lib/utilities";
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default Controller.extend(ModalFunctionality, {
|
export default Controller.extend(ModalFunctionality, {
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
||||||
usernames: null,
|
usernamesAndEmails: null,
|
||||||
setOwner: false,
|
setOwner: false,
|
||||||
notifyUsers: false,
|
notifyUsers: false,
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
loading: false,
|
loading: false,
|
||||||
setOwner: false,
|
setOwner: false,
|
||||||
notifyUsers: 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 });
|
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
|
@action
|
||||||
addMembers() {
|
addMembers() {
|
||||||
if (isEmpty(this.usernames)) {
|
if (isEmpty(this.usernamesAndEmails)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set("loading", true);
|
this.set("loading", true);
|
||||||
|
|
||||||
const usernames = this.usernames.join(",");
|
|
||||||
const promise = this.setOwner
|
const promise = this.setOwner
|
||||||
? this.model.addOwners(usernames, true, this.notifyUsers)
|
? this.model.addOwners(this.usernames, true, this.notifyUsers)
|
||||||
: this.model.addMembers(usernames, true, this.notifyUsers);
|
: this.model.addMembers(
|
||||||
|
this.usernames,
|
||||||
|
true,
|
||||||
|
this.notifyUsers,
|
||||||
|
this.emails
|
||||||
|
);
|
||||||
|
|
||||||
promise
|
promise
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.transitionToRoute("group.members", this.get("model.name"), {
|
this.transitionToRoute("group.members", this.get("model.name"), {
|
||||||
queryParams: usernames ? { filter: usernames } : {},
|
queryParams: this.usernames ? { filter: this.usernames } : {},
|
||||||
});
|
});
|
||||||
|
|
||||||
this.send("closeModal");
|
this.send("closeModal");
|
||||||
|
|
|
@ -4,15 +4,22 @@
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
{{email-group-user-chooser
|
{{email-group-user-chooser
|
||||||
value=usernames
|
value=usernamesAndEmails
|
||||||
onChange=(action (mut usernames))
|
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>
|
</div>
|
||||||
|
|
||||||
{{#if model.can_admin_group}}
|
{{#if model.can_admin_group}}
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label>
|
<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"}}
|
{{i18n "groups.add_members.set_owner"}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -20,7 +27,7 @@
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label>
|
<label>
|
||||||
{{input type="checkbox" checked=notifyUsers}}
|
{{input type="checkbox" checked=notifyUsers disabled=(and (not usernames) emails)}}
|
||||||
{{i18n "groups.add_members.notify_users"}}
|
{{i18n "groups.add_members.notify_users"}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,6 +38,6 @@
|
||||||
{{d-button action=(action "addMembers")
|
{{d-button action=(action "addMembers")
|
||||||
class="add btn-primary"
|
class="add btn-primary"
|
||||||
icon="plus"
|
icon="plus"
|
||||||
disabled=(or loading (not usernames))
|
disabled=(or loading (not usernamesAndEmails))
|
||||||
label="groups.add"}}
|
label="groups.add"}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -668,6 +668,8 @@ en:
|
||||||
add_members:
|
add_members:
|
||||||
title: "Add Users to %{group_name}"
|
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:"
|
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"
|
notify_users: "Notify users"
|
||||||
set_owner: "Set users as owners of this group"
|
set_owner: "Set users as owners of this group"
|
||||||
requests:
|
requests:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user