Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def self.recent_report(user, count = nil, types = [])
end

def self.populate_acting_user(notifications)
if !(SiteSetting.show_user_menu_avatars || SiteSetting.prioritize_full_name_in_ux)
if !(SiteSetting.show_user_menu_avatars || !SiteSetting.prioritize_username_in_ux)
return notifications
end
usernames =
Expand Down
5 changes: 0 additions & 5 deletions config/site_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1029,11 +1029,6 @@ users:
client: true
default: true
area: "users"
prioritize_full_name_in_ux:
client: true
default: false
hidden: true
area: "users"
email_token_valid_hours:
default: 48
min: 1
Expand Down
6 changes: 3 additions & 3 deletions frontend/discourse/app/components/modal/history/revision.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export default class Revision extends Component {
class="revision-details__user"
>
{{boundAvatarTemplate @model.avatar_template "small"}}
{{#if this.siteSettings.prioritize_full_name_in_ux}}
{{@model.acting_user_name}}
{{else}}
{{#if this.siteSettings.prioritize_username_in_ux}}
{{@model.username}}
{{else}}
{{@model.acting_user_name}}
{{/if}}
</LinkTo>
<PluginOutlet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class UserMenuMessagesList extends UserMenuNotificationsList {

if (
this.siteSettings.show_user_menu_avatars ||
this.siteSettings.prioritize_full_name_in_ux
!this.siteSettings.prioritize_username_in_ux
) {
// Populate avatar_template for lastPoster
const usersById = new Map(data.users.map((u) => [u.id, u]));
Expand Down
2 changes: 1 addition & 1 deletion frontend/discourse/app/lib/notification-types/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class NotificationTypeBase {
* @returns {string} The label is the first part of the text content displayed in the notification. For example, in a like notification, the username of the user who liked the post is the label. If a falsey value is returned, the label is omitted.
*/
get label() {
if (!this.siteSettings.prioritize_full_name_in_ux) {
if (this.siteSettings.prioritize_username_in_ux) {
return this.username;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export default class extends NotificationTypeBase {
get label() {
let name;

if (this.siteSettings.prioritize_full_name_in_ux) {
name = this.notification.acting_user_name || this.username;
} else {
if (this.siteSettings.prioritize_username_in_ux) {
name = this.username;
} else {
name = this.notification.acting_user_name || this.username;
}

return `${name} @${this.notification.data.group_name}`;
Expand Down
14 changes: 7 additions & 7 deletions frontend/discourse/app/lib/notification-types/liked.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { i18n } from "discourse-i18n";

export default class extends NotificationTypeBase {
get label() {
const nameOrUsername = this.siteSettings.prioritize_full_name_in_ux
? this.notification.data.display_name ||
this.notification.data.display_username
: this.notification.data.display_username;
const nameOrUsername = this.siteSettings.prioritize_username_in_ux
? this.notification.data.display_username
: this.notification.data.display_name ||
this.notification.data.display_username;

if (this.count === 2) {
const nameOrUsername2 = this.siteSettings.prioritize_full_name_in_ux
? this.notification.data.name2 || this.notification.data.username2
: this.notification.data.username2;
const nameOrUsername2 = this.siteSettings.prioritize_username_in_ux
? this.notification.data.username2
: this.notification.data.name2 || this.notification.data.username2;

return i18n("notifications.liked_by_2_users", {
username: nameOrUsername,
Expand Down
2 changes: 1 addition & 1 deletion frontend/discourse/app/lib/user-menu/bookmark-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class UserMenuBookmarkItem extends UserMenuBaseItem {
}

get label() {
if (!this.siteSettings.prioritize_full_name_in_ux) {
if (this.siteSettings.prioritize_username_in_ux) {
return this.bookmark.user?.username;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/discourse/app/lib/user-menu/message-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class UserMenuMessageItem extends UserMenuBaseItem {
}

get label() {
if (!this.siteSettings.prioritize_full_name_in_ux) {
if (this.siteSettings.prioritize_username_in_ux) {
return this.message.last_poster_username;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module("Unit | Notification Types | group-mentioned", function (hooks) {
this.owner.register(
"service:site-settings",
class extends Service {
prioritize_full_name_in_ux = false;
prioritize_username_in_ux = true;
}
);

Expand All @@ -69,7 +69,7 @@ module("Unit | Notification Types | group-mentioned", function (hooks) {
});

test("label uses the user's name when prioritize_username_in_ux is false", function (assert) {
this.siteSettings.prioritize_full_name_in_ux = true;
this.siteSettings.prioritize_username_in_ux = false;

const notification = getNotification();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module(

test("label", function (assert) {
const siteSettings = this.owner.lookup("service:site-settings");
siteSettings.prioritize_full_name_in_ux = true;
siteSettings.prioritize_username_in_ux = false;

const notification = getNotification();
const director = createRenderDirector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class AssignedToFirstPost extends Component {
prioritizedAssigneeName(assignee) {
// if this code is ever replaced to use `prioritize_username_in_ux`, remove this function and use the helper
// userPrioritizedName instead
return this.siteSettings.prioritize_full_name_in_ux || !assignee.username
return !this.siteSettings.prioritize_username_in_ux || !assignee.username
? assignee.name || assignee.username
: assignee.username;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export default class AssignedToPost extends Component {
@service siteSettings;

get nameOrUsername() {
if (this.siteSettings.prioritize_full_name_in_ux) {
return this.args.assignedToUser.name || this.args.assignedToUser.username;
} else {
if (this.siteSettings.prioritize_username_in_ux) {
return this.args.assignedToUser.username;
} else {
return this.args.assignedToUser.name || this.args.assignedToUser.username;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
content.push(
unassignFromTopicButton(
this.topic,
this.siteSettings.prioritize_full_name_in_ux
this.siteSettings.prioritize_username_in_ux
)
);
}
Expand Down Expand Up @@ -135,11 +135,11 @@ function reassignToSelfButton() {
};
}

function unassignFromTopicButton(topic, prioritize_full_name_in_ux) {
function unassignFromTopicButton(topic, prioritize_username_in_ux) {
let username =
topic.assigned_to_user?.username || topic.assigned_to_group?.name;

if (topic.assigned_to_user && prioritize_full_name_in_ux) {
if (topic.assigned_to_user && !prioritize_username_in_ux) {
username = topic.assigned_to_user?.name || topic.assigned_to_user?.username;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function initialize(api) {
}

const icon = iconHTML(assignee.username ? "user-plus" : "group-plus");
const showNameInUx = siteSettings.prioritize_full_name_in_ux;
const showNameInUx = !siteSettings.prioritize_username_in_ux;
const name =
showNameInUx || !assignee.username
? assignee.name || assignee.username
Expand Down
2 changes: 1 addition & 1 deletion plugins/discourse-assign/lib/assigner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def queue_notification(assignment)
end

def small_action_username_or_name(assign_to)
if (assign_to.is_a?(User) && SiteSetting.prioritize_full_name_in_ux) ||
if (assign_to.is_a?(User) && !SiteSetting.prioritize_username_in_ux) ||
!assign_to.try(:username)
custom_fields = { "action_code_who" => assign_to.name || assign_to.username }
else
Expand Down
7 changes: 4 additions & 3 deletions plugins/discourse-assign/spec/system/assign_post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
fab!(:post2) { Fabricate(:post, topic: topic) }

before do
# FIXME: Test again
skip "Tests are broken and need to be fixed. See https://github.com/discourse/discourse/actions/runs/13890376408/job/38861216842"
SiteSetting.assign_enabled = true
SiteSetting.prioritize_full_name_in_ux = false
SiteSetting.prioritize_username_in_ux = true
# The system tests in this file are flaky and auth token related so turning this on
SiteSetting.verbose_auth_token_logging = true

Expand Down Expand Up @@ -60,8 +61,8 @@ def assign_post(post, assignee)
expect(topic_page.find_post_assign(post2.post_number)).to have_content(staff_user.username)
end

context "when prioritize_full_name_in_ux setting is enabled" do
before { SiteSetting.prioritize_full_name_in_ux = true }
context "when prioritize_username_in_ux setting is disabled" do
before { SiteSetting.prioritize_username_in_ux = false }

it "shows the user's name after assign" do
visit "/t/#{topic.id}"
Expand Down
6 changes: 3 additions & 3 deletions plugins/discourse-assign/spec/system/assign_topic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

before do
SiteSetting.assign_enabled = true
SiteSetting.prioritize_full_name_in_ux = false
SiteSetting.prioritize_username_in_ux = true
SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
SiteSetting.assign_allowed_on_groups = "#{Group::AUTO_GROUPS[:staff]}"

Expand Down Expand Up @@ -64,8 +64,8 @@
expect(find("#topic .assigned-to")).to have_content(admin2.username)
end

context "when prioritize_full_name_in_ux setting is enabled" do
before { SiteSetting.prioritize_full_name_in_ux = true }
context "when prioritize_username_in_ux setting is disabled" do
before { SiteSetting.prioritize_username_in_ux = false }

it "shows the user's name after assign" do
visit "/t/#{topic.id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,10 @@ export default class DiscourseReactionsListEmoji extends Component {

@bind
displayNameForUser(user) {
if (
!this.siteSettings.prioritize_username_in_ux &&
this.siteSettings.prioritize_full_name_in_ux
) {
if (!this.siteSettings.prioritize_username_in_ux) {
return user.name || user.username;
} else if (this.siteSettings.prioritize_username_in_ux) {
return user.username;
} else if (!user.name) {
return user.username;
} else {
return user.name;
return user.username;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ function initializeDiscourseReactions(api) {

get label() {
const count = this.notification.data.count;
const nameOrUsername = this.siteSettings.prioritize_full_name_in_ux
? this.notification.data.display_name || this.username
: this.username;
const nameOrUsername = this.siteSettings.prioritize_username_in_ux
? this.username
: this.notification.data.display_name || this.username;

if (!count || count === 1 || !this.notification.data.username2) {
return nameOrUsername;
Expand All @@ -120,10 +120,10 @@ function initializeDiscourseReactions(api) {
count: count - 1,
});
} else {
const nameOrUsername2 = this.siteSettings.prioritize_full_name_in_ux
? this.notification.data.name2 ||
formatUsername(this.notification.data.username2)
: formatUsername(this.notification.data.username2);
const nameOrUsername2 = this.siteSettings.prioritize_username_in_ux
? formatUsername(this.notification.data.username2)
: this.notification.data.name2 ||
formatUsername(this.notification.data.username2);
return i18n("notifications.reaction_2_users", {
username: nameOrUsername,
username2: nameOrUsername2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
)
end

before { SiteSetting.prioritize_full_name_in_ux = true }
before { SiteSetting.prioritize_username_in_ux = false }

it "renders reaction notifications with full names" do
visit("/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ acceptance(
discourse_reactions_enabled_reactions: "otter|open_mouth",
discourse_reactions_reaction_for_like: "heart",
discourse_reactions_like_icon: "heart",
prioritize_full_name_in_ux: true,
prioritize_username_in_ux: false,
});

needs.pretender((server, helper) => {
Expand Down
2 changes: 1 addition & 1 deletion spec/models/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ def create_membership_request_notification
end

it "Sets the acting_user correctly for each notification" do
SiteSetting.prioritize_full_name_in_ux = true
SiteSetting.prioritize_username_in_ux = false
Notification.populate_acting_user(
[notification1, notification2, notification3, notification4, notification5],
)
Expand Down
2 changes: 1 addition & 1 deletion spec/system/user_page/user_notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

context "when prioritize_username_in_ux is false" do
before do
SiteSetting.prioritize_full_name_in_ux = true
SiteSetting.prioritize_username_in_ux = false
sign_in(user2)
end

Expand Down
10 changes: 4 additions & 6 deletions spec/system/viewing_user_menu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
expect(user_menu).to have_group_mentioned_notification(topic, user, mentionable_group)
end

context "with SiteSetting.prioritize_full_name_in_ux=true" do
before { SiteSetting.prioritize_full_name_in_ux = true }
context "with SiteSetting.prioritize_username_in_ux=false" do
before { SiteSetting.prioritize_username_in_ux = false }

it "should display user full name in mention notifications" do
Jobs.run_immediately!
Expand Down Expand Up @@ -117,14 +117,12 @@
end
end

context "with SiteSetting.prioritize_full_name_in_ux=false" do
before { SiteSetting.prioritize_full_name_in_ux = false }
context "with SiteSetting.prioritize_username_in_ux=true" do
before { SiteSetting.prioritize_username_in_ux = true }

it "should display only username in mention notifications" do
Jobs.run_immediately!

SiteSetting.prioritize_username_in_ux = true

user = Fabricate(:user)
user2 = Fabricate(:user, name: "John Doe")

Expand Down
Loading