Skip to content

Commit

Permalink
Show Run#metadata in the web UI
Browse files Browse the repository at this point in the history
As the example in the README, a common use case of metadata is to record
who ran the task. By displaying metadata in the web UI, we can know who
ran the task at a glance.
  • Loading branch information
shouichi committed Oct 12, 2023
1 parent 7812e0a commit 9f18867
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/views/maintenance_tasks/runs/_run.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

<%= render "maintenance_tasks/runs/csv", run: run %>
<%= tag.hr if run.csv_file.present? && run.arguments.present? %>
<%= render "maintenance_tasks/runs/arguments", run: run %>
<%= render "maintenance_tasks/runs/serializable", serializable: run.arguments, title: "Arguments" %>
<%= tag.hr if run.csv_file.present? || run.arguments.present? && run.metadata.present? %>
<%= render "maintenance_tasks/runs/serializable", serializable: run.metadata, title: "Metadata" %>

<div class="buttons">
<% if run.paused? %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% if run.arguments.present? %>
<% if serializable.present? %>
<div class="table-container">
<h6 class="title is-6">Arguments:</h6>
<h6 class="title is-6"><%= title %>:</h6>
<table class="table">
<tbody>
<% run.arguments.transform_values(&:to_s).each do |key, value| %>
<% serializable.transform_values(&:to_s).each do |key, value| %>
<tr>
<td class="is-family-monospace"><%= key %></td>
<td>
Expand Down
4 changes: 3 additions & 1 deletion app/views/maintenance_tasks/tasks/_task.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

<%= render "maintenance_tasks/runs/csv", run: run %>
<%= tag.hr if run.csv_file.present? && run.arguments.present? %>
<%= render "maintenance_tasks/runs/arguments", run: run %>
<%= render "maintenance_tasks/runs/serializable", serializable: run.arguments, title: "Arguments" %>
<%= tag.hr if run.csv_file.present? || run.arguments.present? && run.metadata.present? %>
<%= render "maintenance_tasks/runs/serializable", serializable: run.metadata, title: "Metadata" %>
<% end %>
</div>
5 changes: 5 additions & 0 deletions test/system/maintenance_tasks/runs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class RunsTest < ApplicationSystemTestCase
assert_title("Maintenance::UpdatePostsTask")
assert_text("Enqueued")
assert_text("Waiting to start.")
assert_text "Metadata"
assert_table do |table|
table.assert_text("user_email")
table.assert_text("michael.elfassy@shopify.com")
end
end
run = Run.last
assert_equal("michael.elfassy@shopify.com", run.metadata["user_email"])
Expand Down

0 comments on commit 9f18867

Please sign in to comment.