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

[7.x] [Security Solution][Detections][Tech Debt] - Move to using common io-ts types (#75009) #76780

Merged
merged 1 commit into from
Sep 4, 2020

Conversation

yctercero
Copy link
Contributor

Backports the following commits to 7.x:

…ts types (elastic#75009)

## Summary

Part of the DE tech debt includes moving to use the common io-ts types in the UI. Currently, we are using some of them in some places and other times we're using the front end defined typescript types. This means that changes often have to be done on both ends, validation isn't being done at the UI boundary on request or response. Using the common types could help us avoid bugs moving forward. Obviously, there's a lot of code to touch so trying to just do it piece by piece. This PR addresses the following:

- Replaced uses of `NewRule` with common type `CreateRuleSchema` and `UpdateRuleSchema`. These were being combined a bit
- Split `usePersistRule` which was used for both `POST` and `PUT` into two hooks - `useCreateRule` and `useUpdateRule`. 
  - The logic for combining these two relied on checking for the existence of an `id` - if present it would `PUT`, otherwise it would `POST`.
  - However, `id` is not a required property for either of these, so it's not reliable
- Updated the rule edit flow to use `useUpdateRule`
- Updated the rule creation flow to use `useCreateRule`
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
securitySolution 1948 +1 1947

async chunks size

id value diff baseline
securitySolution 9.9MB +7.4KB 9.9MB

page load bundle size

id value diff baseline
securitySolution 812.9KB -89.0B 813.0KB

distributable file count

id value diff baseline
total 47127 +2 47125

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@yctercero yctercero merged commit 568e4cd into elastic:7.x Sep 4, 2020
@yctercero yctercero deleted the backport/7.x/pr-75009 branch October 14, 2020 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants