diff options
| -rw-r--r-- | app/helpers/node_actions_helper.rb | 25 | ||||
| -rw-r--r-- | app/views/node_actions/_action_row.html.erb | 1 | ||||
| -rw-r--r-- | public/stylesheets/admin.css | 6 | ||||
| -rw-r--r-- | test/models/helpers/node_actions_helper_test.rb | 10 |
4 files changed, 42 insertions, 0 deletions
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 @@ | |||
| 1 | module NodeActionsHelper | 1 | module NodeActionsHelper |
| 2 | include ERB::Util | 2 | include ERB::Util |
| 3 | 3 | ||
| 4 | # One glyph per verb, rendered before the sentence in _action_row. | ||
| 5 | # Unknown verbs get the dashed circle -- the unknown-verb principle | ||
| 6 | # extended to iconography: the log outlives its vocabulary. | ||
| 7 | VERB_ICONS = { | ||
| 8 | "create" => "file-plus", | ||
| 9 | "publish" => "send", | ||
| 10 | "move" => "arrows-move", | ||
| 11 | "trash" => "trash", | ||
| 12 | "restore_from_trash" => "arrow-back-up", | ||
| 13 | "destroy" => "trash-x", | ||
| 14 | "discard_autosave" => "eraser", | ||
| 15 | "destroy_draft" => "eraser", | ||
| 16 | }.freeze | ||
| 17 | |||
| 18 | def verb_icon action | ||
| 19 | name = if action.action == "publish" && action.metadata["via"] == "revision" | ||
| 20 | "history" | ||
| 21 | else | ||
| 22 | VERB_ICONS.fetch(action.action, "circle-dashed") | ||
| 23 | end | ||
| 24 | content_tag(:span, icon(name, library: "tabler", "aria-hidden": true), | ||
| 25 | :class => "node_action_icon node_action_icon--#{name}", | ||
| 26 | :title => action.action) | ||
| 27 | end | ||
| 28 | |||
| 4 | # One sentence per entry, rendered from metadata alone, so entries | 29 | # One sentence per entry, rendered from metadata alone, so entries |
| 5 | # stay renderable after the rows they reference are gone. Live | 30 | # stay renderable after the rows they reference are gone. Live |
| 6 | # associations only upgrade plain names to links. Every metadata | 31 | # 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 @@ | |||
| 4 | <span class="node_action_clock"><%= action.occurred_at.strftime("%H:%M") %></span> | 4 | <span class="node_action_clock"><%= action.occurred_at.strftime("%H:%M") %></span> |
| 5 | </td> | 5 | </td> |
| 6 | <td class="node_action_body"> | 6 | <td class="node_action_body"> |
| 7 | <%= verb_icon(action) %> | ||
| 7 | <%= action_summary(action) %> | 8 | <%= action_summary(action) %> |
| 8 | <% if action.node_id && params[:node_id].blank? %> | 9 | <% if action.node_id && params[:node_id].blank? %> |
| 9 | <%= link_to t("node_actions.node_history"), admin_log_path(:node_id => action.node_id), :class => "node_action_zoom" %> | 10 | <%= 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 { | |||
| 1544 | color: #777; | 1544 | color: #777; |
| 1545 | } | 1545 | } |
| 1546 | 1546 | ||
| 1547 | .node_action_icon { | ||
| 1548 | color: #777; | ||
| 1549 | margin-right: 0.35em; | ||
| 1550 | vertical-align: text-bottom; | ||
| 1551 | } | ||
| 1552 | |||
| 1547 | .revision_lifecycle { | 1553 | .revision_lifecycle { |
| 1548 | font-size: 0.85rem; | 1554 | font-size: 0.85rem; |
| 1549 | color: #777; | 1555 | 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 | |||
| 10 | { :locale => nil } | 10 | { :locale => nil } |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | def icon(_name, **) | ||
| 14 | '<svg class="stub-icon"></svg>'.html_safe | ||
| 15 | end | ||
| 16 | |||
| 13 | def teardown | 17 | def teardown |
| 14 | I18n.locale = @original_locale | 18 | I18n.locale = @original_locale |
| 15 | end | 19 | end |
| @@ -133,4 +137,10 @@ class NodeActionsHelperTest < ActionView::TestCase | |||
| 133 | 137 | ||
| 134 | assert_equal "", revision_lifecycle_badges(nil) | 138 | assert_equal "", revision_lifecycle_badges(nil) |
| 135 | end | 139 | end |
| 140 | |||
| 141 | test "verb icons map known verbs, distinguish rollbacks, and fall back" do | ||
| 142 | assert_includes verb_icon(entry("trash", { "path" => { "from" => "a", "to" => "t/a" } })), "node_action_icon--trash" | ||
| 143 | assert_includes verb_icon(entry("publish", { "via" => "revision" })), "node_action_icon--history" | ||
| 144 | assert_includes verb_icon(entry("frobnicate")), "node_action_icon--circle-dashed" | ||
| 145 | end | ||
| 136 | end | 146 | end |
