diff --git a/app/assets/images/icons.svg b/app/assets/images/icons.svg index dd7abfcf2f0..2bdd6b85db5 100644 --- a/app/assets/images/icons.svg +++ b/app/assets/images/icons.svg @@ -6,7 +6,7 @@ - + diff --git a/app/views/components/card/timeline_component.rb b/app/views/components/card/timeline_component.rb index 7f7ec86885e..d149fefa088 100644 --- a/app/views/components/card/timeline_component.rb +++ b/app/views/components/card/timeline_component.rb @@ -2,6 +2,7 @@ class Card::TimelineComponent < ApplicationComponent include Phlex::Rails::Helpers::LinkTo + include Phlex::Rails::Helpers::ImageTag include Phlex::Rails::Helpers::TimeAgoInWords def view_template(&) @@ -20,11 +21,40 @@ def timeline_item(datetime, user_link = nil, &) div(class: "flex-1 flex-col ml-5 md:ml-7 pb-4 border-b border-neutral-300 dark:border-neutral-700") do div(class: "flex items-center justify-between") do span(class: "text-b3 text-neutral-600") { t("time_ago", duration: time_ago_in_words(datetime)) } - span(class: "text-b3 text-neutral-800") { user_link } if user_link + span(class: "text-b3 text-neutral-800 dark:text-white max-h-6") { user_link } if user_link end div(class: "flex flex-wrap w-full items-center justify-between", &) end end end + + def link_to_user(user) + link_to(profile_path(user.display_id), alt: user.display_handle, title: user.display_handle, class: "flex items-center") do + span(class: "w-6 h-6 inline-block mr-2 rounded") { helpers.avatar(48, "gravatar-#{user.id}", user) } + span { user.display_handle } + end + end + + def link_to_api_key(api_key_owner) + case api_key_owner + when OIDC::TrustedPublisher::GitHubAction + div(class: "flex items-center") do + span(class: "w-6 h-6 inline-block mr-2 rounded") do + image_tag "github_icon.png", width: 48, height: 48, theme: :light, alt: "GitHub", title: api_key_owner.name + end + span { "GitHub Actions" } + end + else + raise ArgumentError, "unknown api_key_owner type #{api_key_owner.class}" + end + end + + def link_to_pusher(version) + if version.pusher.present? + link_to_user(version.pusher) + elsif version.pusher_api_key&.owner.present? + link_to_api_key(version.pusher_api_key.owner) + end + end end diff --git a/app/views/dashboards/show.html.erb b/app/views/dashboards/show.html.erb index d47c6fa7d52..0d5f1a276b1 100644 --- a/app/views/dashboards/show.html.erb +++ b/app/views/dashboards/show.html.erb @@ -25,14 +25,7 @@ <%= c.scrollable do %> <%= render Card::TimelineComponent.new do |t| %> <% @latest_updates.each do |version| %> - <% - pusher_link = if version.pusher.present? - link_to_user(version.pusher) - elsif version.pusher_api_key&.owner.present? - link_to_pusher(version.pusher_api_key.owner) - end - %> - <%= t.timeline_item(version.authored_at, pusher_link) do %> + <%= t.timeline_item(version.authored_at, t.link_to_pusher(version)) do %>
<%= link_to version.rubygem.name, rubygem_path(version.rubygem.slug) %>
<%= version_number(version) %> <% end %>