-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Marketplace
: Archived Products
are hidden from Products#index
- #2023 Archived `Products` are no longer shown on the `Products` page.
- Loading branch information
Showing
7 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
app/furniture/marketplace/archivable/index_link_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= link_to text, location %> |
24 changes: 24 additions & 0 deletions
24
app/furniture/marketplace/archivable/index_link_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Marketplace | ||
class Archivable::IndexLinkComponent < Component | ||
attr_accessor :marketplace, :resource, :to_archive | ||
|
||
def initialize(marketplace:, resource:, to_archive:, **kwargs) | ||
self.marketplace = marketplace | ||
self.resource = resource | ||
self.to_archive = to_archive | ||
super(**kwargs) | ||
end | ||
|
||
def location | ||
if to_archive | ||
marketplace.location(child: resource, query_params: {archive: true}) | ||
else | ||
marketplace.location(child: resource) | ||
end | ||
end | ||
|
||
def text | ||
t(".#{resource}.#{to_archive ? :archive : :active}") | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
app/furniture/marketplace/archivable/index_link_component.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
en: | ||
delivery_areas: | ||
archive: "Archived Delivery Areas" | ||
active: "Active Delivery Areas" | ||
products: | ||
archive: "Archived Products" | ||
active: "Active Products" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Marketplace | ||
class Component < ApplicationComponent | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
spec/furniture/marketplace/archivable/index_link_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Marketplace::Archivable::IndexLinkComponent, type: :component do | ||
subject(:output) { render_inline(component) } | ||
|
||
let(:component) { described_class.new(marketplace:, resource:, to_archive: to_archive) } | ||
let(:to_archive) { false } | ||
let(:marketplace) { create(:marketplace) } | ||
|
||
context "when the resource is products" do | ||
let(:resource) { :products } | ||
|
||
it { is_expected.to have_link("Active Products", href: polymorphic_path(marketplace.location(child: :products))) } | ||
|
||
context "when to_archive" do | ||
let(:to_archive) { true } | ||
|
||
it { is_expected.to have_link("Archived Products", href: polymorphic_path(marketplace.location(child: :products), {archive: true})) } | ||
end | ||
end | ||
|
||
context "when the resource is delivery_areas" do | ||
let(:resource) { :delivery_areas } | ||
|
||
it { is_expected.to have_link("Active Delivery Areas", href: polymorphic_path(marketplace.location(child: :delivery_areas))) } | ||
|
||
context "when to_archive" do | ||
let(:to_archive) { true } | ||
|
||
it { is_expected.to have_link("Archived Delivery Areas", href: polymorphic_path(marketplace.location(child: :delivery_areas), {archive: true})) } | ||
end | ||
end | ||
end |