plutonium 0.15.2 → 0.15.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7af9842b0dca317dc9cb8ca805d2a73373660f99e897f36862e93d6c3fa637b
4
- data.tar.gz: 3daa392b9b27adc9e4d82fa760a38cf6a953c4be1394ad7cbaf2cad88012c1af
3
+ metadata.gz: 69be8d5055a10969befe7de4c78dea74e60f1da9ed5c3754d7a0b70ad74e6974
4
+ data.tar.gz: 98c4fb79a936ab08f6164c13bcd268f9ecaa4de42fc7ce1be5b47d68fe33a2d7
5
5
  SHA512:
6
- metadata.gz: 020a6db84fe590b28095f4d2f2a60cc61b58a7d1cd4304bf944d464182439d0a4f3d4967c63846282ae8abbc05b5f016d1abae22516518c4ad73745308a359d8
7
- data.tar.gz: 5987f4b5ee94790630c3bc1051b804223837e0fe28713fa5944c66fe719d7c727361d7d411a133c5435d7198db667e586a873314bf189891045c4e33c1aaa458
6
+ metadata.gz: faa4d002ac3d47973decd9531931131407b64de718acf1914ac3f8fa2ca1d584a562940897a4dff20591c94804b029ea001a88af66e0acde61e1dbe58e68a995
7
+ data.tar.gz: b91536d180e95b9d80e95fca3064e788bfca9410da7bd4e003c6fc7a618f7a3e9d7298ac38f7a8453f55e40776b5d6faae6560a9110eb04b8a1b265a74492ddb
@@ -7,7 +7,7 @@ module PlutoniumUi
7
7
  def base_attributes
8
8
  # base attributes go here
9
9
  {
10
- classname: "sidebar-menu space-y-2",
10
+ classname: "sidebar-menu space-y-2 pb-6 mb-6",
11
11
  controller: "sidebar-menu"
12
12
  }
13
13
  end
@@ -28,6 +28,11 @@ module Plutonium
28
28
  def entity_scope_for_authorize
29
29
  scoped_to_entity? ? current_scoped_entity : nil
30
30
  end
31
+
32
+ def verify_authorized
33
+ # we don't use action policy's inbuilt checks, so ensure they are neutered,
34
+ # also ensures pundit checks are disabled.
35
+ end
31
36
  end
32
37
  end
33
38
  end
@@ -18,11 +18,12 @@ module Plutonium
18
18
  end
19
19
 
20
20
  class_methods do
21
- include Plutonium::Lib::SmartCache
22
-
23
21
  def inherited(subclass)
24
22
  super
25
23
 
24
+ subclass.include Plutonium::Lib::SmartCache
25
+ subclass.memoize_unless_reloading :current_package
26
+ subclass.memoize_unless_reloading :current_engine
26
27
  subclass.boot
27
28
  end
28
29
 
@@ -42,13 +43,11 @@ module Plutonium
42
43
  def current_package
43
44
  (current_engine == Rails.application.class) ? nil : current_engine.module_parent
44
45
  end
45
- memoize_unless_reloading :current_package
46
46
 
47
47
  def current_engine
48
48
  potential_package = module_parents[-2]
49
49
  potential_package.nil? ? Rails.application.class : ("#{potential_package}::Engine".safe_constantize || Rails.application.class)
50
50
  end
51
- memoize_unless_reloading :current_engine
52
51
  end
53
52
  end
54
53
  end
@@ -81,16 +81,16 @@ module Plutonium
81
81
  # @return [ActiveRecord::Base, nil] the current scoped entity or nil if not found
82
82
  # @raise [NotImplementedError] if the scoping strategy is unknown
83
83
  def fetch_current_scoped_entity
84
- scoped_entity = case scoped_entity_strategy
84
+ case scoped_entity_strategy
85
85
  when :path
86
- fetch_entity_from_path
86
+ scoped_entity = fetch_entity_from_path
87
+ authorize! scoped_entity, to: :read?
88
+ scoped_entity
87
89
  when Symbol
88
90
  send(scoped_entity_strategy)
89
91
  else
90
92
  raise NotImplementedError, "Unknown scoped entity strategy: #{scoped_entity_strategy.inspect}"
91
93
  end
92
- authorize! scoped_entity, to: :read?
93
- scoped_entity
94
94
  end
95
95
 
96
96
  # Fetches the scoped entity from the path parameters.
@@ -172,8 +172,13 @@ module Plutonium
172
172
  # @param [Hash] input_params The input parameters
173
173
  def override_entity_scoping_params(input_params)
174
174
  if scoped_to_entity?
175
- input_params[scoped_entity_param_key] = current_scoped_entity
176
- input_params[:"#{scoped_entity_param_key}_id"] = current_scoped_entity.id
175
+ if input_params.key?(scoped_entity_param_key) || resource_class.method_defined?(:"#{scoped_entity_param_key}=")
176
+ input_params[scoped_entity_param_key] = current_scoped_entity
177
+ end
178
+
179
+ if input_params.key?(:"#{scoped_entity_param_key}_id") || resource_class.method_defined?(:"#{scoped_entity_param_key}_id=")
180
+ input_params[:"#{scoped_entity_param_key}_id"] = current_scoped_entity.id
181
+ end
177
182
  end
178
183
  end
179
184
 
@@ -181,8 +186,13 @@ module Plutonium
181
186
  # @param [Hash] input_params The input parameters
182
187
  def override_parent_params(input_params)
183
188
  if current_parent.present?
184
- input_params[parent_input_param] = current_parent
185
- input_params[:"#{parent_input_param}_id"] = current_parent.id
189
+ if input_params.key?(parent_input_param) || resource_class.method_defined?(:"#{parent_input_param}=")
190
+ input_params[parent_input_param] = current_parent
191
+ end
192
+
193
+ if input_params.key?(:"#{parent_input_param}_id") || resource_class.method_defined?(:"#{parent_input_param}_id=")
194
+ input_params[:"#{parent_input_param}_id"] = current_parent.id
195
+ end
186
196
  end
187
197
  end
188
198
 
@@ -77,7 +77,7 @@ module Plutonium
77
77
  #
78
78
  # @raise [ActionMissingCurrentAuthorizedScope] if current_authorized_scope hasn't been called
79
79
  def verify_current_authorized_scope
80
- return if current_authorized_scope_count
80
+ return if verify_current_authorized_scope_skipped
81
81
  return if current_authorized_scope_count > 0
82
82
 
83
83
  raise ActionMissingCurrentAuthorizedScope.new(controller_path, action_name)
@@ -1,5 +1,5 @@
1
1
  module Plutonium
2
- VERSION = "0.15.2"
2
+ VERSION = "0.15.4"
3
3
  NEXT_MAJOR_VERSION = VERSION.split(".").tap { |v|
4
4
  v[1] = v[1].to_i + 1
5
5
  v[2] = 0
data/lib/plutonium.rb CHANGED
@@ -26,7 +26,7 @@ module Plutonium
26
26
  loader.ignore("#{__dir__}/generators")
27
27
  loader.ignore("#{__dir__}/plutonium/railtie.rb")
28
28
  loader.inflector.inflect("ui" => "UI")
29
- loader.inflector.inflect("dsl" => "DSL")
29
+ loader.inflector.inflect("workflow_dsl" => "WorkflowDSL")
30
30
  loader.enable_reloading if defined?(Rails.env) && Rails.env.development?
31
31
  loader.setup
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich