Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Admin: Added universal delete link in content header

Damian Legawiecf7fa85a0172a
diff --git a/admin/app/views/spree/admin/products/edit.html.erb b/admin/app/views/spree/admin/products/edit.html.erb
index edad86f583..92b9aaa3a0 100644
--- a/admin/app/views/spree/admin/products/edit.html.erb
+++ b/admin/app/views/spree/admin/products/edit.html.erb
@@ -1,7 +1,7 @@
<% content_for :page_actions_dropdown do %>
<%= link_to_edit_translations(@product) %>
<%= link_to_with_icon(
- "file",
+ "files",
Spree.t(:digital_assets),
spree.admin_product_digital_assets_path(@product),
class: "dropdown-item",
@@ -15,7 +15,7 @@
<% if can?(:clone, @product) %>
<%= link_to_with_icon(
- "copy",
+ "copy-check",
Spree.t(:clone),
spree.clone_admin_product_path(@product),
class: "dropdown-item",
diff --git a/admin/app/views/spree/admin/shared/_content_header.html.erb b/admin/app/views/spree/admin/shared/_content_header.html.erb
index 7202be55d8..59f998d1ac 100644
--- a/admin/app/views/spree/admin/shared/_content_header.html.erb
+++ b/admin/app/views/spree/admin/shared/_content_header.html.erb
@@ -1,4 +1,4 @@
-<% record = @customer_return || @order || @product || @vendor || @user || @taxon || @object %>
+<% record = @object || @customer_return || @order || @product || @vendor || @user || @taxon || @store_credit %>
<% record = nil if @user&.is_a?(Spree.admin_user_class) %>
<% show_record_subtitle = record && record.persisted? && record.has_attribute?(:updated_at) %>
@@ -45,7 +45,7 @@
<div data-controller="clipboard">
<%= hidden_field_tag :record_number, record.number, data: { clipboard_target: 'source' } %>
<button data-action="clipboard#copy" class="text-left dropdown-item">
- <%= icon 'files' %>
+ <%= icon 'copy' %>
<%= 'Copy number' %>
</button>
</div>
@@ -53,10 +53,17 @@
<div data-controller="clipboard">
<%= hidden_field_tag :record_id, record.id, data: { clipboard_target: 'source' } %>
<button data-action="clipboard#copy" class="text-left dropdown-item">
- <%= icon 'files.svg' %>
+ <%= icon 'copy' %>
<%= Spree.t(:copy_id) %>
</button>
</div>
+
+ <% if %w[show edit].include?(action_name) && record.respond_to?(:can_be_deleted?) && record.can_be_deleted? && can?(:destroy, record) %>
+ <% destroy_path = @parent ? [:admin, @parent, record] : [:admin, record] %>
+
+ <div class="dropdown-divider"></div>
+ <%= link_to_with_icon 'trash', Spree.t('actions.destroy'), destroy_path, class: 'dropdown-item btn-danger', data: { turbo_method: :delete, turbo_confirm: Spree.t(:are_you_sure) } %>
+ <% end %>
<% end %>
</div>
</div>
diff --git a/admin/app/views/spree/admin/translations/edit.html.erb b/admin/app/views/spree/admin/translations/edit.html.erb
index e6d93d4510..4585f8d5eb 100644
--- a/admin/app/views/spree/admin/translations/edit.html.erb
+++ b/admin/app/views/spree/admin/translations/edit.html.erb
@@ -1,6 +1,6 @@
<% content_for :page_title do %>
<%= page_header_back_button @back_path %>
- <span class="mr-3"><%= Spree.t(:translations_for, resource_name: @resource_name) %></span>
+ <span class="mr-3"><%= Spree.t(:translations_for, resource_name: @resource.try(:name)) %></span>
<% end %>
<% if @locales.any?%>
<% if @locales.many? %>