diff --git a/app/assets/javascripts/discourse/app/components/user-selector.js b/app/assets/javascripts/discourse/app/components/user-selector.js index 6b9bb6a19a0..cc90f9a849a 100644 --- a/app/assets/javascripts/discourse/app/components/user-selector.js +++ b/app/assets/javascripts/discourse/app/components/user-selector.js @@ -3,6 +3,7 @@ import TextField from "discourse/components/text-field"; import { findRawTemplate } from "discourse-common/lib/raw-templates"; import { isEmpty } from "@ember/utils"; import userSearch from "discourse/lib/user-search"; +import deprecated from "discourse-common/lib/deprecated"; export default TextField.extend({ autocorrect: false, @@ -12,6 +13,14 @@ export default TextField.extend({ single: false, fullWidthWrap: false, + @on("init") + deprecateComponent() { + deprecated( + "`{{user-selector}}` is deprecated. Please use `{{email-group-user-chooser}}` instead.", + { since: "2.7", dropFrom: "2.8" } + ); + }, + @bind _paste(event) { let pastedText = ""; diff --git a/app/assets/javascripts/discourse/app/controllers/change-owner.js b/app/assets/javascripts/discourse/app/controllers/change-owner.js index d2e30c31c30..fe2a7c537c8 100644 --- a/app/assets/javascripts/discourse/app/controllers/change-owner.js +++ b/app/assets/javascripts/discourse/app/controllers/change-owner.js @@ -12,12 +12,12 @@ export default Controller.extend(ModalFunctionality, { topicController: inject("topic"), saving: false, - new_user: null, + newOwner: null, selectedPostsCount: alias("topicController.selectedPostsCount"), selectedPostsUsername: alias("topicController.selectedPostsUsername"), - @discourseComputed("saving", "new_user") + @discourseComputed("saving", "newOwner") buttonDisabled(saving, newUser) { return saving || isEmpty(newUser); }, @@ -25,7 +25,7 @@ export default Controller.extend(ModalFunctionality, { onShow() { this.setProperties({ saving: false, - new_user: "", + newOwner: null, }); }, @@ -35,7 +35,7 @@ export default Controller.extend(ModalFunctionality, { const options = { post_ids: this.get("topicController.selectedPostIds"), - username: this.new_user, + username: this.newOwner, }; Topic.changeOwners(this.get("topicController.model.id"), options).then( @@ -57,5 +57,9 @@ export default Controller.extend(ModalFunctionality, { return false; }, + + updateNewOwner(selected) { + this.set("newOwner", selected.firstObject); + }, }, }); diff --git a/app/assets/javascripts/discourse/app/controllers/group-add-members.js b/app/assets/javascripts/discourse/app/controllers/group-add-members.js index 4964da68867..333060a2a5a 100644 --- a/app/assets/javascripts/discourse/app/controllers/group-add-members.js +++ b/app/assets/javascripts/discourse/app/controllers/group-add-members.js @@ -6,20 +6,18 @@ import discourseComputed from "discourse-common/utils/decorators"; import { emailValid } from "discourse/lib/utilities"; import { extractError } from "discourse/lib/ajax-error"; import { isEmpty } from "@ember/utils"; +import { reads } from "@ember/object/computed"; export default Controller.extend(ModalFunctionality, { loading: false, setAsOwner: false, notifyUsers: false, usernamesAndEmails: null, - usernames: null, - emails: null, + emailsPresent: reads("emails.length"), onShow() { this.setProperties({ - usernamesAndEmails: "", - usernames: [], - emails: [], + usernamesAndEmails: [], setAsOwner: false, notifyUsers: false, }); @@ -30,15 +28,8 @@ export default Controller.extend(ModalFunctionality, { return loading || !usernamesAndEmails || !(usernamesAndEmails.length > 0); }, - @discourseComputed("usernamesAndEmails") - emailsPresent() { - this._splitEmailsAndUsernames(); - return this.emails.length; - }, - @discourseComputed("usernamesAndEmails") notifyUsersDisabled() { - this._splitEmailsAndUsernames(); return this.usernames.length === 0 && this.emails.length > 0; }, @@ -47,6 +38,16 @@ export default Controller.extend(ModalFunctionality, { return I18n.t("groups.add_members.title", { group_name: fullName || name }); }, + @discourseComputed("usernamesAndEmails.[]") + emails(usernamesAndEmails) { + return usernamesAndEmails.filter(emailValid).join(","); + }, + + @discourseComputed("usernamesAndEmails.[]") + usernames(usernamesAndEmails) { + return usernamesAndEmails.reject(emailValid).join(","); + }, + @action addMembers() { this.set("loading", true); @@ -89,16 +90,4 @@ export default Controller.extend(ModalFunctionality, { .catch((error) => this.flash(extractError(error), "error")) .finally(() => this.set("loading", false)); }, - - _splitEmailsAndUsernames() { - let emails = []; - let usernames = []; - - this.usernamesAndEmails.split(",").forEach((u) => { - emailValid(u) ? emails.push(u) : usernames.push(u); - }); - - this.set("emails", emails.join(",")); - this.set("usernames", usernames.join(",")); - }, }); diff --git a/app/assets/javascripts/discourse/app/controllers/groups-new.js b/app/assets/javascripts/discourse/app/controllers/groups-new.js index 821c60c167e..ebb683bdc4d 100644 --- a/app/assets/javascripts/discourse/app/controllers/groups-new.js +++ b/app/assets/javascripts/discourse/app/controllers/groups-new.js @@ -4,6 +4,7 @@ import { action } from "@ember/object"; import { ajax } from "discourse/lib/ajax"; import bootbox from "bootbox"; import { popupAjaxError } from "discourse/lib/ajax-error"; +import discourseComputed from "discourse-common/utils/decorators"; export function popupAutomaticMembershipAlert(group_id, email_domains) { if (!email_domains) { @@ -37,6 +38,16 @@ export function popupAutomaticMembershipAlert(group_id, email_domains) { export default Controller.extend({ saving: null, + @discourseComputed("model.ownerUsernames") + splitOwnerUsernames(owners) { + return owners && owners.length ? owners.split(",") : []; + }, + + @discourseComputed("model.usernames") + splitUsernames(usernames) { + return usernames && usernames.length ? usernames.split(",") : []; + }, + @action save() { this.set("saving", true); @@ -55,4 +66,14 @@ export default Controller.extend({ .catch(popupAjaxError) .finally(() => this.set("saving", false)); }, + + @action + updateOwnerUsernames(selected) { + this.set("model.ownerUsernames", selected.join(",")); + }, + + @action + updateUsernames(selected) { + this.set("model.usernames", selected.join(",")); + }, }); diff --git a/app/assets/javascripts/discourse/app/controllers/ignore-duration-with-username.js b/app/assets/javascripts/discourse/app/controllers/ignore-duration-with-username.js index 408c6f72d7a..b142e3741c1 100644 --- a/app/assets/javascripts/discourse/app/controllers/ignore-duration-with-username.js +++ b/app/assets/javascripts/discourse/app/controllers/ignore-duration-with-username.js @@ -29,5 +29,9 @@ export default Controller.extend(ModalFunctionality, { .finally(() => this.set("loading", false)); }); }, + + updateIgnoredUsername(selected) { + this.set("ignoredUsername", selected.firstObject); + }, }, }); diff --git a/app/assets/javascripts/discourse/app/controllers/move-to-topic.js b/app/assets/javascripts/discourse/app/controllers/move-to-topic.js index 648fa3cabce..ad4df9e79eb 100644 --- a/app/assets/javascripts/discourse/app/controllers/move-to-topic.js +++ b/app/assets/javascripts/discourse/app/controllers/move-to-topic.js @@ -80,7 +80,7 @@ export default Controller.extend(ModalFunctionality, { categoryId: null, topicName: "", tags: null, - participants: null, + participants: [], }); const isPrivateMessage = this.get("model.isPrivateMessage"); @@ -133,7 +133,7 @@ export default Controller.extend(ModalFunctionality, { } else if (type === "existingMessage") { mergeOptions = { destination_topic_id: this.selectedTopicId, - participants: this.participants, + participants: this.participants.join(","), archetype: "private_message", }; moveOptions = Object.assign( diff --git a/app/assets/javascripts/discourse/app/controllers/review-index.js b/app/assets/javascripts/discourse/app/controllers/review-index.js index e1e003870dc..dc28bf6558e 100644 --- a/app/assets/javascripts/discourse/app/controllers/review-index.js +++ b/app/assets/javascripts/discourse/app/controllers/review-index.js @@ -170,5 +170,13 @@ export default Controller.extend({ toggleFilters() { this.toggleProperty("filtersExpanded"); }, + + updateFilterReviewedBy(selected) { + this.set("filterReviewedBy", selected.firstObject); + }, + + updateFilterUsername(selected) { + this.set("filterUsername", selected.firstObject); + }, }, }); diff --git a/app/assets/javascripts/discourse/app/templates/groups/new.hbs b/app/assets/javascripts/discourse/app/templates/groups/new.hbs index 0a923cf3aaa..fbb44248f03 100644 --- a/app/assets/javascripts/discourse/app/templates/groups/new.hbs +++ b/app/assets/javascripts/discourse/app/templates/groups/new.hbs @@ -8,19 +8,29 @@