You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "fisjac (via GitHub)" <gi...@apache.org> on 2024/02/26 22:34:25 UTC

[PR] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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

   <!---
   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 -->
   The behavior of the custom_width input on alerts and reports used to be a numeric input. This PR implements the antd NumberInput behavior. It also implements min and max at 600 and 2400x to prevent users from inputting invalid values.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   Before:
   https://www.loom.com/share/05786eb33da74f3385f8e08fc0bb6427?sid=21aa2e2b-5cc4-4075-aae4-72cc9ce13217
   
   After:
   https://www.loom.com/share/cadf7b979abb48e79afd75893fb80f0e?sid=81bae2c6-b553-4725-a8dc-f4104820f665
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   Create or open an existing alert or report. Ensure that the custom width input is a numeric input.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [x] Required feature flags: ALERTS_REPORTS=true
   - [x] 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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #27260:
URL: https://github.com/apache/superset/pull/27260#discussion_r1504706939


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   Given that we're setting 600 as the minimum value, should accept `null` values here or always start with 600?



-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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


-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/27260?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `66.66667%` with `1 lines` in your changes are missing coverage. Please review.
   > Project coverage is 67.34%. Comparing base [(`ef4b727`)](https://app.codecov.io/gh/apache/superset/commit/ef4b72724e7716b123c10dfc4dae41644e55162f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`3305aba`)](https://app.codecov.io/gh/apache/superset/pull/27260?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 73 commits behind head on master.
   
   | [Files](https://app.codecov.io/gh/apache/superset/pull/27260?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...-frontend/src/features/alerts/AlertReportModal.tsx](https://app.codecov.io/gh/apache/superset/pull/27260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2ZlYXR1cmVzL2FsZXJ0cy9BbGVydFJlcG9ydE1vZGFsLnRzeA==) | 66.66% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/27260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #27260      +/-   ##
   ==========================================
   + Coverage   67.33%   67.34%   +0.01%     
   ==========================================
     Files        1908     1909       +1     
     Lines       74530    74597      +67     
     Branches     8309     8325      +16     
   ==========================================
   + Hits        50185    50239      +54     
   - Misses      22292    22308      +16     
   + Partials     2053     2050       -3     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/27260/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/27260/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.22% <66.66%> (+0.04%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/27260?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   On the backend, custom_width as a field is nullable, and when null, it defaults to the WEBDRIVER_WINDOW in config.py
   
   Default value is:
   ```
    WEBDRIVER_WINDOW = {
       "dashboard": (1600, 2000),
       "slice": (3000, 1200),
       "pixel_density": 1,
   } 
   ```



-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   I think it makes sense to have 600 as a default value here. Perhaps we could export in a const for better visibility



-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #27260:
URL: https://github.com/apache/superset/pull/27260#discussion_r1504706939


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   Given that we're setting 600 as the minimum value, should we accept `null` values here or always start with 600?



-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   @fisjac for the ts error here, I think you're going to want the default to be `undefined`
   `error TS2322: Type 'number | null' is not assignable to type 'number | undefined'.`



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   @fisjac for the ts error here, I think you're going to want the default to be `undefined` instead of `null`
   `error TS2322: Type 'number | null' is not assignable to type 'number | undefined'.`



-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   On the backend, custom_width is a nullable field, and when null, it defaults to either the dashboard or slice attributes of WEBDRIVER_WINDOW in config.py
   
   Default value is:
   ```
    WEBDRIVER_WINDOW = {
       "dashboard": (1600, 2000),
       "slice": (3000, 1200),
       "pixel_density": 1,
   } 
   ```



-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   On the backend, custom_width is a nullable field, and when null, it defaults to the WEBDRIVER_WINDOW in config.py
   
   Default value is:
   ```
    WEBDRIVER_WINDOW = {
       "dashboard": (1600, 2000),
       "slice": (3000, 1200),
       "pixel_density": 1,
   } 
   ```



-- 
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] fix(alerts/reports): implementing custom_width as an Antd number input [superset]

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


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1542,12 +1546,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
             >
               <div className="control-label">{t('Screenshot width')}</div>
               <div className="input-container">
-                <Input
+                <InputNumber
                   type="number"
                   name="custom_width"
-                  value={currentAlert?.custom_width || ''}
+                  value={currentAlert?.custom_width ?? null}

Review Comment:
   This will never be below 600 though right and it won't ever be null or undefined for that reason too?



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