FIX: Show same username or name for post notices. (#7862)
This commit is contained in:
parent
eb9155f3fe
commit
9f500a4ff4
|
@ -8,6 +8,7 @@ import { durationTiny } from "discourse/lib/formatter";
|
|||
import CanCheckEmails from "discourse/mixins/can-check-emails";
|
||||
import CardContentsBase from "discourse/mixins/card-contents-base";
|
||||
import CleansUp from "discourse/mixins/cleans-up";
|
||||
import { prioritizeNameInUx } from "discourse/lib/settings";
|
||||
|
||||
export default Ember.Component.extend(
|
||||
CardContentsBase,
|
||||
|
@ -65,11 +66,7 @@ export default Ember.Component.extend(
|
|||
|
||||
@computed("user.name")
|
||||
nameFirst(name) {
|
||||
return (
|
||||
!this.siteSettings.prioritize_username_in_ux &&
|
||||
name &&
|
||||
name.trim().length > 0
|
||||
);
|
||||
return prioritizeNameInUx(name, this.siteSettings);
|
||||
},
|
||||
|
||||
@computed("username")
|
||||
|
|
|
@ -2,6 +2,7 @@ import CanCheckEmails from "discourse/mixins/can-check-emails";
|
|||
import computed from "ember-addons/ember-computed-decorators";
|
||||
import User from "discourse/models/user";
|
||||
import optionalService from "discourse/lib/optional-service";
|
||||
import { prioritizeNameInUx } from "discourse/lib/settings";
|
||||
|
||||
export default Ember.Controller.extend(CanCheckEmails, {
|
||||
indexStream: false,
|
||||
|
@ -87,11 +88,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
|||
|
||||
@computed("model.name")
|
||||
nameFirst(name) {
|
||||
return (
|
||||
!this.get("siteSettings.prioritize_username_in_ux") &&
|
||||
name &&
|
||||
name.trim().length > 0
|
||||
);
|
||||
return prioritizeNameInUx(name, this.siteSettings);
|
||||
},
|
||||
|
||||
@computed("model.badge_count")
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
export function prioritizeNameInUx(name, siteSettings) {
|
||||
siteSettings = siteSettings || Discourse.SiteSettings;
|
||||
|
||||
return (
|
||||
!siteSettings.prioritize_username_in_ux && name && name.trim().length > 0
|
||||
);
|
||||
}
|
|
@ -15,6 +15,7 @@ import {
|
|||
} from "discourse/lib/utilities";
|
||||
import hbs from "discourse/widgets/hbs-compiler";
|
||||
import { durationTiny } from "discourse/lib/formatter";
|
||||
import { prioritizeNameInUx } from "discourse/lib/settings";
|
||||
|
||||
function transformWithCallbacks(post) {
|
||||
let transformed = transformBasicPost(post);
|
||||
|
@ -454,9 +455,9 @@ createWidget("post-notice", {
|
|||
|
||||
html(attrs) {
|
||||
const user =
|
||||
this.siteSettings.prioritize_username_in_ux || !attrs.name
|
||||
? attrs.username
|
||||
: attrs.name;
|
||||
this.siteSettings.display_name_on_posts && prioritizeNameInUx(attrs.name)
|
||||
? attrs.name
|
||||
: attrs.username;
|
||||
let text, icon;
|
||||
if (attrs.noticeType === "custom") {
|
||||
icon = "user-shield";
|
||||
|
|
|
@ -2,6 +2,7 @@ import { iconNode } from "discourse-common/lib/icon-library";
|
|||
import { createWidget, applyDecorators } from "discourse/widgets/widget";
|
||||
import { h } from "virtual-dom";
|
||||
import { formatUsername } from "discourse/lib/utilities";
|
||||
import { prioritizeNameInUx } from "discourse/lib/settings";
|
||||
|
||||
let sanitizeName = function(name) {
|
||||
return name.toLowerCase().replace(/[\s\._-]/g, "");
|
||||
|
@ -66,9 +67,7 @@ export default createWidget("poster-name", {
|
|||
const name = attrs.name;
|
||||
const nameFirst =
|
||||
this.siteSettings.display_name_on_posts &&
|
||||
!this.siteSettings.prioritize_username_in_ux &&
|
||||
name &&
|
||||
name.trim().length > 0;
|
||||
prioritizeNameInUx(name, this.siteSettings);
|
||||
const classNames = nameFirst
|
||||
? ["first", "full-name"]
|
||||
: ["first", "username"];
|
||||
|
|
|
@ -875,6 +875,7 @@ widgetTest("post notice - with username", {
|
|||
beforeEach() {
|
||||
const twoDaysAgo = new Date();
|
||||
twoDaysAgo.setDate(twoDaysAgo.getDate() - 2);
|
||||
this.siteSettings.display_name_on_posts = false;
|
||||
this.siteSettings.prioritize_username_in_ux = true;
|
||||
this.siteSettings.old_post_notice_days = 14;
|
||||
this.set("args", {
|
||||
|
@ -901,6 +902,7 @@ widgetTest("post notice - with username", {
|
|||
widgetTest("post notice - with name", {
|
||||
template: '{{mount-widget widget="post" args=args}}',
|
||||
beforeEach() {
|
||||
this.siteSettings.display_name_on_posts = true;
|
||||
this.siteSettings.prioritize_username_in_ux = false;
|
||||
this.siteSettings.old_post_notice_days = 14;
|
||||
this.set("args", {
|
||||
|
|
Loading…
Reference in New Issue