You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "geido (via GitHub)" <gi...@apache.org> on 2024/06/09 17:16:35 UTC
[PR] refactor: Upgrade Badge component to Ant Design 5 (POC) [superset]
geido opened a new pull request, #29124:
URL: https://github.com/apache/superset/pull/29124
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
This Proof of Concept (POC) aims 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 [LINK - WIP].
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N.A.
### TESTING INSTRUCTIONS
1. Verify the usage of the Badge throughout the application.
2. Ensure no visual or behavioral changes have been introduced.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Upgrade Badge component to Ant Design 5 [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #29124:
URL: https://github.com/apache/superset/pull/29124
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Upgrade Badge component to Ant Design 5 (POC) [superset]
Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #29124:
URL: https://github.com/apache/superset/pull/29124#discussion_r1632355278
##########
superset-frontend/src/components/Badge/Badge.test.tsx:
##########
@@ -22,7 +22,6 @@ import Badge from '.';
const mockedProps = {
count: 9,
text: 'Text',
- textColor: 'orange',
Review Comment:
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.
##########
superset-frontend/src/components/Badge/index.tsx:
##########
@@ -28,14 +28,25 @@ const Badge = styled(
(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
{ textColor, color, text, ...props }: BadgeProps,
- ) => <AntdBadge text={text} color={text ? color : undefined} {...props} />,
+ ) => (
+ <AntdBadge
+ text={text}
+ color={text ? color : undefined}
+ status={props.status || 'default'}
+ {...props}
+ />
+ ),
)`
- & > sup {
- padding: 0 ${({ theme }) => theme.gridUnit * 2}px;
- background: ${({ theme, color }) => color || theme.colors.primary.base};
- color: ${({ theme, textColor }) =>
- textColor || theme.colors.grayscale.light5};
- }
+ ${({ theme, color, count }) => `
+ & > sup,
+ & > sup.ant-badge-count {
+ ${
+ count !== undefined
+ ? `background: ${color || theme.colors.primary.base};`
Review Comment:
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.
##########
superset-frontend/src/dashboard/components/FiltersBadge/index.tsx:
##########
@@ -84,16 +84,15 @@ const StyledFilterCount = styled.div`
const StyledBadge = styled(Badge)`
${({ theme }) => `
- vertical-align: middle;
margin-left: ${theme.gridUnit * 2}px;
- &>sup {
- padding: 0 ${theme.gridUnit}px;
+ &>sup.ant-badge-count {
Review Comment:
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.
##########
superset-frontend/package.json:
##########
@@ -121,6 +121,7 @@
"abortcontroller-polyfill": "^1.1.9",
"ace-builds": "^1.4.14",
"antd": "4.10.3",
+ "antd-v5": "npm:antd@^5.18.0",
Review Comment:
The previous and target versions of Ant Design can be supported by using different names in the package configuration.
##########
superset-frontend/src/views/RootContextProviders.tsx:
##########
@@ -35,35 +36,48 @@ const { common } = getBootstrapData();
const extensionsRegistry = getExtensionsRegistry();
+const antdTheme = {
Review Comment:
Mapping of the Ant Design theme with Superset theme
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor: Upgrade Badge component to Ant Design 5 (POC) [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #29124:
URL: https://github.com/apache/superset/pull/29124#discussion_r1642970993
##########
superset-frontend/src/views/RootContextProviders.tsx:
##########
@@ -35,35 +36,48 @@ const { common } = getBootstrapData();
const extensionsRegistry = getExtensionsRegistry();
+const antdTheme = {
+ components: {
+ Badge: {
Review Comment:
Some GPT inputs that may help when defining the pattern for global vs component properties.
<img width="968" alt="Screenshot 2024-06-17 at 12 04 02" src="https://github.com/apache/superset/assets/70410625/ef1fb575-07e2-4c09-aabf-d83adaeaaef5">
<img width="941" alt="Screenshot 2024-06-17 at 12 04 40" src="https://github.com/apache/superset/assets/70410625/0bf4ea64-5529-48d7-9d33-7ec80a16ce31">
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org