You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "msyavuz (via GitHub)" <gi...@apache.org> on 2024/10/28 12:39:03 UTC

[PR] refactor(input): Migrate Input component to Ant Design 5 [superset]

msyavuz opened a new pull request, #30730:
URL: https://github.com/apache/superset/pull/30730

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   Migrate Input Component to Ant Design 5 while keeping the visuals consistent.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   Before:
   Standalone:
   ![input-b-s](https://github.com/user-attachments/assets/3b8ba254-89b7-476a-85a8-fcbc6e29242e)
   
   
   Inside SqlLab Save query:
   ![input-b-i](https://github.com/user-attachments/assets/95696f78-4ac5-4a8a-86cf-3c0481f16748)
   
   
   After:
   Standalone:
   ![input-a-s](https://github.com/user-attachments/assets/34395c41-b40a-429d-a18d-3b82a5742bac)
   
   
   Inside SqlLab Save query:
   ![input-a-i](https://github.com/user-attachments/assets/8ae49a98-5764-4e7f-9f77-dd82b2fbb060)
   
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   Test component visuals before and after in used places or in storybook.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: Closes #30727 
   - [ ] 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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1824526526


##########
superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx:
##########
@@ -311,6 +310,7 @@ export const DrillByMenuItems = ({
                 margin: ${theme.gridUnit * 2}px ${theme.gridUnit * 3}px;
                 box-shadow: none;
               `}
+              value={searchInput}

Review Comment:
   I think this approach does not work. Watch the example video. I cannot even type right, it will lag really bad. 
   
   
   https://github.com/user-attachments/assets/c94d51e2-36fb-4b92-8677-303a83accdac
   
   



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30730:
URL: https://github.com/apache/superset/pull/30730#issuecomment-2448072307

   @geido Ephemeral environment spinning up at http://35.92.235.191:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #30730:
URL: https://github.com/apache/superset/pull/30730#issuecomment-2443749579

   /testenv up


-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1821033597


##########
superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx:
##########
@@ -138,10 +138,9 @@ export const DrillByMenuItems = ({
 
   useEffect(() => {
     if (open) {
-      ref.current?.input.focus({ preventScroll: true });
+      ref.current?.input?.focus({ preventScroll: true });
     } else {
       // Reset search input when menu is closed
-      ref.current?.setValue('');

Review Comment:
   There is no setValue method for Input after the migration so this would give type errors. Binding the value to the already kept state makes this obsolete. Another option would be `ref.current?.input?.value = ''` which seemed worse to me.
   
   Relevant issue: https://github.com/ant-design/ant-design/issues/34425



##########
superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx:
##########
@@ -311,6 +310,7 @@ export const DrillByMenuItems = ({
                 margin: ${theme.gridUnit * 2}px ${theme.gridUnit * 3}px;
                 box-shadow: none;
               `}
+              value={searchInput}

Review Comment:
   This is said binding of the state.



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30730:
URL: https://github.com/apache/superset/pull/30730#issuecomment-2443770761

   @geido Ephemeral environment spinning up at http://54.201.85.223:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1821033597


##########
superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx:
##########
@@ -138,10 +138,9 @@ export const DrillByMenuItems = ({
 
   useEffect(() => {
     if (open) {
-      ref.current?.input.focus({ preventScroll: true });
+      ref.current?.input?.focus({ preventScroll: true });
     } else {
       // Reset search input when menu is closed
-      ref.current?.setValue('');

Review Comment:
   There is no setValue method for Input after the migration so this would give type errors. Binding the value to the already kept state makes this obsolete



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido merged PR #30730:
URL: https://github.com/apache/superset/pull/30730


-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1824526526


##########
superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx:
##########
@@ -311,6 +310,7 @@ export const DrillByMenuItems = ({
                 margin: ${theme.gridUnit * 2}px ${theme.gridUnit * 3}px;
                 box-shadow: none;
               `}
+              value={searchInput}

Review Comment:
   I think this approach does not work. Watch the example video. I cannot even type right now, it will lag really bad. 
   
   
   https://github.com/user-attachments/assets/c94d51e2-36fb-4b92-8677-303a83accdac
   
   



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1820954161


##########
superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx:
##########
@@ -138,10 +138,9 @@ export const DrillByMenuItems = ({
 
   useEffect(() => {
     if (open) {
-      ref.current?.input.focus({ preventScroll: true });
+      ref.current?.input?.focus({ preventScroll: true });
     } else {
       // Reset search input when menu is closed
-      ref.current?.setValue('');

Review Comment:
   We don't need this anymore? It seems unrelated to the upgrade



##########
superset-frontend/src/explore/components/controls/BoundsControl.test.jsx:
##########
@@ -34,7 +34,8 @@ test('renders two inputs', () => {
 test('receives null on non-numeric', async () => {
   render(<BoundsControl {...defaultProps} />);
   const minInput = screen.getAllByRole('spinbutton')[0];
-  userEvent.type(minInput, 'text');
+  userEvent.type(minInput, '1');
+  userEvent.clear(minInput);

Review Comment:
   I think this will be giving a false positive for this test?



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -983,8 +983,15 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
     }
   };
 
-  const onCustomWidthChange = (value: number | null | undefined) => {
-    updateAlertState('custom_width', value);
+  const onCustomWidthChange = (value: number | string | null | undefined) => {
+    // Convert string to number if needed and handle empty/invalid values
+    const numValue =
+      value === undefined || value === ''
+        ? undefined
+        : typeof value === 'string'
+          ? Number(value) || null

Review Comment:
   Why are we defaulting to `null` here? What happens if value is '0'?



##########
superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx:
##########
@@ -311,6 +310,7 @@ export const DrillByMenuItems = ({
                 margin: ${theme.gridUnit * 2}px ${theme.gridUnit * 3}px;
                 box-shadow: none;
               `}
+              value={searchInput}

Review Comment:
   Same for this. It seems unrelated to the upgrade? What is this for?



##########
superset-frontend/src/features/alerts/components/AlertReportCronScheduler.tsx:
##########
@@ -51,17 +51,15 @@ export const AlertReportCronScheduler: FC<AlertReportCronSchedulerProps> = ({
   onChange,
 }) => {
   const theme = useTheme();
-  const inputRef = useRef<AntdInput>(null);

Review Comment:
   Is this not necessary after the upgrade?



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #30730:
URL: https://github.com/apache/superset/pull/30730#issuecomment-2448042534

   /testenv up


-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30730:
URL: https://github.com/apache/superset/pull/30730#issuecomment-2473235231

   Ephemeral environment shutdown and build artifacts deleted.


-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1821097459


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -983,8 +983,15 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
     }
   };
 
-  const onCustomWidthChange = (value: number | null | undefined) => {
-    updateAlertState('custom_width', value);
+  const onCustomWidthChange = (value: number | string | null | undefined) => {
+    // Convert string to number if needed and handle empty/invalid values
+    const numValue =
+      value === undefined || value === ''
+        ? undefined
+        : typeof value === 'string'
+          ? Number(value) || null

Review Comment:
   That's a good catch.



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1821113624


##########
superset-frontend/src/features/alerts/components/AlertReportCronScheduler.tsx:
##########
@@ -51,17 +51,15 @@ export const AlertReportCronScheduler: FC<AlertReportCronSchedulerProps> = ({
   onChange,
 }) => {
   const theme = useTheme();
-  const inputRef = useRef<AntdInput>(null);

Review Comment:
   setValue is obsolete and redundant on the customSetValue callback and i think handlePressEnter can use value directly so this becomes unneccessary.



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1821033597


##########
superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx:
##########
@@ -138,10 +138,9 @@ export const DrillByMenuItems = ({
 
   useEffect(() => {
     if (open) {
-      ref.current?.input.focus({ preventScroll: true });
+      ref.current?.input?.focus({ preventScroll: true });
     } else {
       // Reset search input when menu is closed
-      ref.current?.setValue('');

Review Comment:
   There is no setValue method for Input after the migration so this would give type errors.



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #30730:
URL: https://github.com/apache/superset/pull/30730#discussion_r1821062284


##########
superset-frontend/src/explore/components/controls/BoundsControl.test.jsx:
##########
@@ -34,7 +34,8 @@ test('renders two inputs', () => {
 test('receives null on non-numeric', async () => {
   render(<BoundsControl {...defaultProps} />);
   const minInput = screen.getAllByRole('spinbutton')[0];
-  userEvent.type(minInput, 'text');
+  userEvent.type(minInput, '1');
+  userEvent.clear(minInput);

Review Comment:
   InputNumber only accepts numbers by default on v5 so typing 'text' does not fire onChange. This test might be obsolete alltogether.



-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30730:
URL: https://github.com/apache/superset/pull/30730#issuecomment-2449972793

   @geido Ephemeral environment spinning up at http://35.94.182.199:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #30730:
URL: https://github.com/apache/superset/pull/30730#issuecomment-2449923633

   /testenv up FEATURE_ALERT_REPORTS=true


-- 
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(input): Migrate Input component to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #30730:
URL: https://github.com/apache/superset/pull/30730#issuecomment-2461960285

   /testenv up FEATURE_ALERT_REPORTS=true


-- 
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