elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.48k stars 8.05k forks source link

[Epic][Security Solution][Investigations][Tech Debt] - Update timeline redux #124138

Open michaelolo24 opened 2 years ago

michaelolo24 commented 2 years ago

Background:

Currently within the security_solution, there is a mixture of Redux and context used to manage visual logic or manage prop drilling. In addition, react hooks are used to manage query fetching as well. This mixture of state management, query fetching, and ui state management may have negative rendering performance impacts as well as subtle errors masked by the different interacting forms of state. The effects are somewhat unknown at this point, but from a developer experience standpoint this architecture makes it harder to build upon. The goal of this work will be to update the timeline architecture to make better use of existing redux patterns and centralize state management in a more logical manner.

Existing references

Context:

Data fetching hooks

Existing middleware

### Tasks
- [x] Investigate if redux observable middleware is actually necessary for any of the epics [here](https://github.com/elastic/kibana/tree/main/x-pack/plugins/security_solution/public/timelines/store/timeline)
- [x] Migrate aforementioned epics to standard thunk middleware (https://github.com/elastic/kibana/pull/175450).
- [ ] https://github.com/elastic/kibana/issues/175427
- [x] Move comment -> pin event logic to middleware. Context: https://github.com/elastic/kibana/pull/178009#discussion_r1514063469 (https://github.com/elastic/kibana/pull/178212)
- [x] Remove the timeline note's `timelineVersion` prop. It's not used and creates version confusion. (https://github.com/elastic/kibana/pull/178212)
- [ ] Investigate migrating to a standard tool such as RTK for redux state management: https://redux-toolkit.js.org. Specifcially look into syncing reducers, as migrating to RTK may require migrating all reducers to immer, which should not be part of this work.
- [ ] Develop technical design document for new architecture
- [ ] Develop plan for any `localStorage` or UI migrations that may be necessary
- [ ] Develop plan for adding APM and telemetry around key user actions
- [ ] Implement migration for timeline store (consider maintaining architecture for a multi-timeline environment)
- [ ] Implement migration for timeline selectors
- [ ] Migrate data fetching from hook containers to redux middleware to populate `data` slice of state and create actions to trigger fetching
- [ ] Confirm localStorage saving still works as expected
- [ ] Confirm UI state is working as expected
- [ ] Confirm queries only run once or as many times as expected by the ui interactions

Acceptance Criteria

elasticmachine commented 2 years ago

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)