-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
Introduce backoffice UI uplift #8996
Introduce backoffice UI uplift #8996
Conversation
35b3968
to
c599c00
Compare
08257d5
to
a6fceba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting! Really cool work. Thank you.
But 66 commits for review? I think that it can be cleaned up a bit before a proper review. I looked through it all and left some random comments but it was too much to gain deep understanding, especially because some commits undo previous commits.
I wasn't sure with which goal you wanted this reviewed. I guess you've done a lot of work and wanted some affirmation that you are going in the right direction. I think you are.
@@ -0,0 +1,11 @@ | |||
# frozen_string_literal: true | |||
|
|||
class NewProductsPageConstraint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we can write a generic constraint factory because they are all the same except the feature toggle name.
app/components/super_selector_component/super_selector_component.html.haml
Outdated
Show resolved
Hide resolved
app/components/search_input_component/search_input_component.html.haml
Outdated
Show resolved
Hide resolved
🙏
You're absolutely right, will do some git history cleaning. Back
I think that's it. I just wanted to have a small affirmation. Thanks! 🙏 |
91f2b9b
to
d75697f
Compare
I think I'm ready now. Much more clean, and only 35 commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
It's really cool to see it all working.
I tried to see the requests in the browser network console but they didn't show up. I guess that it's because it's using an open connection?
I reckon that this is good to be merged and then we can improve it. It's a lot of code. I hope that it will be less code than the old products page. 😉
app/components/products_table_component/products_table_component.html.haml
Outdated
Show resolved
Hide resolved
app/components/super_selector_component/super_selector_component.html.haml
Outdated
Show resolved
Hide resolved
d823455
to
c32469e
Compare
a29902b
to
bc40fa9
Compare
Yeah, all of that with stimulus reflex and action cable, well done !!! Few comments regarding UI
If you want a hand regarding polishing the design, I can help I like working on this kind of details :) Great job, exciting ! |
bc40fa9
to
ec1def2
Compare
Thanks @seballot !
Right, I'll make the changes needed. (done ✔️ )
Oh ... 😊 I'd be happy if you could have a look... I can't refuse such a proposition!
🙏 💪 🎉 |
ec1def2
to
08da016
Compare
Yes I think it would be the best, so I could directly work on openfoodfoundation/wishlist#255, applying the changes to both the old code and to your new code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of complexity and coupling here and things being mixed together that maybe shouldn't be. I think we'd be better off if we start with the least amount of complexity first, and then add complexity where it's necessary and justified. I'd like to go in a different direction with this first PR, as it'll be foundational for the rest of the work. I'm thinking:
- Remove the
ViewComponentReflex
library for now, I don't think we need it here - Break up this mega-component (
ProductsTableComponent
) into smaller parts so they're not all nested and dependant on each other - Keep everything as simple as possible and keep any components small and generic
- Define the code for the reflexes outside of the components, the only ones we're using here are simple and generic, which means they are potentially re-usable outside of these components
- Are we writing multiple bespoke dropdowns components from scratch? Can we use a nice dropdown library instead?
- There's quite a bit of UX behaviour being handled via reflexes which should just be handled by simple StimulusJS code on the client side instead, eg; opening and closing dropdowns shouldn't require triggering a reflex (which involves a call to the server)
= render partial: 'spree/admin/shared/product_sub_menu' | ||
|
||
#products_page | ||
= render(ProductsTableComponent.new(user: spree_current_user)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parts of the view layer wrapped up inside this component can just be separate parts; the filters, the table, and the pagination buttons.
A lot of the logic that this component holds can be pulled out and kept in separate places; the reflex methods can be in Reflexes and most of the other logic is for fetching the products from the database, which should live in the index
action of the Admin::ProductsController
.
Already done in "controllers"
(this key was added during the development of the PR)
866304b
to
5002870
Compare
Controller were instanced twice.
This one is probably (re, re) ready for review ; I'd be happy to have feedback from @binarygit @dacook or @abdellani |
@@ -0,0 +1,38 @@ | |||
# frozen_string_literal: true | |||
|
|||
class ExampleReflex < ApplicationReflex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I let that file because it contains a lot of documentation. But maybe we need to remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @binarygit wanted to keep this as a reference, let's hear his opinion.
But maybe as we are getting more literate with Stimulus, we don't need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it contains alot of good information which is why I like keeping it around. I think it's okay to keep it, no? 😄
{ label: I18n.t("admin.products_page.columns.#{column}"), value: column, | ||
sortable: SORTABLE_COLUMNS.include?(column) } | ||
}.sort! { |a, b| a[:label] <=> b[:label] } | ||
@columns.unshift(ALL_COLUMN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct me if I'm wrong.
Looks like ALL_COLUMN
only stored the name
column. Maybe we can find a better name for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right!
- if @image | ||
.image | ||
= image_tag @image.url(:mini) | ||
= @name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looks good.
Just wondering if it'll be better to add a case for name
openfoodnetwork/app/components/product_component.rb
Lines 17 to 28 in 500c4e8
def column_value(column) | |
case column | |
when 'price' | |
@product.price | |
when 'unit' | |
"#{@product.unit_value} #{@product.variant_unit}" | |
when 'producer' | |
@product.supplier.name | |
when 'category' | |
@product.taxons.map(&:name).join(', ') | |
end | |
end |
then you'll add one guard clause for the image, this will maybe require some CSS changes, something like:
%td.products_column{class: column[:id]}
- if column[:id] == "name" && @image
.image
= image_tag @image.url(:mini)
= column[:value]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way simpler. Thanks! 🙏
0a19148
to
a827844
Compare
Okay @jibees let's move this to Test Ready, no? 💪 |
@openfoodfoundation/testers I will take this one on as this is behind a feature toggle / the first of many PR before we reach a version ready to be tested in and out. |
@jibees I will merge because the feature toggle is working fine and this PR is a monster :D . However I'm not sure what you meant by "the missing part is to print a product row". I see the following missing bits to close the issue:
current: Previous:
Previous current
|
That what I meant by "the missing part is to print a product row"
Seems like I forgot some of them right.
Probably a miss too. |
What? Why?
Part of #8930
As this PR is long enough, I do prefer divide it into two.
This one introduce the read-only new page in the admin section, behind a feature toggle (the feature toggle is
new_products_page
):/admin/new_products
. The missing part is to print a product row as it is specified in the issue #8930Some screenshots
What should we test?
This PR is more for a code review purpose than a real test, as the page is still not functional.
Release notes
Prepare the new Products page
Changelog Category: Technical changes