motor-admin 0.2.50 → 0.2.55
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/locales/en.yml +2 -0
- data/config/locales/es.yml +2 -0
- data/config/locales/pt.yml +2 -0
- data/lib/generators/motor/templates/upgrade_motor_api_actions.rb +71 -0
- data/lib/generators/motor/upgrade_generator.rb +11 -3
- data/lib/motor/admin.rb +6 -2
- data/lib/motor/build_schema/apply_permissions.rb +8 -3
- data/lib/motor/build_schema/load_from_rails.rb +2 -1
- data/lib/motor/configs/build_ui_app_tag.rb +9 -1
- data/lib/motor/version.rb +1 -1
- data/ui/dist/{main-405235dcc7061ef18101.css.gz → main-2d5ae868ed1fe51a0981.css.gz} +0 -0
- data/ui/dist/main-2d5ae868ed1fe51a0981.js.gz +0 -0
- data/ui/dist/manifest.json +5 -5
- metadata +8 -5
- data/ui/dist/main-405235dcc7061ef18101.js.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15459e6ad4c135a1534bf82cf8bb202ef3bcee0ae479b05c316cc07f4abc4a4
|
4
|
+
data.tar.gz: 129ebeba47d066bd9990fbe1408e5a4ae2d2aba49444ba93bdcc7c67c160dd89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97b8da084ad4ab06935288abba3ab0e3a9bae933df5977400049347d35e24dcc18cd6615e527cb55b7bf123da689f187bdacfc00e5041c66b3c1155f7487b968
|
7
|
+
data.tar.gz: 6910ec1a51c0b90781e6dedfa3b602f920297e2d37a32dbf6ea34362c71ffadd70464c88385eea760fc53f0eb1c245300a5942f144ebe56e82d755c7c921d929
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/pt.yml
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
+
class MotorApiConfig < ActiveRecord::Base
|
3
|
+
self.table_name = 'motor_api_configs'
|
4
|
+
|
5
|
+
encrypts :credentials if defined?(::Motor::EncryptedConfig)
|
6
|
+
|
7
|
+
serialize :credentials, Motor::HashSerializer
|
8
|
+
serialize :preferences, Motor::HashSerializer
|
9
|
+
|
10
|
+
attribute :preferences, default: -> { HashWithIndifferentAccess.new }
|
11
|
+
attribute :credentials, default: -> { HashWithIndifferentAccess.new }
|
12
|
+
end
|
13
|
+
|
14
|
+
class MotorForm < ActiveRecord::Base
|
15
|
+
self.table_name = 'motor_forms'
|
16
|
+
|
17
|
+
serialize :preferences, Motor::HashSerializer
|
18
|
+
end
|
19
|
+
|
20
|
+
class MotorResource < ActiveRecord::Base
|
21
|
+
self.table_name = 'motor_resources'
|
22
|
+
|
23
|
+
serialize :preferences, Motor::HashSerializer
|
24
|
+
end
|
25
|
+
|
26
|
+
def up
|
27
|
+
MotorResource.all.each do |resource|
|
28
|
+
resource.preferences.fetch(:actions, []).each do |action|
|
29
|
+
next unless action[:action_type] == 'api'
|
30
|
+
|
31
|
+
api_path = action[:preferences][:api_path]
|
32
|
+
api_url = form.api_path[%r{\Ahttps?://[^/]+}]
|
33
|
+
api_path = api_path.delete_prefix(api_url).sub(/\A\/?/, '/') if api_url
|
34
|
+
|
35
|
+
api_config =
|
36
|
+
if api_url
|
37
|
+
MotorApiConfig.create_with(url: api_url).find_or_create_by!(name: api_url.sub(%r{\Ahttps?://}))
|
38
|
+
else
|
39
|
+
MotorApiConfig.create_with(url: '/').find_or_create_by!(name: 'origin')
|
40
|
+
end
|
41
|
+
|
42
|
+
resource_display_name = (resource[:preferences][:display_name] || resource.name).titleize.singularize
|
43
|
+
|
44
|
+
form = MotorForm.create_with(
|
45
|
+
api_config_name: api_config.name,
|
46
|
+
api_path: api_path.sub(/\{{1,2}\w+\}{1,2}/, '{{id}}'),
|
47
|
+
http_method: 'POST',
|
48
|
+
preferences: {
|
49
|
+
fields: [{
|
50
|
+
name: 'id',
|
51
|
+
display_name: resource_display_name,
|
52
|
+
default_value: '',
|
53
|
+
field_type: 'reference',
|
54
|
+
reference: { model_name: resource.name },
|
55
|
+
validators: [{ required: true }]
|
56
|
+
}]
|
57
|
+
}
|
58
|
+
).find_or_create_by!(
|
59
|
+
name: "#{action[:display_name]} #{resource_display_name}"
|
60
|
+
)
|
61
|
+
|
62
|
+
action[:action_type] = 'form'
|
63
|
+
action[:preferences] = { form_id: form.id }
|
64
|
+
end
|
65
|
+
|
66
|
+
resource.save!
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def down; end
|
71
|
+
end
|
@@ -15,11 +15,19 @@ module Motor
|
|
15
15
|
source_root File.expand_path('templates', __dir__)
|
16
16
|
|
17
17
|
def copy_migration
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
has_api_actions = Motor::Resource.all.any? do |resource|
|
19
|
+
resource.preferences[:actions]&.any? { |action| action[:action_type] == 'api' }
|
20
|
+
end
|
21
|
+
|
22
|
+
unless Motor::ApiConfig.table_exists?
|
21
23
|
migration_template 'install_api_configs.rb', 'db/migrate/install_motor_api_configs.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
migration_template 'upgrade_motor_api_actions.rb', 'db/migrate/upgrade_motor_api_actions.rb' if has_api_actions
|
22
27
|
|
28
|
+
if Motor::ApiConfig.table_exists? && !has_api_actions
|
29
|
+
puts 'The latest Motor Admin features are already configured'
|
30
|
+
else
|
23
31
|
puts 'Run `rake db:migrate` to update DB schema'
|
24
32
|
end
|
25
33
|
end
|
data/lib/motor/admin.rb
CHANGED
@@ -97,10 +97,14 @@ module Motor
|
|
97
97
|
|
98
98
|
initializer 'motor.upgrade' do
|
99
99
|
config.after_initialize do
|
100
|
+
next unless Motor.server?
|
101
|
+
|
100
102
|
unless Motor::Query.table_exists?
|
101
103
|
puts
|
102
104
|
puts ' => Run `rails g motor:install && rake db:migrate` in order to create Motor Admin configuration tables'
|
103
105
|
puts
|
106
|
+
|
107
|
+
raise
|
104
108
|
end
|
105
109
|
|
106
110
|
unless Motor::ApiConfig.table_exists?
|
@@ -108,9 +112,9 @@ module Motor
|
|
108
112
|
puts ' => Run `rails g motor:upgrade && rake db:migrate`' \
|
109
113
|
' to perform data migration and enable the latest features'
|
110
114
|
puts
|
115
|
+
|
116
|
+
raise
|
111
117
|
end
|
112
|
-
rescue ActiveRecord::NoDatabaseError
|
113
|
-
nil
|
114
118
|
end
|
115
119
|
end
|
116
120
|
end
|
@@ -21,7 +21,9 @@ module Motor
|
|
21
21
|
|
22
22
|
def filter_associations(associations, ability)
|
23
23
|
associations.select do |assoc|
|
24
|
-
|
24
|
+
model_class = assoc[:model_name].classify.safe_constantize
|
25
|
+
|
26
|
+
model_class && ability.can?(:read, model_class)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -29,8 +31,11 @@ module Motor
|
|
29
31
|
columns.map do |column|
|
30
32
|
next unless ability.can?(:read, model, column[:name])
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
reference_model_name = column.dig(:reference, :model_name)
|
35
|
+
model_class = reference_model_name&.classify&.safe_constantize
|
36
|
+
|
37
|
+
next if reference_model_name &&
|
38
|
+
(model_class.nil? || !ability.can?(:read, model_class))
|
34
39
|
|
35
40
|
unless ability.can?(:update, model, column[:name])
|
36
41
|
column = column.merge(access_type: BuildSchema::ColumnAccessTypes::READ_ONLY)
|
@@ -154,7 +154,8 @@ module Motor
|
|
154
154
|
|
155
155
|
return {} if column.name == 'year'
|
156
156
|
|
157
|
-
return { number_format: true } if !column.name
|
157
|
+
return { number_format: true } if !column.name == 'id' &&
|
158
|
+
!column.name.match?(/_(?:id|year)\z/) &&
|
158
159
|
%i[integer float].include?(column.type)
|
159
160
|
|
160
161
|
{}
|
@@ -13,7 +13,7 @@ module Motor
|
|
13
13
|
module_function
|
14
14
|
|
15
15
|
def call(current_user = nil, current_ability = nil, cache_keys: LoadFromCache.load_cache_keys)
|
16
|
-
CACHE_STORE.fetch(
|
16
|
+
CACHE_STORE.fetch(app_tag_cache_key(cache_keys, current_user, current_ability)) do
|
17
17
|
CACHE_STORE.clear
|
18
18
|
|
19
19
|
data = build_data(cache_keys, current_user, current_ability)
|
@@ -21,6 +21,14 @@ module Motor
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def app_tag_cache_key(cache_keys, current_user, current_ability)
|
25
|
+
key = "#{I18n.locale}#{cache_keys.hash}#{current_user&.id}#{current_ability&.rules_hash}"
|
26
|
+
|
27
|
+
key += Motor::DefineArModels.defined_models_schema_md5.to_s if defined?(Motor::DefineArModels)
|
28
|
+
|
29
|
+
key
|
30
|
+
end
|
31
|
+
|
24
32
|
# rubocop:disable Metrics/AbcSize
|
25
33
|
# @return [Hash]
|
26
34
|
def build_data(cache_keys = {}, current_user = nil, current_ability = nil)
|
data/lib/motor/version.rb
CHANGED
Binary file
|
Binary file
|
data/ui/dist/manifest.json
CHANGED
@@ -2601,9 +2601,9 @@
|
|
2601
2601
|
"icons/zoom-out.svg.gz": "icons/zoom-out.svg.gz",
|
2602
2602
|
"icons/zoom-question.svg": "icons/zoom-question.svg",
|
2603
2603
|
"icons/zoom-question.svg.gz": "icons/zoom-question.svg.gz",
|
2604
|
-
"main-
|
2605
|
-
"main-
|
2606
|
-
"main-
|
2607
|
-
"main.css": "main-
|
2608
|
-
"main.js": "main-
|
2604
|
+
"main-2d5ae868ed1fe51a0981.css.gz": "main-2d5ae868ed1fe51a0981.css.gz",
|
2605
|
+
"main-2d5ae868ed1fe51a0981.js.LICENSE.txt": "main-2d5ae868ed1fe51a0981.js.LICENSE.txt",
|
2606
|
+
"main-2d5ae868ed1fe51a0981.js.gz": "main-2d5ae868ed1fe51a0981.js.gz",
|
2607
|
+
"main.css": "main-2d5ae868ed1fe51a0981.css",
|
2608
|
+
"main.js": "main-2d5ae868ed1fe51a0981.js"
|
2609
2609
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motor-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.55
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Matsyburka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-filter
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/generators/motor/migration.rb
|
163
163
|
- lib/generators/motor/templates/install.rb
|
164
164
|
- lib/generators/motor/templates/install_api_configs.rb
|
165
|
+
- lib/generators/motor/templates/upgrade_motor_api_actions.rb
|
165
166
|
- lib/generators/motor/upgrade_generator.rb
|
166
167
|
- lib/motor-admin.rb
|
167
168
|
- lib/motor.rb
|
@@ -1532,14 +1533,16 @@ files:
|
|
1532
1533
|
- ui/dist/icons/zoom-money.svg.gz
|
1533
1534
|
- ui/dist/icons/zoom-out.svg.gz
|
1534
1535
|
- ui/dist/icons/zoom-question.svg.gz
|
1535
|
-
- ui/dist/main-
|
1536
|
-
- ui/dist/main-
|
1536
|
+
- ui/dist/main-2d5ae868ed1fe51a0981.css.gz
|
1537
|
+
- ui/dist/main-2d5ae868ed1fe51a0981.js.gz
|
1537
1538
|
- ui/dist/manifest.json
|
1538
1539
|
homepage:
|
1539
1540
|
licenses:
|
1540
1541
|
- MIT
|
1541
1542
|
metadata: {}
|
1542
|
-
post_install_message:
|
1543
|
+
post_install_message: "\n ==================\n Run `rails g motor:upgrade &&
|
1544
|
+
rake db:migrate`\n to perform data migration and enable the latest features'\n
|
1545
|
+
\ ==================\n "
|
1543
1546
|
rdoc_options: []
|
1544
1547
|
require_paths:
|
1545
1548
|
- lib
|
Binary file
|