summaryrefslogtreecommitdiff
path: root/app/helpers/node_actions_helper.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-16 13:50:15 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-16 13:50:15 +0200
commit603ccfbd5fe96f0b83aaf3d5118aded2a39992fb (patch)
tree0e88ec41af6ce1a03e65bedb3f68a5a9881d96bb /app/helpers/node_actions_helper.rb
parentbb7ef80d084f474bb4c3be0ae0d033aff3de0272 (diff)
Condense the action log into a scannable table
Several minor improvements to the action log presentation: * Now a table with date and human readable presentation as rows is displayed * If no changes in a title were detected, the old version is omitted * The "inferred" flag is demoted to the end of the line * You can zoom in on the node's history directly from a log line * byline for the first publish action is preserved * Revisions are directly linked to when a new one i published
Diffstat (limited to 'app/helpers/node_actions_helper.rb')
-rw-r--r--app/helpers/node_actions_helper.rb74
1 files changed, 63 insertions, 11 deletions
diff --git a/app/helpers/node_actions_helper.rb b/app/helpers/node_actions_helper.rb
index 55ca982..996f98d 100644
--- a/app/helpers/node_actions_helper.rb
+++ b/app/helpers/node_actions_helper.rb
@@ -16,8 +16,57 @@ module NodeActionsHelper
16 :action => h(action.action), :subject => subject_ref(action)).html_safe 16 :action => h(action.action), :subject => subject_ref(action)).html_safe
17 end 17 end
18 18
19
20 def action_details? action
21 m = action.metadata
22 return true if m["translation_diff"].present?
23 return true if m["title"].is_a?(Hash) && m.dig("title", "from") != m.dig("title", "to")
24 %w[author tags template_changed assets_changed
25 abstract_changed body_changed].any? { |key| m[key].present? }
26 end
27
28 # Plain strings by design -- safe_join in the template escapes them.
29 def default_locale_changes action
30 m = action.metadata
31 items = []
32 if m["title"].is_a?(Hash) && m.dig("title", "from") && m.dig("title", "from") != m.dig("title", "to")
33 items << t("node_actions.detail_title",
34 :from => m.dig("title", "from"), :to => m.dig("title", "to"))
35 end
36 items << t("node_actions.detail_author",
37 :from => m.dig("author", "from"), :to => m.dig("author", "to")) if m["author"]
38 items << t("node_actions.detail_tags",
39 :from => Array(m.dig("tags", "from")).join(", "),
40 :to => Array(m.dig("tags", "to")).join(", ")) if m["tags"]
41 items << t("node_actions.abstract_changed") if m["abstract_changed"]
42 items << t("node_actions.body_changed") if m["body_changed"]
43 items << t("node_actions.template_changed") if m["template_changed"]
44 items << t("node_actions.assets_changed") if m["assets_changed"]
45 items
46 end
47
48 def translation_changes diff
49 case diff["status"]
50 when "added" then [t("node_actions.locale_added", :title => diff.dig("title", "to"))]
51 when "removed" then [t("node_actions.locale_removed", :title => diff.dig("title", "from"))]
52 else
53 items = []
54 items << t("node_actions.detail_title",
55 :from => diff.dig("title", "from"), :to => diff.dig("title", "to")) if diff["title"]
56 items << t("node_actions.abstract_changed") if diff["abstract_changed"]
57 items << t("node_actions.body_changed") if diff["body_changed"]
58 items
59 end
60 end
61
19 private 62 private
20 63
64 def revision_ref action, key
65 label = t(key)
66 return label unless action.node && action.page
67 link_to(label, node_revision_path(action.node, action.page))
68 end
69
21 def actor_ref action 70 def actor_ref action
22 action.user ? link_to(h(action.actor_name), admin_log_path(:user_id => action.user_id)) 71 action.user ? link_to(h(action.actor_name), admin_log_path(:user_id => action.user_id))
23 : h(action.actor_name) 72 : h(action.actor_name)
@@ -29,17 +78,20 @@ module NodeActionsHelper
29 end 78 end
30 79
31 def summarize_publish action 80 def summarize_publish action
32 key = if action.metadata["via"] == "revision" 81 if action.metadata["via"] == "revision"
33 "node_actions.publish_rollback" 82 t("node_actions.publish_rollback",
34 elsif action.metadata.dig("title", "from").nil? 83 :actor => actor_ref(action), :subject => subject_ref(action),
35 "node_actions.publish_first" 84 :revision => revision_ref(action, "node_actions.revision_earlier")).html_safe
36 else 85 elsif action.metadata.dig("title", "from").nil?
37 "node_actions.publish" 86 author = action.metadata.dig("author", "to")
38 end 87 key = author ? "node_actions.publish_first_with_author" : "node_actions.publish_first"
39 88 t(key, :actor => actor_ref(action), :subject => subject_ref(action),
40 t(key, :actor => actor_ref(action), :subject => subject_ref(action), 89 :author => h(author)).html_safe
41 :from => h(action.metadata.dig("title", "from")), 90 else
42 :to => h(action.metadata.dig("title", "to"))).html_safe 91 t("node_actions.publish",
92 :actor => actor_ref(action), :subject => subject_ref(action),
93 :revision => revision_ref(action, "node_actions.revision_new")).html_safe
94 end
43 end 95 end
44 96
45 def summarize_move action 97 def summarize_move action