[ENDPOINT][TECH DEBT] Simplify the code to do history navigation in trusted apps (and other sections) #80143
Labels
Feature:SecurityAdmin
Security Solution administration feature
Team:Defend Workflows
“EDR Workflows” sub-team of Security Solution
Team: SecuritySolution
Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc.
technical debt
Improvement of the software architecture and operational architecture
In trusted apps I've experimented with a custom hook for making navigation simpler:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/hooks.ts#L33
There were some comments about it being not ideal:
#79485 (comment)
The issue to be discussed solved - when implementing history navigation in trusted apps (and in other sections of endpoint management) for that matter we always have to perform couple of operations that are same all over the place:
const location = useTrustedAppsSelector(getCurrentLocation);
const newLocation = { ...location, param: 'new value' }
const uri = getTrustedAppsListPath(newLocation);
hostory.push(uri);
Though it's not tremendously big chunk of code it repeats often and it makes every component that wants to do navigation directly have dependencies on useHistory (react routing), useTrustedAppsSelector (useSelector, react-redux), and location type. To avoid this boilerplate I've added the mentioned above hook. As mentioned it has couple of consequences:
callback
parameter from the list of dependencies. This is suboptimal.Here are some proposed solutions:
Makes it a bit bulkier but solves the memoization problems and allows to remove disabling of ESLint check.
The text was updated successfully, but these errors were encountered: