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

[Chrome] Expose api to to set custom component for project left nav #156205

Merged
merged 9 commits into from
May 2, 2023

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented Apr 28, 2023

In this PR I've exposed a new api from the Chrome service to set a custom React component for the side navigation.
Calling this API does not have any effect if Kibana is not started in "project" ChromeStyle.

Api

chrome.project.setSideNavComponent(/* component */);

Example

// my_nav.tsx
import React, { type FC } from 'react';
import type { SideNavComponent } from '@kbn/core-chrome-browser';

// SideNavComponent will receive in its props Chrome service state (the current active route, the navTree...) 
export const MyNav: SideNavComponent = (props) => {
  return <div>Custom navigation...</div>;
};

-------------------

// serverless plugin.ts (public)
import { MyNav } from './my_nav';
...

public start(core: CoreStart) {
  core.chrome.project.setSideNavComponent(MyNav);
  return {};
}

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

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

I like the idea of exposing setNavigation and setNavigationComponent. Consumers must call setNavigation with a configuration that defines the nav tree, and other settings for parts of the chrome that deal with navigation info: breadcrumbs, recent items, global search. Calling setNavigationComponent is optional - if consumers don't set that, we will render the SharedUX component.

@sebelga sebelga force-pushed the chrome-nav/setup-api branch from 937b318 to dcfd0b6 Compare May 2, 2023 11:12
@sebelga sebelga marked this pull request as ready for review May 2, 2023 12:10
@sebelga sebelga requested a review from a team as a code owner May 2, 2023 12:10
@sebelga sebelga self-assigned this May 2, 2023
@sebelga sebelga added release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) Project:Serverless MVP labels May 2, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@sebelga
Copy link
Contributor Author

sebelga commented May 2, 2023

Thanks for the review @Dosant and @tsullivan !

I addressed your feedback, can you have another look?

@tsullivan : This first PR is really only to unblock teams that need to set custom react component for the serveless project left navigation. In future PR I will improve the interface for the navigation config and add everything that the @kbn/shared-ux-chrome-navigation requires.

Copy link
Contributor

@Dosant Dosant left a comment

Choose a reason for hiding this comment

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

👍

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
core 423 426 +3

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-chrome-browser 47 58 +11

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 362.3KB 363.5KB +1.1KB
Unknown metric groups

API count

id before after diff
@kbn/core-chrome-browser 124 136 +12

ESLint disabled line counts

id before after diff
@kbn/core-chrome-browser 0 1 +1
enterpriseSearch 19 21 +2
securitySolution 398 401 +3
total +6

Total ESLint disabled count

id before after diff
@kbn/core-chrome-browser 0 1 +1
enterpriseSearch 20 22 +2
securitySolution 478 481 +3
total +6

History

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

cc @sebelga

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

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

LGTM

@clintandrewhall clintandrewhall merged commit 06054cd into elastic:main May 2, 2023
@kibanamachine kibanamachine added v8.9.0 backport:skip This commit does not require backporting labels May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Project:Serverless MVP release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants