FEATURE: Allow sending a message with invite (#12892)

* FEATURE: Allow sending a message with invite

It used to be a staff-only feature and this commit makes it available
to everyone who can invite.

* FIX: Inviting to topic uses another email template

This used to be the case, but the extra parameter was lost when we
switched to the new modal.
This commit is contained in:
Dan Ungureanu 2021-05-06 10:16:42 +03:00 committed by GitHub
parent b5a70bbb25
commit 17efce9023
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 10 deletions

View File

@ -20,6 +20,7 @@ export default Controller.extend(
invites: null,
showAdvanced: false,
inviteToTopic: false,
limitToEmail: false,
autogenerated: false,
@ -34,6 +35,7 @@ export default Controller.extend(
invite: null,
invites: null,
showAdvanced: false,
inviteToTopic: false,
limitToEmail: false,
autogenerated: false,
});
@ -90,6 +92,9 @@ export default Controller.extend(
if (opts.sendEmail) {
data.send_email = true;
if (this.inviteToTopic) {
data.invite_to_topic = true;
}
} else {
data.skip_email = true;
}
@ -160,6 +165,11 @@ export default Controller.extend(
return hasBufferedChanges || (inviteEmail ? "email" : "link") !== type;
},
@discourseComputed("currentUser.staff", "type")
hasAdvanced(staff, type) {
return staff || type === "email";
},
@action
copied() {
if (this.type === "email" && !this.buffered.get("email")) {

View File

@ -105,7 +105,10 @@ export default Controller.extend(
inviteUsers() {
this.set("showNotifyUsers", false);
const controller = showModal("create-invite");
controller.set("showAdvanced", true);
controller.setProperties({
showAdvanced: true,
inviteToTopic: true,
});
controller.buffered.setProperties({
topicId: this.topic.id,
topicTitle: this.topic.title,

View File

@ -52,12 +52,10 @@
{{#if isEmail}}
{{#if showAdvanced}}
{{#if currentUser.staff}}
<div class="input-group invite-custom-message">
<label for="invite-message">{{i18n "user.invited.invite.custom_message"}}</label>
{{textarea id="invite-message" value=buffered.custom_message}}
</div>
{{/if}}
<div class="input-group invite-custom-message">
<label for="invite-message">{{i18n "user.invited.invite.custom_message"}}</label>
{{textarea id="invite-message" value=buffered.custom_message}}
</div>
{{/if}}
{{/if}}
@ -71,7 +69,7 @@
label="user.invited.invite.invite_to_topic"
}}
</div>
{{else}}
{{else if buffered.topicTitle}}
<div class="input-group">
<label for="invite-topic">{{i18n "user.invited.invite.invite_to_topic"}}</label>
{{input
@ -133,7 +131,7 @@
}}
{{/if}}
{{#if currentUser.staff}}
{{#if hasAdvanced}}
{{d-button
action=(action "toggleAdvanced")
class="show-advanced"

View File

@ -183,7 +183,7 @@ class InvitesController < ApplicationController
if invite.emailed_status == Invite.emailed_status_types[:pending]
invite.update_column(:emailed_status, Invite.emailed_status_types[:sending])
Jobs.enqueue(:invite_email, invite_id: invite.id)
Jobs.enqueue(:invite_email, invite_id: invite.id, invite_to_topic: params[:invite_to_topic])
end
render_serialized(invite, InviteSerializer, scope: guardian, root: nil, show_emails: params.has_key?(:email))