Skip to content

Commit 17d8201

Browse files
committed
Added a per‑user preference under Profile to toggle bold unread thread titles and wired it into the topics list rendering/styles, plus a migration for the new user setting.
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
1 parent fa7628a commit 17d8201

8 files changed

Lines changed: 41 additions & 5 deletions

File tree

app/assets/stylesheets/components/topics.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ a.topic-icon {
283283
color: var(--color-text-muted);
284284
}
285285

286+
.topics-table.unread-bold-enabled .topic-link {
287+
font-weight: var(--font-weight-normal);
288+
}
289+
290+
.topics-table.unread-bold-enabled .topic-row.topic-unread .topic-link {
291+
font-weight: var(--font-weight-bold);
292+
}
293+
286294
.topic-icon-hover {
287295
display: none;
288296
position: absolute;

app/controllers/settings/preferences_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def update
1313
private
1414

1515
def preferences_params
16-
params.require(:user).permit(:mention_restriction)
16+
params.require(:user).permit(:mention_restriction, :bold_unread_threads)
1717
end
1818
end
1919
end

app/views/settings/profiles/show.html.slim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,21 @@
2828
strong Teammates only
2929
span.radio-description Only users who share a team with you can @mention you
3030
= f.submit "Save", class: "button-primary"
31+
32+
.settings-section
33+
h2 Thread Overview
34+
p.settings-hint Choose how unread threads are emphasized in topic lists.
35+
= form_with model: current_user, url: settings_preferences_path, method: :patch, local: true do |f|
36+
.form-group
37+
.radio-group
38+
label
39+
= f.radio_button :bold_unread_threads, false
40+
span.radio-text
41+
strong Colored marker only
42+
span.radio-description Use the existing left-side status marker
43+
label
44+
= f.radio_button :bold_unread_threads, true
45+
span.radio-text
46+
strong Bold unread titles
47+
span.radio-description Unread threads appear in bold like an email inbox
48+
= f.submit "Save", class: "button-primary"

app/views/topics/_topic_row_user.html.slim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
- tp_data = topic_participants_map[topic.id] || {}
88
- top_participants = tp_data[:top] || []
99
- contributor_participants = tp_data[:contributors] || []
10+
- status = (state[:status] || "new").to_s
11+
- unread_status = %w[new reading].include?(status)
1012

11-
tr id=dom_id(topic) class="topic-row topic-#{state[:status] || 'new'}" data-topic-id=topic.id data-last-message-id=topic.last_message_id
13+
tr id=dom_id(topic) class=["topic-row", "topic-#{status}", ("topic-unread" if unread_status)].compact.join(" ") data-topic-id=topic.id data-last-message-id=topic.last_message_id
1214
= render partial: "topics/status_cell", locals: { topic: topic, state: state, note_count: note_count, team_readers: team_readers, star_data: star_data }
1315
td.topic-activity data-label="Activity"
1416
- replies_count = [topic.message_count - 1, 0].max

app/views/topics/index.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
span Filtering by ##{@active_note_tag}
88
= link_to "Clear", topics_path, class: "clear-tag-filter"
99

10-
.topics-table
10+
.topics-table class=("unread-bold-enabled" if current_user&.bold_unread_threads?)
1111
table
1212
thead
1313
tr

app/views/topics/search.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- if user_signed_in?
1111
#user-state-requests
1212
= turbo_frame_tag "user-state-root", src: user_state_frame_topics_path(topic_ids: @topics.map(&:id), format: :turbo_stream), loading: :eager
13-
.topics-table
13+
.topics-table class=("unread-bold-enabled" if current_user&.bold_unread_threads?)
1414
table
1515
thead
1616
tr
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class AddBoldUnreadThreadsToUsers < ActiveRecord::Migration[8.0]
4+
def change
5+
add_column :users, :bold_unread_threads, :boolean, default: false, null: false
6+
end
7+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)