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

Navbar Extensions in KbnTopNav with Config controls #7508

Merged
merged 15 commits into from
Jul 1, 2016

Conversation

w33ble
Copy link
Contributor

@w33ble w33ble commented Jun 20, 2016

This PR changes the way Navbar Extensions work. It does away with the special directive and instead just loads the extensions out of the registry in the kbnTopNav directive directly. This simplifies how the menu is extended, and also allows the extensions to provide a Config template with application-specific controls.

  • Load ui/registry/navbar_extensions in kbnTopNav
  • Rename some of the kbnTopNav methods for clarity
  • Adds optional label parameter, instead of only relying on the key
    • Used to provide a custom label for the navigation item
  • Update tests
  • Remove navbarExtensions directive

const KbnTopNavController = Private(KbnTopNavControllerProvider);
const navbarExtensions = Private(RegistryNavbarExtensionsProvider);
const getNavbarExtensions = _.memoize(function (name) {
Copy link
Contributor

@panda01 panda01 Jun 21, 2016

Choose a reason for hiding this comment

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

This should be moved outside of this controller function for the memoize to work correctly, no? Otherwise a new instance of these is made every time you use this directive.

If you move this you should also move the navbarExtensions along with it since this is the only place it's used.

@panda01
Copy link
Contributor

panda01 commented Jun 21, 2016

@w33ble Man this is sexy, this is how it should've been done the first time.

@w33ble
Copy link
Contributor Author

w33ble commented Jun 21, 2016

@panda01 well, it wouldn't have been possible without your work consolidating the top nav stuff ;)

I'll go make those changes, thanks for taking a look.


// apply the defaults to individual options
_applyOptDefault(opt = {}) {
return defaults({}, opt, {
label: capitalize(opt.key),
label: opt.label || capitalize(opt.key),
Copy link
Contributor

Choose a reason for hiding this comment

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

I should test this, but this shouldn't be necessary, if you set opt.label on the raw object due to _.defaults. docs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

D'oh!

@panda01
Copy link
Contributor

panda01 commented Jun 21, 2016

Smooth @w33ble, other than the mentions, this looks phenomenal. Once those are in, I'll give it the acronym of approval.

@panda01
Copy link
Contributor

panda01 commented Jun 21, 2016

Also, we can close #7443 in exchange for this one, no?

w33ble added 3 commits June 21, 2016 10:12
now that we no longer need to inject values from the code
makes the include happen once, and the memoize actually work as expected
@w33ble
Copy link
Contributor Author

w33ble commented Jun 21, 2016

Changes are in, waiting on the tests.

#7443 is for the backport to 4.x; same functionality, different implementation since there's no kbnTopNav there.

@panda01
Copy link
Contributor

panda01 commented Jun 29, 2016

LGTM!

@panda01 panda01 assigned w33ble and unassigned panda01 Jun 29, 2016
@w33ble w33ble mentioned this pull request Jul 1, 2016
@w33ble w33ble merged commit b583bf6 into elastic:master Jul 1, 2016
@jbudz jbudz mentioned this pull request Jul 5, 2016
@epixa epixa added v5.0.0 and removed v5.0.0 labels Aug 1, 2016
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
Navbar Extensions in KbnTopNav with Config controls

Former-commit-id: b583bf6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants