Skip to content
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

[Ingest Manager] Consolidate routing and add breadcrumbs to all pages #66475

Merged
merged 11 commits into from
May 14, 2020

Conversation

jen-huang
Copy link
Contributor

@jen-huang jen-huang commented May 13, 2020

Resolves #63981
Resolves #66030

Summary

This PR adds breadcrumbs to all pages. As part of this work, I also consolidated our routing and linking constants and methods (the breadcrumbs work would have been messy otherwise 🙂). More detailed summary of changes:

  • constants/page_paths.ts was added which exports PAGE_ROUTING_PATHS and pagePathGetters, as well as types for page names
    • PAGE_ROUTING_PATHS are strings used for declaring React routes i.e. <Routh path={...}>
    • pagePathGetters are methods to retrieve/build a path to a specific page
    • The two are declared separately rather than using 'magic' to build pagePathGetters from PAGE_ROUTING_PATHS as it's trivial to update paths in both places
  • useLink() hook was updated to return two methods: getHref() and getPath()
    • Exporting methods rather than returning an href string directly lets us use useLink more easily in components
    • getHref is used for links that appear in the UI, it builds a full path that includes the Kibana base path
    • getPath does not include the Kibana base path and is used for React router's history.push
  • All existing links and redirects were updated to use useLink()
    • Some components/sections had their own routing hooks, those were removed and usages were replaced
  • useBreadcrumbs() hook was created and implemented across all pages
    • In addition to setting breadcrumbs, calling useBreadcrumbs() also sets the page title by reversing breadcrumbs
    • The file also includes definitions for breadcrumbs for all page names

Updating routes becomes trivial with these changes. For example in 7a09c91 I updated /epm routes to /integrations to resolve #66030. This updated all links including breadcrumbs.

Screenshots

image

image

image

@jen-huang jen-huang added chore v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.9.0 Team:Fleet Team label for Observability Data Collection Fleet team labels May 13, 2020
@jen-huang jen-huang requested a review from a team May 13, 2020 20:43
@jen-huang jen-huang self-assigned this May 13, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

return core.http.basePath.prepend(`${BASE_PATH}#${path}`);
}
return {
getPath: (page: StaticPage | DynamicPage, values?: DynamicPagePathValues) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not returning getPath directly? we can avoid to create a new function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, leftover logic from when I DRY'd getPath 😅

Copy link
Contributor

@jfsiii jfsiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this out locally and clicked around. The breadcrumb changes LGTM and are reason enough for me to ship.

I'd like to revisit the links later but anything I'd want to change is also much easier thanks to this PR. It's a big improvement over what we have now. Thanks!

edit_datasource: ({ configId, datasourceId }) =>
`/configs/${configId}/edit-datasource/${datasourceId}`,
fleet: () => '/fleet',
fleet_agent_list: () => '/fleet/agents',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw the kuery param used somewhere. Can we change to something like

Suggested change
fleet_agent_list: () => '/fleet/agents',
fleet_agent_list: ({ kuery }) => `/fleet/agents?kuery=${kuery}`',

<EuiLink
href={`${getHref(
'fleet_agent_list'
)}?kuery=${AGENT_SAVED_OBJECT_TYPE}.config_id : ${agentConfigId}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this go into an options object?

panel: 'settings',
});
window.location.href = settingsUrl;
history.push(settingsPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@paul-tavares
Copy link
Contributor

Hi @jen-huang my only suggestion would be for the Plugin unmount callback to reset the breadcrumb. I recently noticed that the breadcrumb seems to persist across Plugins - noticed it in Endpoint where we are not currently setting it and were seeing other plugin's crumbs :)

@jen-huang
Copy link
Contributor Author

Thanks for the reviews everyone. I pushed up a change that addresses the concerns 🙂

@jen-huang
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jen-huang jen-huang merged commit 7c22204 into elastic:master May 14, 2020
@jen-huang jen-huang deleted the ingest/breadcrumb branch May 14, 2020 22:28
jen-huang added a commit to jen-huang/kibana that referenced this pull request May 14, 2020
…elastic#66475)

* Initial pass at normalizing links and redirects

* Remove unused nav components

* Normalize & centralize routing paths

* Add breadcrumbs to all pages

* Remove unused var

* Change /epm to /integrations (elastic#66030)

* Fixes from review: kuery param, getPath cleanup, use chrome.docTitle, and teardown breadcrumb and doc title

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jen-huang added a commit that referenced this pull request May 15, 2020
…#66475) (#66668)

* Initial pass at normalizing links and redirects

* Remove unused nav components

* Normalize & centralize routing paths

* Add breadcrumbs to all pages

* Remove unused var

* Change /epm to /integrations (#66030)

* Fixes from review: kuery param, getPath cleanup, use chrome.docTitle, and teardown breadcrumb and doc title

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jloleysens added a commit to jloleysens/kibana that referenced this pull request May 15, 2020
…ent/add-support-in-url-for-hidden-toggle

* 'master' of github.com:elastic/kibana: (34 commits)
  [SIEM][CASE] Fix bug when connector is deleted. (elastic#65876)
  [SIEM][CASE] Improve layout (elastic#66232)
  [Index Management] Support Hidden Indices (elastic#66422)
  Add Login Selector functional tests. (elastic#65705)
  Lens drilldowns (elastic#65675)
  [ML] Custom template for apiDoc markdown (elastic#66567)
  Don't bootstrap core type emits (elastic#66377)
  [Dashboard] Improve loading error handling (elastic#66372)
  [APM] Minor style fixes for the node strokes (elastic#66574)
  [Ingest Manager] Fix create data source from integration (elastic#66626)
  [Metrics UI] Fix default metric alert interval for new conditions (elastic#66610)
  [Metrics UI] Fix alignment and allow clearing metric value (elastic#66589)
  Don't return package name for non-package data streams (elastic#66606)
  [Ingest Manager] Consolidate routing and add breadcrumbs to all pages (elastic#66475)
  [Docs/Reporting] Have the docs about granular timeout match Cloud docs (elastic#66267)
  Don't automatically add license header to code inside plugins dir. (elastic#66601)
  [APM] Don't trigger map layout if no elements (elastic#66625)
  [Logs UI] Validate ML job setup time ranges (elastic#66426)
  Fix pagination bugs in CCR and Remote Clusters (elastic#65931)
  Add cloud icon for supported settings and embed single-sourced getting started (elastic#65610)
  ...

# Conflicts:
#	x-pack/plugins/index_management/public/application/sections/home/index_list/index_table/index_table.js
#	x-pack/plugins/index_management/server/lib/fetch_indices.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch client side route to /integrations [Ingest] Add breadcrumbs across all pages
6 participants