Skip to content

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

Merged
yctercero merged 1 commit intoelastic:7.xfrom
yctercero:backport/7.x/pr-75009
Sep 4, 2020
Merged

[7.x] [Security Solution][Detections][Tech Debt] - Move to using common io-ts types (#75009)#76780
yctercero merged 1 commit intoelastic:7.xfrom
yctercero:backport/7.x/pr-75009

Conversation

@yctercero
Copy link
Copy Markdown
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`
@yctercero yctercero added the backport This PR is a backport of another PR label Sep 4, 2020
@kibanamachine
Copy link
Copy Markdown
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

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants