FIX: Set the "hasTargetGroups" attribute in the composer when clicking the group message button. (#12536)

After clicking the message button on the group page, the composer shouldn't display the "official warning" checkbox. The discourse-bcc plugin also relies on this attribute to display an option in the composer.
This commit is contained in:
Roman Rizzi 2021-03-29 14:43:00 -03:00 committed by GitHub
parent 87b5d16c10
commit 1a3c5f55d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 18 deletions

View File

@ -81,7 +81,10 @@ export default Component.extend(CardContentsBase, CleansUp, {
}, },
messageGroup() { messageGroup() {
this.createNewMessageViaParams(this.get("group.name")); this.createNewMessageViaParams({
recipients: this.get("group.name"),
hasGroups: true,
});
}, },
showGroup(group) { showGroup(group) {

View File

@ -1008,6 +1008,7 @@ export default Controller.extend({
composerModel.setProperties({ composerModel.setProperties({
composeState: Composer.OPEN, composeState: Composer.OPEN,
isWarning: false, isWarning: false,
hasTargetGroups: opts.hasGroups,
}); });
if (!this.model.targetRecipients) { if (!this.model.targetRecipients) {

View File

@ -132,7 +132,10 @@ export default Controller.extend({
@action @action
messageGroup() { messageGroup() {
this.send("createNewMessageViaParams", this.get("model.name")); this.send("createNewMessageViaParams", {
recipients: this.get("model.name"),
hasGroups: true,
});
}, },
@action @action

View File

@ -39,7 +39,12 @@ export default Mixin.create({
}); });
}, },
openComposerWithMessageParams(recipients, topicTitle, topicBody) { openComposerWithMessageParams({
recipients = [],
topicTitle = "",
topicBody = "",
hasGroups = false,
} = {}) {
this.controllerFor("composer").open({ this.controllerFor("composer").open({
action: Composer.PRIVATE_MESSAGE, action: Composer.PRIVATE_MESSAGE,
recipients, recipients,
@ -47,6 +52,7 @@ export default Mixin.create({
topicBody, topicBody,
archetypeId: "private_message", archetypeId: "private_message",
draftKey: Composer.NEW_PRIVATE_MESSAGE_KEY, draftKey: Composer.NEW_PRIVATE_MESSAGE_KEY,
hasGroups: hasGroups,
}); });
}, },
}); });

View File

@ -230,8 +230,18 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
); );
}, },
createNewMessageViaParams(recipients, title, body) { createNewMessageViaParams({
this.openComposerWithMessageParams(recipients, title, body); recipients = [],
topicTitle = "",
topicBody = "",
hasGroups = false,
} = {}) {
this.openComposerWithMessageParams({
recipients,
topicTitle,
topicBody,
hasGroups,
});
}, },
}, },

View File

@ -20,12 +20,11 @@ export default DiscourseRoute.extend({
.then((user) => { .then((user) => {
if (user.can_send_private_message_to_user) { if (user.can_send_private_message_to_user) {
next(() => next(() =>
e.send( e.send("createNewMessageViaParams", {
"createNewMessageViaParams", recipients: user.username,
user.username, topicTitle: params.title,
params.title, topicBody: params.body,
params.body })
)
); );
} else { } else {
bootbox.alert( bootbox.alert(
@ -40,12 +39,11 @@ export default DiscourseRoute.extend({
.then((result) => { .then((result) => {
if (result.messageable) { if (result.messageable) {
next(() => next(() =>
e.send( e.send("createNewMessageViaParams", {
"createNewMessageViaParams", recipients: groupName,
groupName, topicTitle: params.title,
params.title, topicBody: params.body,
params.body })
)
); );
} else { } else {
bootbox.alert( bootbox.alert(
@ -55,7 +53,10 @@ export default DiscourseRoute.extend({
}) })
.catch(() => bootbox.alert(I18n.t("generic_error"))); .catch(() => bootbox.alert(I18n.t("generic_error")));
} else { } else {
e.send("createNewMessageViaParams", null, params.title, params.body); e.send("createNewMessageViaParams", {
topicTitle: params.title,
topicBody: params.body,
});
} }
}); });
} else { } else {

View File

@ -219,6 +219,8 @@ acceptance("Group - Authenticated", function (needs) {
"discourse", "discourse",
"it prefills the group name" "it prefills the group name"
); );
assert.ok(!exists(".add-warning"), "groups can't receive warnings");
}); });
test("Admin viewing group messages when there are no messages", async function (assert) { test("Admin viewing group messages when there are no messages", async function (assert) {