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

Introduce backoffice UI uplift #8996

Merged
merged 49 commits into from
Dec 14, 2022

Conversation

jibees
Copy link
Contributor

@jibees jibees commented Mar 14, 2022

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 #8930

Some screenshots

Capture d’écran 2022-03-25 à 14 58 49

Capture d’écran 2022-03-25 à 14 56 40

Capture d’écran 2022-03-25 à 14 56 26

Capture d’écran 2022-03-25 à 14 56 18

Capture d’écran 2022-03-25 à 14 55 49

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

@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch from 35b3968 to c599c00 Compare March 15, 2022 15:13
@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch from 08257d5 to a6fceba Compare March 25, 2022 13:26
@jibees jibees self-assigned this Mar 25, 2022
@jibees jibees marked this pull request as ready for review March 25, 2022 13:58
Copy link
Member

@mkllnk mkllnk left a 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
Copy link
Member

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/views/admin/products/index.html.haml Outdated Show resolved Hide resolved
app/webpacker/css/admin/all.scss Outdated Show resolved Hide resolved
app/views/admin/products/index.html.haml Outdated Show resolved Hide resolved
app/webpacker/controllers/hello_controller.js Outdated Show resolved Hide resolved
app/components/product_component.rb Outdated Show resolved Hide resolved
app/reflexes/application_reflex.rb Outdated Show resolved Hide resolved
app/reflexes/application_reflex.rb Outdated Show resolved Hide resolved
@jibees
Copy link
Contributor Author

jibees commented Mar 28, 2022

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.

You're absolutely right, will do some git history cleaning. Back in dev

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.

I think that's it. I just wanted to have a small affirmation. Thanks! 🙏

@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch 4 times, most recently from 91f2b9b to d75697f Compare March 28, 2022 09:33
@jibees
Copy link
Contributor Author

jibees commented Mar 28, 2022

I think I'm ready now. Much more clean, and only 35 commits.

Copy link
Member

@mkllnk mkllnk left a 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. 😉

@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch 5 times, most recently from d823455 to c32469e Compare March 29, 2022 12:21
app/components/super_selector_component.rb Outdated Show resolved Hide resolved
app/components/products_table_component.rb Show resolved Hide resolved
@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch from a29902b to bc40fa9 Compare March 30, 2022 07:23
@seballot
Copy link
Contributor

seballot commented Apr 3, 2022

Yeah, all of that with stimulus reflex and action cable, well done !!!

Few comments regarding UI

  • The select box should open when we click anywhere in the input, currently it open only when clicking on the right arrow
  • some elements does not fit quite with the design : missing grey background, table should have a large grey border-bottom, not a box-shadow, elements should have border-radius, floating labels should be smaller than input text and others, table header background should be darker and without border separation, pagination should be hidden when there is only one page, and probably some more :)

If you want a hand regarding polishing the design, I can help I like working on this kind of details :)

Great job, exciting !

@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch from bc40fa9 to ec1def2 Compare April 4, 2022 07:16
@jibees
Copy link
Contributor Author

jibees commented Apr 4, 2022

Yeah, all of that with stimulus reflex and action cable, well done !!!

Thanks @seballot !

Few comments regarding UI

  • The select box should open when we click anywhere in the input, currently it open only when clicking on the right arrow

Right, I'll make the changes needed. (done ✔️ )

  • some elements does not fit quite with the design : missing grey background, table should have a large grey border-bottom, not a box-shadow, elements should have border-radius, floating labels should be smaller than input text and others, table header background should be darker and without border separation, pagination should be hidden when there is only one page, and probably some more :)

If you want a hand regarding polishing the design, I can help I like working on this kind of details :)

Oh ... 😊 I'd be happy if you could have a look... I can't refuse such a proposition! Would like to commit little as possible, I can then do some git history cleaning by squashing commits together after? (it seems to be difficult as files have been moved, ...)

Great job, exciting !

🙏 💪 🎉

@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch from ec1def2 to 08da016 Compare April 4, 2022 08:16
@seballot
Copy link
Contributor

seballot commented Apr 4, 2022

Hi @jibees ! Ok I will first finish the report refactor #9032 , then I'll try to participate in the UI uplift :)

@jibees
Copy link
Contributor Author

jibees commented Apr 5, 2022

Hi @jibees ! Ok I will first finish the report refactor #9032 , then I'll try to participate in the UI uplift :)

Yes!
Maybe we could open a new PR if this one is merged in the meantime.

@seballot
Copy link
Contributor

seballot commented Apr 5, 2022

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

Copy link
Contributor

@Matt-Yorkley Matt-Yorkley left a 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))
Copy link
Contributor

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.

@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch from 866304b to 5002870 Compare December 7, 2022 14:09
@jibees
Copy link
Contributor Author

jibees commented Dec 7, 2022

This one is probably (re, re) ready for review ; I'd be happy to have feedback from @binarygit @dacook or @abdellani

@abdellani abdellani self-requested a review December 7, 2022 16:20
@@ -0,0 +1,38 @@
# frozen_string_literal: true

class ExampleReflex < ApplicationReflex
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Member

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.

Copy link
Contributor Author

@jibees jibees Dec 12, 2022

Choose a reason for hiding this comment

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

Right!

918827c

- if @image
.image
= image_tag @image.url(:mini)
= @name
Copy link
Member

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

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]

Copy link
Contributor Author

@jibees jibees Dec 12, 2022

Choose a reason for hiding this comment

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

Way simpler. Thanks! 🙏

0a19148

@jibees jibees force-pushed the introduce-backoffice-ui-uplift branch from 0a19148 to a827844 Compare December 12, 2022 14:20
@sigmundpetersen
Copy link
Contributor

Okay @jibees let's move this to Test Ready, no? 💪

@RachL
Copy link
Contributor

RachL commented Dec 14, 2022

@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.

@RachL RachL self-assigned this Dec 14, 2022
@RachL RachL added the pr-staged-fr staging.coopcircuits.fr label Dec 14, 2022
@RachL
Copy link
Contributor

RachL commented Dec 14, 2022

@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:

  • display variants and display the placeholder when there is no picture

current:

image

Previous:

image

  • display missing columns : We can turn "import date" as "last update" like in the design but other than that I don't think we should loose columns?

Previous

image

current

image

  • I see you've chosen to do all filter boxes the same size: it was easier i guess? On the design, sizes vary:

image

@RachL RachL merged commit fd95970 into openfoodfoundation:master Dec 14, 2022
@RachL RachL removed the pr-staged-fr staging.coopcircuits.fr label Dec 14, 2022
@jibees
Copy link
Contributor Author

jibees commented Dec 15, 2022

display variants and display the placeholder when there is no picture

That what I meant by "the missing part is to print a product row"

I don't think we should loose columns?

Seems like I forgot some of them right.

it was easier i guess?

Probably a miss too.

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.

8 participants