elastic / kibana

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

[ENDPOINT][TECH DEBT] Simplify the code to do history navigation in trusted apps (and other sections) #80143

Open efreeti opened 3 years ago

efreeti commented 3 years ago

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:

https://github.com/elastic/kibana/pull/79485#discussion_r499799145

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:

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:

Here are some proposed solutions:

elasticmachine commented 3 years ago

Pinging @elastic/endpoint-management (Team:Endpoint Management)

paul-tavares commented 3 years ago

Not sure if this helps with the issue being tracked here, but we do have this hook here with may be related:

https://github.com/elastic/kibana/blob/1216b0f7cd2c0697393547432bee343ed33b96b5/x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_by_router_event_handler.ts