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

Move Nav APIs to new platform #34490

Merged
merged 9 commits into from
May 10, 2019
Merged

Conversation

joshdover
Copy link
Contributor

@joshdover joshdover commented Apr 3, 2019

Summary

Subpart of #18843 and #34091

This moves the core Nav APIs from ui/chrome into the ChromeService in the new platform.

  • ChromeStart now exposes a sub-service for reading and making limited updates to navlinks. These are powered by apps registered with the ApplicationService and filtered by UI Capabilities before being exposed by the ChromeService.
  • The header-global-nav directive now consumes navlinks from the new platform.
  • The lastSubUrl feature utilized by legacy apps has been refactored and will remain in ui/chrome. This feature utilizes the limited fields that ChromeService exposes to updates by outside code.

This change is the main blocker to moving the Chrome UI to the new platform. This will be necessary to enable the new platform to control top-level routing.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@joshdover joshdover force-pushed the chrome-navlinks branch 2 times, most recently from 1a9c0c7 to c613334 Compare April 9, 2019 22:11
@elasticmachine

This comment has been minimized.

@joshdover joshdover changed the base branch from master to application-service April 10, 2019 18:50
@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@joshdover joshdover force-pushed the chrome-navlinks branch 2 times, most recently from 34c6aac to 3f83a08 Compare April 16, 2019 17:00
@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine

This comment has been minimized.

@joshdover joshdover changed the base branch from application-service to master May 7, 2019 18:56
@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@joshdover
Copy link
Contributor Author

joshdover commented May 8, 2019

At some point in the future we might want to look at what should be available to plugins when adding icons to the nav bar.
It appears the ability to disable an icon is broken or not available any more. This has been the case from before this PR. Is it a feature that is needed at all?
Looking at the license checking in most plugins, they are all quite similar, probably due to people copying code. When we first came to add ML to kibana we copied the way an existing plugin was doing it.
Because of this I believe there is some redundant code which people have added to their plugins because they assumed they needed to.
For example, most plugins add an enableLinks flag to the features passed to the client side.
It looks like logstash and reporting are making use of this flag, but others aren't.

@jgowdyelastic

I'm going to dig into why this is broken exactly, it may be that the Nav UI code is not reading the disabled property correctly.

My idea for this going forward is to allow applications to update their status via the ApplicationService in the new platform, rather than interfacing with Chrome APIs to update links. This way, the ApplicationService can manage displaying a license page of information or redirecting to somewhere else in Kibana.

@joshdover joshdover requested a review from eliperelman May 8, 2019 16:14
Copy link
Contributor

@eliperelman eliperelman left a comment

Choose a reason for hiding this comment

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

Looks great!

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Things are looking really good, but I'm pretty sure that subUrl handling is applying outside of Kibana and I'm pretty sure that wasn't the case before recently (maybe before this change)

src/legacy/ui/public/chrome/api/sub_url_hooks.js Outdated Show resolved Hide resolved
const href = relativeToAbsolute(chrome.addBasePath(recentlyAccessed.link));
const navLink = navLinks.find(nl => href.startsWith(nl.subUrlBase));
const href = chrome.addBasePath(recentlyAccessed.link);
const navLink = navLinks.find(nl => href.startsWith(nl.appUrl));
Copy link
Contributor

Choose a reason for hiding this comment

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

This no longer finds the navLink for recently accessed items when basePath is in use, because nl.appUrl doesn't have the basePath, but href does.

@joshdover
Copy link
Contributor Author

@spalger I've updated this to fix the bug when there are multiple Kibana instances running under different base paths on the same domain. This requires using mostly absolute URLs as the internal representation (as it was before this change). I've also renamed appUrl (which wasn't actually a URL) to baseUrl (which now is an absolute URL).

navLink.disabled = !xpackInfo.get('features.ml.isAvailable', false);
}

const navLinkUpdates = {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 want to apply the same treatment to x-pack/plugins/graph/public/hacks/toggle_app_link_in_nav.js?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Bring subUrlBase into new platform ☹️
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

LGTM!

@joshdover joshdover merged commit 3dacef2 into elastic:master May 10, 2019
@joshdover joshdover deleted the chrome-navlinks branch May 10, 2019 14:03
joshdover added a commit to joshdover/kibana that referenced this pull request May 10, 2019
This moves the core Nav APIs from `ui/chrome` into the `ChromeService` in the new platform.

- `ChromeStart` now exposes a sub-service for reading and making limited updates to navlinks. These are powered by apps registered with the `ApplicationService` and filtered by UI Capabilities before being exposed by the `ChromeService`.
- The `header-global-nav` directive now consumes navlinks from the new platform.
- The `lastSubUrl` feature utilized by legacy apps has been refactored and will remain in `ui/chrome`. This feature utilizes the limited fields that `ChromeService` exposes to updates by outside code.

This change is the main blocker to moving the Chrome UI to the new platform. This will be necessary to enable the new platform to control top-level routing.
@joshdover joshdover added this to In progress in kibana-core [DEPRECATED] May 10, 2019
joshdover added a commit that referenced this pull request May 10, 2019
This moves the core Nav APIs from `ui/chrome` into the `ChromeService` in the new platform.

- `ChromeStart` now exposes a sub-service for reading and making limited updates to navlinks. These are powered by apps registered with the `ApplicationService` and filtered by UI Capabilities before being exposed by the `ChromeService`.
- The `header-global-nav` directive now consumes navlinks from the new platform.
- The `lastSubUrl` feature utilized by legacy apps has been refactored and will remain in `ui/chrome`. This feature utilizes the limited fields that `ChromeService` exposes to updates by outside code.

This change is the main blocker to moving the Chrome UI to the new platform. This will be necessary to enable the new platform to control top-level routing.
@joshdover joshdover moved this from In progress to Done in kibana-core [DEPRECATED] May 10, 2019
@epixa epixa mentioned this pull request May 10, 2019
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants