-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Logs / Metrics UI] Link handling / stop page reloads #58478
[Logs / Metrics UI] Link handling / stop page reloads #58478
Conversation
… been serialized by convert_document_source_to_log_item_fields
@elasticmachine merge upstream |
Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui) |
Note: #58943 will affect this PR ever so slightly (the one line that handles encoding, and potentially minor test changes). I'm going to try and preemptively make those changes on this branch, without that needing merged first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the useLinkProps
hook. It makes all the link generation a lot more readable and I expect it will prevent quite a number of mistakes in the future - great work 👏
One interesting behavior I noticed was that switching between the logs and metrics apps via the sidebar causes no reload, but clicking the "Host logs" entry in the waffle map node context menu does. 🤔 Any idea why that might be?
x-pack/plugins/infra/public/components/navigation/routed_tabs.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/infra/public/components/navigation/routed_tabs.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx
Show resolved
Hide resolved
x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.test.tsx
Show resolved
Hide resolved
@weltenwort Thanks for the review.
The links in the sidebar receive special treatment in new platform allowing the nice no-refresh behaviour when switching between apps. However, with metrics and logs now technically being two separate apps, with independent App IDs, mount functions, and routers, the link rendered in the node context menu for logs is just a plain old If it's okay with you I'd like to look into fixing this when dealing with #58112? Will start addressing the other feedback now 👍 |
Co-Authored-By: Felix Stürmer <[email protected]>
Co-Authored-By: Felix Stürmer <[email protected]>
Co-Authored-By: Felix Stürmer <[email protected]>
Certainly, I just wasn't aware of that separate issue 👍 |
…t/log_entry_actions_menu.tsx Co-Authored-By: Felix Stürmer <[email protected]>
…bana into 58007-stop-link-page-reloads
@weltenwort I've responded to all of the feedback now, this should be ready for another look. The |
(For #58943 I'm not going to try and preemptively make those changes here due to package / webpack alias changes etc. Instead, as there's only really a one line change (and whatever merge conflicts), I'll help with making them over there once this is merged). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for including the explanatory comments. Together with the external/internal comparison it's quite straightforward to understand now. 👍 Nicely done 👏
x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx
Outdated
Show resolved
Hide resolved
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* Add a hook for seamlessly handling onClick and href props of links, buttons etc Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Felix Stürmer <[email protected]>
* master: [Logs / Metrics UI] Link handling / stop page reloads (elastic#58478) Add SavedObject management section registration in core (elastic#59291)
* master: Add a retry to dashboard test for a sometimes slow async operation (elastic#59600) [Endpoint] Sample data generator for endpoint app (elastic#58936) [Vis Editor] Refactoring metrics axes (elastic#59135) [DOCS] Changed Discover app to Discover (elastic#59769) [Metrics Alerts] Add support for search query and groupBy on alerts (elastic#59388) Enhancement - EUICodeEditor for Visualize JSON (elastic#58679) [ML] Transforms: Data grid fixes. (elastic#59538) [SIEM] Fix and consolidate handling of error responses in the client (elastic#59438) [Maps] convert tooltip classes to typescript (elastic#59589) [ML] Functional tests - re-activate date_nanos test (elastic#59649) Move canvas to use NP Expressions service (elastic#58387) Update misc dependencies (elastic#59542) [Unit Testing] Configure react-testing-library queries to use Kibana's data-test-subj instead of default data-testid (elastic#59445) [Console] Remove unused code (elastic#59554) [Logs / Metrics UI] Link handling / stop page reloads (elastic#58478) Add SavedObject management section registration in core (elastic#59291)
* Add a hook for seamlessly handling onClick and href props of links, buttons etc Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Felix Stürmer <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Felix Stürmer <[email protected]>
Summary
This PR fixes #58007. No internal links (metrics <-> metrics, logs <-> logs) will cause a page reload now. Some stray broken links (from the NP migration) have also been fixed. A longstanding bug with the
getUptimeLink
function has also been fixed (serialized arrays (e.g.host.ip
) weren't being handled correctly).Going into more detail: A
useLinkProps
hook has been introduced. My hope is that this can become the primary (hopefully only) way we handle links. This hook takes care of using either interal routing via the react-routerhistory
instance, or external routing. It will return ahref
attribute, plusonClick
where relevant. This return value can be spread (...
) wherever it's needed (generally with EUI components). It is app andbasePath
aware and will handle all of those niggles.To acquire the correct
href
andonClick
atrributes we just need to supply aLinkDescriptor
. We had a lot of locations handling links, and in a lot of cases they were all doing something slightly different. By consolidating things we should be able to have a lot more trust in our linking (as they're hanled in the same way), and changes will be easier to make when necessary.The only thing the hook doesn't handle is complex data types and complex encoding for
search
, e.g. using Rison encoding. This is because some apps use it, and some don't, so I've left this as something for the consumer to handle. It could very well be an option to the hook though, with a default. Ultimately, the hook expectssearch
values to already be strings, or arrays of strings, and in a state that is ready to be handed off tourlUtils.encodeQuery
.Example of an internal link:
This would return a space / basepath aware
href
, plus anonClick
handler that will deal withreact-router
and pushing to thehistory
instance.Example of an external link:
These changes affect links in:
inventory
,settings
etc)