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

Remove awesome nested set gem and dependencies [OFN-11636] #12749

Merged
merged 6 commits into from
Aug 14, 2024

Conversation

wandji20
Copy link
Contributor

@wandji20 wandji20 commented Aug 7, 2024

What? Why?

Awesomenested set and related dependencies where removed

  • Taxonomy model (deleted)
  • Attributes: parent_id, lft, and rgt where removed from Taxon model
  • Taxonomy controller (including API/V0) and specs deleted
  • Taxon controller ((including API/V0) and specs updated to reflect model change and all CRUD actions added
  • Taxons replaced Taxonomies in admin setting page

What should we test?

  • Admin setting page should work properly with new taxons options
  • Taxnonomies should be removed from admin settings page
  • All crud actions should be available in adminnn settings for taxons

Video

Screencast.from.07-08-2024.15.48.29.webm

Release notes

Removes unused tree structure on product categories. Your taxons and taxonomies will now be listed in one flat alphabetical list.

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0)
  • Technical changes only

Dependencies

N/A

Documentation updates

N/A

@wandji20 wandji20 marked this pull request as draft August 7, 2024 15:50
@wandji20 wandji20 force-pushed the wb-OFN-11636 branch 3 times, most recently from 3c31056 to 10d436a Compare August 7, 2024 18:42
@wandji20 wandji20 marked this pull request as ready for review August 8, 2024 07:33
@mkllnk mkllnk added api changes These pull requests change the API and can break integrations user facing changes Thes pull requests affect the user experience labels Aug 8, 2024
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.

Excellent work! Thank you.

It would have been easier to review if you had created several smaller commits to guide us through the changes step by step.

I'm adding one commit to fix up the migration but otherwise it's all good. There's one leftover jquery plugin now that we can remove as well. Would you like to tackle that?

Comment on lines 8 to 9
remove_reference :spree_taxons, :parent, index: true, foriegn_key: true
remove_reference :spree_taxons, :taxonomy, index: true, foriegn_key: true
Copy link
Member

Choose a reason for hiding this comment

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

It looks like a typo here:

Suggested change
remove_reference :spree_taxons, :parent, index: true, foriegn_key: true
remove_reference :spree_taxons, :taxonomy, index: true, foriegn_key: true
remove_reference :spree_taxons, :parent, index: true, foreign_key: true
remove_reference :spree_taxons, :taxonomy, index: true, foreign_key: true

So I assume that you didn't test rolling back the migration and check that it reverts back to how it was.

Copy link
Member

Choose a reason for hiding this comment

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

I'll add a commit to make the migration reversible.

Copy link
Member

Choose a reason for hiding this comment

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

What about the Javascript part?

vendor/assets/javascripts/jquery.jstree/jquery.jstree.js

@mkllnk
Copy link
Member

mkllnk commented Aug 9, 2024

Oh, and it looks like you need to rebase this pull request on the latest master to resolve conflicts.

@mkllnk
Copy link
Member

mkllnk commented Aug 9, 2024

While testing I noticed that the permalink is not visible. Setting a new value doesn't work either. I don't actually think that it's used anywhere. Can you remove at least the input field from the form?

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Awesome, thanks ! 🙏
I'll second Maikel here, it would have been easier to follow if it was split in multiple small commit.
I think we'll need to flag this to the instance manager when it get released, they might want to review their taxonomy afterward.

@drummer83 drummer83 self-assigned this Aug 14, 2024
@drummer83 drummer83 added the pr-staged-au staging.openfoodnetwork.org.au label Aug 14, 2024
@drummer83
Copy link
Contributor

Hi @wandji20,
Thank you for yet another PR! 💪
I have tested it on our servers.

Configuration tabs in the instance settings

Before:
image

After:
image

Taxonomies vs. Product Categories page

Before:
image

image

image

After:
image

Taxonomy edit vs. Product Category edit page

Before:
image

After:
image

Header taxonomies and sub taxons listed as Product Categories

After:
image

Additional test cases

  • New page 'Product Categories'. ✔️
  • Old page 'Taxonomies' is gone. ✔️
  • All previous header taxonomies are listed as product categories now. ✔️
  • All previous taxons and sub taxons are listed as product categories. ✔️
  • Create new product category. ✔️
  • Edit product category. ✔️
  • Can't delete a product category with assigned products. ✔️
    image
  • Can delete a product category without assigned products. ✔️
  • Product categories are listed in an alphabetical order. ✔️
  • Permalink has been removed. ✔️

Open (nice to have in a follow-up)

  • Improve error message (spree.admin.taxons.destroy.delete_taxon.error): Unable to delete the product category due to assigned products.
  • Is the key spree_classification_primary_taxon_error still used anywhere? ❓
  • Is the key spree.new_taxon still used anywhere? ❓
  • Is the key spree.api.invalid_taxonomy_id still used anywhere? ❓

Task

❗ Inform instance managers about this change.

Conclusion

Everything I tested is working well. Great job!
I only have minor questions, which can be addressed in a follow up, if at all.

This PR is ready to go. Merging! 🚀
Thanks! 🎉

@drummer83 drummer83 merged commit 8442c7d into openfoodfoundation:master Aug 14, 2024
52 checks passed
@drummer83 drummer83 removed the pr-staged-au staging.openfoodnetwork.org.au label Aug 14, 2024
@drummer83
Copy link
Contributor

Created #12773 for follow up issues.

@dacook dacook mentioned this pull request Aug 15, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api changes These pull requests change the API and can break integrations user facing changes Thes pull requests affect the user experience
Projects
Status: Done
4 participants