From 42375866cc171e66bd71529daf2b05822d5b7989 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sun, 15 Jun 2014 12:55:34 +0530 Subject: [PATCH] Consider User trust level while showing Invites tab --- .../discourse/controllers/user.js.es6 | 9 ++ .../templates/user/invited.js.handlebars | 132 +++++++++--------- .../templates/user/user.js.handlebars | 4 +- config/locales/client.en.yml | 3 +- 4 files changed, 82 insertions(+), 66 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/user.js.es6 b/app/assets/javascripts/discourse/controllers/user.js.es6 index 05e7527ec..5980cf047 100644 --- a/app/assets/javascripts/discourse/controllers/user.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user.js.es6 @@ -27,6 +27,15 @@ export default Discourse.ObjectController.extend({ (this.get('userActionType') === Discourse.UserAction.TYPES.messages_received); }.property('userActionType'), + /** + Can the currently logged in user invite users to the site + + @property canInviteToForum + **/ + canInviteToForum: function() { + return Discourse.User.currentProp('can_invite_to_forum'); + }.property(), + privateMessagesActive: Em.computed.equal('pmView', 'index'), privateMessagesMineActive: Em.computed.equal('pmView', 'mine'), privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread') diff --git a/app/assets/javascripts/discourse/templates/user/invited.js.handlebars b/app/assets/javascripts/discourse/templates/user/invited.js.handlebars index 2cf87fa32..19d2077ad 100644 --- a/app/assets/javascripts/discourse/templates/user/invited.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/invited.js.handlebars @@ -1,75 +1,79 @@ -
+{{#if canInviteToForum}} +
-

{{i18n user.invited.title}}

+

{{i18n user.invited.title}}

-
- {{#if canInviteToForum}} +
- {{/if}} - {{#if canBulkInvite}} - {{resumable-upload target="/invites/upload" success="uploadSuccess" error="uploadError" uploadText=uploadText}} - {{/if}} -
+ {{#if canBulkInvite}} + {{resumable-upload target="/invites/upload" success="uploadSuccess" error="uploadError" uploadText=uploadText}} + {{/if}} +
- {{#if showSearch}} -
- {{text-field value=searchTerm placeholderKey="user.invited.search"}} -
- {{/if}} + {{#if showSearch}} +
+ {{text-field value=searchTerm placeholderKey="user.invited.search"}} +
+ {{/if}} - {{#if model.invites}} - - - - - {{#if can_see_invite_details}} - - - - - - {{/if}} - - {{#each invite in model.invites}} + {{#if model.invites}} +
{{i18n user.invited.user}}{{i18n user.invited.redeemed_at}}{{i18n user.last_seen}}{{i18n user.invited.topics_entered}}{{i18n user.invited.posts_read_count}}{{i18n user.invited.time_read}}{{i18n user.invited.days_visited}}
- {{#if invite.user}} - - - {{#if can_see_invite_details}} - - - - - - {{/if}} - {{else}} - - + + + {{#if can_see_invite_details}} + + + + + {{/if}} - {{/each}} -
- {{#link-to 'user' invite.user}}{{avatar invite.user imageSize="tiny"}}{{/link-to}} - {{#link-to 'user' invite.user}}{{invite.user.username}}{{/link-to}} - {{date invite.redeemed_at}}{{date invite.user.last_seen_at}}{{number invite.user.topics_entered}}{{number invite.user.posts_read_count}}{{{unbound invite.user.time_read}}}{{{unbound invite.user.days_visited}}} - / - {{{unbound invite.user.days_since_created}}}{{unbound invite.email}} - {{#if invite.expired}} - {{i18n user.invited.expired}} - {{/if}} - {{#if invite.rescinded}} - {{i18n user.invited.rescinded}} - {{else}} - - {{/if}} - {{i18n user.invited.user}}{{i18n user.invited.redeemed_at}}{{i18n user.last_seen}}{{i18n user.invited.topics_entered}}{{i18n user.invited.posts_read_count}}{{i18n user.invited.time_read}}{{i18n user.invited.days_visited}}
+ {{#each invite in model.invites}} + + {{#if invite.user}} + + {{#link-to 'user' invite.user}}{{avatar invite.user imageSize="tiny"}}{{/link-to}} + {{#link-to 'user' invite.user}}{{invite.user.username}}{{/link-to}} + + {{date invite.redeemed_at}} + {{#if can_see_invite_details}} + {{date invite.user.last_seen_at}} + {{number invite.user.topics_entered}} + {{number invite.user.posts_read_count}} + {{{unbound invite.user.time_read}}} + {{{unbound invite.user.days_visited}}} + / + {{{unbound invite.user.days_since_created}}} + {{/if}} + {{else}} + {{unbound invite.email}} + + {{#if invite.expired}} + {{i18n user.invited.expired}} + {{/if}} + {{#if invite.rescinded}} + {{i18n user.invited.rescinded}} + {{else}} + + {{/if}} + + {{/if}} + + {{/each}} + - {{#if truncated}} -

{{i18n user.invited.truncated count=maxInvites}}

+ {{#if truncated}} +

{{i18n user.invited.truncated count=maxInvites}}

+ {{/if}} + + {{else}} + {{#if canBulkInvite}} + {{{i18n user.invited.bulk_invite.none}}} + {{else}} + {{i18n user.invited.none}} + {{/if}} {{/if}} - {{else}} - {{{i18n user.invited.none}}} - {{/if}} - -
+
+{{/if}} diff --git a/app/assets/javascripts/discourse/templates/user/user.js.handlebars b/app/assets/javascripts/discourse/templates/user/user.js.handlebars index a17d9a108..a969d80fc 100644 --- a/app/assets/javascripts/discourse/templates/user/user.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/user.js.handlebars @@ -134,7 +134,9 @@ {{#link-to 'preferences' class="btn right"}}{{i18n user.preferences}}{{/link-to}} {{/if}} - {{#link-to 'user.invited' class="btn right"}}{{i18n user.invited.title}}{{/link-to}} + {{#if canInviteToForum}} + {{#link-to 'user.invited' class="btn right"}}{{i18n user.invited.title}}{{/link-to}} + {{/if}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 5a2e3aaa6..304abb3b7 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -403,7 +403,7 @@ en: search: "type to search invites..." title: "Invites" user: "Invited User" - none: "You haven't invited anyone here yet. You can send individual invites, or invite a bunch of people at once by uploading a bulk invite file." + none: "You haven't invited anyone here yet." truncated: "Showing the first {{count}} invites." redeemed: "Redeemed Invites" redeemed_at: "Redeemed" @@ -418,6 +418,7 @@ en: account_age_days: "Account age in days" create: "Send an Invite" bulk_invite: + none: "You haven't invited anyone here yet. You can send individual invites, or invite a bunch of people at once by uploading a bulk invite file." text: "Bulk Invite from File" uploading: "UPLOADING" success: "File uploaded successfully, you will be notified shortly with progress."