Skip to content

Commit 5c6de3e

Browse files
authored
Team activity now includes a Sender column (#103)
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
1 parent 9c2f149 commit 5c6de3e

5 files changed

Lines changed: 62 additions & 3 deletions

File tree

app/assets/stylesheets/components/profile.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,29 @@
218218
text-decoration: underline;
219219
}
220220

221+
.activity-sender {
222+
display: inline-flex;
223+
align-items: center;
224+
gap: var(--spacing-2);
225+
color: var(--color-text-primary);
226+
text-decoration: none;
227+
}
228+
229+
.activity-sender:hover .activity-sender-name {
230+
text-decoration: underline;
231+
}
232+
233+
.activity-sender-avatar {
234+
width: 32px;
235+
height: 32px;
236+
border-radius: 50%;
237+
flex-shrink: 0;
238+
}
239+
240+
.activity-sender-name {
241+
font-weight: var(--font-weight-medium);
242+
}
243+
221244
.activity-filters {
222245
padding: var(--spacing-4);
223246
background: var(--color-bg-card);

app/controllers/concerns/profile_activity.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def build_activity_entries(scope: nil, filters: nil)
4444
return [] if ids.blank?
4545

4646
scope ||= Message.where(sender_person_id: ids)
47-
messages = scope.includes(:topic, :attachments)
47+
messages = scope.includes(:topic, :attachments, :sender, sender_person: :default_alias)
4848
.order(created_at: :desc)
4949

5050
return [] if messages.empty?

app/views/shared/profile/_recent_threads.html.slim

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
h2 Recent messages (last 30 days)
1414

1515
- if activity_entries.any?
16+
- show_sender = local_assigns.fetch(:show_sender, false)
1617
- summary = local_assigns[:activity_summary] || {}
1718
- total = summary[:total] || activity_entries.size
1819
- started = summary[:started_thread] || 0
@@ -45,11 +46,14 @@
4546
thead
4647
tr
4748
th Activity
49+
- if show_sender
50+
th Sender
4851
th Thread
4952
th Sent
5053
tbody
5154
- activity_entries.each do |entry|
5255
- topic = entry[:topic]
56+
- message = entry[:message]
5357
- types = entry[:activity_types] || []
5458
tr
5559
td.activity-types
@@ -65,8 +69,21 @@
6569
span.activity-tag.tag-patch First patch
6670
- when :sent_followup_patch
6771
span.activity-tag.tag-patch Follow-up patch
72+
- if show_sender
73+
- sender_alias = message.sender_display_alias
74+
td
75+
- if sender_alias && message.sender_person
76+
= link_to person_path(sender_alias.email), class: "activity-sender", data: { turbo_frame: "_top" } do
77+
= image_tag sender_alias.gravatar_url(size: 32), class: "activity-sender-avatar", alt: sender_alias.name
78+
span.activity-sender-name = sender_alias.name
79+
- elsif sender_alias
80+
.activity-sender
81+
= image_tag sender_alias.gravatar_url(size: 32), class: "activity-sender-avatar", alt: sender_alias.name
82+
span.activity-sender-name = sender_alias.name
83+
- else
84+
span.activity-sender-name Unknown
6885
td
69-
= link_to topic.title, topic_path(topic, anchor: "message-#{entry[:message].id}"), class: "activity-topic", data: { turbo_frame: "_top" }
86+
= link_to topic.title, topic_path(topic, anchor: "message-#{message.id}"), class: "activity-topic", data: { turbo_frame: "_top" }
7087
td
7188
= time_ago_in_words(entry[:sent_at])
7289
| ago
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
= render "shared/profile/recent_threads", activity_entries: @activity_entries, activity_period: @activity_period, activity_summary: @activity_summary
1+
= render "shared/profile/recent_threads", activity_entries: @activity_entries, activity_period: @activity_period, activity_summary: @activity_summary, show_sender: true

spec/requests/teams_profile_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,24 @@ def attach_verified_alias(user, email:, primary: true)
8787
get team_profile_path("non-existent")
8888
expect(response).to have_http_status(:not_found)
8989
end
90+
91+
it "shows the sender column and links team activity rows to the sender profile" do
92+
team.update!(visibility: :visible)
93+
94+
member_alias = attach_verified_alias(member, email: "member@example.com")
95+
create(:team_member, team: team, user: non_member, role: "member")
96+
sender_alias = attach_verified_alias(non_member, email: "sender@example.com")
97+
98+
topic = create(:topic, creator_alias: member_alias, title: "Sender activity thread")
99+
create(:message, topic: topic, sender: sender_alias, sender_person_id: non_member.person.id, created_at: 2.days.ago, updated_at: 2.days.ago)
100+
101+
get team_profile_path("test-team")
102+
103+
expect(response).to have_http_status(:success)
104+
expect(response.body).to include("<th>Sender</th>")
105+
expect(response.body).to include("sender@example.com")
106+
expect(response.body).to include(person_path("sender@example.com"))
107+
expect(response.body).to include("Sender activity thread")
108+
end
90109
end
91110
end

0 commit comments

Comments
 (0)