Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup some minor inconsistencies in dashboard #5189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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/assets/images/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 31 additions & 1 deletion app/views/components/card/timeline_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(&)
Expand All @@ -20,11 +21,40 @@
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 }

Check warning on line 35 in app/views/components/card/timeline_component.rb

View check run for this annotation

Codecov / codecov/patch

app/views/components/card/timeline_component.rb#L33-L35

Added lines #L33 - L35 were not covered by tests
end
end

def link_to_api_key(api_key_owner)
case api_key_owner

Check warning on line 40 in app/views/components/card/timeline_component.rb

View check run for this annotation

Codecov / codecov/patch

app/views/components/card/timeline_component.rb#L40

Added line #L40 was not covered by tests
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

Check warning on line 44 in app/views/components/card/timeline_component.rb

View check run for this annotation

Codecov / codecov/patch

app/views/components/card/timeline_component.rb#L42-L44

Added lines #L42 - L44 were not covered by tests
end
span { "GitHub Actions" }

Check warning on line 46 in app/views/components/card/timeline_component.rb

View check run for this annotation

Codecov / codecov/patch

app/views/components/card/timeline_component.rb#L46

Added line #L46 was not covered by tests
end
else
raise ArgumentError, "unknown api_key_owner type #{api_key_owner.class}"

Check warning on line 49 in app/views/components/card/timeline_component.rb

View check run for this annotation

Codecov / codecov/patch

app/views/components/card/timeline_component.rb#L49

Added line #L49 was not covered by tests
end
end

def link_to_pusher(version)
if version.pusher.present?
link_to_user(version.pusher)

Check warning on line 55 in app/views/components/card/timeline_component.rb

View check run for this annotation

Codecov / codecov/patch

app/views/components/card/timeline_component.rb#L55

Added line #L55 was not covered by tests
elsif version.pusher_api_key&.owner.present?
link_to_api_key(version.pusher_api_key.owner)

Check warning on line 57 in app/views/components/card/timeline_component.rb

View check run for this annotation

Codecov / codecov/patch

app/views/components/card/timeline_component.rb#L57

Added line #L57 was not covered by tests
end
end
end
9 changes: 1 addition & 8 deletions app/views/dashboards/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<div class="flex text-b1 text-neutral-800 dark:text-white"><%= link_to version.rubygem.name, rubygem_path(version.rubygem.slug) %></div>
<%= version_number(version) %>
<% end %>
Expand Down