apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
61.84k stars 13.54k forks source link

[SIP-139] Proposal for Ant Design 5.x Upgrade #29268

Closed geido closed 2 months ago

geido commented 3 months ago

Motivation

Superset currently utilizes Ant Design version 4, which has proven to be a significant blocker for major initiatives such as theming (see blog and SIP for the state of this effort) and accessibility improvements. The limitations and difficulties associated with Ant Design 4.x have hindered progress in achieving these goals effectively.

Goals

Non-Goals

Incremental Component Upgrade

The proposed solution is to upgrade each component in isolation, allowing for incremental upgrades and community participation. The immediate consequence of this approach is the necessity to support two versions of Ant Design—the current Superset version and the target version—until all components have been upgraded, and the legacy AntD version is finally removed. This situation requires the establishment of clear standards and methodologies to minimize the duration of maintaining both versions.

A proof of concept (POC) has been created, upgrading the Badge component to Ant Design 5 in isolation (https://github.com/apache/superset/pull/29124). This approach minimizes coordination complexity and enables community contributions while maintaining clear standards.

The POC shows the viability of this approach and also details eventual limitations and edge cases.

To ensure the transition period is as short as possible, we need a structured and efficient process:

Detailed approach

We have identified several areas that have posed obstacles to upgrading Ant Design and have increased maintenance costs. These include:

• Custom styles • Modifications to standard behaviors • Insufficient Storybook and test coverage

Custom styles

Custom styles are frequently applied to tailor components to our design needs, significantly complicating the upgrade process. It is advisable to use Ant Design’s built-in theme capabilities whenever possible and only resort to custom styles after carefully considering the maintenance costs.

As we upgrade Ant Design to version 5, it is critical to reassess these choices. Here is the proposed approach:

Modifications to standard behaviors

Heavily leveraging CSS styles in our custom components to override standard behaviors is common practice in Superset. However, this approach incurs high maintenance costs due to the challenges of upgrading to newer versions of Ant Design.

It is advisable to consider the standard, out-of-the-box behavior of components sufficient and only implement significant behavior changes if they are absolutely necessary for product requirements using the available props.

Any such changes should be thoroughly documented, showcased in Storybook, and rigorously tested.

Insufficient Storybook and test coverage

Automation and rigorous testing are essential for maintaining quality and preventing regressions. Therefore, as we proceed with upgrading Ant Design components in isolation, it is crucial to include RTL tests, Storybook, and visual regression tests as fundamental components of the definition of done for each PR.

Proposed Workflow Approach

The following workflow should ensure a structured and efficient upgrade process:

  1. Component Usage Check:
    • Identify all instances of the component across the application to understand its current usage and dependencies.
  2. Compare Current and New Versions:
    • Use Storybook to compare the current component state with the upgraded version, highlighting any differences.
  3. Remove Unused Props and Styles:
    • Clean up the component by removing any props and styles that are no longer necessary, incompatible with the new version, or unused.
  4. Adjust Ant Design Theme:
    • Fine-tune the Ant Design theme to match the previous look and feel as closely as possible, ensuring a seamless user experience.
  5. Minimal Custom Style Application:
    • Apply custom styles only when absolutely necessary and document these changes to facilitate future maintenance.
  6. Design Confrontation:
    • Regularly consult with the design team to ensure that customizations are necessary and maintainable, reducing long-term technical debt.
  7. Documentation and Testing:
    • Update or create Storybook stories and test cases for each upgraded component to ensure comprehensive coverage and easy reference for future developers.

Rejected Alternative Solution: Feature Branch Approach

The feature branch approach was considered but ultimately rejected due to its complexity and coordination requirements. While it allows for testing changes without risking the master branch, the need for extensive coordination and potential for prolonged support of multiple Ant Design versions outweighs its benefits. The incremental component upgrade approach, by contrast, is more manageable and enables community contributions with clear standards.

Conclusion

The proposed incremental approach, utilizing an isolated component upgrade strategy, enables a controlled and manageable upgrade path to the latest version of Ant Design. This approach minimizes coordination complexity, leverages community contributions, and unblocks essential theming and accessibility improvements, ensuring a more robust and user-friendly Superset application.

Kanban Board

A list of all Ant Design components and where they are used can be found here: https://github.com/apache/superset/discussions/29293

michael-s-molina commented 3 months ago

Thanks for the detailed SIP @geido and for leading the efforts to upgrade Ant Design.

As we upgrade Ant Design to version 5, it is critical to reassess these choices. Here is the proposed approach:

Strip All Custom Styles: Integrate Ant Design Theme Correctly: Showcase States in Storybook: Reapply Essential Custom Styles:

This is great! Get ready @kasiazjc! 😄

Modifications to standard behaviors Heavily leveraging component props to alter standard behaviors is common practice in Superset. However, this approach incurs high maintenance costs due to the challenges of upgrading to newer versions of Ant Design.

When reading this, I was a little bit confused. Altering standard behaviors using Ant Design properties is ok as they are part of the API. I believe you meant that we pass properties to our custom components which override the Ant Design component using CSS styles instead of properties. If that's what you meant, then we can improve this paragraph to make it more clear.

Proposed Workflow Approach

One suggestion I have is to create the PRs that upgrade a component as an atomic unit of work that can be reverted easily. This will allow us to require @kasiazjc's approval in each of these PRs, before merging them. We can use labels to block the merge button.

A list of all Ant Design components and where they are used.

Is this list complete? I don't see Ant Design's Select component.

geido commented 3 months ago

Thanks @michael-s-molina! Updated.

rusackas commented 3 months ago

If we ever get that tech debt dashboard merged, this'll be trivial to track with a new linting rule.

geido commented 3 months ago

To improve readability I moved the list to a dedicated discussion https://github.com/apache/superset/discussions/29293

rusackas commented 2 months ago

Hooray, it passed! Closing and moving it on the kanban...