FEATURE: user card shows staff if a user is staged and lets them check the email address

This commit is contained in:
Neil Lalonde 2017-11-23 16:38:11 -05:00
parent e0dc4ea4fc
commit 3f58b18dab
5 changed files with 36 additions and 3 deletions

View File

@ -7,12 +7,13 @@ import DiscourseURL from 'discourse/lib/url';
import User from 'discourse/models/user'; import User from 'discourse/models/user';
import { userPath } from 'discourse/lib/url'; import { userPath } from 'discourse/lib/url';
import { durationTiny } from 'discourse/lib/formatter'; import { durationTiny } from 'discourse/lib/formatter';
import CanCheckEmails from 'discourse/mixins/can-check-emails';
const clickOutsideEventName = "mousedown.outside-user-card"; const clickOutsideEventName = "mousedown.outside-user-card";
const clickDataExpand = "click.discourse-user-card"; const clickDataExpand = "click.discourse-user-card";
const clickMention = "click.discourse-user-mention"; const clickMention = "click.discourse-user-mention";
export default Ember.Component.extend(CleansUp, { export default Ember.Component.extend(CleansUp, CanCheckEmails, {
elementId: 'user-card', elementId: 'user-card',
classNameBindings: ['visible:show', 'showBadges', 'hasCardBadgeImage', 'user.card_background::no-bg'], classNameBindings: ['visible:show', 'showBadges', 'hasCardBadgeImage', 'user.card_background::no-bg'],
allowBackgrounds: setting('allow_profile_backgrounds'), allowBackgrounds: setting('allow_profile_backgrounds'),
@ -30,6 +31,7 @@ export default Ember.Component.extend(CleansUp, {
showDelete: Ember.computed.and("viewingAdmin", "showName", "user.canBeDeleted"), showDelete: Ember.computed.and("viewingAdmin", "showName", "user.canBeDeleted"),
linkWebsite: Ember.computed.not('user.isBasic'), linkWebsite: Ember.computed.not('user.isBasic'),
hasLocationOrWebsite: Ember.computed.or('user.location', 'user.website_name'), hasLocationOrWebsite: Ember.computed.or('user.location', 'user.website_name'),
showCheckEmail: Ember.computed.and('user.staged', 'canCheckEmails'),
visible: false, visible: false,
user: null, user: null,
@ -291,6 +293,10 @@ export default Ember.Component.extend(CleansUp, {
showUser() { showUser() {
this.sendAction('showUser', this.get('user')); this.sendAction('showUser', this.get('user'));
this._close(); this._close();
},
checkEmail(user) {
user.checkEmail();
} }
} }
}); });

View File

@ -31,6 +31,10 @@
<h2>{{user.title}}</h2> <h2>{{user.title}}</h2>
{{/if}} {{/if}}
{{#if showCheckEmail}}
<h2 class="staged">{{i18n 'user.staged'}}</h2>
{{/if}}
{{plugin-outlet name="user-card-post-names" args=(hash user=user) tagName='div'}} {{plugin-outlet name="user-card-post-names" args=(hash user=user) tagName='div'}}
</span> </span>
</div> </div>
@ -125,6 +129,16 @@
<span>({{i18n 'time_read_recently' time_read=recentTimeRead}})</span> <span>({{i18n 'time_read_recently' time_read=recentTimeRead}})</span>
{{/if}} {{/if}}
</h3> </h3>
{{#if showCheckEmail}}
<h3 class="email">
{{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}}
</h3>
{{/if}}
{{plugin-outlet name="user-card-metadata" args=(hash user=user)}} {{plugin-outlet name="user-card-metadata" args=(hash user=user)}}
</div> </div>
{{/if}} {{/if}}

View File

@ -41,6 +41,9 @@ $user_card_background: $secondary;
a.card-huge-avatar { a.card-huge-avatar {
outline: none; outline: none;
} }
.staged {
font-style: italic;
}
} }
&.no-bg { &.no-bg {
@ -255,4 +258,8 @@ $user_card_background: $secondary;
font-size: 2.143em; font-size: 2.143em;
i {color: $user_card_primary;} i {color: $user_card_primary;}
} }
.metadata .email .btn {
padding: 2px 12px;
}
} }

View File

@ -71,7 +71,8 @@ class UserSerializer < BasicUserSerializer
:primary_group_name, :primary_group_name,
:primary_group_flair_url, :primary_group_flair_url,
:primary_group_flair_bg_color, :primary_group_flair_bg_color,
:primary_group_flair_color :primary_group_flair_color,
:staged
has_one :invited_by, embed: :object, serializer: BasicUserSerializer has_one :invited_by, embed: :object, serializer: BasicUserSerializer
has_many :groups, embed: :object, serializer: BasicGroupSerializer has_many :groups, embed: :object, serializer: BasicGroupSerializer
@ -411,4 +412,8 @@ class UserSerializer < BasicUserSerializer
time = object.recent_time_read time = object.recent_time_read
end end
def include_staged?
scope.is_staff?
end
end end

View File

@ -665,6 +665,7 @@ en:
api_approved: "Approved:" api_approved: "Approved:"
theme: "Theme" theme: "Theme"
home: "Default Home Page" home: "Default Home Page"
staged: "Staged"
staff_counters: staff_counters:
flags_given: "helpful flags" flags_given: "helpful flags"