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: Upgrade Badge component to Ant Design 5 #29124

Merged
merged 10 commits into from
Jul 9, 2024

Conversation

geido
Copy link
Member

@geido geido commented Jun 9, 2024

SUMMARY

This was a Proof of Concept (POC) aiming to demonstrate the capability to upgrade Ant Design components to the latest version in isolation, facilitating incremental upgrades.

Two versions of Ant Design will be maintained until all components are upgraded to the latest version.

Please refer to the inline comments in this PR and the Superset Improvement Proposal #29268

This PR is dependent on PR #29328

Promoting this PR to a mergiable state.

BEFORE

340085271-92a84b90-7d3b-47cc-8895-fadaf673b3e4

340429169-6c6264ec-6780-48d9-bb40-8edab2ae2e92

AFTER

Note that the prop textColor has been removed as it was unused.

340085221-236370b1-69f9-46e4-97bf-37ce2842e06c

340429536-8910c99e-db52-428d-9a17-daece5d5e3ac

TESTING INSTRUCTIONS

  1. Verify the usage of the Badge throughout the application.
  2. Ensure no visual or behavioral changes have been introduced.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Comment on lines 123 to 125
"antd": "4.10.3",
"antd-v5": "npm:antd@^5.18.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

The previous and target versions of Ant Design can be supported by using different names in the package configuration.

@@ -22,7 +22,6 @@ import Badge from '.';
const mockedProps = {
count: 9,
text: 'Text',
textColor: 'orange',
Copy link
Member Author

Choose a reason for hiding this comment

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

This property is custom. Since it is not used in the code, it does not make sense to maintain it. Additionally, one of the goals of the proposal is to minimize the introduction of custom properties to reduce maintenance costs.

& > sup.ant-badge-count {
${
count !== undefined
? `background: ${color || theme.colors.primary.base};`
Copy link
Member Author

Choose a reason for hiding this comment

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

This is an example of a necessary customization for backward compatibility. Ant Design uses colorError as the background color for the count component of the Badge. However, in Superset, the count requires a different color. Changing the colorError of the Badge in the Ant Design ConfigProvider would affect all variations of the Badge, which is not desirable. See all variations here: https://ant.design/components/badge.

margin-left: ${theme.gridUnit * 2}px;
&>sup {
padding: 0 ${theme.gridUnit}px;
&>sup.ant-badge-count {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is another example of a forced customization to meet Superset’s requirements to fit the Badge within the available space. Such customizations are undesirable as they introduce maintenance costs. Another issue to consider is the reliance on a specific className, which poses risks if this className is removed or changed in future versions of Ant Design.

@@ -35,35 +36,48 @@ const { common } = getBootstrapData();

const extensionsRegistry = getExtensionsRegistry();

const antdTheme = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Mapping of the Ant Design theme with Superset theme

@@ -35,35 +36,48 @@ const { common } = getBootstrapData();

const extensionsRegistry = getExtensionsRegistry();

const antdTheme = {
components: {
Badge: {
Copy link
Member

Choose a reason for hiding this comment

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

Some GPT inputs that may help when defining the pattern for global vs component properties.

Screenshot 2024-06-17 at 12 04 02 Screenshot 2024-06-17 at 12 04 40

@github-actions github-actions bot removed the packages label Jun 20, 2024
@geido geido changed the title refactor: Upgrade Badge component to Ant Design 5 (POC) refactor: Upgrade Badge component to Ant Design 5 Jun 27, 2024
@pull-request-size pull-request-size bot added size/M and removed size/L labels Jul 8, 2024
@geido geido marked this pull request as ready for review July 8, 2024 09:59
@dosubot dosubot bot added the change:frontend Requires changing the frontend label Jul 8, 2024
Copy link
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Looks good!

@rusackas rusackas merged commit 428b68f into master Jul 9, 2024
34 checks passed
@rusackas rusackas deleted the geido/feat/antdesign-5 branch July 9, 2024 21:18
eschutho pushed a commit that referenced this pull request Jul 24, 2024
Co-authored-by: Evan Rusackas <evan@rusackas.com>
@github-actions github-actions bot added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.1.0 labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels change:frontend Requires changing the frontend frontend:refactor:antd5 size/L 🚢 4.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants