rails_admin_next 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/rails_admin_next/application_controller.rb +1 -1
- data/docs/UPGRADING.md +10 -0
- data/lib/rails_admin_next/config/actions/base.rb +5 -0
- data/lib/rails_admin_next/config/actions/history_index.rb +4 -0
- data/lib/rails_admin_next/config/actions/history_show.rb +4 -0
- data/lib/rails_admin_next/extensions/paper_trail/auditing_adapter.rb +11 -1
- data/lib/rails_admin_next/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50219c685864a241e7cca2ff03fbd7c0d8e7c3c9a1f49e65bb19b73f15924525
|
|
4
|
+
data.tar.gz: 37808fdd9c7012a71cd5e6973102dc0b3baf2c2fb7778a4c2eb0421ca4df585a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a85fc8b87439b96f6910ec47d197d35d889dd4da565138982e25db0f039b7cbcef93178b98dae160f29ee8c701f7d3d58c827f85dc8b7172b8107536ac62f2b
|
|
7
|
+
data.tar.gz: d6b0b230e6ee33e864b9242fcff419197cc52e24220a007b0743585388ec96261c8bdb22b3384e2e79338d445cca4d26d4a4e7dd53f36ad48e1778a8179790ff
|
|
@@ -24,7 +24,7 @@ module RailsAdminNext
|
|
|
24
24
|
|
|
25
25
|
helper_method :_current_user
|
|
26
26
|
|
|
27
|
-
attr_reader :object, :model_config, :abstract_model, :authorization_adapter
|
|
27
|
+
attr_reader :object, :model_config, :abstract_model, :auditing_adapter, :authorization_adapter
|
|
28
28
|
|
|
29
29
|
# nil without an authorization adapter. With one, a scope that is not a relation (nil, a
|
|
30
30
|
# Hash, a Proc, an Array) comes from a broken policy and lists nothing: merged in, most of
|
data/docs/UPGRADING.md
CHANGED
|
@@ -913,3 +913,13 @@ A `last_created_at` override in model config is not scoped for you. It runs with
|
|
|
913
913
|
`bindings[:controller].authorization_scope(:index, abstract_model)`: the authorized relation, an
|
|
914
914
|
empty one when the policy scope is broken, or `nil` without an authorization adapter. Calling the
|
|
915
915
|
adapter's `query` directly skips that check.
|
|
916
|
+
|
|
917
|
+
## History is hidden for a model PaperTrail does not version
|
|
918
|
+
|
|
919
|
+
With `config.audit_with :paper_trail`, a model without `has_paper_trail` no longer shows History
|
|
920
|
+
links, and its history pages list no versions. They used to fail with `NoMethodError`.
|
|
921
|
+
|
|
922
|
+
An auditing adapter may define `auditable?(abstract_model)`. When it answers false, the
|
|
923
|
+
`history_index` and `history_show` actions are hidden for that model. A custom adapter that does
|
|
924
|
+
not define it keeps the History links on every model, as before. A `visible` block you configure
|
|
925
|
+
on either history action replaces this check.
|
|
@@ -58,6 +58,11 @@ module RailsAdminNext
|
|
|
58
58
|
)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
def auditable?
|
|
62
|
+
adapter = bindings[:controller].try(:auditing_adapter)
|
|
63
|
+
bindings[:abstract_model].nil? || !adapter.respond_to?(:auditable?) || adapter.auditable?(bindings[:abstract_model])
|
|
64
|
+
end
|
|
65
|
+
|
|
61
66
|
# Is the action acting on the root level (Example: /admin/contact)
|
|
62
67
|
register_instance_option :root? do
|
|
63
68
|
false
|
|
@@ -114,6 +114,12 @@ module RailsAdminNext
|
|
|
114
114
|
.collect { |version| VersionProxy.new(version, user_class) }
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
+
# Optional in the auditing adapter contract: the history actions hide themselves for a model
|
|
118
|
+
# whose adapter answers false, and stay visible for an adapter that does not define it.
|
|
119
|
+
def auditable?(abstract_model)
|
|
120
|
+
versioned?(abstract_model.model)
|
|
121
|
+
end
|
|
122
|
+
|
|
117
123
|
def delete_object(_object, _model, _user)
|
|
118
124
|
# do nothing
|
|
119
125
|
end
|
|
@@ -146,7 +152,11 @@ module RailsAdminNext
|
|
|
146
152
|
sort_by
|
|
147
153
|
end
|
|
148
154
|
|
|
149
|
-
versions =
|
|
155
|
+
versions =
|
|
156
|
+
if !auditable?(model) then version_class.none
|
|
157
|
+
elsif object.nil? then versions_for_model(model, scope)
|
|
158
|
+
else object.public_send(model.model.versions_association_name)
|
|
159
|
+
end
|
|
150
160
|
versions = versions.where("event LIKE ?", "%#{query}%") if query.present?
|
|
151
161
|
versions = versions.reorder(sort)
|
|
152
162
|
|