spree_backend 4.6.2 → 4.7.0

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -101
  3. data/.codeclimate.yml +1 -1
  4. data/.rubocop.yml +5 -2
  5. data/Gemfile +10 -14
  6. data/app/assets/javascripts/spree/backend/global/tinymce.es6 +2 -2
  7. data/app/assets/javascripts/spree/backend/stock_transfer.js +1 -1
  8. data/app/controllers/spree/admin/products_controller.rb +22 -0
  9. data/app/helpers/spree/admin/navigation_helper.rb +77 -11
  10. data/app/helpers/spree/admin/orders_helper.rb +0 -18
  11. data/app/models/spree/admin/actions/action.rb +48 -0
  12. data/app/models/spree/admin/actions/action_builder.rb +79 -0
  13. data/app/models/spree/admin/actions/action_style.rb +11 -0
  14. data/app/models/spree/admin/actions/adjustments_default_actions_builder.rb +28 -0
  15. data/app/models/spree/admin/actions/images_default_actions_builder.rb +29 -0
  16. data/app/models/spree/admin/actions/order_default_actions_builder.rb +92 -0
  17. data/app/models/spree/admin/actions/orders_default_actions_builder.rb +29 -0
  18. data/app/models/spree/admin/actions/payments_default_actions_builder.rb +33 -0
  19. data/app/models/spree/admin/actions/product_properties_default_actions_builder.rb +42 -0
  20. data/app/models/spree/admin/actions/products_default_actions_builder.rb +29 -0
  21. data/app/models/spree/admin/actions/root.rb +15 -0
  22. data/app/models/spree/admin/actions/store_credits_default_actions_builder.rb +28 -0
  23. data/app/models/spree/admin/actions/user_default_actions_builder.rb +29 -0
  24. data/app/models/spree/admin/actions/users_default_actions_builder.rb +29 -0
  25. data/app/models/spree/admin/actions/variants_default_actions_builder.rb +30 -0
  26. data/app/models/spree/admin/item_manager.rb +50 -0
  27. data/app/models/spree/admin/main_menu/default_configuration_builder.rb +263 -0
  28. data/app/models/spree/admin/main_menu/item.rb +30 -0
  29. data/app/models/spree/admin/main_menu/item_builder.rb +37 -0
  30. data/app/models/spree/admin/main_menu/root.rb +17 -0
  31. data/app/models/spree/admin/main_menu/section.rb +31 -0
  32. data/app/models/spree/admin/main_menu/section_builder.rb +36 -0
  33. data/app/models/spree/admin/permission_checks.rb +50 -0
  34. data/app/models/spree/admin/tabs/order_default_tabs_builder.rb +147 -0
  35. data/app/models/spree/admin/tabs/product_default_tabs_builder.rb +144 -0
  36. data/app/models/spree/admin/tabs/root.rb +15 -0
  37. data/app/models/spree/admin/tabs/tab.rb +38 -0
  38. data/app/models/spree/admin/tabs/tab_builder.rb +63 -0
  39. data/app/models/spree/admin/tabs/user_default_tabs_builder.rb +77 -0
  40. data/app/views/spree/admin/adjustments/index.html.erb +9 -1
  41. data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +27 -33
  42. data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +18 -22
  43. data/app/views/spree/admin/images/index.html.erb +12 -3
  44. data/app/views/spree/admin/orders/_order_actions.html.erb +10 -15
  45. data/app/views/spree/admin/orders/index.html.erb +11 -6
  46. data/app/views/spree/admin/payments/index.html.erb +9 -4
  47. data/app/views/spree/admin/prices/index.html.erb +12 -2
  48. data/app/views/spree/admin/product_properties/index.html.erb +13 -13
  49. data/app/views/spree/admin/products/_add_stock_form.html.erb +12 -1
  50. data/app/views/spree/admin/products/edit.html.erb +12 -1
  51. data/app/views/spree/admin/products/index.html.erb +11 -2
  52. data/app/views/spree/admin/shared/_main_menu.html.erb +19 -77
  53. data/app/views/spree/admin/shared/_order_tabs.html.erb +10 -83
  54. data/app/views/spree/admin/shared/_product_tabs.html.erb +12 -64
  55. data/app/views/spree/admin/store_credits/index.html.erb +9 -1
  56. data/app/views/spree/admin/users/_tabs.html.erb +11 -30
  57. data/app/views/spree/admin/users/_user_page_actions.html.erb +9 -1
  58. data/app/views/spree/admin/users/index.html.erb +11 -2
  59. data/app/views/spree/admin/variants/index.html.erb +12 -2
  60. data/app/views/spree/admin/webhooks_subscribers/index.html.erb +0 -11
  61. data/config/locales/en.yml +6 -4
  62. data/lib/spree/backend/configuration.rb +0 -17
  63. data/lib/spree/backend/engine.rb +28 -1
  64. data/lib/spree/backend/version.rb +1 -1
  65. data/spree_backend.gemspec +2 -2
  66. data/yarn.lock +58 -22
  67. metadata +36 -17
  68. data/app/views/spree/admin/shared/sub_menu/_apps.html.erb +0 -3
  69. data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +0 -19
  70. data/app/views/spree/admin/shared/sub_menu/_content.html.erb +0 -4
  71. data/app/views/spree/admin/shared/sub_menu/_integrations.html.erb +0 -5
  72. data/app/views/spree/admin/shared/sub_menu/_orders.html.erb +0 -5
  73. data/app/views/spree/admin/shared/sub_menu/_organizations.html.erb +0 -3
  74. data/app/views/spree/admin/shared/sub_menu/_product.html.erb +0 -8
  75. data/app/views/spree/admin/shared/sub_menu/_promotion.html.erb +0 -4
  76. data/app/views/spree/admin/shared/sub_menu/_returns.html.erb +0 -4
  77. data/app/views/spree/admin/shared/sub_menu/_stock.html.erb +0 -4
@@ -0,0 +1,144 @@
1
+ module Spree
2
+ module Admin
3
+ module Tabs
4
+ # rubocop:disable Metrics/ClassLength
5
+ class ProductDefaultTabsBuilder
6
+ include Spree::Core::Engine.routes.url_helpers
7
+
8
+ def build
9
+ root = Root.new
10
+ add_details_tab(root)
11
+ add_images_tab(root)
12
+ add_variants_tab(root)
13
+ add_properties_tab(root)
14
+ add_stock_tab(root)
15
+ add_prices_tab(root)
16
+ add_digitals_tab(root)
17
+ add_translations_tab(root)
18
+ root
19
+ end
20
+
21
+ private
22
+
23
+ def add_details_tab(root)
24
+ tab =
25
+ TabBuilder.new('details', ->(resource) { edit_admin_product_path(resource) }).
26
+ with_icon_key('edit.svg').
27
+ with_active_check.
28
+ with_admin_ability_check(::Spree::Product).
29
+ build
30
+
31
+ root.add(tab)
32
+ end
33
+
34
+ def add_images_tab(root)
35
+ tab =
36
+ TabBuilder.new('images', ->(resource) { admin_product_images_path(resource) }).
37
+ with_icon_key('images.svg').
38
+ with_active_check.
39
+ with_availability_check(
40
+ lambda do |ability, resource|
41
+ ability.can?(:admin, ::Spree::Image) && !resource.deleted?
42
+ end
43
+ ).
44
+ build
45
+
46
+ root.add(tab)
47
+ end
48
+
49
+ def add_variants_tab(root)
50
+ tab =
51
+ TabBuilder.new('variants', ->(resource) { admin_product_variants_path(resource) }).
52
+ with_icon_key('adjust.svg').
53
+ with_active_check.
54
+ with_availability_check(
55
+ lambda do |ability, resource|
56
+ ability.can?(:admin, ::Spree::Variant) && !resource.deleted?
57
+ end
58
+ ).
59
+ build
60
+
61
+ root.add(tab)
62
+ end
63
+
64
+ def add_properties_tab(root)
65
+ tab =
66
+ TabBuilder.new('properties', ->(resource) { admin_product_product_properties_path(resource) }).
67
+ with_icon_key('list.svg').
68
+ with_active_check.
69
+ with_availability_check(
70
+ lambda do |ability, resource|
71
+ ability.can?(:admin, ::Spree::ProductProperty) && !resource.deleted?
72
+ end
73
+ ).
74
+ build
75
+
76
+ root.add(tab)
77
+ end
78
+
79
+ def add_stock_tab(root)
80
+ tab =
81
+ TabBuilder.new('stock', ->(resource) { stock_admin_product_path(resource) }).
82
+ with_icon_key('box-seam.svg').
83
+ with_active_check.
84
+ with_availability_check(
85
+ lambda do |ability, resource|
86
+ ability.can?(:admin, ::Spree::StockItem) && !resource.deleted?
87
+ end
88
+ ).
89
+ build
90
+
91
+ root.add(tab)
92
+ end
93
+
94
+ def add_prices_tab(root)
95
+ tab =
96
+ TabBuilder.new('prices', ->(resource) { admin_product_prices_path(resource) }).
97
+ with_icon_key('currency-exchange.svg').
98
+ with_active_check.
99
+ with_availability_check(
100
+ lambda do |ability, resource|
101
+ ability.can?(:admin, ::Spree::Price) && !resource.deleted?
102
+ end
103
+ ).
104
+ build
105
+
106
+ root.add(tab)
107
+ end
108
+
109
+ def add_digitals_tab(root)
110
+ tab =
111
+ TabBuilder.new('digital_assets', ->(resource) { admin_product_digitals_path(resource) }).
112
+ with_icon_key('download.svg').
113
+ with_label_translation_key('admin.digitals.digital_assets').
114
+ with_partial_name('digitals').
115
+ with_active_check.
116
+ with_availability_check(
117
+ lambda do |ability, resource|
118
+ ability.can?(:admin, ::Spree::Digital) && !resource.deleted?
119
+ end
120
+ ).
121
+ build
122
+
123
+ root.add(tab)
124
+ end
125
+
126
+ def add_translations_tab(root)
127
+ tab =
128
+ TabBuilder.new('translations', ->(resource) { translations_admin_product_path(resource) }).
129
+ with_icon_key('translate.svg').
130
+ with_active_check.
131
+ with_availability_check(
132
+ lambda do |ability, resource|
133
+ ability.can?(:admin, ::Spree::Product) && !resource.deleted?
134
+ end
135
+ ).
136
+ build
137
+
138
+ root.add(tab)
139
+ end
140
+ end
141
+ # rubocop:enable Metrics/ClassLength
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,15 @@
1
+ module Spree
2
+ module Admin
3
+ module Tabs
4
+ class Root
5
+ include ::Spree::Admin::ItemManager
6
+
7
+ attr_reader :items
8
+
9
+ def initialize
10
+ @items = []
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ module Spree
2
+ module Admin
3
+ module Tabs
4
+ class Tab
5
+ attr_reader :icon_key, :key, :label_translation_key, :data_hook
6
+
7
+ def initialize(key, label_translation_key, url, icon_key, partial_name, availability_checks, active_check, data_hook) # rubocop:disable Metrics/ParameterLists
8
+ @key = key
9
+ @label_translation_key = label_translation_key
10
+ @url = url
11
+ @icon_key = icon_key
12
+ @partial_name = partial_name
13
+ @availability_checks = availability_checks
14
+ @active_check = active_check
15
+ @data_hook = data_hook
16
+ end
17
+
18
+ def available?(current_ability, resource)
19
+ return true if @availability_checks.empty?
20
+
21
+ result = @availability_checks.map { |check| check.call(current_ability, resource) }
22
+
23
+ result.all?(true)
24
+ end
25
+
26
+ def url(resource = nil)
27
+ @url.is_a?(Proc) ? @url.call(resource) : @url
28
+ end
29
+
30
+ def active?(current_tab)
31
+ return false unless @active_check.present?
32
+
33
+ @active_check.call(current_tab, @partial_name)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,63 @@
1
+ module Spree
2
+ module Admin
3
+ module Tabs
4
+ class TabBuilder
5
+ include ::Spree::Admin::PermissionChecks
6
+
7
+ def initialize(key, url)
8
+ @key = key
9
+ @label_translation_key = key
10
+ @url = url
11
+ @icon_key = nil
12
+ @partial_name = key
13
+ @availability_checks = []
14
+ @active_check = nil
15
+ @data_hook = nil
16
+ end
17
+
18
+ def with_label_translation_key(key)
19
+ @label_translation_key = key
20
+ self
21
+ end
22
+
23
+ def with_icon_key(icon_key)
24
+ @icon_key = icon_key
25
+ self
26
+ end
27
+
28
+ def with_partial_name(partial_name)
29
+ @partial_name = partial_name
30
+ self
31
+ end
32
+
33
+ def with_active_check
34
+ @active_check = ->(current_tab, partial_name) { current_tab.to_s == partial_name.to_s }
35
+ self
36
+ end
37
+
38
+ def with_completed_check
39
+ @availability_checks << ->(_current_ability, resource) { resource.completed? }
40
+ self
41
+ end
42
+
43
+ def with_data_hook(data_hook)
44
+ @data_hook = data_hook
45
+ self
46
+ end
47
+
48
+ def build
49
+ Tab.new(
50
+ @key,
51
+ @label_translation_key,
52
+ @url,
53
+ @icon_key,
54
+ @partial_name,
55
+ @availability_checks,
56
+ @active_check,
57
+ @data_hook
58
+ )
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,77 @@
1
+ module Spree
2
+ module Admin
3
+ module Tabs
4
+ class UserDefaultTabsBuilder
5
+ include Spree::Core::Engine.routes.url_helpers
6
+
7
+ def build
8
+ root = Root.new
9
+ add_account_tab(root)
10
+ add_addresses_tab(root)
11
+ add_orders_tab(root)
12
+ add_items_tab(root)
13
+ add_store_credits_tab(root)
14
+ root
15
+ end
16
+
17
+ private
18
+
19
+ def add_account_tab(root)
20
+ tab =
21
+ TabBuilder.new('account', ->(resource) { edit_admin_user_path(resource) }).
22
+ with_label_translation_key('admin.user.account').
23
+ with_icon_key('person.svg').
24
+ with_active_check.
25
+ build
26
+
27
+ root.add(tab)
28
+ end
29
+
30
+ def add_addresses_tab(root)
31
+ tab =
32
+ TabBuilder.new('addresses', ->(resource) { addresses_admin_user_path(resource) }).
33
+ with_label_translation_key('admin.user.addresses').
34
+ with_icon_key('pin-map.svg').
35
+ with_partial_name('address').
36
+ with_active_check.
37
+ build
38
+
39
+ root.add(tab)
40
+ end
41
+
42
+ def add_orders_tab(root)
43
+ tab =
44
+ TabBuilder.new('orders', ->(resource) { orders_admin_user_path(resource) }).
45
+ with_label_translation_key('admin.user.orders').
46
+ with_icon_key('inbox.svg').
47
+ with_active_check.
48
+ build
49
+
50
+ root.add(tab)
51
+ end
52
+
53
+ def add_items_tab(root)
54
+ tab =
55
+ TabBuilder.new('items', ->(resource) { items_admin_user_path(resource) }).
56
+ with_label_translation_key('admin.user.items').
57
+ with_icon_key('tag.svg').
58
+ with_active_check.
59
+ build
60
+
61
+ root.add(tab)
62
+ end
63
+
64
+ def add_store_credits_tab(root)
65
+ tab =
66
+ TabBuilder.new('store_credits', ->(resource) { admin_user_store_credits_path(resource) }).
67
+ with_label_translation_key('admin.user.store_credits').
68
+ with_icon_key('gift.svg').
69
+ with_active_check.
70
+ build
71
+
72
+ root.add(tab)
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -1,7 +1,15 @@
1
1
  <%= render partial: 'spree/admin/shared/order_tabs', locals: { current: :adjustments} %>
2
2
 
3
3
  <% content_for :page_actions do %>
4
- <%= button_link_to(Spree.t(:new_adjustment), new_admin_order_adjustment_url(@order), class: "btn-success", icon: 'add.svg') if can? :create, Spree::Adjustment %>
4
+ <% adjustments_actions.items.each do |action| %>
5
+ <% next unless action.available?(current_ability) %>
6
+ <%= button_link_to(
7
+ Spree.t(action.label_translation_key),
8
+ action.url(@order),
9
+ class: action.classes,
10
+ icon: action.icon_key
11
+ ) %>
12
+ <% end %>
5
13
  <% end %>
6
14
 
7
15
  <% if @adjustments.present? %>
@@ -37,17 +37,15 @@
37
37
  <% end %>
38
38
 
39
39
  <div class="col-12"><hr></div>
40
- <% unless rails_5? %>
41
- <%= f.field_container :link_type_one do %>
42
- <%= f.label :link_type_one, Spree.t('admin.navigation.link_to') %>
43
- <%= f.select(:link_type_one,
44
- spree_humanize_dropdown_values('Spree::Cms::Sections::ImageGallery',
45
- { const: 'LINKED_RESOURCE_TYPE' }),
46
- { include_blank: false },
47
- class: 'link_switcher',
48
- data: { target_field: :link_one}) %>
49
- <%= f.error_message_on :link_type_one %>
50
- <% end %>
40
+ <%= f.field_container :link_type_one do %>
41
+ <%= f.label :link_type_one, Spree.t('admin.navigation.link_to') %>
42
+ <%= f.select(:link_type_one,
43
+ spree_humanize_dropdown_values('Spree::Cms::Sections::ImageGallery',
44
+ { const: 'LINKED_RESOURCE_TYPE' }),
45
+ { include_blank: false },
46
+ class: 'link_switcher',
47
+ data: { target_field: :link_one}) %>
48
+ <%= f.error_message_on :link_type_one %>
51
49
  <% end %>
52
50
  <%= render "spree/admin/shared/link_fields", resource: @cms_section, linked_type: @cms_section.link_type_one, save_to: :link_one, f: f %>
53
51
  </div>
@@ -69,17 +67,15 @@
69
67
  <% end %>
70
68
 
71
69
  <div class="col-12"><hr></div>
72
- <% unless rails_5? %>
73
- <%= f.field_container :link_type_two do %>
74
- <%= f.label :link_type_two, Spree.t('admin.navigation.link_to') %>
75
- <%= f.select(:link_type_two,
76
- spree_humanize_dropdown_values('Spree::Cms::Sections::ImageGallery',
77
- { const: 'LINKED_RESOURCE_TYPE' }),
78
- { include_blank: false },
79
- class: 'link_switcher',
80
- data: { target_field: :link_two}) %>
81
- <%= f.error_message_on :link_type_two %>
82
- <% end %>
70
+ <%= f.field_container :link_type_two do %>
71
+ <%= f.label :link_type_two, Spree.t('admin.navigation.link_to') %>
72
+ <%= f.select(:link_type_two,
73
+ spree_humanize_dropdown_values('Spree::Cms::Sections::ImageGallery',
74
+ { const: 'LINKED_RESOURCE_TYPE' }),
75
+ { include_blank: false },
76
+ class: 'link_switcher',
77
+ data: { target_field: :link_two}) %>
78
+ <%= f.error_message_on :link_type_two %>
83
79
  <% end %>
84
80
  <%= render "spree/admin/shared/link_fields", resource: @cms_section, linked_type: @cms_section.link_type_two, save_to: :link_two, f: f %>
85
81
  </div>
@@ -101,17 +97,15 @@
101
97
  <% end %>
102
98
 
103
99
  <div class="col-12"><hr></div>
104
- <% unless rails_5? %>
105
- <%= f.field_container :link_type_three do %>
106
- <%= f.label :link_type_three, Spree.t('admin.navigation.link_to') %>
107
- <%= f.select(:link_type_three,
108
- spree_humanize_dropdown_values('Spree::Cms::Sections::ImageGallery',
109
- { const: 'LINKED_RESOURCE_TYPE' }),
110
- { include_blank: false },
111
- class: 'link_switcher',
112
- data: { target_field: :link_three}) %>
113
- <%= f.error_message_on :link_type_three %>
114
- <% end %>
100
+ <%= f.field_container :link_type_three do %>
101
+ <%= f.label :link_type_three, Spree.t('admin.navigation.link_to') %>
102
+ <%= f.select(:link_type_three,
103
+ spree_humanize_dropdown_values('Spree::Cms::Sections::ImageGallery',
104
+ { const: 'LINKED_RESOURCE_TYPE' }),
105
+ { include_blank: false },
106
+ class: 'link_switcher',
107
+ data: { target_field: :link_three}) %>
108
+ <%= f.error_message_on :link_type_three %>
115
109
  <% end %>
116
110
  <%= render "spree/admin/shared/link_fields", resource: @cms_section, linked_type: @cms_section.link_type_three, save_to: :link_three, f: f %>
117
111
  </div>
@@ -21,17 +21,15 @@
21
21
  <% end %>
22
22
 
23
23
  <div class="col-12"><hr></div>
24
- <% unless rails_5? %>
25
- <%= f.field_container :link_type_one do %>
26
- <%= f.label :link_type_one, Spree.t('admin.navigation.link_to') %>
27
- <%= f.select(:link_type_one,
28
- spree_humanize_dropdown_values('Spree::Cms::Sections::SideBySideImages',
29
- { const: 'LINKED_RESOURCE_TYPE' }),
30
- { include_blank: false },
31
- class: 'link_switcher',
32
- data: { target_field: :link_one}) %>
33
- <%= f.error_message_on :link_type_one %>
34
- <% end %>
24
+ <%= f.field_container :link_type_one do %>
25
+ <%= f.label :link_type_one, Spree.t('admin.navigation.link_to') %>
26
+ <%= f.select(:link_type_one,
27
+ spree_humanize_dropdown_values('Spree::Cms::Sections::SideBySideImages',
28
+ { const: 'LINKED_RESOURCE_TYPE' }),
29
+ { include_blank: false },
30
+ class: 'link_switcher',
31
+ data: { target_field: :link_one}) %>
32
+ <%= f.error_message_on :link_type_one %>
35
33
  <% end %>
36
34
  <%= render "spree/admin/shared/link_fields", resource: @cms_section, linked_type: @cms_section.link_type_one, save_to: :link_one, f: f %>
37
35
  </div>
@@ -60,17 +58,15 @@
60
58
 
61
59
  <div class="col-12"><hr></div>
62
60
 
63
- <% unless rails_5? %>
64
- <%= f.field_container :link_type_two do %>
65
- <%= f.label :link_type_two, Spree.t('admin.navigation.link_to') %>
66
- <%= f.select(:link_type_two,
67
- spree_humanize_dropdown_values('Spree::Cms::Sections::SideBySideImages',
68
- { const: 'LINKED_RESOURCE_TYPE' }),
69
- { include_blank: false },
70
- class: 'link_switcher',
71
- data: { target_field: :link_two}) %>
72
- <%= f.error_message_on :link_type_two %>
73
- <% end %>
61
+ <%= f.field_container :link_type_two do %>
62
+ <%= f.label :link_type_two, Spree.t('admin.navigation.link_to') %>
63
+ <%= f.select(:link_type_two,
64
+ spree_humanize_dropdown_values('Spree::Cms::Sections::SideBySideImages',
65
+ { const: 'LINKED_RESOURCE_TYPE' }),
66
+ { include_blank: false },
67
+ class: 'link_switcher',
68
+ data: { target_field: :link_two}) %>
69
+ <%= f.error_message_on :link_type_two %>
74
70
  <% end %>
75
71
  <%= render "spree/admin/shared/link_fields", resource: @cms_section, linked_type: @cms_section.link_type_two, save_to: :link_two, f: f %>
76
72
  </div>
@@ -1,9 +1,18 @@
1
1
  <%= render partial: 'spree/admin/shared/product_tabs', locals: { current: :images } %>
2
2
 
3
3
  <% content_for :page_actions do %>
4
- <%= yield :page_actions %>
5
- <%= external_page_preview_link(@product) %>
6
- <%= button_link_to(Spree.t(:new_image), spree.new_admin_product_image_url(@product), { class: "btn-success", icon: 'add.svg', id: 'new_image_link' }) if can? :create, Spree::Image %>
4
+ <% images_actions.items.each do |action| %>
5
+ <% next unless action.available?(current_ability) %>
6
+ <%= button_link_to(
7
+ Spree.t(action.label_translation_key),
8
+ action.url(@product),
9
+ class: action.classes,
10
+ icon: action.icon_key,
11
+ id: action.id,
12
+ target: action.target,
13
+ data: action.data_attributes
14
+ ) %>
15
+ <% end %>
7
16
  <% end %>
8
17
 
9
18
  <% has_variants = @product.has_variants? %>
@@ -1,18 +1,13 @@
1
1
  <% content_for :page_actions do %>
2
- <% if can?(:fire, order) %>
3
- <%= event_links(order, events) %>
4
- <% end %>
5
- <% if can?(:resend, order) %>
6
- <%= button_link_to Spree.t(:resend, scope: 'admin.order.events', default: Spree.t(:resend)),
7
- resend_admin_order_url(order),
8
- method: :post,
9
- icon: 'envelope.svg', class: 'btn-secondary' %>
10
- <% end %>
11
-
12
- <% if (can? :update, @order) && @order.some_digital? %>
13
- <%= button_link_to Spree.t('admin.digitals.reset_download_links'),
14
- reset_digitals_admin_order_url(@order),
15
- method: :put,
16
- icon: 'hdd.svg' %>
2
+ <% order_actions.items.each do |action| %>
3
+ <% next unless action.available?(current_ability, order) %>
4
+ <%= button_link_to(
5
+ Spree.t(action.label_translation_key),
6
+ action.url(order),
7
+ class: action.classes,
8
+ icon: action.icon_key,
9
+ method: action.method,
10
+ data: action.data_attributes
11
+ ) %>
17
12
  <% end %>
18
13
  <% end %>
@@ -3,12 +3,17 @@
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
- <%= button_link_to Spree.t(:new_order),
7
- new_admin_order_url,
8
- class: "btn-success",
9
- icon: 'add.svg',
10
- id: 'admin_new_order' %>
11
- <% end if can? :create, Spree::Order %>
6
+ <% orders_actions.items.each do |action| %>
7
+ <% next unless action.available?(current_ability) %>
8
+ <%= button_link_to(
9
+ Spree.t(action.label_translation_key),
10
+ action.url,
11
+ class: action.classes,
12
+ icon: action.icon_key,
13
+ id: action.id
14
+ ) %>
15
+ <% end %>
16
+ <% end %>
12
17
 
13
18
  <% content_for :page_tabs do %>
14
19
  <li class="nav-item">
@@ -1,10 +1,15 @@
1
1
  <%= render partial: 'spree/admin/shared/order_tabs', locals: { current: :payments } %>
2
2
 
3
3
  <% content_for :page_actions do %>
4
- <% if @order.outstanding_balance? && can?(:create, Spree::Payment) %>
5
- <span id="new_payment_section">
6
- <%= button_link_to Spree.t(:new_payment), new_admin_order_payment_url(@order), class: "btn-success", icon: 'add.svg' %>
7
- </span>
4
+ <% payments_actions.items.each do |action| %>
5
+ <% next unless action.available?(current_ability, @order) %>
6
+ <%= button_link_to(
7
+ Spree.t(action.label_translation_key),
8
+ action.url(@order),
9
+ class: action.classes,
10
+ icon: action.icon_key,
11
+ id: action.id
12
+ ) %>
8
13
  <% end %>
9
14
  <% end %>
10
15
 
@@ -1,8 +1,18 @@
1
1
  <%= render partial: 'spree/admin/shared/product_tabs', locals: { current: :prices } %>
2
2
 
3
3
  <% content_for :page_actions do %>
4
- <%= yield :page_actions %>
5
- <%= external_page_preview_link(@product) %>
4
+ <% prices_actions.items.each do |action| %>
5
+ <% next unless action.available?(current_ability) %>
6
+ <%= button_link_to(
7
+ Spree.t(action.label_translation_key),
8
+ action.url(@product),
9
+ class: action.classes,
10
+ icon: action.icon_key,
11
+ id: action.id,
12
+ target: action.target,
13
+ data: action.data_attributes
14
+ ) %>
15
+ <% end if product_actions&.items %>
6
16
  <% end %>
7
17
 
8
18
  <form>
@@ -2,19 +2,19 @@
2
2
  <%= render 'spree/admin/shared/error_messages', target: @product %>
3
3
 
4
4
  <% content_for :page_actions do %>
5
- <%= external_page_preview_link(@product) %>
6
-
7
- <span class="js-new-ptype-link">
8
- <%= button_link_to Spree.t(:select_from_prototype),
9
- available_admin_prototypes_url,
10
- { icon: 'list.svg', remote: true, 'data-update' => 'prototypes', class: 'btn-light' } %>
11
- </span>
12
-
13
- <%= button_link_to(
14
- Spree.t(:add_product_properties),
15
- "javascript:;",
16
- { icon: 'add.svg', :'data-target' => "tbody#sortVert", class: 'btn-success spree_add_fields' }) %>
17
- <% end if can? :create, Spree::ProductProperty %>
5
+ <% product_properties_actions.items.each do |action| %>
6
+ <% next unless action.available?(current_ability) %>
7
+ <%= button_link_to(
8
+ Spree.t(action.label_translation_key),
9
+ action.url(@product),
10
+ class: action.classes,
11
+ icon: action.icon_key,
12
+ id: action.id,
13
+ target: action.target,
14
+ data: action.data_attributes
15
+ ) %>
16
+ <% end %>
17
+ <% end %>
18
18
 
19
19
  <%= form_for @product, url: spree.admin_product_url(@product), method: :put do |f| %>
20
20
  <fieldset>