Skip to content

Commit

Permalink
Add a product state for deleted products
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Nov 30, 2023
1 parent 3288ca9 commit 4729130
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions admin/app/components/solidus_admin/products/status/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
class SolidusAdmin::Products::Status::Component < SolidusAdmin::BaseComponent
STATUSES = {
available: :green,
discontinued: :red
discontinued: :yellow,
deleted: :red,
}.freeze

def self.from_product(product)
new(status: product.available? ? :available : :discontinued)
status =
if product.deleted?
:deleted
elsif product.discontinued?
:discontinued
else
:available
end

new(status: status)
end

def initialize(status:)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
en:
available: 'Available'
discontinued: 'Discontinued'
deleted: 'Deleted'

0 comments on commit 4729130

Please sign in to comment.