avo 0.5.0.beta3 → 0.5.0.beta8

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.

Files changed (293) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -6
  3. data/Gemfile.lock +28 -22
  4. data/app/components/avo/common/badge_viewer_component.html.erb +1 -1
  5. data/app/components/avo/common/gravatar_viewer_component.html.erb +2 -2
  6. data/app/components/avo/common/gravatar_viewer_component.rb +2 -1
  7. data/app/components/avo/edit/fields/trix_field_component.html.erb +1 -1
  8. data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
  9. data/app/components/avo/index/fields/belongs_to_field_component.html.erb +1 -5
  10. data/app/components/avo/index/fields/boolean_group_field_component.html.erb +1 -1
  11. data/app/components/avo/index/fields/gravatar_field_component.html.erb +2 -1
  12. data/app/components/avo/index/fields/has_one_field_component.html.erb +1 -5
  13. data/app/components/avo/index/fields/id_field_component.html.erb +1 -1
  14. data/app/components/avo/index/grid_item_component.html.erb +8 -8
  15. data/app/components/avo/index/grid_item_component.rb +6 -12
  16. data/app/components/avo/index/resource_controls_component.html.erb +12 -4
  17. data/app/components/avo/index/resource_grid_component.html.erb +1 -1
  18. data/app/components/avo/index/resource_table_component.html.erb +2 -2
  19. data/app/components/avo/index/table_row_component.html.erb +1 -1
  20. data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
  21. data/app/components/avo/show/fields/boolean_group_field_component.html.erb +1 -1
  22. data/app/components/avo/show/fields/external_image_field_component.html.erb +1 -1
  23. data/app/components/avo/views/resource_show_component.html.erb +14 -2
  24. data/app/controllers/avo/actions_controller.rb +6 -8
  25. data/app/controllers/avo/application_controller.rb +30 -6
  26. data/app/controllers/avo/base_controller.rb +5 -16
  27. data/app/controllers/avo/relations_controller.rb +2 -2
  28. data/app/controllers/avo/search_controller.rb +1 -1
  29. data/app/helpers/avo/application_helper.rb +1 -1
  30. data/app/{frontend/css → packs/entrypoints}/application.css +12 -11
  31. data/app/{frontend/packs → packs/entrypoints}/application.js +4 -3
  32. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.eot +0 -0
  33. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.svg +0 -0
  34. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.ttf +0 -0
  35. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.woff +0 -0
  36. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.woff2 +0 -0
  37. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.eot +0 -0
  38. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.svg +0 -0
  39. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.ttf +0 -0
  40. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.woff +0 -0
  41. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.woff2 +0 -0
  42. data/app/{frontend → packs}/images/logo.png +0 -0
  43. data/app/{frontend → packs}/importmap.json.erb +0 -0
  44. data/app/{frontend → packs}/js/controllers/action_controller.js +0 -0
  45. data/app/{frontend → packs}/js/controllers/actions_picker_controller.js +0 -0
  46. data/app/{frontend → packs}/js/controllers/alerts_controller.js +0 -0
  47. data/app/{frontend → packs}/js/controllers/attachments_controller.js +0 -0
  48. data/app/{frontend → packs}/js/controllers/boolean_filter_controller.js +0 -0
  49. data/app/{frontend → packs}/js/controllers/fields/code_field_controller.js +0 -0
  50. data/app/{frontend → packs}/js/controllers/fields/date_field_controller.js +0 -0
  51. data/app/{frontend → packs}/js/controllers/fields/simple_mde_controller.js +0 -0
  52. data/app/{frontend → packs}/js/controllers/filter_controller.js +19 -3
  53. data/app/{frontend → packs}/js/controllers/hidden_input_controller.js +0 -0
  54. data/app/{frontend → packs}/js/controllers/item_selector_controller.js +0 -0
  55. data/app/{frontend → packs}/js/controllers/modal_controller.js +0 -0
  56. data/app/{frontend → packs}/js/controllers/per_page_controller.js +5 -1
  57. data/app/{frontend → packs}/js/controllers/select_filter_controller.js +0 -0
  58. data/app/{frontend → packs}/js/controllers/tippy_controller.js +0 -0
  59. data/app/{frontend → packs}/js/controllers/toggle_panel_controller.js +0 -0
  60. data/app/{frontend → packs}/js/helpers/cast_boolean.js +0 -0
  61. data/app/{frontend → packs}/js/toastr.js +0 -0
  62. data/app/{frontend/css → packs/stylesheets}/alerts.css +0 -0
  63. data/app/{frontend/css → packs/stylesheets}/components/code.css +0 -0
  64. data/app/{frontend/css → packs/stylesheets}/components/status.css +0 -0
  65. data/app/{frontend/css → packs/stylesheets}/fonts.css +0 -0
  66. data/app/{frontend/css → packs/stylesheets}/loader.css +0 -0
  67. data/app/{frontend/css → packs/stylesheets}/pagination.css +0 -0
  68. data/app/{frontend/css → packs/stylesheets}/tailwindcss/base.css +0 -0
  69. data/app/{frontend/css → packs/stylesheets}/tailwindcss/components.css +0 -0
  70. data/app/{frontend/css → packs/stylesheets}/tailwindcss/utilities.css +0 -0
  71. data/app/{frontend/css → packs/stylesheets}/tooltips.css +0 -0
  72. data/app/{frontend/css → packs/stylesheets}/typography.css +0 -0
  73. data/app/{frontend → packs}/svgs/arrow-circle-right.svg +0 -0
  74. data/app/{frontend → packs}/svgs/arrow-left.svg +0 -0
  75. data/app/{frontend → packs}/svgs/avocado.svg +0 -0
  76. data/app/{frontend → packs}/svgs/badge-check-sm.svg +0 -0
  77. data/app/{frontend → packs}/svgs/check-circle.svg +0 -0
  78. data/app/{frontend → packs}/svgs/chevron-down.svg +0 -0
  79. data/app/{frontend → packs}/svgs/chevron-up.svg +0 -0
  80. data/app/{frontend → packs}/svgs/code.svg +0 -0
  81. data/app/{frontend → packs}/svgs/color-swatch.svg +0 -0
  82. data/app/{frontend → packs}/svgs/document-text.svg +0 -0
  83. data/app/{frontend → packs}/svgs/download.svg +0 -0
  84. data/app/{frontend → packs}/svgs/edit.svg +0 -0
  85. data/app/{frontend → packs}/svgs/exclamation-circle-sm.svg +0 -0
  86. data/app/{frontend → packs}/svgs/exclamation-sm.svg +0 -0
  87. data/app/{frontend → packs}/svgs/exclamation.svg +0 -0
  88. data/app/{frontend → packs}/svgs/eye.svg +0 -0
  89. data/app/{frontend → packs}/svgs/filter.svg +0 -0
  90. data/app/{frontend → packs}/svgs/fire.svg +0 -0
  91. data/app/{frontend → packs}/svgs/game-board.svg +0 -0
  92. data/app/{frontend → packs}/svgs/globe.svg +0 -0
  93. data/app/{frontend → packs}/svgs/information-circle-sm.svg +0 -0
  94. data/app/{frontend → packs}/svgs/information-circle.svg +0 -0
  95. data/app/{frontend → packs}/svgs/library.svg +0 -0
  96. data/app/{frontend → packs}/svgs/photograph.svg +0 -0
  97. data/app/{frontend → packs}/svgs/play.svg +0 -0
  98. data/app/{frontend → packs}/svgs/plus-circle.svg +0 -0
  99. data/app/{frontend → packs}/svgs/plus.svg +0 -0
  100. data/app/{frontend → packs}/svgs/question-mark-circle.svg +0 -0
  101. data/app/{frontend → packs}/svgs/save.svg +0 -0
  102. data/app/{frontend → packs}/svgs/selector.svg +0 -0
  103. data/app/{frontend → packs}/svgs/sort-ascending.svg +0 -0
  104. data/app/{frontend → packs}/svgs/sort-descending.svg +0 -0
  105. data/app/{frontend → packs}/svgs/switch-horizontal.svg +0 -0
  106. data/app/{frontend → packs}/svgs/thumbs-down.svg +0 -0
  107. data/app/{frontend → packs}/svgs/thumbs-up.svg +0 -0
  108. data/app/{frontend → packs}/svgs/times.svg +0 -0
  109. data/app/{frontend → packs}/svgs/trash-sm.svg +0 -0
  110. data/app/{frontend → packs}/svgs/trash.svg +0 -0
  111. data/app/{frontend → packs}/svgs/view-grid-add.svg +0 -0
  112. data/app/{frontend → packs}/svgs/view-grid.svg +0 -0
  113. data/app/{frontend → packs}/svgs/view-list.svg +0 -0
  114. data/app/{frontend → packs}/svgs/x-circle.svg +0 -0
  115. data/app/views/avo/actions/show.html.erb +3 -39
  116. data/app/views/avo/attachments/show.html.erb +8 -1
  117. data/app/views/avo/base/_actions.html.erb +0 -6
  118. data/app/views/avo/base/_boolean_filter.html.erb +2 -1
  119. data/app/views/avo/base/_filters.html.erb +4 -11
  120. data/app/views/avo/base/_select_filter.html.erb +2 -1
  121. data/app/views/avo/home/_resources.html.erb +0 -1
  122. data/app/views/avo/partials/_paginator.html.erb +24 -5
  123. data/app/views/avo/relations/new.html.erb +5 -1
  124. data/app/views/layouts/avo/_filter_wrapper.html.erb +1 -1
  125. data/avo.gemspec +1 -1
  126. data/bin/helpers.rb +0 -0
  127. data/bin/rspec +1 -0
  128. data/bin/webpack +2 -1
  129. data/config/webpack/aliases.js +1 -1
  130. data/config/webpack/base.js +14 -0
  131. data/config/webpack/development.js +2 -2
  132. data/config/webpack/production.js +2 -2
  133. data/config/webpack/test.js +2 -2
  134. data/config/webpacker.yml +10 -62
  135. data/db/factories.rb +1 -0
  136. data/lib/avo.rb +5 -16
  137. data/lib/avo/action_model.rb +20 -0
  138. data/lib/avo/app.rb +162 -0
  139. data/lib/avo/base_action.rb +126 -0
  140. data/lib/avo/base_resource.rb +301 -0
  141. data/lib/avo/configuration.rb +6 -4
  142. data/lib/avo/engine.rb +17 -20
  143. data/lib/avo/{app/fields → fields}/badge_field.rb +1 -1
  144. data/lib/avo/{app/fields/field.rb → fields/base_field.rb} +22 -16
  145. data/lib/avo/{app/fields/belongs_to.rb → fields/belongs_to_field.rb} +3 -3
  146. data/lib/avo/{app/fields → fields}/boolean_field.rb +1 -1
  147. data/lib/avo/{app/fields → fields}/boolean_group_field.rb +1 -1
  148. data/lib/avo/{app/fields → fields}/code_field.rb +1 -1
  149. data/lib/avo/{app/fields → fields}/country_field.rb +1 -1
  150. data/lib/avo/{app/fields → fields}/currency_field.rb +1 -1
  151. data/lib/avo/{app/fields → fields}/date_field.rb +0 -2
  152. data/lib/avo/{app/fields → fields}/date_time_field.rb +0 -2
  153. data/lib/avo/{app/fields → fields}/external_image_field.rb +1 -1
  154. data/lib/avo/{app/fields → fields}/field_extensions/has_field_name.rb +2 -9
  155. data/lib/avo/{app/fields → fields}/field_extensions/visible_in_different_views.rb +1 -1
  156. data/lib/avo/{app/fields → fields}/file_field.rb +1 -2
  157. data/lib/avo/{app/fields → fields}/files_field.rb +1 -2
  158. data/lib/avo/{app/fields → fields}/gravatar_field.rb +2 -2
  159. data/lib/avo/{app/fields/has_and_belongs_to_many.rb → fields/has_and_belongs_to_many_field.rb} +1 -1
  160. data/lib/avo/{app/fields/has_many.rb → fields/has_many_field.rb} +1 -1
  161. data/lib/avo/{app/fields/has_one.rb → fields/has_one_field.rb} +1 -1
  162. data/lib/avo/{app/fields → fields}/heading_field.rb +1 -1
  163. data/lib/avo/{app/fields → fields}/hidden_field.rb +0 -2
  164. data/lib/avo/{app/fields → fields}/id_field.rb +1 -1
  165. data/lib/avo/{app/fields → fields}/key_value_field.rb +1 -1
  166. data/lib/avo/{app/fields → fields}/markdown_field.rb +1 -3
  167. data/lib/avo/{app/fields → fields}/number_field.rb +0 -2
  168. data/lib/avo/{app/fields → fields}/password_field.rb +0 -2
  169. data/lib/avo/{app/fields → fields}/select_field.rb +1 -1
  170. data/lib/avo/{app/fields → fields}/status_field.rb +1 -1
  171. data/lib/avo/{app/fields → fields}/text_field.rb +1 -1
  172. data/lib/avo/{app/fields → fields}/textarea_field.rb +0 -2
  173. data/lib/avo/{app/fields → fields}/trix_field.rb +1 -3
  174. data/lib/avo/fields_collector.rb +31 -0
  175. data/lib/avo/filters/base_filter.rb +20 -0
  176. data/lib/avo/filters/boolean_filter.rb +7 -0
  177. data/lib/avo/filters/select_filter.rb +7 -0
  178. data/lib/avo/grid_collector.rb +39 -0
  179. data/lib/avo/{app/grid_fields → grid_fields}/body_field.rb +0 -2
  180. data/lib/avo/{app/grid_fields → grid_fields}/grid_field.rb +0 -0
  181. data/lib/avo/{app/grid_fields → grid_fields}/preview_field.rb +0 -2
  182. data/lib/avo/{app/grid_fields → grid_fields}/title_field.rb +0 -2
  183. data/lib/avo/has_context.rb +7 -0
  184. data/lib/avo/licensing/community_license.rb +6 -0
  185. data/lib/avo/licensing/h_q.rb +88 -0
  186. data/lib/avo/licensing/license.rb +50 -0
  187. data/lib/avo/licensing/license_manager.rb +22 -0
  188. data/lib/avo/licensing/null_license.rb +14 -0
  189. data/lib/avo/licensing/pro_license.rb +11 -0
  190. data/lib/avo/loaders/actions_loader.rb +6 -0
  191. data/lib/avo/loaders/fields_loader.rb +27 -0
  192. data/lib/avo/loaders/filters_loader.rb +6 -0
  193. data/lib/avo/loaders/loader.rb +15 -0
  194. data/lib/avo/services/authorization_service.rb +93 -0
  195. data/lib/avo/services/panel_service.rb +27 -0
  196. data/lib/avo/{app/tools_manager.rb → tools_manager.rb} +0 -0
  197. data/lib/avo/version.rb +1 -1
  198. data/lib/generators/avo/action_generator.rb +11 -5
  199. data/lib/generators/avo/controller_generator.rb +14 -8
  200. data/lib/generators/avo/filter_generator.rb +14 -8
  201. data/lib/generators/avo/install_generator.rb +14 -10
  202. data/lib/generators/avo/locales_generator.rb +11 -7
  203. data/lib/generators/avo/partials_generator.rb +11 -5
  204. data/lib/generators/avo/resource_generator.rb +33 -15
  205. data/lib/generators/avo/templates/{action.rb → action.tt} +4 -6
  206. data/lib/generators/avo/templates/filters/boolean_filter.tt +11 -0
  207. data/lib/generators/avo/templates/filters/select_filter.tt +11 -0
  208. data/lib/generators/avo/templates/initializer/{avo.rb → avo.tt} +6 -0
  209. data/lib/generators/avo/templates/resource/controller.tt +2 -0
  210. data/lib/generators/avo/templates/resource/resource.tt +17 -0
  211. data/public/avo-packs/css/application-5bb09ba4.css +6024 -0
  212. data/public/avo-packs/css/application-5bb09ba4.css.br +0 -0
  213. data/public/avo-packs/css/application-5bb09ba4.css.gz +0 -0
  214. data/public/avo-packs/css/application-5bb09ba4.css.map +1 -0
  215. data/public/avo-packs/css/application-5bb09ba4.css.map.br +0 -0
  216. data/public/avo-packs/css/application-5bb09ba4.css.map.gz +0 -0
  217. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js +2 -0
  218. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.br +0 -0
  219. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.gz +0 -0
  220. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map +1 -0
  221. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map.br +0 -0
  222. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map.gz +0 -0
  223. data/public/avo-packs/js/application-86a3ea5a835b0c758203.js +26 -0
  224. data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.LICENSE.txt → application-86a3ea5a835b0c758203.js.LICENSE.txt} +17 -17
  225. data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.br +0 -0
  226. data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.gz +0 -0
  227. data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.map +1 -0
  228. data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.map.br +0 -0
  229. data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.map.gz +0 -0
  230. data/public/avo-packs/manifest.json +46 -23
  231. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg → images/13ae283c0d7cc04efe7e.svg} +0 -0
  232. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.br → images/13ae283c0d7cc04efe7e.svg.br} +0 -0
  233. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.gz → images/13ae283c0d7cc04efe7e.svg.gz} +0 -0
  234. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg → images/195026a50008c53526ef.svg} +0 -0
  235. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.br → images/195026a50008c53526ef.svg.br} +0 -0
  236. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.gz → images/195026a50008c53526ef.svg.gz} +0 -0
  237. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-cb632c9fe211ba2c2bf1564c9a9295cc.woff → images/1f30e08faa7c60d1f7ac.woff} +0 -0
  238. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf → images/1fd17dabf6b7d2b15348.ttf} +0 -0
  239. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.br → images/1fd17dabf6b7d2b15348.ttf.br} +0 -0
  240. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.gz → images/1fd17dabf6b7d2b15348.ttf.gz} +0 -0
  241. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-bcf84d6cb8a0ac214c8c14ba9af834f3.woff2 → images/39a18f443d434999b89b.woff2} +0 -0
  242. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-412073df419ad5f6f8f2ea76eb4aced9.woff2 → images/4ad349571e28bb59c5a5.woff2} +0 -0
  243. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-2fae1e2418251b68fe5d0505ab93dd5c.eot → images/57a5470848663767abbf.eot} +0 -0
  244. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf → images/b2e4cf0fab6c8ca66b7f.ttf} +0 -0
  245. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.br → images/b2e4cf0fab6c8ca66b7f.ttf.br} +0 -0
  246. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.gz → images/b2e4cf0fab6c8ca66b7f.ttf.gz} +0 -0
  247. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-df7e79af617f98cd3b95d320e8b2a1af.eot → images/b78d61ab7e046de8c156.eot} +0 -0
  248. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-7c472b19cb573f537bad8ef62ca917ac.woff → images/c9ab29becb76ddab01d0.woff} +0 -0
  249. data/public/avo-packs/media/images/{logo-edf8d8d0d263e0c1f73bb32a222d9991.png → f1b4befac91a3336db9a.png} +0 -0
  250. metadata +195 -193
  251. data/app/views/layouts/avo/application_vue.html.erb +0 -61
  252. data/config/webpack/environment.js +0 -18
  253. data/config/webpacker_packed.yml +0 -86
  254. data/db/migrate/20210305082639_add_url_to_teams.rb +0 -5
  255. data/lib/avo/app/action.rb +0 -145
  256. data/lib/avo/app/actions_loader.rb +0 -11
  257. data/lib/avo/app/app.rb +0 -183
  258. data/lib/avo/app/fields_loader.rb +0 -29
  259. data/lib/avo/app/filter.rb +0 -23
  260. data/lib/avo/app/filters/boolean_filter.rb +0 -13
  261. data/lib/avo/app/filters/select_filter.rb +0 -13
  262. data/lib/avo/app/licensing/community_license.rb +0 -4
  263. data/lib/avo/app/licensing/hq.rb +0 -86
  264. data/lib/avo/app/licensing/license.rb +0 -48
  265. data/lib/avo/app/licensing/license_manager.rb +0 -25
  266. data/lib/avo/app/licensing/null_license.rb +0 -12
  267. data/lib/avo/app/licensing/pro_license.rb +0 -9
  268. data/lib/avo/app/resource.rb +0 -291
  269. data/lib/avo/app/resource_grid_fields.rb +0 -30
  270. data/lib/avo/app/services/authorization_service.rb +0 -110
  271. data/lib/avo/app/services/panel_service.rb +0 -25
  272. data/lib/avo/app/tool.rb +0 -5
  273. data/lib/generators/avo/templates/filters/boolean_filter.rb +0 -17
  274. data/lib/generators/avo/templates/filters/select_filter.rb +0 -17
  275. data/lib/generators/avo/templates/resource/%plural_name%_controller.tt +0 -2
  276. data/lib/generators/avo/templates/resource/%singular_name%.tt +0 -20
  277. data/public/avo-packs/css/application-3598cfbb.css +0 -6
  278. data/public/avo-packs/css/application-3598cfbb.css.br +0 -0
  279. data/public/avo-packs/css/application-3598cfbb.css.gz +0 -0
  280. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js +0 -2
  281. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.br +0 -0
  282. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.gz +0 -0
  283. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map +0 -1
  284. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map.br +0 -0
  285. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map.gz +0 -0
  286. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js +0 -26
  287. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.br +0 -0
  288. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.gz +0 -0
  289. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map +0 -1
  290. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map.br +0 -0
  291. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map.gz +0 -0
  292. data/public/avo-packs/manifest.json.br +0 -0
  293. data/public/avo-packs/manifest.json.gz +0 -0
@@ -0,0 +1,6 @@
1
+ module Avo
2
+ module Licensing
3
+ class CommunityLicense < License
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,88 @@
1
+ module Avo
2
+ module Licensing
3
+ class HQ
4
+ attr_accessor :current_request
5
+
6
+ ENDPOINT = 'https://avohq.io/api/v1/licenses/check' unless const_defined?(:ENDPOINT)
7
+ CACHE_KEY = 'avo.hq.response' unless const_defined?(:CACHE_KEY)
8
+ REQUEST_TIMEOUT = 5 unless const_defined?(:REQUEST_TIMEOUT) # seconds
9
+
10
+ def initialize(current_request)
11
+ @current_request = current_request
12
+ @cache_store = Avo::App.cache_store
13
+ end
14
+
15
+ def response
16
+ @hq_response or request
17
+ end
18
+
19
+ private
20
+ def request
21
+ return cached_response if has_cached_response
22
+
23
+ begin
24
+ perform_and_cache_request
25
+ rescue HTTParty::Error => exception
26
+ cache_and_return_error 'HTTP client error.', exception.message
27
+ rescue Net::OpenTimeout => exception
28
+ cache_and_return_error 'Request timeout.', exception.message
29
+ rescue SocketError => exception
30
+ cache_and_return_error 'Connection error.', exception.message
31
+ end
32
+ end
33
+
34
+ def perform_and_cache_request
35
+ hq_response = perform_request
36
+
37
+ return cache_and_return_error 'Avo HQ Internal server error.', hq_response.body if hq_response.code == 500
38
+
39
+ cache_response 1.hour.to_i, hq_response.parsed_response if hq_response.code == 200
40
+ end
41
+
42
+ def cache_response(time, response)
43
+ response.merge!(
44
+ expiry: time,
45
+ **payload,
46
+ ).stringify_keys!
47
+
48
+ @cache_store.write(CACHE_KEY, response, expires_in: time)
49
+
50
+ @hq_response = response
51
+
52
+ response
53
+ end
54
+
55
+ def perform_request
56
+ puts 'Performing request to avohq.io API to check license availability.'.inspect if Rails.env.development?
57
+
58
+ HTTParty.post ENDPOINT, body: payload.to_json, headers: { 'Content-type': 'application/json' }, timeout: REQUEST_TIMEOUT
59
+ end
60
+
61
+ def payload
62
+ {
63
+ license: Avo.configuration.license,
64
+ license_key: Avo.configuration.license_key,
65
+ avo_version: Avo::VERSION,
66
+ rails_version: Rails::VERSION::STRING,
67
+ ruby_version: RUBY_VERSION,
68
+ environment: Rails.env,
69
+ ip: current_request.ip,
70
+ host: current_request.host,
71
+ port: current_request.port,
72
+ }
73
+ end
74
+
75
+ def cache_and_return_error(error, exception_message = '')
76
+ cache_response 5.minutes.to_i, { error: error, exception_message: exception_message }.stringify_keys
77
+ end
78
+
79
+ def has_cached_response
80
+ @cache_store.exist? CACHE_KEY
81
+ end
82
+
83
+ def cached_response
84
+ @cache_store.read CACHE_KEY
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,50 @@
1
+ module Avo
2
+ module Licensing
3
+ class License
4
+ attr_accessor :id
5
+ attr_accessor :response
6
+ attr_accessor :valid
7
+
8
+ def initialize(response)
9
+ @response = response
10
+ @id = response['id']
11
+ @valid = response['valid']
12
+ end
13
+
14
+ def valid?
15
+ valid
16
+ end
17
+
18
+ def invalid?
19
+ !valid?
20
+ end
21
+
22
+ def pro?
23
+ id == 'pro'
24
+ end
25
+
26
+ def error
27
+ @response['error']
28
+ end
29
+
30
+ def properties
31
+ @response.slice('valid', 'id', 'error').symbolize_keys
32
+ end
33
+
34
+ def abilities
35
+ []
36
+ end
37
+
38
+ def can(ability)
39
+ abilities.include? ability
40
+ end
41
+
42
+ def cant(ability)
43
+ !can ability
44
+ end
45
+
46
+ alias_method :has, :can
47
+ alias_method :lacks, :cant
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,22 @@
1
+ module Avo
2
+ module Licensing
3
+ class LicenseManager
4
+ def initialize(hq_response)
5
+ @hq_response = hq_response
6
+ end
7
+
8
+ def license
9
+ return NullLicense.new if Rails.env.test? and ENV['RUN_WITH_NULL_LICENSE'] == '1'
10
+
11
+ case @hq_response['id']
12
+ when 'community'
13
+ CommunityLicense.new @hq_response
14
+ when 'pro'
15
+ ProLicense.new @hq_response
16
+ else
17
+ NullLicense.new @hq_response
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ module Avo
2
+ module Licensing
3
+ class NullLicense < License
4
+ def initialize(response = nil)
5
+ response ||= {
6
+ id: 'community',
7
+ valid: true,
8
+ }
9
+
10
+ super(response)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module Avo
2
+ module Licensing
3
+ class ProLicense < License
4
+ def abilities
5
+ [
6
+ :authorization,
7
+ ]
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module Avo
2
+ module Loaders
3
+ class ActionsLoader < Loader
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,27 @@
1
+ module Avo
2
+ module Loaders
3
+ class FieldsLoader < Loader
4
+ def add_field(field)
5
+ @bag.push field
6
+ end
7
+
8
+ def method_missing(method, *args, &block)
9
+ matched_field = Avo::App.fields.find do |field|
10
+ field[:name].to_s == method.to_s
11
+ end
12
+
13
+ if matched_field.present? and matched_field[:class].present?
14
+ klass = matched_field[:class]
15
+
16
+ if block.present?
17
+ field = klass.new(args[0], **args[1] || {}, &block)
18
+ else
19
+ field = klass.new(args[0], **args[1] || {})
20
+ end
21
+
22
+ add_field field
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ module Avo
2
+ module Loaders
3
+ class FiltersLoader < Loader
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ module Avo
2
+ module Loaders
3
+ class Loader
4
+ attr_accessor :bag
5
+
6
+ def initialize
7
+ @bag = []
8
+ end
9
+
10
+ def use(klass)
11
+ @bag.push klass
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,93 @@
1
+ module Avo
2
+ module Services
3
+ class AuthorizationService
4
+ attr_accessor :user
5
+ attr_accessor :record
6
+
7
+ def initialize(user = nil, record = nil)
8
+ @user = user
9
+ @record = record
10
+ end
11
+
12
+ def authorize(action, **args)
13
+ self.class.authorize(user, record, action, **args)
14
+ end
15
+
16
+ def set_record(record)
17
+ @record = record
18
+
19
+ self
20
+ end
21
+
22
+ def set_user(user)
23
+ @user = user
24
+
25
+ self
26
+ end
27
+
28
+ def authorize_action(action, **args)
29
+ self.class.authorize_action(user, record, action, **args)
30
+ end
31
+
32
+ def apply_policy(model)
33
+ self.class.apply_policy(user, model)
34
+ end
35
+
36
+ class << self
37
+ def authorize(user, record, action, **args)
38
+ return true if skip_authorization
39
+ return true if user.nil?
40
+
41
+ begin
42
+ if Pundit.policy user, record
43
+ Pundit.authorize user, record, action
44
+ end
45
+
46
+ true
47
+ rescue Pundit::NotDefinedError => error
48
+ false
49
+ rescue => error
50
+ if args[:raise_exception] == false
51
+ false
52
+ else
53
+ raise error
54
+ end
55
+ end
56
+ end
57
+
58
+ def authorize_action(user, record, action, **args)
59
+ action = Avo.configuration.authorization_methods.stringify_keys[action.to_s]
60
+
61
+ return true if action.nil?
62
+
63
+ authorize user, record, action, **args
64
+ end
65
+
66
+ def apply_policy(user, model)
67
+ return model if skip_authorization
68
+ return model if user.nil?
69
+
70
+ begin
71
+ Pundit.policy_scope! user, model
72
+ rescue => exception
73
+ model
74
+ end
75
+ end
76
+
77
+ def skip_authorization
78
+ Avo::App.license.lacks :authorization
79
+ end
80
+
81
+ def authorized_methods(user, record)
82
+ [:new, :edit, :update, :show, :destroy].map do |method|
83
+ [method, authorize(user, record, Avo.configuration.authorization_methods[method])]
84
+ end.to_h
85
+ end
86
+
87
+ def get_policy(user, record)
88
+ Pundit.policy user, record
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,27 @@
1
+ module Avo
2
+ module Services
3
+ class PanelService
4
+ attr_accessor :request
5
+ attr_accessor :params
6
+ attr_accessor :resource
7
+
8
+ def initialize(request: nil, resource: nil)
9
+ @request = request
10
+ @params = request.params
11
+ end
12
+
13
+ def default_panel_name
14
+ return @request[:via_relation_param].capitalize if @request[:via_relation_param] == 'has_one'
15
+
16
+ case @view
17
+ when :show
18
+ I18n.t('avo.resource_details', item: @resource.name.downcase, title: @resource.model_title).upcase_first
19
+ when :edit
20
+ I18n.t('avo.update_item', item: @resource.name.downcase, title: @resource.model_title).upcase_first
21
+ when :new
22
+ I18n.t('avo.create_new_item', item: @resource.name.downcase).upcase_first
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
File without changes
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = '0.5.0.beta3'
2
+ VERSION = '0.5.0.beta8'
3
3
  end
@@ -1,8 +1,14 @@
1
- class ActionGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path('templates', __dir__)
3
- namespace 'avo:action'
1
+ require 'rails/generators'
4
2
 
5
- def create_resource_file
6
- template 'action.rb', "app/avo/actions/#{singular_name}.rb"
3
+ module Generators
4
+ module Avo
5
+ class ActionGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('templates', __dir__)
7
+ namespace 'avo:action'
8
+
9
+ def create_resource_file
10
+ template 'action.rb', "app/avo/actions/#{singular_name}.rb"
11
+ end
12
+ end
7
13
  end
8
14
  end
@@ -1,13 +1,19 @@
1
- class ControllerGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path('templates', __dir__)
1
+ require 'rails/generators'
3
2
 
4
- namespace 'avo:controller'
3
+ module Generators
4
+ module Avo
5
+ class ControllerGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('templates', __dir__)
5
7
 
6
- def create
7
- template 'resource/%plural_name%_controller.tt', "app/controllers/avo/#{controller_name}.rb"
8
- end
8
+ namespace 'avo:controller'
9
+
10
+ def create
11
+ template 'resource/%plural_name%_controller.tt', "app/controllers/avo/#{controller_name}.rb"
12
+ end
9
13
 
10
- def controller_name
11
- "#{plural_name}_controller"
14
+ def controller_name
15
+ "#{plural_name}_controller"
16
+ end
17
+ end
12
18
  end
13
19
  end
@@ -1,14 +1,20 @@
1
- class FilterGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path('templates', __dir__)
3
- class_option :select, type: :boolean
1
+ require 'rails/generators'
4
2
 
5
- namespace 'avo:filter'
3
+ module Generators
4
+ module Avo
5
+ class FilterGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path('templates', __dir__)
7
+ class_option :select, type: :boolean
6
8
 
7
- def create_resource_file
8
- type = 'boolean'
9
+ namespace 'avo:filter'
9
10
 
10
- type = 'select' if options[:select]
11
+ def create_resource_file
12
+ type = 'boolean'
11
13
 
12
- template "filters/#{type}_filter.rb", "app/services/avo/filters/#{singular_name}.rb"
14
+ type = 'select' if options[:select]
15
+
16
+ template "filters/#{type}_filter.rb", "app/services/avo/filters/#{singular_name}.rb"
17
+ end
18
+ end
13
19
  end
14
20
  end