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

[k7] Make breadcrumbs more consistent #25884

Closed
20 tasks done
spalger opened this issue Nov 19, 2018 · 1 comment
Closed
20 tasks done

[k7] Make breadcrumbs more consistent #25884

spalger opened this issue Nov 19, 2018 · 1 comment
Assignees
Labels
Meta Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@spalger
Copy link
Contributor

spalger commented Nov 19, 2018

Breadcrumbs are an important navigational element in the new k7 redesign, and in an effort to have consistent and predictable breadcrumbs that users can rely on we need to re-evaluate which breadcrumbs we use in different applications. Many applications already use breadcrumbs, but in a way that violates the guidelines for breadcrumbs set out by the Breadcrumb taxonomy issue.

This issue represents the effort I'll be heading up to get the breadcrumbs in shape before 7.0.0-alpha2, which hopefully will give us some time to gather feedback from the community about the new navigation with more of it's components properly implemented before 7.0 GA.

Integrating with the breadcrumbs is pretty straightforward, to set the breadcrumbs use the chrome.breadcrumbs api:

import chrome from 'ui/chrome';

chrome.breadcrumbs.set([
  // each breadcrumb must have a `text` property and optionally an `href` property
  {
    text: 'Section',
    href: '#/some/href'
  },
  // The last breadcrumb should represent the current page and should not have an href
  {
    text: 'Page',
  },
])

If your app uses the angular router then the breadcrumbs will be cleared after each route navigation completes, unless new breadcrumbs have been set since route navigation started. If you are not using the angular router then your app will be responsible for setting/clearing the breadcrumbs between pages. The easiest way to do this is with the k7Breadcrumbs property on your angular routes. This function is called at after your route's resolve functions have been called so they can be accessed with $route.current.locals and should return the breadcrumbs to be used for this route:

uiRoutes.when('/some/path', {
  template,
  // if you have many routes that nest you might want to try breaking them out into
  // their own module like https://github.com/elastic/kibana/blob/16e56bf78715d40eb84b48c833cc63141be29b27/src/legacy/core_plugins/kibana/public/management/sections/indices/breadcrumbs.js
  k7Breadcrumbs: ($route) => [
    { text: 'Foo', href: '#/bar' },
    { text: $route.current.locals.indexPattern.title }
  ]
});

If your app already shows its own breadcrumbs you should conditionally render them by checking the k7Design uiSetting. When this setting is true you should stop rendering the breadcrumbs yourself and instead pass breadcrumbs to the chrome.breadcrumbs API described above.

In non-angular contexts, do this with the uiSettingsClient:

import chrome from 'ui/chrome'
const uiSettings = chrome.getUiSettingsClient();

const k7design = uiSettings.get('k7design');

// if your app is integrated into the Kibana app, please
// subscribe to updates and react on changes
const subscription = uiSettings.getUpdate$().subscribe({
  next: ({ key, newValue }) => {
    if (key === 'k7design') {
      ...
    }
  }
});

// when your component unmounts or whatever
subscription.unsubscribe();

In angular controllers/directives you can bind this config value to your scope with:

.directive('someDirective', {
  ...
  controller($scope, config) {
    config.bindToScope($scope, 'k7design'[, 'optionalAltPropertyName']);
  }
});

Issues:

@spalger spalger added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Meta labels Nov 19, 2018
@spalger spalger self-assigned this Nov 19, 2018
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@spalger spalger changed the title [k7] Update breadcrumbs for k7 [k7] Make breadcrumbs more consistent Nov 19, 2018
spalger pushed a commit that referenced this issue Dec 4, 2018
## Summary

This PR updates the security management routes to provide k7Breadcrumbs used by the new header navigation. See #25884 for general information about the integration with the router and #25689 for the breadcrumb taxonomy

![2018-12-03 19 05 40](https://user-images.githubusercontent.com/1329312/49416328-764b4200-f72e-11e8-9db7-aeb1294d131b.gif)

### Checklist

- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)
spalger pushed a commit that referenced this issue Dec 6, 2018
## Summary

This PR updates the reporting routes to provide k7Breadcrumbs used by the new header navigation. See #25884 for general information about the integration with the router and #25689 for the breadcrumb taxonomy

![image](https://user-images.githubusercontent.com/1329312/49533708-9127ce80-f874-11e8-8f60-ad76f4caafcd.png)

### Checklist

- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)
@spalger spalger closed this as completed Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

2 participants