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

feat: alerts/reports add/edit modal #11770

Merged
merged 19 commits into from
Dec 11, 2020

Conversation

riahk
Copy link
Contributor

@riahk riahk commented Nov 21, 2020

SUMMARY

  • Add AlertReportModal
  • Add components for ant-d Select and Radio

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2020-12-07 at 2 18 32 PM

Screen Shot 2020-12-07 at 2 17 49 PM

TEST PLAN

  • Add spec file for AlertReportModal

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov-io
Copy link

codecov-io commented Nov 21, 2020

Codecov Report

Merging #11770 (5b15176) into master (2769de3) will decrease coverage by 6.67%.
The diff coverage is 5.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11770      +/-   ##
==========================================
- Coverage   67.23%   60.56%   -6.68%     
==========================================
  Files         948      906      -42     
  Lines       46177    44641    -1536     
  Branches     4405     4038     -367     
==========================================
- Hits        31046    27035    -4011     
- Misses      15019    17606    +2587     
+ Partials      112        0     -112     
Flag Coverage Δ
cypress 53.17% <5.42%> (+3.86%) ⬆️
javascript ?
python 64.54% <66.66%> (-0.04%) ⬇️

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

Impacted Files Coverage Δ
...set-frontend/src/common/components/Modal/Modal.tsx 100.00% <ø> (ø)
superset-frontend/src/common/components/index.tsx 100.00% <ø> (ø)
superset-frontend/src/middleware/asyncEvent.ts 26.38% <ø> (-61.77%) ⬇️
...perset-frontend/src/views/CRUD/alert/AlertList.tsx 1.51% <0.00%> (-80.68%) ⬇️
superset-frontend/src/views/CRUD/alert/types.ts 100.00% <ø> (ø)
superset-frontend/src/views/CRUD/hooks.ts 59.60% <0.00%> (+2.72%) ⬆️
superset/reports/api.py 84.21% <ø> (ø)
...frontend/src/views/CRUD/alert/AlertReportModal.tsx 4.15% <4.15%> (ø)
superset-frontend/src/common/components/Radio.tsx 37.50% <37.50%> (ø)
superset-frontend/src/common/components/Select.tsx 60.00% <60.00%> (ø)
... and 354 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2769de3...f2b2556. Read the comment docs.

@riahk riahk marked this pull request as ready for review December 7, 2020 22:19
superset/config.py Outdated Show resolved Hide resolved
}`,
})),
// @ts-ignore: Type not assignable
validator_config_json: JSON.parse(resource.validator_config_json),
Copy link
Member

Choose a reason for hiding this comment

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

if you assign this to a var with a type, you should be able to assign it. Eg,

const validatorConfig: AlertObject["validator_config_json"] = JSON.parse(resource.validator_config_json)

...

validator_config_json: validatorConfig

or (JSON.parse(resource.validator_config_json) as AlertObject["validator_config_json"])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the issue here if more that resource is expecting validator_config_json to be an object, not a string. I considered adding string to the type definition but it ended up creating more errors/checks I would need to handle, so ignoring this one case with the stringified response felt like less work in the long run.

Copy link
Member

Choose a reason for hiding this comment

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

right, I don't think having to always serialize the validator config object to json before adding it to an AlertObject is desirable or practical. This suggestion is to get rid of the ts-ignore comment by casting the output of the json parse to the desired type or to store it in typed var.

https://stackoverflow.com/questions/38688822/how-to-parse-json-string-in-typescript

Comment on lines +91 to +95
if "validator_config_json" in self._properties:
self._properties["validator_config_json"] = json.dumps(
self._properties["validator_config_json"]
)

Copy link
Member

Choose a reason for hiding this comment

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

wondering if we should handle this client side before we make the request. It is confusing having json inside json. Or perhaps add a check to see if validator_config_json is already a json string before running this, that way the api would support both (json string or json object).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dpgaspar added this logic to make it easier for the FE (you can see it in the create logic already), by not requiring us to stringify our json beforehand, which I'm fine with. Do you see it as being an issue in the long run?

Copy link
Member

Choose a reason for hiding this comment

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

My main concern is with the api spec (ie, /swagger/v1). If it specifies a json string for this field a user will likely make an api request with a json string and possibly encounter a opaque error message from the api server.

Copy link
Member

@dpgaspar dpgaspar Dec 9, 2020

Choose a reason for hiding this comment

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

I think that the OpenAPI spec is clear on this, it's just a nested structure, this happens on other places also. I think it's more elegant then sending a JSON string for a specific field

Screenshot 2020-12-09 at 18 28 46

@nytai
Copy link
Member

nytai commented Dec 9, 2020

Screen Shot 2020-12-08 at 5 56 27 PM

We should probably set a min-width and overflow-x: auto on the modal.

@riahk riahk requested a review from nytai December 9, 2020 22:28
@@ -0,0 +1,1317 @@
/**
Copy link
Member

Choose a reason for hiding this comment

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

this is a very large file, it's kind of hard to parse out the various pieces. Moving the styled components into a seperate file would help. Separating out some of the stateful logic from the jsx markup would also help.

We're planning another round of changes for this feature so we can wait to address this then.

Copy link
Member

@nytai nytai left a comment

Choose a reason for hiding this comment

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

LGTM

@nytai nytai merged commit 6963087 into apache:master Dec 11, 2020
@nytai nytai deleted the moriah/alert-report-modal branch December 11, 2020 23:50
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.0 labels Mar 12, 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/XXL 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants