Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🥔✨ Marketplace: DeliveryAreas may be Archived #2024

Merged
merged 9 commits into from
Dec 13, 2023

Conversation

zspencer
Copy link
Member

This adds the discard gem so that we can archive objects. It also updates the workflow for removing DeliveryArea to have an Archive step first.

Once a DeliveryArea is archived, it can not yet be restored; but it can be removed if there are no Orders associated with the DeliveryArea

@zspencer zspencer requested review from a team December 12, 2023 01:31
@zspencer
Copy link
Member Author

I decided to merge my PRs that were building on this one.

Copy link
Member

@anaulin anaulin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

Some suggestions below, but nothing blocking.

app/furniture/marketplace/delivery_area_component.html.erb Outdated Show resolved Hide resolved
app/furniture/marketplace/delivery_area_component.rb Outdated Show resolved Hide resolved
href: delivery_area.location, method: :delete, scheme: :secondary)
end

def discard_button?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: it feels like this method and the destroy_button? methods want to instead to be methods on Delivery Area, DeliveryArea#discardable? and DeliveryArea#destroyable?. Then those can be unit-tested in the model spec, and this component calls those methods to determine if the buttons can/should be displayed.

It also helps the model self-document its behavior in terms of when it can be discarded or destroyed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dig it! I've left the policy check but pulled out the state checks.

Copy link
Contributor

@rosschapman rosschapman Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same thing @anaulin!

Was thinking about how in React (or similar) -- which supposedly influences ViewComponent -- it wasn't encouraged to pass entities into a component but instead a view over the model1 with strong indirections already prepped so you wouldn't end up coupling your entity layer to your view layer so tightly. In that modality we'd have a view function like:

class MyComponent {
	constructor(data) {
		this.model = data;
	}

	showDiscardButton() {
		return this.model.canRemoveDeliveryArea;
	}
}

1 Presenter, view model, etc... but a simple data bag

<%- if params[:archive] %>
<%= link_to "Active", marketplace.location(child: :delivery_areas) %>
<%- else %>
<%= link_to "Archive", marketplace.location(child: :delivery_areas, query_params: { archive: true }) %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the links want to be say "Active areas" and "Archived areas" (or "Active delivery areas", if there is enough space), otherwise I'm not sure it's clear what they are for.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I've updated these too!

zspencer and others added 6 commits December 12, 2023 20:09
- #2014

This adds the `discard` gem so that we can archive objects. It also
updates the workflow for removing DeliveryArea to have an `Archive` step
first.

Once a `DeliveryArea` is archived, it can not yet be restored; but it
can be removed if there are no `Orders` associated with the
`DeliveryArea`
Now that we have a better idea how to use TurboFrames, the Streams seem
pretty unnecessary.

This also makes it so following links within the
`Marketplace::ManagementComponent` update the browser URL.
…nk (#2027)

* 🧹 `Marketplace`: `DeliveryArea` Strip TurboStreams

Now that we have a better idea how to use TurboFrames, the Streams seem
pretty unnecessary.

This also makes it so following links within the
`Marketplace::ManagementComponent` update the browser URL.

* ✨ `Marketplace`: Put Archived DeliveryAreas behind the `Archive` link
Co-authored-by: Ana Ulin <[email protected]>
Co-authored-by: Ana Ulin <[email protected]>
Co-authored-by: Ana Ulin <[email protected]>
@zspencer zspencer force-pushed the marketplace/delivery-areas-may-be-delisted branch from 2c75567 to e19398d Compare December 13, 2023 04:09
@zspencer zspencer force-pushed the marketplace/delivery-areas-may-be-delisted branch from 2533a11 to 854d0cf Compare December 13, 2023 04:30
@zspencer zspencer force-pushed the marketplace/delivery-areas-may-be-delisted branch from 854d0cf to 971df03 Compare December 13, 2023 04:30
@zspencer zspencer merged commit 9f029b2 into main Dec 13, 2023
4 checks passed
@zspencer zspencer deleted the marketplace/delivery-areas-may-be-delisted branch December 13, 2023 04:34
zspencer added a commit that referenced this pull request Feb 10, 2024
- #2198

When we added [archiving delivery areas], I didn't take into account
that `Marketplace#cart_for_shopper` was checking against all the
delivery areas.

This fixes that and adds a system spec to make sure we can still
checkout after!

[archiving delivery areas]: #2024
zspencer added a commit that referenced this pull request Feb 10, 2024
- #2198

When we added [archiving delivery areas], I didn't take into account
that `Marketplace#cart_for_shopper` was checking against all the
delivery areas.

This fixes that and adds a system spec to make sure we can still
checkout after!

[archiving delivery areas]: #2024
zspencer added a commit that referenced this pull request Feb 16, 2024
- #2198

When we added [archiving delivery areas], I didn't take into account
that `Marketplace#cart_for_shopper` was checking against all the
delivery areas.

This fixes that and adds a system spec to make sure we can still
checkout after!

[archiving delivery areas]: #2024
zspencer added a commit that referenced this pull request Feb 16, 2024
- #2198

When we added [archiving delivery areas], I didn't take into account
that `Marketplace#cart_for_shopper` was checking against all the
delivery areas.

This fixes that and adds a system spec to make sure we can still
checkout after!

[archiving delivery areas]: #2024
zspencer added a commit to zinc-collective/tobias that referenced this pull request Mar 25, 2024
- zinc-collective#2198

When we added [archiving delivery areas], I didn't take into account
that `Marketplace#cart_for_shopper` was checking against all the
delivery areas.

This fixes that and adds a system spec to make sure we can still
checkout after!

[archiving delivery areas]: zinc-collective#2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants