-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
Conversation
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
76f8d03
to
426d4bd
Compare
8f0c15c
to
ecc5506
Compare
}`, | ||
})), | ||
// @ts-ignore: Type not assignable | ||
validator_config_json: JSON.parse(resource.validator_config_json), |
There was a problem hiding this comment.
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"])
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
if "validator_config_json" in self._properties: | ||
self._properties["validator_config_json"] = json.dumps( | ||
self._properties["validator_config_json"] | ||
) | ||
|
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f333a08
to
9d95e36
Compare
@@ -0,0 +1,1317 @@ | |||
/** |
There was a problem hiding this comment.
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.
e5175ee
to
c22de64
Compare
c22de64
to
38f19ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
SUMMARY
AlertReportModal
Select
andRadio
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
AlertReportModal
ADDITIONAL INFORMATION