From 6b6e50909cc77de1797e88be5445c5b643b008a9 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 18 Jul 2026 15:28:30 +0200 Subject: Give action log entries per-verb icons A muted glyph before each sentence makes both log surfaces scannable by verb: create, publish, move, trash, restore, destroy, and the discard pair. Rollback publishes get their own icon (history) distinct from ordinary promotion. Unknown verbs fall back to a dashed circle. --- app/helpers/node_actions_helper.rb | 25 +++++++++++++++++++++++++ app/views/node_actions/_action_row.html.erb | 1 + public/stylesheets/admin.css | 6 ++++++ test/models/helpers/node_actions_helper_test.rb | 10 ++++++++++ 4 files changed, 42 insertions(+) diff --git a/app/helpers/node_actions_helper.rb b/app/helpers/node_actions_helper.rb index eb761e3..fd8cc36 100644 --- a/app/helpers/node_actions_helper.rb +++ b/app/helpers/node_actions_helper.rb @@ -1,6 +1,31 @@ module NodeActionsHelper include ERB::Util + # One glyph per verb, rendered before the sentence in _action_row. + # Unknown verbs get the dashed circle -- the unknown-verb principle + # extended to iconography: the log outlives its vocabulary. + VERB_ICONS = { + "create" => "file-plus", + "publish" => "send", + "move" => "arrows-move", + "trash" => "trash", + "restore_from_trash" => "arrow-back-up", + "destroy" => "trash-x", + "discard_autosave" => "eraser", + "destroy_draft" => "eraser", + }.freeze + + def verb_icon action + name = if action.action == "publish" && action.metadata["via"] == "revision" + "history" + else + VERB_ICONS.fetch(action.action, "circle-dashed") + end + content_tag(:span, icon(name, library: "tabler", "aria-hidden": true), + :class => "node_action_icon node_action_icon--#{name}", + :title => action.action) + end + # One sentence per entry, rendered from metadata alone, so entries # stay renderable after the rows they reference are gone. Live # associations only upgrade plain names to links. Every metadata diff --git a/app/views/node_actions/_action_row.html.erb b/app/views/node_actions/_action_row.html.erb index 5b5488b..c640f0d 100644 --- a/app/views/node_actions/_action_row.html.erb +++ b/app/views/node_actions/_action_row.html.erb @@ -4,6 +4,7 @@ <%= action.occurred_at.strftime("%H:%M") %> + <%= verb_icon(action) %> <%= action_summary(action) %> <% if action.node_id && params[:node_id].blank? %> <%= link_to t("node_actions.node_history"), admin_log_path(:node_id => action.node_id), :class => "node_action_zoom" %> diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index 15e753d..05e47e7 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -1544,6 +1544,12 @@ div#image_browser ul li { color: #777; } +.node_action_icon { + color: #777; + margin-right: 0.35em; + vertical-align: text-bottom; +} + .revision_lifecycle { font-size: 0.85rem; color: #777; diff --git a/test/models/helpers/node_actions_helper_test.rb b/test/models/helpers/node_actions_helper_test.rb index ef6035d..1b72ec9 100644 --- a/test/models/helpers/node_actions_helper_test.rb +++ b/test/models/helpers/node_actions_helper_test.rb @@ -10,6 +10,10 @@ class NodeActionsHelperTest < ActionView::TestCase { :locale => nil } end + def icon(_name, **) + ''.html_safe + end + def teardown I18n.locale = @original_locale end @@ -133,4 +137,10 @@ class NodeActionsHelperTest < ActionView::TestCase assert_equal "", revision_lifecycle_badges(nil) end + + test "verb icons map known verbs, distinguish rollbacks, and fall back" do + assert_includes verb_icon(entry("trash", { "path" => { "from" => "a", "to" => "t/a" } })), "node_action_icon--trash" + assert_includes verb_icon(entry("publish", { "via" => "revision" })), "node_action_icon--history" + assert_includes verb_icon(entry("frobnicate")), "node_action_icon--circle-dashed" + end end -- cgit v1.3