You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/22 10:01:38 UTC

[GitHub] [superset] stephenLYZ opened a new pull request, #20823: fix(dashboard): add toast if JSON metadata is invalid

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

   <!---
   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 -->
   When the json metadata of the dashboard is not legal, the user clicks the save button without any response and no other prompt, this PR adds toast to inform the user.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   ### before
   
   https://user-images.githubusercontent.com/11830681/180412795-4eae920a-6ce2-4d55-b209-98baedb42448.mov
   
   
   ### after
   
   https://user-images.githubusercontent.com/11830681/180412783-b5464423-d9a6-42ea-acea-c10a8116d545.mov
   
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### 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


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20823: fix(dashboard): add toast if JSON metadata is invalid

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20823:
URL: https://github.com/apache/superset/pull/20823#discussion_r974806497


##########
superset-frontend/src/dashboard/components/PropertiesModal/index.tsx:
##########
@@ -294,7 +296,12 @@ const PropertiesModal = ({
 
     // color scheme in json metadata has precedence over selection
     if (currentJsonMetadata?.length) {
-      const metadata = JSON.parse(currentJsonMetadata);
+      let metadata;
+      try {
+        metadata = JSON.parse(currentJsonMetadata);
+      } catch (error) {
+        addDangerToast(t('JSON metadata is invalid!'));

Review Comment:
   @john-bodley @etr2460 add a new PR at [here](https://github.com/apache/superset/pull/21524).



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


[GitHub] [superset] zhaoyongjie merged pull request #20823: fix(dashboard): add toast if JSON metadata is invalid

Posted by GitBox <gi...@apache.org>.
zhaoyongjie merged PR #20823:
URL: https://github.com/apache/superset/pull/20823


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


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20823: fix(dashboard): add toast if JSON metadata is invalid

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20823:
URL: https://github.com/apache/superset/pull/20823#discussion_r972529938


##########
superset-frontend/src/dashboard/components/PropertiesModal/index.tsx:
##########
@@ -294,7 +296,12 @@ const PropertiesModal = ({
 
     // color scheme in json metadata has precedence over selection
     if (currentJsonMetadata?.length) {
-      const metadata = JSON.parse(currentJsonMetadata);
+      let metadata;
+      try {
+        metadata = JSON.parse(currentJsonMetadata);
+      } catch (error) {
+        addDangerToast(t('JSON metadata is invalid!'));

Review Comment:
   @etr2460 good point, let's try to make an invalid JSON to verify.



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


[GitHub] [superset] etr2460 commented on a diff in pull request #20823: fix(dashboard): add toast if JSON metadata is invalid

Posted by GitBox <gi...@apache.org>.
etr2460 commented on code in PR #20823:
URL: https://github.com/apache/superset/pull/20823#discussion_r972481872


##########
superset-frontend/src/dashboard/components/PropertiesModal/index.tsx:
##########
@@ -294,7 +296,12 @@ const PropertiesModal = ({
 
     // color scheme in json metadata has precedence over selection
     if (currentJsonMetadata?.length) {
-      const metadata = JSON.parse(currentJsonMetadata);
+      let metadata;
+      try {
+        metadata = JSON.parse(currentJsonMetadata);
+      } catch (error) {
+        addDangerToast(t('JSON metadata is invalid!'));

Review Comment:
   @zhaoyongjie shouldn't this re-throw the error (or at least return from the function) if we don't have valid metadata here so we don't try to save an invalid payload?



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


[GitHub] [superset] codecov[bot] commented on pull request #20823: fix(dashboard): add toast if JSON metadata is invalid

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #20823:
URL: https://github.com/apache/superset/pull/20823#issuecomment-1192513270

   # [Codecov](https://codecov.io/gh/apache/superset/pull/20823?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#20823](https://codecov.io/gh/apache/superset/pull/20823?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d272a7c) into [master](https://codecov.io/gh/apache/superset/commit/9c7bcfceadb1101899d6c09330aa8e79330d656f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9c7bcfc) will **increase** coverage by `0.01%`.
   > The diff coverage is `66.66%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #20823      +/-   ##
   ==========================================
   + Coverage   66.30%   66.32%   +0.01%     
   ==========================================
     Files        1756     1757       +1     
     Lines       66735    66766      +31     
     Branches     7049     7059      +10     
   ==========================================
   + Hits        44251    44284      +33     
   + Misses      20688    20684       -4     
   - Partials     1796     1798       +2     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `51.98% <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=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/20823?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...src/dashboard/components/PropertiesModal/index.tsx](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL1Byb3BlcnRpZXNNb2RhbC9pbmRleC50c3g=) | `62.82% <66.66%> (-0.17%)` | :arrow_down: |
   | [...t-frontend/src/dashboard/containers/SliceAdder.jsx](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb250YWluZXJzL1NsaWNlQWRkZXIuanN4) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...rontend/src/dashboard/containers/DashboardGrid.jsx](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb250YWluZXJzL0Rhc2hib2FyZEdyaWQuanN4) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset-frontend/src/featureFlags.ts](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2ZlYXR1cmVGbGFncy50cw==) | `66.66% <0.00%> (-33.34%)` | :arrow_down: |
   | [...c/dashboard/components/dnd/AddSliceDragPreview.jsx](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2RuZC9BZGRTbGljZURyYWdQcmV2aWV3LmpzeA==) | `50.00% <0.00%> (-10.00%)` | :arrow_down: |
   | [...t-frontend/src/dashboard/components/SliceAdder.jsx](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL1NsaWNlQWRkZXIuanN4) | `62.66% <0.00%> (-9.34%)` | :arrow_down: |
   | [...rontend/src/dashboard/components/DashboardGrid.jsx](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0Rhc2hib2FyZEdyaWQuanN4) | `55.35% <0.00%> (-7.15%)` | :arrow_down: |
   | [superset-frontend/src/views/store.ts](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3ZpZXdzL3N0b3JlLnRz) | `65.00% <0.00%> (-3.75%)` | :arrow_down: |
   | [...set-frontend/src/explore/actions/hydrateExplore.ts](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvYWN0aW9ucy9oeWRyYXRlRXhwbG9yZS50cw==) | `60.00% <0.00%> (-1.54%)` | :arrow_down: |
   | [superset-frontend/src/dashboard/constants.ts](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb25zdGFudHMudHM=) | `100.00% <0.00%> (ø)` | |
   | ... and [34 more](https://codecov.io/gh/apache/superset/pull/20823/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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


[GitHub] [superset] john-bodley commented on a diff in pull request #20823: fix(dashboard): add toast if JSON metadata is invalid

Posted by GitBox <gi...@apache.org>.
john-bodley commented on code in PR #20823:
URL: https://github.com/apache/superset/pull/20823#discussion_r974411277


##########
superset-frontend/src/dashboard/components/PropertiesModal/index.tsx:
##########
@@ -294,7 +296,12 @@ const PropertiesModal = ({
 
     // color scheme in json metadata has precedence over selection
     if (currentJsonMetadata?.length) {
-      const metadata = JSON.parse(currentJsonMetadata);
+      let metadata;
+      try {
+        metadata = JSON.parse(currentJsonMetadata);
+      } catch (error) {
+        addDangerToast(t('JSON metadata is invalid!'));

Review Comment:
   @zhaoyongjie is there any update regarding a fix for this?



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