From 3f58b18dabd064bd51151905dff4c19361d82345 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 23 Nov 2017 16:38:11 -0500 Subject: [PATCH] FEATURE: user card shows staff if a user is staged and lets them check the email address --- .../discourse/components/user-card-contents.js.es6 | 8 +++++++- .../templates/components/user-card-contents.hbs | 14 ++++++++++++++ app/assets/stylesheets/desktop/user-card.scss | 9 ++++++++- app/serializers/user_serializer.rb | 7 ++++++- config/locales/client.en.yml | 1 + 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/components/user-card-contents.js.es6 b/app/assets/javascripts/discourse/components/user-card-contents.js.es6 index 844322aab2a..238b86cdb26 100644 --- a/app/assets/javascripts/discourse/components/user-card-contents.js.es6 +++ b/app/assets/javascripts/discourse/components/user-card-contents.js.es6 @@ -7,12 +7,13 @@ import DiscourseURL from 'discourse/lib/url'; import User from 'discourse/models/user'; import { userPath } from 'discourse/lib/url'; import { durationTiny } from 'discourse/lib/formatter'; +import CanCheckEmails from 'discourse/mixins/can-check-emails'; const clickOutsideEventName = "mousedown.outside-user-card"; const clickDataExpand = "click.discourse-user-card"; const clickMention = "click.discourse-user-mention"; -export default Ember.Component.extend(CleansUp, { +export default Ember.Component.extend(CleansUp, CanCheckEmails, { elementId: 'user-card', classNameBindings: ['visible:show', 'showBadges', 'hasCardBadgeImage', 'user.card_background::no-bg'], allowBackgrounds: setting('allow_profile_backgrounds'), @@ -30,6 +31,7 @@ export default Ember.Component.extend(CleansUp, { showDelete: Ember.computed.and("viewingAdmin", "showName", "user.canBeDeleted"), linkWebsite: Ember.computed.not('user.isBasic'), hasLocationOrWebsite: Ember.computed.or('user.location', 'user.website_name'), + showCheckEmail: Ember.computed.and('user.staged', 'canCheckEmails'), visible: false, user: null, @@ -291,6 +293,10 @@ export default Ember.Component.extend(CleansUp, { showUser() { this.sendAction('showUser', this.get('user')); this._close(); + }, + + checkEmail(user) { + user.checkEmail(); } } }); diff --git a/app/assets/javascripts/discourse/templates/components/user-card-contents.hbs b/app/assets/javascripts/discourse/templates/components/user-card-contents.hbs index d6895c408ba..02ee31c9bd1 100644 --- a/app/assets/javascripts/discourse/templates/components/user-card-contents.hbs +++ b/app/assets/javascripts/discourse/templates/components/user-card-contents.hbs @@ -31,6 +31,10 @@

{{user.title}}

{{/if}} + {{#if showCheckEmail}} +

{{i18n 'user.staged'}}

+ {{/if}} + {{plugin-outlet name="user-card-post-names" args=(hash user=user) tagName='div'}} @@ -125,6 +129,16 @@ ({{i18n 'time_read_recently' time_read=recentTimeRead}}) {{/if}} + {{#if showCheckEmail}} +

+ {{i18n 'user.email.title'}}: + {{#if user.email}} + {{user.email}} + {{else}} + {{d-button action="checkEmail" actionParam=user icon="envelope-o" label="admin.users.check_email.text" class="btn-primary"}} + {{/if}} +

+ {{/if}} {{plugin-outlet name="user-card-metadata" args=(hash user=user)}} {{/if}} diff --git a/app/assets/stylesheets/desktop/user-card.scss b/app/assets/stylesheets/desktop/user-card.scss index e2fdce0db4e..c6bbe50c961 100644 --- a/app/assets/stylesheets/desktop/user-card.scss +++ b/app/assets/stylesheets/desktop/user-card.scss @@ -41,6 +41,9 @@ $user_card_background: $secondary; a.card-huge-avatar { outline: none; } + .staged { + font-style: italic; + } } &.no-bg { @@ -221,7 +224,7 @@ $user_card_background: $secondary; .user-badge { background: scale-color($user_card_background, $lightness: -5%); - border: 1px solid $primary-low; + border: 1px solid $primary-low; color: $user_card_primary; } @@ -255,4 +258,8 @@ $user_card_background: $secondary; font-size: 2.143em; i {color: $user_card_primary;} } + + .metadata .email .btn { + padding: 2px 12px; + } } diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index 6a436eb6428..82a8dcb2b92 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -71,7 +71,8 @@ class UserSerializer < BasicUserSerializer :primary_group_name, :primary_group_flair_url, :primary_group_flair_bg_color, - :primary_group_flair_color + :primary_group_flair_color, + :staged has_one :invited_by, embed: :object, serializer: BasicUserSerializer has_many :groups, embed: :object, serializer: BasicGroupSerializer @@ -411,4 +412,8 @@ class UserSerializer < BasicUserSerializer time = object.recent_time_read end + def include_staged? + scope.is_staff? + end + end diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 3693e2a486a..dd18e005024 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -665,6 +665,7 @@ en: api_approved: "Approved:" theme: "Theme" home: "Default Home Page" + staged: "Staged" staff_counters: flags_given: "helpful flags"