Skip to content

Commit e02a0d4

Browse files
authored
bug/69230 Use enhanced Primer::OpenProject::AvatarWithFallback to render initials in a styled SVG when avatar img src is nil/blank (#21343)
1 parent 31ecad0 commit e02a0d4

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

modules/documents/app/components/documents/show_edit_view/page_header/live_users_component.html.erb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
concat(
4343
flex_layout do |flex_container|
4444
flex_container.with_column do
45-
render Primer::Beta::AvatarStack.new(
45+
render Primer::OpenProject::AvatarStack.new(
4646
data: { "documents--live-events-target": "users" }
4747
) do |component|
4848
users.map do |user|
49-
component.with_avatar(src: avatar_url(user), alt: user.name)
49+
component.with_avatar_with_fallback(**avatar_options_for(user))
5050
end
5151
end
5252
end
@@ -67,14 +67,12 @@
6767
component.with_body(caret: :top_left) do
6868
flex_layout do |container|
6969
users.each do |user|
70-
container.with_row do
71-
render Users::AvatarComponent.new(
72-
user: user,
73-
show_name: true,
74-
link: false,
75-
hover_card: { active: false },
76-
size: :mini
77-
)
70+
container.with_column do
71+
render Primer::OpenProject::AvatarWithFallback.new(**avatar_options_for(user))
72+
end
73+
74+
container.with_column(ml: 2) do
75+
render(Primer::Beta::Text.new(color: :subtle)) { user.name }
7876
end
7977
end
8078
end

modules/documents/app/components/documents/show_edit_view/page_header/live_users_component.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ def initialize(users: [User.current])
4949
def active_editors
5050
I18n.t("documents.active_editors_count", count: users.count).html_safe
5151
end
52+
53+
def avatar_options_for(user)
54+
{
55+
src: avatar_url(user),
56+
alt: user.name,
57+
unique_id: user.id
58+
}
59+
end
5260
end
5361
end
5462
end

0 commit comments

Comments
 (0)