spree_backend 4.6.1 → 4.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) 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/stock_transfer.js +1 -1
  7. data/app/helpers/spree/admin/navigation_helper.rb +77 -11
  8. data/app/helpers/spree/admin/orders_helper.rb +0 -18
  9. data/app/models/spree/admin/actions/action.rb +48 -0
  10. data/app/models/spree/admin/actions/action_builder.rb +79 -0
  11. data/app/models/spree/admin/actions/action_style.rb +11 -0
  12. data/app/models/spree/admin/actions/adjustments_default_actions_builder.rb +28 -0
  13. data/app/models/spree/admin/actions/images_default_actions_builder.rb +29 -0
  14. data/app/models/spree/admin/actions/order_default_actions_builder.rb +92 -0
  15. data/app/models/spree/admin/actions/orders_default_actions_builder.rb +29 -0
  16. data/app/models/spree/admin/actions/payments_default_actions_builder.rb +33 -0
  17. data/app/models/spree/admin/actions/product_properties_default_actions_builder.rb +42 -0
  18. data/app/models/spree/admin/actions/products_default_actions_builder.rb +29 -0
  19. data/app/models/spree/admin/actions/root.rb +15 -0
  20. data/app/models/spree/admin/actions/store_credits_default_actions_builder.rb +28 -0
  21. data/app/models/spree/admin/actions/user_default_actions_builder.rb +29 -0
  22. data/app/models/spree/admin/actions/users_default_actions_builder.rb +29 -0
  23. data/app/models/spree/admin/actions/variants_default_actions_builder.rb +30 -0
  24. data/app/models/spree/admin/item_manager.rb +50 -0
  25. data/app/models/spree/admin/main_menu/default_configuration_builder.rb +263 -0
  26. data/app/models/spree/admin/main_menu/item.rb +30 -0
  27. data/app/models/spree/admin/main_menu/item_builder.rb +37 -0
  28. data/app/models/spree/admin/main_menu/root.rb +17 -0
  29. data/app/models/spree/admin/main_menu/section.rb +31 -0
  30. data/app/models/spree/admin/main_menu/section_builder.rb +36 -0
  31. data/app/models/spree/admin/permission_checks.rb +50 -0
  32. data/app/models/spree/admin/tabs/order_default_tabs_builder.rb +147 -0
  33. data/app/models/spree/admin/tabs/product_default_tabs_builder.rb +144 -0
  34. data/app/models/spree/admin/tabs/root.rb +15 -0
  35. data/app/models/spree/admin/tabs/tab.rb +38 -0
  36. data/app/models/spree/admin/tabs/tab_builder.rb +63 -0
  37. data/app/models/spree/admin/tabs/user_default_tabs_builder.rb +77 -0
  38. data/app/views/spree/admin/adjustments/index.html.erb +9 -1
  39. data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +27 -33
  40. data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +18 -22
  41. data/app/views/spree/admin/images/index.html.erb +12 -3
  42. data/app/views/spree/admin/orders/_order_actions.html.erb +10 -15
  43. data/app/views/spree/admin/orders/index.html.erb +11 -6
  44. data/app/views/spree/admin/payments/index.html.erb +9 -4
  45. data/app/views/spree/admin/prices/index.html.erb +12 -2
  46. data/app/views/spree/admin/product_properties/index.html.erb +13 -13
  47. data/app/views/spree/admin/products/_add_stock_form.html.erb +12 -1
  48. data/app/views/spree/admin/products/edit.html.erb +12 -1
  49. data/app/views/spree/admin/products/index.html.erb +11 -2
  50. data/app/views/spree/admin/prototypes/show.html.erb +2 -2
  51. data/app/views/spree/admin/shared/_main_menu.html.erb +19 -77
  52. data/app/views/spree/admin/shared/_order_tabs.html.erb +10 -83
  53. data/app/views/spree/admin/shared/_product_tabs.html.erb +12 -64
  54. data/app/views/spree/admin/store_credits/index.html.erb +9 -1
  55. data/app/views/spree/admin/users/_tabs.html.erb +11 -30
  56. data/app/views/spree/admin/users/_user_page_actions.html.erb +9 -1
  57. data/app/views/spree/admin/users/index.html.erb +11 -2
  58. data/app/views/spree/admin/variants/index.html.erb +12 -2
  59. data/config/locales/en.yml +6 -4
  60. data/lib/spree/backend/configuration.rb +0 -17
  61. data/lib/spree/backend/engine.rb +28 -1
  62. data/lib/spree/backend/version.rb +1 -1
  63. data/spree_backend.gemspec +2 -2
  64. data/yarn.lock +58 -22
  65. metadata +36 -17
  66. data/app/views/spree/admin/shared/sub_menu/_apps.html.erb +0 -3
  67. data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +0 -19
  68. data/app/views/spree/admin/shared/sub_menu/_content.html.erb +0 -4
  69. data/app/views/spree/admin/shared/sub_menu/_integrations.html.erb +0 -5
  70. data/app/views/spree/admin/shared/sub_menu/_orders.html.erb +0 -5
  71. data/app/views/spree/admin/shared/sub_menu/_organizations.html.erb +0 -3
  72. data/app/views/spree/admin/shared/sub_menu/_product.html.erb +0 -8
  73. data/app/views/spree/admin/shared/sub_menu/_promotion.html.erb +0 -4
  74. data/app/views/spree/admin/shared/sub_menu/_returns.html.erb +0 -4
  75. data/app/views/spree/admin/shared/sub_menu/_stock.html.erb +0 -4
@@ -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>
@@ -4,7 +4,18 @@
4
4
  </h5>
5
5
  </div>
6
6
  <% content_for :page_actions do %>
7
- <%= external_page_preview_link(@product) %>
7
+ <% stock_actions.items.each do |action| %>
8
+ <% next unless action.available?(current_ability) %>
9
+ <%= button_link_to(
10
+ Spree.t(action.label_translation_key),
11
+ action.url(@product),
12
+ class: action.classes,
13
+ icon: action.icon_key,
14
+ id: action.id,
15
+ target: action.target,
16
+ data: action.data_attributes
17
+ ) %>
18
+ <% end if product_actions&.items %>
8
19
  <% end %>
9
20
  <div class="card-body">
10
21
  <%= form_for [:admin, Spree::StockMovement.new], url: admin_stock_items_path do |f| %>
@@ -1,5 +1,16 @@
1
1
  <% content_for :page_actions do %>
2
- <%= external_page_preview_link(@product) %>
2
+ <% product_actions.items.each do |action| %>
3
+ <% next unless action.available?(current_ability) %>
4
+ <%= button_link_to(
5
+ Spree.t(action.label_translation_key),
6
+ action.url(@product),
7
+ class: action.classes,
8
+ icon: action.icon_key,
9
+ id: action.id,
10
+ target: action.target,
11
+ data: action.data_attributes
12
+ ) %>
13
+ <% end if product_actions&.items %>
3
14
  <% end %>
4
15
 
5
16
  <%= render partial: 'spree/admin/shared/product_tabs', locals: {current: :details} %>
@@ -3,8 +3,17 @@
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
- <%= button_link_to Spree.t(:new_product), new_object_url, { class: "btn-success", icon: 'add.svg', id: 'admin_new_product' } %>
7
- <% end if can?(:create, Spree::Product) %>
6
+ <% products_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 %>
8
17
 
9
18
  <% content_for :page_tabs do %>
10
19
  <li class="nav-item">
@@ -13,7 +13,7 @@
13
13
  <% ot.option_values.each do |ov| %>
14
14
  <li>
15
15
  <%= label_tag "option_value_#{ov.id}" do %>
16
- <%= check_box_tag "product[option_values_hash[#{ot.id}]][]", ov.id, params[:product] && (params[:product][:option_values_hash] || {}).values.flatten.include?(ov.id.to_s), id: "option_value_#{ov.id}", class: "option-value" %>
16
+ <%= check_box_tag "product[option_values_hash][#{ot.id}][]", ov.id, params[:product] && (params[:product][:option_values_hash] || {}).values.flatten.include?(ov.id.to_s), id: "option_value_#{ov.id}", class: "option-value" %>
17
17
  <div class="option-value__color" style="--presentation: <%= ov.presentation %>"></div>
18
18
  <% end %>
19
19
  </li>
@@ -23,7 +23,7 @@
23
23
  <ul class="option-type-values">
24
24
  <% ot.option_values.each do |ov| %>
25
25
  <li>
26
- <%= check_box_tag "product[option_values_hash[#{ot.id}]][]", ov.id, params[:product] && (params[:product][:option_values_hash] || {}).values.flatten.include?(ov.id.to_s), id: "option_value_#{ov.id}", class: "option-value" %>
26
+ <%= check_box_tag "product[option_values_hash][#{ot.id}][]", ov.id, params[:product] && (params[:product][:option_values_hash] || {}).values.flatten.include?(ov.id.to_s), id: "option_value_#{ov.id}", class: "option-value" %>
27
27
  <%= label_tag "option_value_#{ov.id}", ov.presentation %>
28
28
  </li>
29
29
  <% end %>
@@ -11,83 +11,25 @@
11
11
  </button>
12
12
  </div>
13
13
 
14
- <ul class="nav nav-sidebar" id="sidebarDashboard">
15
- <%= tab Spree.t('admin.home'), url: spree.admin_dashboard_path, match_path: '/dashboard', icon: 'house-door-fill.svg' %>
16
- </ul>
17
-
18
- <% if can? :admin, Spree::Order %>
19
- <ul class="nav nav-sidebar" id="sidebarOrder">
20
- <%= main_menu_tree Spree.t(:orders), icon: "inbox-fill.svg", sub_menu: "orders", url: "#sidebar-orders" %>
21
- </ul>
22
- <% end %>
23
-
24
- <% if can?(:admin, Spree::ReturnAuthorization) || can?(:admin, Spree::CustomerReturn) %>
25
- <ul class="nav nav-sidebar" id="sidebarReturn">
26
- <%= main_menu_tree Spree.t(:returns), icon: "reply-fill.svg", sub_menu: "returns", url: "#sidebar-returns" %>
27
- </ul>
28
- <% end %>
29
-
30
- <% if can? :admin, Spree::Product %>
31
- <ul class="nav nav-sidebar" id="sidebarProduct">
32
- <%= main_menu_tree Spree.t(:products), icon: "tags-fill.svg", sub_menu: "product", url: "#sidebar-product" %>
33
- </ul>
34
- <% end %>
35
-
36
- <% if can?(:admin, Spree::StockLocation) || can?(:admin, Spree::StockTransfer) %>
37
- <ul class="nav nav-sidebar" id="sidebarStock">
38
- <%= main_menu_tree Spree.t(:stock), icon: "box-seam.svg", sub_menu: "stock", url: "#sidebar-stock" %>
39
- </ul>
40
- <% end %>
41
-
42
- <% if can? :admin, Spree::Admin::ReportsController %>
43
- <ul class="nav nav-sidebar" id="sidebarReport">
44
- <%= tab *Spree::Backend::Configuration::REPORT_TABS, icon: 'pie-chart-fill.svg' %>
45
- </ul>
46
- <% end %>
47
-
48
- <% if can? :admin, Spree::Promotion %>
49
- <ul class="nav nav-sidebar" id="sidebarPromotion">
50
- <%= main_menu_tree Spree.t(:promotions), icon: "percent.svg", sub_menu: "promotion", url: "#sidebar-promotions" %>
51
- </ul>
52
- <% end %>
53
-
54
- <% if defined?(Spree::Vendor) && can?(:manage, Spree::Vendor) && can?(:index, Spree::Vendor) %>
55
- <ul class="nav nav-sidebar" id="sidebarOrganizations">
56
- <%= main_menu_tree Spree.t(:organizations), icon: "building.svg", sub_menu: "organizations", url: "#sidebar-organizations" %>
57
- </ul>
58
- <% end %>
59
-
60
- <% if Spree.user_class && can?(:admin, Spree.user_class) %>
61
- <ul class="nav nav-sidebar" id="sidebarUser">
62
- <%= tab *Spree::Backend::Configuration::USER_TABS, url: spree.admin_users_path, icon: 'people-fill.svg' %>
63
- </ul>
64
- <% end %>
65
-
66
- <% if can? :admin, Spree::Menu %>
67
- <ul class="nav nav-sidebar" id="sidebarMenu">
68
- <%= main_menu_tree Spree.t('admin.tab.content'), icon: "card-heading.svg", sub_menu: "content", url: "#sidebar-content" %>
69
- </ul>
70
- <% end %>
71
-
72
- <% if can?(:admin, Spree::Webhooks::Subscriber) || can?(:admin, Spree::PaymentMethod) %>
73
- <ul class="nav nav-sidebar" id="sidebarIntegrations">
74
- <%= main_menu_tree Spree.t('admin.tab.integrations'), icon: "stack.svg", sub_menu: "integrations", url: "#sidebar-integrations" %>
75
- </ul>
76
- <% end %>
77
-
78
- <% if can? :admin, Spree::OauthApplication %>
79
- <ul class="nav nav-sidebar" id="sidebarApps">
80
- <%= main_menu_tree Spree.t('admin.tab.apps'), icon: "terminal-fill.svg", sub_menu: "apps", url: "#sidebar-apps" %>
81
- </ul>
82
- <% end %>
83
-
84
- <% if can? :admin, current_store %>
85
- <ul class="nav nav-sidebar" id="sidebarConfiguration">
86
- <%= main_menu_tree Spree.t('admin.settings'), icon: "gear-fill.svg", sub_menu: "configuration", url: "#sidebar-configuration" %>
87
- </ul>
88
- <% elsif defined?(current_spree_vendor) && current_spree_vendor.present? %>
89
- <ul class="nav nav-sidebar" id="sidebarConfiguration">
90
- <%= main_menu_tree Spree.t('admin.settings'), icon: "gear-fill.svg", sub_menu: "vendor_configuration", url: "#sidebar-configuration" %>
14
+ <% main_menu.items.each do |item| %>
15
+ <% next unless item.available?(current_ability, current_store) %>
16
+
17
+ <ul class="nav nav-sidebar" id="sidebar<%= item.key.upcase %>>">
18
+ <% if item.children? %>
19
+ <li class="sidebar-menu-item d-block w-100 text-muted">
20
+ <%= main_menu_item(Spree.t(item.label_translation_key), url: "#sidebar-#{item.key}", icon: item.icon_key) %>
21
+
22
+ <ul id="sidebar-<%= item.key %>" class="collapse nav nav-pills nav-stacked pb-2" data-hook="admin_orders">
23
+ <% item.items.each do |section_item| %>
24
+ <% next unless section_item.available?(current_ability, current_store) %>
25
+
26
+ <%= tab(Spree.t(section_item.label_translation_key), url: section_item.url.is_a?(Proc) ? section_item.url.call(current_store) : section_item.url, match_path: section_item.match_path, icon: section_item.icon_key) %>
27
+ <% end %>
28
+ </ul>
29
+ </li>
30
+ <% else %>
31
+ <%= tab(Spree.t(item.label_translation_key), url: item.url.is_a?(Proc) ? item.url.call(current_store) : item.url, match_path: item.match_path, icon: item.icon_key) %>
32
+ <% end %>
91
33
  </ul>
92
34
  <% end %>
93
35
  </nav>
@@ -4,88 +4,15 @@
4
4
  <% end %>
5
5
 
6
6
  <% content_for :page_tabs do %>
7
- <% if ((can? :update, @order) && (@order.shipments.size.zero? || @order.shipments.shipped.size.zero?)) %>
8
- <li class="nav-item" data-hook='admin_order_tabs_cart_details'>
9
- <%= link_to_with_icon 'cart-check.svg',
10
- Spree.t(:cart),
11
- cart_admin_order_url(@order),
12
- class: "#{'active' if current == :cart} nav-link" %>
13
- </li>
14
- <% end %>
15
-
16
- <% if can? :update, @order %>
17
- <li class="nav-item" data-hook='admin_order_tabs_channel_details'>
18
- <%= link_to_with_icon 'funnel.svg',
19
- Spree.t(:channel),
20
- channel_admin_order_url(@order),
21
- class: "#{'active' if current == :channel} nav-link" %>
22
- </li>
23
- <% end %>
24
-
25
- <% if can?(:update, @order) && @order.checkout_steps.include?("address") %>
26
- <li class="nav-item" data-hook='admin_order_tabs_customer_details'>
27
- <%= link_to_with_icon 'person-lines-fill.svg',
28
- Spree.t(:customer),
29
- spree.admin_order_customer_url(@order),
30
- class: "#{'active' if current == :customer_details} nav-link" %>
31
- </li>
32
- <% end %>
33
-
34
- <% if can? :update, @order %>
35
- <li class="nav-item" data-hook='admin_order_tabs_shipment_details'>
36
- <%= link_to_with_icon 'truck.svg',
37
- Spree.t(:shipments),
38
- edit_admin_order_url(@order),
39
- class: "#{'active' if current == :shipments} nav-link" %>
40
- </li>
41
- <% end %>
42
-
43
- <% if can? :index, Spree::Adjustment %>
44
- <li class="nav-item" data-hook='admin_order_tabs_adjustments'>
45
- <%= link_to_with_icon 'adjust.svg',
46
- Spree.t(:adjustments),
47
- spree.admin_order_adjustments_url(@order),
48
- class: "#{'active' if current == :adjustments} nav-link" %>
49
- </li>
50
- <% end %>
51
-
52
- <% if can?(:index, Spree::Payment) %>
53
- <li class="nav-item" data-hook='admin_order_tabs_payments'>
54
- <%= link_to_with_icon 'credit-card.svg',
55
- Spree.t(:payments),
56
- spree.admin_order_payments_url(@order),
57
- class: "#{'active' if current == :payments} nav-link" %>
58
- </li>
59
- <% end %>
60
-
61
- <% if can? :index, Spree::ReturnAuthorization %>
62
- <% if @order.completed? %>
63
- <li class="nav-item" data-hook='admin_order_tabs_return_authorizations'>
64
- <%= link_to_with_icon 'enter.svg',
65
- Spree.t(:return_authorizations),
66
- spree.admin_order_return_authorizations_url(@order),
67
- class: "#{'active' if current == :return_authorizations} nav-link" %>
68
- </li>
69
- <% end %>
70
- <% end %>
71
-
72
- <% if can? :index, Spree::CustomerReturn %>
73
- <% if @order.completed? %>
74
- <li class="nav-item">
75
- <%= link_to_with_icon 'returns.svg',
76
- Spree.t(:customer_returns),
77
- spree.admin_order_customer_returns_url(@order),
78
- class: "#{'active' if current == :customer_returns} nav-link" %>
79
- </li>
80
- <% end %>
81
- <% end %>
82
-
83
- <% if can? :update, @order %>
84
- <li class="nav-item" data-hook='admin_order_tabs_state_changes'>
85
- <%= link_to_with_icon 'calendar3.svg',
86
- Spree::StateChange.human_attribute_name(:state_changes),
87
- spree.admin_order_state_changes_url(@order),
88
- class: "#{'active' if current == :state_changes} nav-link" %>
89
- </li>
7
+ <% order_tabs.items.each do |tab| %>
8
+ <% next unless tab.available?(current_ability, @order) %>
9
+ <%= content_tag :li, class: 'nav-item', data: { hook: tab.data_hook } do %>
10
+ <%= link_to_with_icon(
11
+ tab.icon_key,
12
+ Spree.t(tab.label_translation_key),
13
+ tab.url(@order),
14
+ class: tab.active?(current) ? 'active nav-link' : 'nav-link'
15
+ ) %>
16
+ <% end %>
90
17
  <% end %>
91
18
  <% end %>