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

chore: should return if get a exception in Dashboard edit modal #21524

Merged
merged 1 commit into from
Sep 20, 2022

Conversation

zhaoyongjie
Copy link
Member

SUMMARY

According to the discussion here, make a minor refactor to validate the JSON string to make sure the currentJsonMetadata must be a validated JSON string and it should be in '{}'

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

After

validate.JSON.mov

TESTING INSTRUCTIONS

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 -24 to +32
import { AsyncSelect, Row, Col, AntdForm } from 'src/components';
import { AntdForm, AsyncSelect, Col, Row } from 'src/components';
import rison from 'rison';
import {
styled,
t,
SupersetClient,
getCategoricalSchemeRegistry,
ensureIsArray,
getCategoricalSchemeRegistry,
getSharedLabelColor,
styled,
SupersetClient,
t,
Copy link
Member Author

Choose a reason for hiding this comment

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

resort by IDE

Comment on lines +303 to +315
let metadata;
try {
if (
!currentJsonMetadata.startsWith('{') ||
!currentJsonMetadata.endsWith('}')
) {
throw new Error();
}
metadata = JSON.parse(currentJsonMetadata);
} catch (error) {
addDangerToast(t('JSON metadata is invalid!'));
return;
}
Copy link
Member Author

@zhaoyongjie zhaoyongjie Sep 20, 2022

Choose a reason for hiding this comment

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

Move the validated logic out of the if clause. Add return statement in catch case,

Copy link
Member

@stephenLYZ stephenLYZ left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Sep 20, 2022

Codecov Report

Merging #21524 (c09a5a1) into master (fdb4702) will decrease coverage by 0.00%.
The diff coverage is 42.10%.

@@            Coverage Diff             @@
##           master   #21524      +/-   ##
==========================================
- Coverage   66.67%   66.66%   -0.01%     
==========================================
  Files        1793     1793              
  Lines       68493    68500       +7     
  Branches     7275     7279       +4     
==========================================
  Hits        45665    45665              
- Misses      20966    20971       +5     
- Partials     1862     1864       +2     
Flag Coverage Δ
javascript 52.82% <42.10%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...src/dashboard/components/PropertiesModal/index.tsx 61.07% <42.10%> (-0.75%) ⬇️
...frontend/src/components/ListView/Filters/index.tsx 52.17% <0.00%> (-14.50%) ⬇️
...ns/plugin-chart-word-cloud/src/chart/WordCloud.tsx 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zhaoyongjie zhaoyongjie merged commit 4200082 into apache:master Sep 20, 2022
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Sep 21, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 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 size/M 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants