Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Added active_badge helper method for nice status badges across the Admin UI
Damian Legawiecda7668cbf5e3
diff --git a/backend/app/helpers/spree/admin/navigation_helper.rb b/backend/app/helpers/spree/admin/navigation_helper.rbindex b5b8d02e90..b256fd765d 100644--- a/backend/app/helpers/spree/admin/navigation_helper.rb+++ b/backend/app/helpers/spree/admin/navigation_helper.rb@@ -251,6 +251,16 @@ module Spreeendend+ def active_badge(condition, options = {})+ label = options[:label]+ label ||= condition ? Spree.t(:say_yes) : Spree.t(:say_no)+ css_class = condition ? 'badge-active' : 'badge-inactive'++ content_tag(:strong, class: "badge #{css_class} text-uppercase") do+ label+ end+ end+def main_part_classesif cookies['sidebar-minimized'] == 'true''col-12 sidebar-collapsed'diff --git a/backend/app/views/spree/admin/customer_returns/index.html.erb b/backend/app/views/spree/admin/customer_returns/index.html.erbindex ef88039435..589250678b 100644--- a/backend/app/views/spree/admin/customer_returns/index.html.erb+++ b/backend/app/views/spree/admin/customer_returns/index.html.erb@@ -32,9 +32,9 @@<td><%= pretty_time(customer_return.created_at) %></td><td><% if customer_return.fully_reimbursed? %>- <span class="badge badge-success"><%= Spree.t(:reimbursed) %></span>+ <strong class="badge badge-success text-uppercase"><%= Spree.t(:reimbursed) %></strong><% else %>- <span class="badge badge-info"><%= Spree.t(:incomplete) %></span>+ <strong class="badge badge-inactive text-uppercase"><%= Spree.t(:incomplete) %></strong><% end %></td><td class='actions actions-1' data-hook="admin_orders_customer_returns_index_row_actions">diff --git a/backend/app/views/spree/admin/option_types/index.html.erb b/backend/app/views/spree/admin/option_types/index.html.erbindex 133a138054..f5f17a14f4 100644--- a/backend/app/views/spree/admin/option_types/index.html.erb+++ b/backend/app/views/spree/admin/option_types/index.html.erb@@ -30,7 +30,7 @@</td><td><%= option_type.name %></td><td class="presentation"><%= option_type.presentation %></td>- <td><%= option_type.filterable %></td>+ <td><%= active_badge(option_type.filterable) %></td><td class="actions actions-2 text-right"><%= link_to_edit(option_type, class: 'admin_edit_option_type', no_text: true) if can?(:edit, option_type) %><%= link_to_delete(option_type, no_text: true) if can?(:delete, option_type) %>diff --git a/backend/app/views/spree/admin/payment_methods/index.html.erb b/backend/app/views/spree/admin/payment_methods/index.html.erbindex 681d2129e8..9bff1c3cb4 100644--- a/backend/app/views/spree/admin/payment_methods/index.html.erb+++ b/backend/app/views/spree/admin/payment_methods/index.html.erb@@ -30,7 +30,7 @@<td><%= method.name %></td><td><%= method.type.split('::', 3).last %></td><td class="text-center"><%= Spree.t(method.display_on) %></td>- <td class="text-center"><%= method.active ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>+ <td class="text-center"><%= active_badge(method.active) %></td><td data-hook="admin_payment_methods_index_row_actions" class="actions actions-2 text-right"><%= link_to_edit(method, no_text: true) if can? :edit, method %><%= link_to_delete(method, no_text: true) if can? :delete, method %>diff --git a/backend/app/views/spree/admin/products/index.html.erb b/backend/app/views/spree/admin/products/index.html.erbindex 62ecbf4e5c..1864036234 100644--- a/backend/app/views/spree/admin/products/index.html.erb+++ b/backend/app/views/spree/admin/products/index.html.erb@@ -64,6 +64,7 @@</thead><tbody><% @collection.each do |product| %>+ <% available_status = available_status(product) %><tr <%== "style='color: red;'" if product.deleted? %> id="<%= spree_dom_id product %>" data-hook="admin_products_index_rows" class="<%= cycle('odd', 'even') %>"><td scope="row" class="image"><%= link_to edit_admin_product_path(product) do %>@@ -72,7 +73,7 @@</td><td><%= link_to product.try(:name), edit_admin_product_path(product) %></td><td class="sku"><%= product.sku rescue '' %></td>- <td class="status"><%= available_status(product) %> </td>+ <td class="status"><%= active_badge(available_status == Spree.t(:available), label: available_status) %></td><td class="text-center"><%= display_price(product) %></td><td class="actions " data-hook="admin_products_index_row_actions"><span class="d-flex justify-content-end">diff --git a/backend/app/views/spree/admin/return_authorizations/index.html.erb b/backend/app/views/spree/admin/return_authorizations/index.html.erbindex 7812054834..fc3f374d8a 100644--- a/backend/app/views/spree/admin/return_authorizations/index.html.erb+++ b/backend/app/views/spree/admin/return_authorizations/index.html.erb@@ -27,9 +27,9 @@<tr id="<%= spree_dom_id(return_authorization) %>" data-hook="rma_row"><td><%= return_authorization.number %></td><td>- <span class="badge badge-<%= return_authorization.state %>">+ <strong class="badge badge-<%= return_authorization.state %> text-uppercase"><%= Spree.t("return_authorization_states.#{return_authorization.state}") %>- </span>+ </strong></td><td><%= return_authorization.display_pre_tax_total.to_html %></td><td><%= pretty_time(return_authorization.created_at) %></td>diff --git a/backend/app/views/spree/admin/return_index/customer_returns.html.erb b/backend/app/views/spree/admin/return_index/customer_returns.html.erbindex e5c1ea6592..0052cc2fa3 100644--- a/backend/app/views/spree/admin/return_index/customer_returns.html.erb+++ b/backend/app/views/spree/admin/return_index/customer_returns.html.erb@@ -41,9 +41,9 @@<td><%= link_to customer_return.order.number, spree.edit_admin_order_path(customer_return.order) %></td><td><% if customer_return.fully_reimbursed? %>- <span class="badge badge-success"><%= Spree.t(:reimbursed) %></span>+ <span class="badge badge-success text-uppercase"><%= Spree.t(:reimbursed) %></span><% else %>- <span class="badge badge-info"><%= Spree.t(:incomplete) %></span>+ <span class="badge badge-inactive text-uppercase"><%= Spree.t(:incomplete) %></span><% end %></td><td><%= customer_return.display_pre_tax_total.to_html %></td>diff --git a/backend/app/views/spree/admin/return_index/return_authorizations.html.erb b/backend/app/views/spree/admin/return_index/return_authorizations.html.erbindex c97864d65f..e1f4d9685e 100644--- a/backend/app/views/spree/admin/return_index/return_authorizations.html.erb+++ b/backend/app/views/spree/admin/return_index/return_authorizations.html.erb@@ -63,7 +63,7 @@<td><%= link_to return_authorization.number, spree.edit_admin_order_return_authorization_path(return_authorization.order, return_authorization) %></td><td><%= link_to return_authorization.order.number, spree.edit_admin_order_path(return_authorization.order) %></td><td>- <span class="badge badge-<%= return_authorization.state %>"><%= Spree.t("return_authorization_states.#{return_authorization.state}") %></span>+ <span class="badge badge-<%= return_authorization.state %> text-uppercase"><%= Spree.t("return_authorization_states.#{return_authorization.state}") %></span></td><td class="actions actions-1 text-right"><%= link_to_edit return_authorization, url: spree.edit_admin_order_return_authorization_path(return_authorization.order, return_authorization), no_text: true if can?(:edit, return_authorization) %>diff --git a/backend/app/views/spree/admin/shared/named_types/_index.html.erb b/backend/app/views/spree/admin/shared/named_types/_index.html.erbindex bd46207fcd..0e5c91fe9b 100644--- a/backend/app/views/spree/admin/shared/named_types/_index.html.erb+++ b/backend/app/views/spree/admin/shared/named_types/_index.html.erb@@ -23,7 +23,7 @@<%= named_type.name %></td><td class="align-center">- <%= Spree.t(named_type.active? ? :active : :inactive) %>+ <%= active_badge(named_type.active, label: Spree.t(named_type.active? ? :active : :inactive)) %></td><td class="actions actions-1 text-right"><% if named_type.mutable? %>diff --git a/backend/app/views/spree/admin/stock_locations/index.html.erb b/backend/app/views/spree/admin/stock_locations/index.html.erbindex 2fbd3fe309..fecd858c4e 100644--- a/backend/app/views/spree/admin/stock_locations/index.html.erb+++ b/backend/app/views/spree/admin/stock_locations/index.html.erb@@ -12,8 +12,8 @@<thead><tr data-hook="stock_locations_header"><th><%= Spree.t(:name) %></th>- <th><%= Spree.t(:status) %></th><th><%= Spree.t(:stock_movements) %></th>+ <th><%= Spree.t(:status) %></th><th class="actions"></th></tr></thead>@@ -24,8 +24,8 @@%><tr id="<%= spree_dom_id stock_location %>" data-hook="stock_location_row"><td><%= display_name(stock_location) %></td>- <td><span class="state <%= state(stock_location) %>"><%= Spree.t(state(stock_location)) %></span></td><td><%= link_to Spree.t(:stock_movements), admin_stock_location_stock_movements_path(stock_location.id) %> </td>+ <td><%= active_badge(stock_location.active, label: Spree.t(state(stock_location))) %></td><td class="actions actions-2 text-center"><%= link_to_edit(stock_location, no_text: true) if can? :create, stock_location %><%= link_to_delete(stock_location, no_text: true) if can? :create, stock_location %>diff --git a/backend/app/views/spree/admin/stores/index.html.erb b/backend/app/views/spree/admin/stores/index.html.erbindex 16982a6d68..753550f919 100644--- a/backend/app/views/spree/admin/stores/index.html.erb+++ b/backend/app/views/spree/admin/stores/index.html.erb@@ -22,7 +22,7 @@<td><%= store.unique_name %></td><td><%= link_to store.url, 'https://' + store.url, target: :blank %></td><td><%= store.default_currency %></td>- <td><%= store.default ? "<strong>#{Spree.t(:say_yes)}</strong>".html_safe : Spree.t(:say_no) %>+ <td><%= active_badge(store.default) %></td><td class="actions actions-2 text-right" data-hook="admin_stores_index_row_actions"><% if can?(:edit, store) && !store.default %><%= link_to_with_icon('save.svg', Spree.t(:store_set_default_button), spree.set_default_admin_store_path(store), no_text: true, method: :put, class: 'btn btn-warning btn-sm with-tip') %>diff --git a/backend/app/views/spree/admin/tax_categories/index.html.erb b/backend/app/views/spree/admin/tax_categories/index.html.erbindex cb365700a3..72772e2fce 100644--- a/backend/app/views/spree/admin/tax_categories/index.html.erb+++ b/backend/app/views/spree/admin/tax_categories/index.html.erb@@ -27,7 +27,7 @@<td><%= tax_category.name %></td><td><%= tax_category.tax_code %></td><td><%= tax_category.description %></td>- <td><%= tax_category.is_default? ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>+ <td><%= active_badge(tax_category.is_default?) %></td><td class="actions actions-2 text-right"><%= link_to_edit(tax_category, no_text: true) if can? :edit, tax_category %><%= link_to_delete(tax_category, no_text: true) if can? :delete, tax_category %>diff --git a/backend/app/views/spree/admin/tax_rates/index.html.erb b/backend/app/views/spree/admin/tax_rates/index.html.erbindex d7d875c883..0b8d7a5a1d 100644--- a/backend/app/views/spree/admin/tax_rates/index.html.erb+++ b/backend/app/views/spree/admin/tax_rates/index.html.erb@@ -28,8 +28,8 @@<td><%=tax_rate.name %></td><td><%=tax_rate.tax_category.try(:name) || Spree.t(:not_available) %></td><td><%=tax_rate.amount %></td>- <td><%=tax_rate.included_in_price? ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>- <td><%=tax_rate.show_rate_in_label? ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>+ <td><%= active_badge(tax_rate.included_in_price?) %></td>+ <td><%= active_badge(tax_rate.show_rate_in_label?) %></td><td><%=tax_rate.calculator.to_s %></td><td class="actions actions-2 text-right"><%= link_to_edit(tax_rate, no_text: true) if can? :edit, tax_rate %>diff --git a/backend/app/views/spree/admin/zones/index.html.erb b/backend/app/views/spree/admin/zones/index.html.erbindex 26dba263d0..5d5808dba6 100644--- a/backend/app/views/spree/admin/zones/index.html.erb+++ b/backend/app/views/spree/admin/zones/index.html.erb@@ -24,7 +24,7 @@<tr id="<%= spree_dom_id zone %>" data-hook="zones_row"><td><%= zone.name %></td><td><%= zone.description %></td>- <td><%= zone.default_tax? ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>+ <td><%= active_badge(zone.default_tax?) %></td><td class="actions actions-2 text-right"><%= link_to_edit(zone, no_text: true) if can? :edit, zone %><%= link_to_delete(zone, no_text: true) if can? :delete, zone %>diff --git a/backend/spec/features/admin/configuration/countries_spec.rb b/backend/spec/features/admin/configuration/countries_spec.rbindex 21d36866d4..c6ac79bb76 100644--- a/backend/spec/features/admin/configuration/countries_spec.rb+++ b/backend/spec/features/admin/configuration/countries_spec.rb@@ -19,8 +19,8 @@ module Spreeexpect(page).to have_content('Brazil')expect(page).to have_content('BRL')- expect(page).to have_content('Yes')- expect(page).to have_content('No')+ expect(page).to have_content('YES')+ expect(page).to have_content('NO')accept_confirm doclick_icon :deletediff --git a/backend/spec/features/admin/orders/customer_details_spec.rb b/backend/spec/features/admin/orders/customer_details_spec.rbindex d2a1a13570..1942149278 100644--- a/backend/spec/features/admin/orders/customer_details_spec.rb+++ b/backend/spec/features/admin/orders/customer_details_spec.rb@@ -100,7 +100,7 @@ describe 'Customer Details', type: :feature, js: true do# Regression test for #2950 + #2433# This act should transition the state of the order as far as it will go toowithin('#order_tab_summary') do- expect(page).to have_css('.state', text: 'complete')+ expect(page).to have_css('.state', text: 'COMPLETE')endenddiff --git a/backend/spec/features/admin/orders/new_order_spec.rb b/backend/spec/features/admin/orders/new_order_spec.rbindex 9e5ab0f05a..3865eead43 100644--- a/backend/spec/features/admin/orders/new_order_spec.rb+++ b/backend/spec/features/admin/orders/new_order_spec.rb@@ -141,7 +141,7 @@ describe 'New Order', type: :feature doclick_on 'Payments'click_on 'Continue'- expect(page).to have_css('.additional-info .state', text: 'complete')+ expect(page).to have_css('.additional-info .state', text: 'COMPLETE')endenddiff --git a/backend/spec/features/admin/orders/order_details_spec.rb b/backend/spec/features/admin/orders/order_details_spec.rbindex 6403dfdb24..d1a0093538 100644--- a/backend/spec/features/admin/orders/order_details_spec.rb+++ b/backend/spec/features/admin/orders/order_details_spec.rb@@ -588,7 +588,7 @@ describe 'Order Details', type: :feature, js: true doendend- context 'display order summary' do+ context 'display order summary', js: false dobefore dovisit spree.cart_admin_order_path(order)enddiff --git a/backend/spec/features/admin/orders/payments_spec.rb b/backend/spec/features/admin/orders/payments_spec.rbindex e724cf4dad..7122bdf1c5 100644--- a/backend/spec/features/admin/orders/payments_spec.rb+++ b/backend/spec/features/admin/orders/payments_spec.rb@@ -61,17 +61,17 @@ describe 'Payments', type: :feature, js: true dowithin_row(1) doexpect(column_text(3)).to eq('$150.00')expect(column_text(4)).to eq('Credit Card')- expect(column_text(6)).to eq('checkout')+ expect(column_text(6)).to eq('CHECKOUT')endclick_icon :void- expect(page).to have_css('#payment_status', exact_text: 'balance due')+ expect(page).to have_css('#payment_status', exact_text: 'BALANCE DUE')expect(page).to have_content('Payment Updated')within_row(1) doexpect(column_text(3)).to eq('$150.00')expect(column_text(4)).to eq('Credit Card')- expect(column_text(6)).to eq('void')+ expect(column_text(6)).to eq('VOID')endwithin find('#contentHeader') doclick_on 'New Payment'@@ -82,7 +82,7 @@ describe 'Payments', type: :feature, js: true doclick_icon(:capture)- expect(page).to have_css('#payment_status', exact_text: 'paid')+ expect(page).to have_css('#payment_status', exact_text: 'PAID')expect(page).not_to have_selector('#new_payment_section')end