avo 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +49 -48
- data/Gemfile.lock +19 -2
- data/README.md +33 -54
- data/app/controllers/avo/application_controller.rb +34 -1
- data/app/controllers/avo/filters_controller.rb +19 -0
- data/app/controllers/avo/relations_controller.rb +34 -0
- data/app/controllers/avo/resource_overview_controller.rb +14 -7
- data/app/controllers/avo/resources_controller.rb +66 -142
- data/app/controllers/avo/search_controller.rb +55 -0
- data/app/helpers/avo/application_helper.rb +6 -2
- data/app/views/layouts/avo/_javascript.html.erb +1 -0
- data/app/views/layouts/avo/application.html.erb +34 -17
- data/app/views/partials/_footer.html.erb +1 -1
- data/app/views/partials/_header.html.erb +1 -1
- data/avo.gemspec +18 -4
- data/config/credentials.yml.enc +1 -0
- data/config/routes.rb +11 -7
- data/lib/avo.rb +2 -0
- data/lib/avo/app/app.rb +18 -29
- data/lib/avo/app/authorization_service.rb +40 -0
- data/lib/avo/app/fields/has_and_belongs_to_many.rb +1 -0
- data/lib/avo/app/fields/has_many.rb +1 -0
- data/lib/avo/app/fields/id_field.rb +4 -4
- data/lib/avo/app/licensing/community_license.rb +4 -0
- data/lib/avo/app/licensing/hq.rb +85 -0
- data/lib/avo/app/licensing/license.rb +48 -0
- data/lib/avo/app/licensing/license_manager.rb +25 -0
- data/lib/avo/app/licensing/null_license.rb +12 -0
- data/lib/avo/app/licensing/pro_license.rb +9 -0
- data/lib/avo/app/resource.rb +31 -12
- data/lib/avo/configuration.rb +14 -0
- data/lib/avo/engine.rb +1 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/initializer.rb +2 -0
- data/lib/generators/avo/templates/views/_footer.html.erb +1 -1
- data/lib/generators/avo/templates/views/_header.html.erb +1 -1
- data/lib/generators/avo/templates/views/_scripts.html.erb +0 -0
- data/public/avo-packs/css/application-73e568bc.css +3 -0
- data/public/avo-packs/css/application-73e568bc.css.br +0 -0
- data/public/avo-packs/css/application-73e568bc.css.gz +0 -0
- data/public/avo-packs/js/application-044386b1f6fe7a8dcb9f.js +3 -0
- data/public/avo-packs/js/{application-8071f9a0f167bb82b39d.js.LICENSE.txt → application-044386b1f6fe7a8dcb9f.js.LICENSE.txt} +0 -0
- data/public/avo-packs/js/application-044386b1f6fe7a8dcb9f.js.br +0 -0
- data/public/avo-packs/js/application-044386b1f6fe7a8dcb9f.js.gz +0 -0
- data/public/avo-packs/js/application-044386b1f6fe7a8dcb9f.js.map +1 -0
- data/public/avo-packs/js/application-044386b1f6fe7a8dcb9f.js.map.br +0 -0
- data/public/avo-packs/js/application-044386b1f6fe7a8dcb9f.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +8 -6
- data/public/avo-packs/manifest.json.br +0 -0
- data/public/avo-packs/manifest.json.gz +0 -0
- data/public/avo-packs/media/svgs/arrow-circle-right-1ad1e15ec9a7aa54b67d126566a5aa2d.svg +1 -0
- data/public/avo-packs/media/svgs/arrow-circle-right-1ad1e15ec9a7aa54b67d126566a5aa2d.svg.br +0 -0
- data/public/avo-packs/media/svgs/arrow-circle-right-1ad1e15ec9a7aa54b67d126566a5aa2d.svg.gz +0 -0
- data/public/avo-packs/media/svgs/exclamation-8d1c0baa390a8df9bb52176011eb5892.svg +1 -0
- data/public/avo-packs/media/svgs/exclamation-8d1c0baa390a8df9bb52176011eb5892.svg.br +0 -0
- data/public/avo-packs/media/svgs/exclamation-8d1c0baa390a8df9bb52176011eb5892.svg.gz +0 -0
- metadata +70 -25
- data/public/avo-packs/css/application-64b0f124.css +0 -3
- data/public/avo-packs/css/application-64b0f124.css.br +0 -0
- data/public/avo-packs/css/application-64b0f124.css.gz +0 -0
- data/public/avo-packs/js/application-8071f9a0f167bb82b39d.js +0 -3
- data/public/avo-packs/js/application-8071f9a0f167bb82b39d.js.br +0 -0
- data/public/avo-packs/js/application-8071f9a0f167bb82b39d.js.gz +0 -0
- data/public/avo-packs/js/application-8071f9a0f167bb82b39d.js.map +0 -1
- data/public/avo-packs/js/application-8071f9a0f167bb82b39d.js.map.br +0 -0
- data/public/avo-packs/js/application-8071f9a0f167bb82b39d.js.map.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: 21149eeeb028f3834fe8d5571cb4bd78800c8a7e7968f26ebfc59ab106bea7ce
|
4
|
+
data.tar.gz: 77adc8b341c1222e937ba3f19acc311c4d18a29f65279061049bb3cfb22f9234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72c6106edf707ee07d7b4b1b9a6b3ea6fbbc83a88ab8c897cb452940d61ef10b586114069fe5af4cbf49339ac06bd0976cd60bf835922a9742f59e4524e38ad6
|
7
|
+
data.tar.gz: dc397f7fa9bdde84e619d4285ff5d3426cacce5980798dfc58535ae22390a33c4ec4152fe9d6ff91d2dc0967cae59a808558b87923a87409ba0ec982be3f1f18
|
data/Gemfile
CHANGED
@@ -23,54 +23,52 @@ gem 'inline_svg'
|
|
23
23
|
gem 'countries'
|
24
24
|
|
25
25
|
# Authorization
|
26
|
-
gem
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
gem 'debase'
|
73
|
-
end
|
26
|
+
gem 'pundit'
|
27
|
+
|
28
|
+
# Dependencies for dummy_app
|
29
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
30
|
+
gem 'rails', '~> 6.0.2', '>= 6.0.2.2'
|
31
|
+
# Use postgresql as the database for Active Record
|
32
|
+
gem 'pg', '>= 0.18', '< 2.0'
|
33
|
+
# Use Puma as the app server
|
34
|
+
gem 'puma', '~> 4.3.5'
|
35
|
+
# Use SCSS for stylesheets
|
36
|
+
gem 'sass-rails', '>= 6'
|
37
|
+
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
38
|
+
# gem 'turbolinks', '~> 5'
|
39
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
40
|
+
gem 'jbuilder', '~> 2.7'
|
41
|
+
# Use Redis adapter to run Action Cable in production
|
42
|
+
# gem 'redis', '~> 4.0'
|
43
|
+
# Use Active Model has_secure_password
|
44
|
+
# gem 'bcrypt', '~> 3.1.7'
|
45
|
+
|
46
|
+
# Use Active Storage variant
|
47
|
+
# gem 'image_processing', '~> 1.2'
|
48
|
+
|
49
|
+
# Reduces boot times through caching; required in config/boot.rb
|
50
|
+
gem 'bootsnap', '>= 1.4.2', require: false
|
51
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
52
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
53
|
+
gem 'dotenv-rails'
|
54
|
+
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
|
55
|
+
gem 'web-console', '>= 3.3.0'
|
56
|
+
gem 'listen', '>= 3.0.5', '< 3.2'
|
57
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
58
|
+
gem 'spring'
|
59
|
+
gem 'spring-watcher-listen', '~> 2.0.0'
|
60
|
+
|
61
|
+
gem 'factory_bot_rails'
|
62
|
+
gem 'faker'
|
63
|
+
|
64
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
65
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
66
|
+
|
67
|
+
gem 'devise'
|
68
|
+
gem 'database_cleaner'
|
69
|
+
|
70
|
+
gem 'ruby-debug-ide', require: false
|
71
|
+
gem 'debase'
|
74
72
|
|
75
73
|
group :development, :test do
|
76
74
|
gem 'rspec-rails', '~> 4.0.0'
|
@@ -83,6 +81,7 @@ group :development, :test do
|
|
83
81
|
gem 'rubocop'
|
84
82
|
gem 'simplecov', require: false
|
85
83
|
gem 'simplecov-cobertura'
|
84
|
+
gem 'webmock'
|
86
85
|
|
87
86
|
# Release helper
|
88
87
|
gem 'bump', require: false
|
@@ -93,3 +92,5 @@ gem 'zeitwerk', '~> 2.3'
|
|
93
92
|
|
94
93
|
# Pagination
|
95
94
|
gem 'kaminari'
|
95
|
+
|
96
|
+
gem 'httparty'
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (0.
|
4
|
+
avo (0.3.1)
|
5
5
|
countries
|
6
|
+
httparty
|
6
7
|
inline_svg
|
7
8
|
kaminari
|
8
|
-
|
9
|
+
pundit
|
10
|
+
rails (>= 6.0)
|
9
11
|
webpacker
|
10
12
|
zeitwerk
|
11
13
|
|
@@ -91,6 +93,7 @@ GEM
|
|
91
93
|
i18n_data (~> 0.10.0)
|
92
94
|
sixarm_ruby_unaccent (~> 1.1)
|
93
95
|
unicode_utils (~> 1.4)
|
96
|
+
crack (0.4.4)
|
94
97
|
crass (1.0.6)
|
95
98
|
database_cleaner (1.8.5)
|
96
99
|
debase (0.2.4.1)
|
@@ -123,6 +126,10 @@ GEM
|
|
123
126
|
gem-release (2.1.1)
|
124
127
|
globalid (0.4.2)
|
125
128
|
activesupport (>= 4.2.0)
|
129
|
+
hashdiff (1.0.1)
|
130
|
+
httparty (0.18.1)
|
131
|
+
mime-types (~> 3.0)
|
132
|
+
multi_xml (>= 0.5.2)
|
126
133
|
i18n (1.8.5)
|
127
134
|
concurrent-ruby (~> 1.0)
|
128
135
|
i18n_data (0.10.0)
|
@@ -155,11 +162,15 @@ GEM
|
|
155
162
|
marcel (0.3.3)
|
156
163
|
mimemagic (~> 0.3.2)
|
157
164
|
method_source (1.0.0)
|
165
|
+
mime-types (3.3.1)
|
166
|
+
mime-types-data (~> 3.2015)
|
167
|
+
mime-types-data (3.2020.0512)
|
158
168
|
mimemagic (0.3.5)
|
159
169
|
mini_mime (1.0.2)
|
160
170
|
mini_portile2 (2.4.0)
|
161
171
|
minitest (5.14.2)
|
162
172
|
msgpack (1.3.3)
|
173
|
+
multi_xml (0.6.0)
|
163
174
|
nio4r (2.5.4)
|
164
175
|
nokogiri (1.10.10)
|
165
176
|
mini_portile2 (~> 2.4.0)
|
@@ -296,6 +307,10 @@ GEM
|
|
296
307
|
nokogiri (~> 1.6)
|
297
308
|
rubyzip (>= 1.3.0)
|
298
309
|
selenium-webdriver (>= 3.0, < 4.0)
|
310
|
+
webmock (3.9.3)
|
311
|
+
addressable (>= 2.3.6)
|
312
|
+
crack (>= 0.3.2)
|
313
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
299
314
|
webpacker (4.3.0)
|
300
315
|
activesupport (>= 4.2)
|
301
316
|
rack-proxy (>= 0.6.1)
|
@@ -325,6 +340,7 @@ DEPENDENCIES
|
|
325
340
|
faker
|
326
341
|
fuubar
|
327
342
|
gem-release
|
343
|
+
httparty
|
328
344
|
inline_svg
|
329
345
|
jbuilder (~> 2.7)
|
330
346
|
kaminari
|
@@ -345,6 +361,7 @@ DEPENDENCIES
|
|
345
361
|
tzinfo-data
|
346
362
|
web-console (>= 3.3.0)
|
347
363
|
webdrivers
|
364
|
+
webmock
|
348
365
|
webpacker (~> 4.0)
|
349
366
|
zeitwerk (~> 2.3)
|
350
367
|
|
data/README.md
CHANGED
@@ -1,69 +1,48 @@
|
|
1
1
|
![Tests](https://github.com/avo-hq/avo/workflows/Tests/badge.svg)
|
2
2
|
![reviewdog](https://github.com/avo-hq/avo/workflows/reviewdog/badge.svg)
|
3
3
|
[![codecov](https://codecov.io/gh/avo-hq/avo/branch/master/graph/badge.svg?token=Q2LMFE4989)](https://codecov.io/gh/avo-hq/avo)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/676a0afa2cc79f03aa29/maintainability)](https://codeclimate.com/github/avo-hq/avo/maintainability)
|
4
5
|
|
5
|
-
|
6
|
-
The missing Ruby on Rails admin
|
6
|
+
![](https://avohq.io/img/logo-full-stroke-tiny-2x.png)
|
7
7
|
|
8
|
-
|
9
|
-
How to use my plugin.
|
8
|
+
**Configuration-based, no-maintenance, extendable Ruby on Rails admin**
|
10
9
|
|
11
|
-
|
12
|
-
Add this line to your application's Gemfile:
|
10
|
+
Avo is a beautiful next-generation framework that empowers you, the developer, to create fantastic admin panels for your Ruby on Rails apps with the flexibility to fit your needs as you grow.
|
13
11
|
|
14
|
-
|
15
|
-
gem 'avo'
|
16
|
-
```
|
12
|
+
## Get started
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
**Website**: [avohq.io](https://avohq.io)\
|
15
|
+
**Documentation**: [docs.avohq.io](https://docs.avohq.io)\
|
16
|
+
**Twitter**: [avo_hq](https://twitter.com/avo_hq)\
|
17
|
+
**Community chat**: [discord](https://discord.gg/pkTF6y8)\
|
18
|
+
**Issue tracker**: [GitHub issues](http://github.com/avo-hq/avo/issues)
|
22
19
|
|
23
|
-
|
24
|
-
```bash
|
25
|
-
$ gem install avo
|
26
|
-
```
|
20
|
+
## Features
|
27
21
|
|
28
|
-
|
22
|
+
- **Code driven configuration** - Configure your Rails dashboard entirely by writing Ruby code.
|
23
|
+
- **Resource Management** - Create a CRUD interface for Active Record from one command. No more copy-pasting view and controller files around.
|
24
|
+
- **Active Storage support** - Amazingly easy, **one-line**, single or multi-file integration with **ActiveStorage**.
|
25
|
+
- **Grid view** - Beautiful card layout to showcase your content.
|
26
|
+
- **Actions** - Run custom actions to one or more of your resources with as little as pressing a button 💪
|
27
|
+
- **Filters** - Write your own custom filters to quickly segment your data.
|
28
|
+
- **Keeps your app clean** - You don't need to change your app to use Avo. Drop it in your existing app or add it to a new one and you're done 🙌
|
29
|
+
- **Custom fields***- No worries if we missed a field you need. Generate a custom field in a jiffy.
|
30
|
+
- **Dashboard widgets and metrics*** - Customize your dashboard with the tools and analytics you need.
|
31
|
+
- **Custom tools*** - You need to add a page with something completely new, you've got it!
|
32
|
+
- **Authorization*** - Leverage Pundit policies to build a robust and scalable authorization system.
|
33
|
+
- **Themable*** - Dress it up into your own colors.
|
34
|
+
- **Localization*** - Have it available in any language you need.
|
29
35
|
|
30
|
-
|
36
|
+
*Some features are still under development
|
31
37
|
|
32
|
-
|
38
|
+
# Installation
|
39
|
+
Add this line to your application's `Gemfile`:
|
33
40
|
|
41
|
+
```ruby
|
42
|
+
gem 'avo'
|
34
43
|
```
|
35
|
-
git clone
|
36
|
-
cd avo
|
37
|
-
bundle install
|
38
|
-
yarn
|
39
|
-
bin/rails server
|
40
|
-
```
|
41
|
-
|
42
|
-
You may also use the VSCode launcher to take advantage of the debugger.
|
43
|
-
|
44
|
-
You may need to run `rake db:migrate && rake db:test:prepare` for local development.
|
45
|
-
|
46
|
-
To start the Webpack dev server you need to have a different session running `bin/webpack-dev-server`.
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
### Build
|
54
|
-
|
55
|
-
If you just need a quick development build of the gem, just run `rails build`.
|
56
|
-
|
57
|
-
To build for **release** (production mode), you need to run `yarn build`. This will build a docker image that will build the gem using `production` env variables. At the end of the process it will place the new gem under `pkg/` directory.
|
58
|
-
|
59
|
-
### Release
|
60
|
-
|
61
|
-
To release the gem, run `yarn release [patch(default)|minor|major]`. This will increment the version name, cut a tag and push to GitHub. From there, GitHub Actions will take over to build the artifact, create a release and add the artifact to that release.
|
62
|
-
|
63
|
-
At every PR merge a `Next release draft` release will be auto-filled by [Release drafter](https://github.com/marketplace/actions/release-drafter). When a real release happens (on `yarn release`). The contents body of that release will be moved to the actual release and the draft will be destroyed so it can be refilled on next PR's.
|
64
|
-
|
65
|
-
### Publish
|
66
|
-
|
67
|
-
To publish on GitHub package registry you need to run `yarn run publish`. This will publish the current version on their registry.
|
68
|
-
|
69
|
-
As a prerequisite you need to have the GitHub token in your `~/.gem/credentials` file. You may run `echo ":github: Bearer GH_TOKEN" >> ~/.gem/credentials`.
|
45
|
+
And then execute:
|
46
|
+
```bash
|
47
|
+
$ bundle install
|
48
|
+
```
|
@@ -5,7 +5,10 @@ module Avo
|
|
5
5
|
before_action :init_app
|
6
6
|
|
7
7
|
def init_app
|
8
|
-
Avo::App.
|
8
|
+
Avo::App.boot unless Rails.env.production?
|
9
|
+
Avo::App.init request
|
10
|
+
|
11
|
+
@license = Avo::App.license
|
9
12
|
end
|
10
13
|
|
11
14
|
def exception_logger(exception)
|
@@ -20,6 +23,20 @@ module Avo
|
|
20
23
|
end
|
21
24
|
|
22
25
|
private
|
26
|
+
def resource
|
27
|
+
eager_load_files(resource_model).find params[:id]
|
28
|
+
end
|
29
|
+
|
30
|
+
def eager_load_files(query)
|
31
|
+
if avo_resource.attached_file_fields.present?
|
32
|
+
avo_resource.attached_file_fields.map(&:id).map do |field|
|
33
|
+
query = query.send :"with_attached_#{field}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
query
|
38
|
+
end
|
39
|
+
|
23
40
|
def resource_model
|
24
41
|
avo_resource.model
|
25
42
|
end
|
@@ -27,5 +44,21 @@ module Avo
|
|
27
44
|
def avo_resource
|
28
45
|
App.get_resource params[:resource_name].to_s.camelize.singularize
|
29
46
|
end
|
47
|
+
|
48
|
+
def authorize_user
|
49
|
+
return if params[:controller] == 'avo/search'
|
50
|
+
|
51
|
+
model = record = avo_resource.model
|
52
|
+
|
53
|
+
if ['show', 'edit', 'update'].include?(params[:action]) && params[:controller] == 'avo/resources'
|
54
|
+
record = resource
|
55
|
+
end
|
56
|
+
|
57
|
+
return render_unauthorized unless AuthorizationService::authorize_action current_user, record, params[:action]
|
58
|
+
end
|
59
|
+
|
60
|
+
def render_unauthorized
|
61
|
+
render json: { message: 'Unauthorized' }, status: 403
|
62
|
+
end
|
30
63
|
end
|
31
64
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_dependency 'avo/application_controller'
|
2
|
+
|
3
|
+
module Avo
|
4
|
+
class FiltersController < ApplicationController
|
5
|
+
before_action :authorize_user
|
6
|
+
|
7
|
+
def index
|
8
|
+
filters = []
|
9
|
+
|
10
|
+
avo_resource.get_filters.each do |filter|
|
11
|
+
filters.push(filter.new.render_response)
|
12
|
+
end
|
13
|
+
|
14
|
+
render json: {
|
15
|
+
filters: filters,
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_dependency 'avo/application_controller'
|
2
|
+
|
3
|
+
module Avo
|
4
|
+
class RelationsController < ApplicationController
|
5
|
+
before_action :authorize_user
|
6
|
+
|
7
|
+
def attach
|
8
|
+
resource.send(params[:attachment_name]) << attachment_model
|
9
|
+
|
10
|
+
render json: {
|
11
|
+
success: true,
|
12
|
+
message: "#{attachment_class} attached.",
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def detach
|
17
|
+
resource.send(params[:attachment_name]).delete attachment_model
|
18
|
+
|
19
|
+
render json: {
|
20
|
+
success: true,
|
21
|
+
message: "#{attachment_class} attached.",
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def attachment_class
|
27
|
+
App.get_model_class_by_name params[:attachment_name].pluralize 1
|
28
|
+
end
|
29
|
+
|
30
|
+
def attachment_model
|
31
|
+
attachment_class.safe_constantize.find params[:attachment_id]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -3,13 +3,15 @@ require_dependency 'avo/application_controller'
|
|
3
3
|
module Avo
|
4
4
|
class ResourceOverviewController < ApplicationController
|
5
5
|
def index
|
6
|
-
resources = App.get_resources
|
7
|
-
{
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
resources = App.get_resources
|
7
|
+
.select { |resource| AuthorizationService::authorize session_user, resource.model, Avo.configuration.authorization_methods.stringify_keys['index'] }
|
8
|
+
.map do |resource|
|
9
|
+
{
|
10
|
+
name: resource.name,
|
11
|
+
url: resource.url,
|
12
|
+
count: resource.model.count,
|
13
|
+
}
|
14
|
+
end
|
13
15
|
|
14
16
|
render json: {
|
15
17
|
resources: resources,
|
@@ -17,5 +19,10 @@ module Avo
|
|
17
19
|
hide_docs: Avo.configuration.hide_documentation_link,
|
18
20
|
}
|
19
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def session_user
|
25
|
+
current_user.present? ? current_user : nil
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|