FIX: invite accepted notification should link to invited user profile

This commit is contained in:
Arpit Jalan 2015-08-10 10:25:27 +05:30
parent 2052ceca95
commit 066824e545
4 changed files with 22 additions and 21 deletions

View File

@ -30,9 +30,9 @@ export default Ember.Component.extend({
} }
if (it.get('notification_type') === INVITED_TYPE) { if (it.get('notification_type') === INVITED_TYPE) {
return Discourse.getURL('/my/invited'); return Discourse.getURL('/users/' + it.get('data.display_username'));
} }
}.property("notification.data.{badge_id,badge_name}", "model.slug", "model.topic_id", "model.post_number"), }.property("notification.data.{badge_id,badge_name,display_username}", "model.slug", "model.topic_id", "model.post_number"),
description: function() { description: function() {
const badgeName = this.get("notification.data.badge_name"); const badgeName = this.get("notification.data.badge_name");

View File

@ -14,7 +14,7 @@ export default ObjectController.extend(Presence, ModalFunctionality, {
}.property(), }.property(),
disabled: function() { disabled: function() {
if (this.get('saving')) return true; if (this.get('model.saving')) return true;
if (this.blank('emailOrUsername')) return true; if (this.blank('emailOrUsername')) return true;
const emailOrUsername = this.get('emailOrUsername').trim(); const emailOrUsername = this.get('emailOrUsername').trim();
// when inviting to forum, email must be valid // when inviting to forum, email must be valid
@ -22,14 +22,14 @@ export default ObjectController.extend(Presence, ModalFunctionality, {
// normal users (not admin) can't invite users to private topic via email // normal users (not admin) can't invite users to private topic via email
if (!this.get('isAdmin') && this.get('isPrivateTopic') && Discourse.Utilities.emailValid(emailOrUsername)) return true; if (!this.get('isAdmin') && this.get('isPrivateTopic') && Discourse.Utilities.emailValid(emailOrUsername)) return true;
// when invting to private topic via email, group name must be specified // when invting to private topic via email, group name must be specified
if (this.get('isPrivateTopic') && this.blank('groupNames') && Discourse.Utilities.emailValid(emailOrUsername)) return true; if (this.get('isPrivateTopic') && this.blank('model.groupNames') && Discourse.Utilities.emailValid(emailOrUsername)) return true;
if (this.get('model.details.can_invite_to')) return false; if (this.get('model.details.can_invite_to')) return false;
return false; return false;
}.property('isAdmin', 'emailOrUsername', 'invitingToTopic', 'isPrivateTopic', 'groupNames', 'saving'), }.property('isAdmin', 'emailOrUsername', 'invitingToTopic', 'isPrivateTopic', 'model.groupNames', 'model.saving'),
buttonTitle: function() { buttonTitle: function() {
return this.get('saving') ? I18n.t('topic.inviting') : I18n.t('topic.invite_reply.action'); return this.get('model.saving') ? I18n.t('topic.inviting') : I18n.t('topic.invite_reply.action');
}.property('saving'), }.property('model.saving'),
// We are inviting to a topic if the model isn't the current user. // We are inviting to a topic if the model isn't the current user.
// The current user would mean we are inviting to the forum in general. // The current user would mean we are inviting to the forum in general.
@ -117,8 +117,8 @@ export default ObjectController.extend(Presence, ModalFunctionality, {
// Reset the modal to allow a new user to be invited. // Reset the modal to allow a new user to be invited.
reset() { reset() {
this.setProperties({ this.set('emailOrUsername', null);
emailOrUsername: null, this.get('model').setProperties({
groupNames: null, groupNames: null,
error: false, error: false,
saving: false, saving: false,
@ -131,13 +131,14 @@ export default ObjectController.extend(Presence, ModalFunctionality, {
createInvite() { createInvite() {
if (this.get('disabled')) { return; } if (this.get('disabled')) { return; }
const groupNames = this.get('groupNames'), const groupNames = this.get('model.groupNames'),
userInvitedController = this.get('controllers.user-invited-show'); userInvitedController = this.get('controllers.user-invited-show'),
model = this.get('model');
this.setProperties({ saving: true, error: false }); model.setProperties({ saving: true, error: false });
return this.get('model').createInvite(this.get('emailOrUsername').trim(), groupNames).then(result => { return this.get('model').createInvite(this.get('emailOrUsername').trim(), groupNames).then(result => {
this.setProperties({ saving: false, finished: true }); model.setProperties({ saving: false, finished: true });
if (!this.get('invitingToTopic')) { if (!this.get('invitingToTopic')) {
Discourse.Invite.findInvitedBy(this.currentUser, userInvitedController.get('filter')).then(invite_model => { Discourse.Invite.findInvitedBy(this.currentUser, userInvitedController.get('filter')).then(invite_model => {
userInvitedController.set('model', invite_model); userInvitedController.set('model', invite_model);
@ -146,7 +147,7 @@ export default ObjectController.extend(Presence, ModalFunctionality, {
} else if (this.get('isMessage') && result && result.user) { } else if (this.get('isMessage') && result && result.user) {
this.get('model.details.allowed_users').pushObject(result.user); this.get('model.details.allowed_users').pushObject(result.user);
} }
}).catch(() => this.setProperties({ saving: false, error: true })); }).catch(() => model.setProperties({ saving: false, error: true }));
} }
} }

View File

@ -1,11 +1,11 @@
<div class="modal-body invite-modal"> <div class="modal-body invite-modal">
{{#if error}} {{#if model.error}}
<div class="alert alert-error"> <div class="alert alert-error">
<button class="close" data-dismiss="alert">×</button> <button class="close" data-dismiss="alert">×</button>
{{errorMessage}} {{errorMessage}}
</div> </div>
{{/if}} {{/if}}
{{#if finished}} {{#if model.finished}}
{{{successMessage}}} {{{successMessage}}}
{{else}} {{else}}
<label>{{inviteInstructions}}</label> <label>{{inviteInstructions}}</label>
@ -20,12 +20,12 @@
{{/if}} {{/if}}
{{#if showGroups}} {{#if showGroups}}
<label>{{{groupInstructions}}}</label> <label>{{{groupInstructions}}}</label>
{{group-selector groupFinder=groupFinder groupNames=groupNames placeholderKey="topic.invite_private.group_name"}} {{group-selector groupFinder=groupFinder groupNames=model.groupNames placeholderKey="topic.invite_private.group_name"}}
{{/if}} {{/if}}
{{/if}} {{/if}}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
{{#if finished}} {{#if model.finished}}
{{d-button class="btn-primary" action="closeModal" label="close"}} {{d-button class="btn-primary" action="closeModal" label="close"}}
{{else}} {{else}}
<button class='btn btn-primary' {{bind-attr disabled="disabled"}} {{action "createInvite"}}>{{fa-icon "user-plus"}}{{buttonTitle}}</button> <button class='btn btn-primary' {{bind-attr disabled="disabled"}} {{action "createInvite"}}>{{fa-icon "user-plus"}}{{buttonTitle}}</button>

View File

@ -2,7 +2,7 @@
<section class='user-content'> <section class='user-content'>
<h2>{{i18n 'user.invited.title'}}</h2> <h2>{{i18n 'user.invited.title'}}</h2>
{{#if can_see_invite_details}} {{#if model.can_see_invite_details}}
<div class='user-invite-controls'> <div class='user-invite-controls'>
<div class='span15'> <div class='span15'>
<ul class="nav nav-pills"> <ul class="nav nav-pills">
@ -32,7 +32,7 @@
{{#if inviteRedeemed}} {{#if inviteRedeemed}}
<th>{{i18n 'user.invited.user'}}</th> <th>{{i18n 'user.invited.user'}}</th>
<th>{{i18n 'user.invited.redeemed_at'}}</th> <th>{{i18n 'user.invited.redeemed_at'}}</th>
{{#if can_see_invite_details}} {{#if model.can_see_invite_details}}
<th>{{i18n 'user.last_seen'}}</th> <th>{{i18n 'user.last_seen'}}</th>
<th>{{i18n 'user.invited.topics_entered'}}</th> <th>{{i18n 'user.invited.topics_entered'}}</th>
<th>{{i18n 'user.invited.posts_read_count'}}</th> <th>{{i18n 'user.invited.posts_read_count'}}</th>
@ -51,7 +51,7 @@
{{#link-to 'user' invite.user}}{{invite.user.username}}{{/link-to}} {{#link-to 'user' invite.user}}{{invite.user.username}}{{/link-to}}
</td> </td>
<td>{{format-date invite.redeemed_at}}</td> <td>{{format-date invite.redeemed_at}}</td>
{{#if can_see_invite_details}} {{#if model.can_see_invite_details}}
<td>{{format-date invite.user.last_seen_at}}</td> <td>{{format-date invite.user.last_seen_at}}</td>
<td>{{number invite.user.topics_entered}}</td> <td>{{number invite.user.topics_entered}}</td>
<td>{{number invite.user.posts_read_count}}</td> <td>{{number invite.user.posts_read_count}}</td>