avo 2.11.1.pre.3 → 2.11.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.

Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/stylesheets/avo.css +4 -1
  4. data/app/components/avo/fields/date_field/show_component.html.erb +0 -4
  5. data/app/components/avo/fields/has_one_field/show_component.html.erb +1 -1
  6. data/app/components/avo/fields/has_one_field/show_component.rb +6 -7
  7. data/app/components/avo/fields/text_field/index_component.html.erb +0 -2
  8. data/app/components/avo/fields/text_field/show_component.html.erb +0 -2
  9. data/app/components/avo/index/field_wrapper_component.html.erb +0 -4
  10. data/app/components/avo/index/resource_controls_component.rb +5 -7
  11. data/app/components/avo/index/resource_table_component.html.erb +1 -1
  12. data/app/components/avo/index/resource_table_component.rb +1 -2
  13. data/app/components/avo/index/table_row_component.html.erb +1 -1
  14. data/app/components/avo/index/table_row_component.rb +1 -2
  15. data/app/components/avo/resource_component.rb +5 -11
  16. data/app/components/avo/sidebar_component.html.erb +2 -2
  17. data/app/components/avo/tab_switcher_component.rb +0 -4
  18. data/app/components/avo/views/resource_edit_component.rb +6 -4
  19. data/app/components/avo/views/resource_index_component.html.erb +1 -1
  20. data/app/components/avo/views/resource_index_component.rb +3 -5
  21. data/app/components/avo/views/resource_show_component.html.erb +1 -1
  22. data/app/components/avo/views/resource_show_component.rb +1 -3
  23. data/app/controllers/avo/application_controller.rb +9 -24
  24. data/app/controllers/avo/associations_controller.rb +12 -38
  25. data/app/controllers/avo/base_controller.rb +1 -2
  26. data/app/javascript/js/controllers/mobile_controller.js +9 -0
  27. data/app/javascript/js/controllers.js +2 -2
  28. data/app/views/avo/base/index.html.erb +0 -1
  29. data/app/views/avo/base/show.html.erb +1 -7
  30. data/app/views/avo/partials/_javascript.html.erb +0 -1
  31. data/app/views/avo/partials/_navbar.html.erb +2 -5
  32. data/app/views/layouts/avo/application.html.erb +3 -3
  33. data/lib/avo/concerns/has_fields.rb +0 -5
  34. data/lib/avo/concerns/has_html_attributes.rb +1 -1
  35. data/lib/avo/fields/has_base_field.rb +0 -11
  36. data/lib/avo/fields/text_field.rb +2 -4
  37. data/lib/avo/services/authorization_service.rb +37 -41
  38. data/lib/avo/version.rb +1 -1
  39. data/lib/avo.rb +0 -1
  40. data/public/avo-assets/avo.css +11 -43
  41. data/public/avo-assets/avo.js +67 -68
  42. data/public/avo-assets/avo.js.map +3 -3
  43. metadata +5 -6
  44. data/app/assets/stylesheets/css/sidebar.css +0 -28
  45. data/app/javascript/js/controllers/sidebar_controller.js +0 -46
@@ -19,12 +19,12 @@
19
19
  <% end %>
20
20
  </head>
21
21
  <body class="bg-gray-25 os-mac">
22
- <div class="relative flex flex-1 w-full min-h-full" data-controller="sidebar" data-sidebar-open-value="<%= @sidebar_open %>">
22
+ <div class="relative flex flex-1 w-full min-h-full" data-controller="mobile">
23
23
  <div class="flex-1 flex flex-col max-w-full">
24
24
  <%= render partial: "avo/partials/navbar" %>
25
- <div data-sidebar-target="mainArea" class="content-area flex-1 flex pt-16 relative <%= 'sidebar-open' if @sidebar_open %>">
25
+ <div class="flex-1 flex pt-16 relative">
26
26
  <%= render Avo::SidebarComponent.new %>
27
- <div class="main-content-area flex-1 flex flex-col min-h-full max-w-full">
27
+ <div class="lg:pl-64 flex-1 flex flex-col min-h-full max-w-full">
28
28
  <div class="content p-4 lg:p-6 flex-1 flex flex-col justify-between items-stretch <%= @container_classes %>">
29
29
  <%= render partial: "avo/partials/custom_tools_alert" %>
30
30
  <div class="flex flex-1 flex-col justify-between items-stretch space-y-8">
@@ -252,14 +252,9 @@ module Avo
252
252
  if item.respond_to? :visible_on?
253
253
  next unless item.visible_on?(view)
254
254
  end
255
- # each field has it's own visibility checker
256
255
  if item.respond_to? :visible?
257
256
  next unless item.visible?
258
257
  end
259
- # check if the user is authorized to view it
260
- if item.respond_to? :authorized?
261
- next unless item.hydrate(model: @model).authorized?
262
- end
263
258
 
264
259
  if item.is_field?
265
260
  if item.has_own_panel?
@@ -58,7 +58,7 @@ module Avo
58
58
  end
59
59
  .to_h
60
60
 
61
- attributes.merge extra_attributes
61
+ extra_attributes.merge attributes
62
62
  else
63
63
  attributes
64
64
  end
@@ -78,17 +78,6 @@ module Avo
78
78
 
79
79
  super view
80
80
  end
81
-
82
- def authorized?
83
- method = "view_#{id}?".to_sym
84
- service = resource.authorization
85
-
86
- if service.has_method? method
87
- service.authorize_action(method, raise_exception: false)
88
- else
89
- true
90
- end
91
- end
92
81
  end
93
82
  end
94
83
  end
@@ -3,14 +3,12 @@ module Avo
3
3
  class TextField < BaseField
4
4
  attr_reader :link_to_resource
5
5
  attr_reader :as_html
6
- attr_reader :protocol
7
6
 
8
7
  def initialize(id, **args, &block)
9
8
  super(id, **args, &block)
10
9
 
11
- add_boolean_prop args, :link_to_resource
12
- add_boolean_prop args, :as_html
13
- add_string_prop args, :protocol
10
+ @link_to_resource = args[:link_to_resource].present? ? args[:link_to_resource] : false
11
+ @as_html = args[:as_html].present? ? args[:as_html] : false
14
12
  end
15
13
  end
16
14
  end
@@ -4,6 +4,43 @@ module Avo
4
4
  attr_accessor :user
5
5
  attr_accessor :record
6
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
+ def defined_methods(model, **args)
37
+ self.class.defined_methods(user, model, **args)
38
+ end
39
+
40
+ def has_method?(method, **args)
41
+ self.class.defined_methods(user, record, **args).include? method.to_sym
42
+ end
43
+
7
44
  class << self
8
45
  def authorize(user, record, action, **args)
9
46
  return true if skip_authorization
@@ -74,10 +111,6 @@ module Avo
74
111
 
75
112
  def defined_methods(user, record, **args)
76
113
  Pundit.policy!(user, record).methods
77
- rescue Pundit::NotDefinedError => e
78
- return [] unless Avo.configuration.raise_error_on_missing_policy
79
-
80
- raise e
81
114
  rescue => error
82
115
  if args[:raise_exception] == false
83
116
  []
@@ -86,43 +119,6 @@ module Avo
86
119
  end
87
120
  end
88
121
  end
89
-
90
- def initialize(user = nil, record = nil)
91
- @user = user
92
- @record = record
93
- end
94
-
95
- def authorize(action, **args)
96
- self.class.authorize(user, record, action, **args)
97
- end
98
-
99
- def set_record(record)
100
- @record = record
101
-
102
- self
103
- end
104
-
105
- def set_user(user)
106
- @user = user
107
-
108
- self
109
- end
110
-
111
- def authorize_action(action, **args)
112
- self.class.authorize_action(user, record, action, **args)
113
- end
114
-
115
- def apply_policy(model)
116
- self.class.apply_policy(user, model)
117
- end
118
-
119
- def defined_methods(model, **args)
120
- self.class.defined_methods(user, model, **args)
121
- end
122
-
123
- def has_method?(method, **args)
124
- defined_methods(record, **args).include? method.to_sym
125
- end
126
122
  end
127
123
  end
128
124
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.11.1.pre.3" unless const_defined?(:VERSION)
2
+ VERSION = "2.11.1" unless const_defined?(:VERSION)
3
3
  end
data/lib/avo.rb CHANGED
@@ -39,7 +39,6 @@ module Avo
39
39
  ROOT_PATH = Pathname.new(File.join(__dir__, ".."))
40
40
  IN_DEVELOPMENT = ENV["AVO_IN_DEVELOPMENT"] == "1"
41
41
  PACKED = !IN_DEVELOPMENT
42
- COOKIES_KEY = "avo"
43
42
 
44
43
  class LicenseVerificationTemperedError < StandardError; end
45
44
 
@@ -4536,45 +4536,6 @@ input[type=file][data-direct-upload-url][disabled] {
4536
4536
  display: none;
4537
4537
  }
4538
4538
 
4539
- .application-sidebar .active:hover, .application-sidebar .active{
4540
- --tw-bg-opacity:1;
4541
- background-color:rgb(206 231 248 / var(--tw-bg-opacity));
4542
- --tw-text-opacity:1;
4543
- color:rgb(8 134 222 / var(--tw-text-opacity))
4544
- }
4545
-
4546
- /* remove the left padding. */
4547
-
4548
- @media (min-width: 1024px){
4549
- .content-area .main-content-area{
4550
- padding-left:0px
4551
- }
4552
- }
4553
-
4554
- /* Hide the sidebar by default. */
4555
-
4556
- @media (min-width: 1024px){
4557
- .content-area .avo-sidebar{
4558
- display:none
4559
- }
4560
- }
4561
-
4562
- /* Add padding to the main area to allow for the sidebar to expand. */
4563
-
4564
- @media (min-width: 1024px){
4565
- .content-area.sidebar-open .main-content-area{
4566
- padding-left:16rem
4567
- }
4568
- }
4569
-
4570
- /* Show the sidebar. */
4571
-
4572
- @media (min-width: 1024px){
4573
- .content-area.sidebar-open .avo-sidebar{
4574
- display:block
4575
- }
4576
- }
4577
-
4578
4539
  .button-spinner {
4579
4540
  width: 24px;
4580
4541
  height: 24px;
@@ -8042,6 +8003,13 @@ html, body{
8042
8003
  opacity:0
8043
8004
  }
8044
8005
 
8006
+ .application-sidebar .active:hover, .application-sidebar .active{
8007
+ --tw-bg-opacity:1;
8008
+ background-color:rgb(206 231 248 / var(--tw-bg-opacity));
8009
+ --tw-text-opacity:1;
8010
+ color:rgb(8 134 222 / var(--tw-text-opacity))
8011
+ }
8012
+
8045
8013
  .turbo-progress-bar{
8046
8014
  --tw-bg-opacity:1;
8047
8015
  background-color:rgb(57 158 229 / var(--tw-bg-opacity))
@@ -8945,10 +8913,6 @@ trix-editor {
8945
8913
  margin-bottom:-1rem
8946
8914
  }
8947
8915
 
8948
- .lg\:block{
8949
- display:block
8950
- }
8951
-
8952
8916
  .lg\:flex{
8953
8917
  display:flex
8954
8918
  }
@@ -9008,6 +8972,10 @@ trix-editor {
9008
8972
  .lg\:pl-4{
9009
8973
  padding-left:1rem
9010
8974
  }
8975
+
8976
+ .lg\:pl-64{
8977
+ padding-left:16rem
8978
+ }
9011
8979
  }
9012
8980
 
9013
8981
  @media (min-width: 1280px){