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

Refactor class components to functional components #4460

Open
44 of 93 tasks
sneridagh opened this issue Mar 4, 2023 · 3 comments
Open
44 of 93 tasks

Refactor class components to functional components #4460

sneridagh opened this issue Mar 4, 2023 · 3 comments

Comments

@sneridagh
Copy link
Member

sneridagh commented Mar 4, 2023

PLIP (Plone Improvement Proposal)

Responsible Persons

Proposer: Víctor Fernández de Alba (@sneridagh)

Seconder:

Abstract

Refactor all the possible components in Volto that still are class-based components. Convert them to functional components, whenever possible.

Motivation

Volto still have a number of core components that are React class-based components. This prevents the use of hooks in them, and newest DX on them.

The idea is also while moving to them, use hooks to abstract the functionality present in Redux and in data fetching so in a near future we can easily switch using the hooks to use other props provider.

Assumptions

No assumptions.

Proposal & Implementation

Refactor should be done carefully and providing Cypress (acceptance) tests where they do not exist. The lifecycle of the components should be preserved while watching out for edge cases and UX problems.

Deliverables

It should be delivered all at once, as a major breaking change. Ideally, we won't change the contract of any of the components, so no new props passed down, no return anything to the tree that we were not returning before, unless it's justified.

If the contract has to be broken, then it must be properly documented and exposed in the upgrade guide.

The refactored components. Here there is a preliminary list, subject to change:

Complex / Optional:

  • src/components/theme/View/View.jsx
  • src/components/theme/App/App.jsx
  • src/components/manage/Edit/Edit.jsx
  • src/components/manage/Add/Add.jsx
  • src/components/manage/Form/Form.jsx
  • src/components/manage/Contents/Contents.jsx
  • src/components/manage/Controlpanels/ContentTypeLayout.jsx
  • src/components/manage/Sidebar/ObjectBrowserBody.jsx
  • src/helpers/Html/Html.jsx
  • src/helpers/BodyClass/BodyClass.jsx

Risks

The lifecycle of a component could easily be changed if the refactor is not done carefully and giving attention to details, that's why we should provide acceptance tests and heavy QA should be done while doing it.

Participants

This PLIP was part of the GSOC 2023 project assigned to Tisha Soumya (@Tishasoumya-02). Its scope proved to be too large for a single GSoC effort, and some components were left unfactored. She is available to review or approve pull requests for this PLIP.

⚠️ IMPORTANT ⚠️

The above list may be out of date. Do not duplicate effort. Search the issues and pull requests for existing work.

Read and follow First-time contributors, especially Things not to do, Contributing to Plone, and Contributing to Volto.

If your instructor gave you a class assignment to work on Volto or open source software, or you otherwise have no commitment to use and develop Plone or Volto, then you are not a contributor.

Pull requests that fail to comply with these contributing guidelines may be closed without explanation.

@sneridagh
Copy link
Member Author

@tisto
Copy link
Member

tisto commented Feb 12, 2024

@sneridagh what Plone version is this feature planned for?

@sneridagh
Copy link
Member Author

@tisto This is an ongoing effort. Tisha worked on this during her GSOC. The reach was too broad, so we had to cut it down. This can be presented again in the next GSOC for continuation of the work.

The ones reviewed and merged (during 17 alpha phase) were released in Volto 17.

In the meanwhile, there are still some PRs opened (one per component). These are merged in alpha stages, because they are considered breaking. AFAIK, the project is stalled right now.

@plone plone deleted a comment from sudhanshu1309 Feb 14, 2024
@plone plone deleted a comment from lord2anil Feb 14, 2024
@plone plone deleted a comment from Ciggzy1312 Feb 14, 2024
@plone plone deleted a comment from Pranshu1902 Feb 14, 2024
@plone plone deleted a comment from Vanshika432 Feb 14, 2024
@plone plone deleted a comment from KGoutham7214 Feb 14, 2024
@plone plone deleted a comment from pupsb Feb 14, 2024
@plone plone deleted a comment from YOKESHCR Feb 14, 2024
@plone plone deleted a comment from rajvinder-kaur Feb 14, 2024
@plone plone deleted a comment from SHOORS Feb 14, 2024
@plone plone deleted a comment from Src0p Feb 14, 2024
@plone plone deleted a comment from geekyasif Feb 14, 2024
@plone plone deleted a comment from avijitsaha2997 Feb 14, 2024
@plone plone deleted a comment from manju121212 Feb 14, 2024
@plone plone deleted a comment from sneridagh Feb 14, 2024
@plone plone deleted a comment from kd1729 Feb 14, 2024
@plone plone deleted a comment from BhuvaneshPatil Feb 14, 2024
@plone plone deleted a comment from Pathholder1806 Feb 14, 2024
@plone plone deleted a comment from SaiRev0 Feb 14, 2024
@plone plone deleted a comment from Pathholder1806 Feb 14, 2024
@plone plone deleted a comment from naveen1m Feb 14, 2024
@plone plone deleted a comment from danielperaza Feb 14, 2024
@plone plone locked and limited conversation to collaborators Feb 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: No status
Status: In progress
Status: Plan approved
Development

Successfully merging a pull request may close this issue.

4 participants