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

[Stateful sidenav] Dynamic links #183157

Merged
merged 43 commits into from May 22, 2024

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented May 10, 2024

In this PR I've added the dynamic links to the new solution view side navigation for the "enterprise search" solution.

I've decided to remove the original package created for the navigation tree declaration and move it to the enterprise_search plugin as it created an unnecessary indirection and boilerplate.

Fixes #179751

How to test

Add the following in the kibana.dev.yml

xpack.cloud.id: "ftr_fake_cloud_id:aGVsbG8uY29tOjQ0MyRFUzEyM2FiYyRrYm4xMjNhYmM="
xpack.cloud.base_url: "https://cloud.elastic.co"
xpack.cloud.deployment_url: "/deployments/deploymentId"

navigation.solutionNavigation.enabled: true
xpack.cloud_integrations.experiments.enabled: true
xpack.cloud_integrations.experiments.flag_overrides:
  "solutionNavEnabled": true

Screenshots

Screenshot 2024-05-21 at 11 18 32 Screenshot 2024-05-21 at 11 19 18 Screenshot 2024-05-21 at 11 19 53

@sebelga
Copy link
Contributor Author

sebelga commented May 10, 2024

/ci

3 similar comments
@sebelga
Copy link
Contributor Author

sebelga commented May 13, 2024

/ci

@sebelga
Copy link
Contributor Author

sebelga commented May 13, 2024

/ci

@sebelga
Copy link
Contributor Author

sebelga commented May 13, 2024

/ci

@sebelga sebelga force-pushed the stateful-sidenav/dynamic-links branch from e69d849 to d1373e1 Compare May 14, 2024 09:18
@sebelga
Copy link
Contributor Author

sebelga commented May 14, 2024

/ci

@sebelga
Copy link
Contributor Author

sebelga commented May 14, 2024

/ci

@sebelga sebelga self-assigned this May 21, 2024
@sebelga sebelga added release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) Feature:Chrome Core's Chrome UI (sidenav, header, breadcrumbs) labels May 21, 2024
@sebelga sebelga marked this pull request as ready for review May 21, 2024 10:55
@sebelga sebelga requested review from a team as code owners May 21, 2024 10:55
@elasticmachine
Copy link
Contributor

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

@sebelga
Copy link
Contributor Author

sebelga commented May 21, 2024

/ci

@sebelga
Copy link
Contributor Author

sebelga commented May 21, 2024

Thanks for the early review @TattdCodeMonkey ! 👍 I'd like to keep this PR focused only on the dynamic links and leave refactors to a separate PR if possible.
I've added tests and fixed CI, could you have another look? Thanks!

Copy link
Contributor

@gsoldevila gsoldevila left a comment

Choose a reason for hiding this comment

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

Core changes LGTM (review only)

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.

code lgtm and tested a bit

const onClick = (e: React.MouseEvent) => {
const onClick = (e: React.MouseEvent<HTMLElement | HTMLButtonElement>) => {
if (customOnClick) {
customOnClick(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to prevent default and/or stop propagation or is the idea that it has to be handled by the CB?

I see that below propagation is stopped even if customOnClick is passed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't want to prevent default for the customOnClick as the consumer handles it.
Regarding the stopPropagation calls, those were probably added to fix some behaviour but it works fine without them. I removed those in 891581c

Thanks for pointing that out 👍


useEffect(() => {
return () => {
updateSideNavDefinition({ collections: undefined });
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why it is in a separate useEffect and not cleaned up on the previous one.

maybe the intention was to clean up only on unmount? but then the dependencies need to be [updateSideNavDefinition]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put it in a separate useEffect as I only want updateSideNavDefinition to be called with undefined when the comp unmounts. Otherwise we would get 2 calls each time navItems changes, right? Or does React handles this case and merges the 2 calls into 1?

Great catch for the useEffect dependency, I removed it in 3271e19

Copy link
Contributor

Choose a reason for hiding this comment

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

React should handle this and only call this function a single time when the component is unmounted.

Copy link
Contributor Author

@sebelga sebelga May 22, 2024

Choose a reason for hiding this comment

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

Apparently it does have a slight effect: it calls the cleaning function on more time

Everytime navItems changes

Screenshot 2024-05-22 at 16 52 05

Only when component unmounts

Screenshot 2024-05-22 at 16 52 40

I am going to leave it as is for now if that's OK.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
enterpriseSearch 2320 2321 +1
navigation 88 86 -2
total -1

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/solution-nav-es 6 - -6
navigation 47 48 +1
total -5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
enterpriseSearch 2.7MB 2.7MB +6.8KB
navigation 22.0KB 22.3KB +252.0B
serverless 22.3KB 22.5KB +252.0B
total +7.3KB

Page load bundle

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

id before after diff
core 409.8KB 409.9KB +129.0B
enterpriseSearch 48.5KB 48.9KB +403.0B
navigation 31.1KB 27.6KB -3.6KB
total -3.0KB
Unknown metric groups

API count

id before after diff
@kbn/core-chrome-browser 205 206 +1
@kbn/solution-nav-es 6 - -6
navigation 49 50 +1
total -4

async chunk count

id before after diff
enterpriseSearch 16 17 +1

ESLint disabled in files

id before after diff
enterpriseSearch 1 2 +1

Total ESLint disabled count

id before after diff
enterpriseSearch 20 21 +1

History

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

cc @sebelga


useEffect(() => {
return () => {
updateSideNavDefinition({ collections: undefined });
Copy link
Contributor

Choose a reason for hiding this comment

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

React should handle this and only call this function a single time when the component is unmounted.

@sebelga sebelga merged commit 5b38b5a into elastic:main May 22, 2024
34 checks passed
@sebelga sebelga deleted the stateful-sidenav/dynamic-links branch May 22, 2024 15:55
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels May 22, 2024
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 Feature:Chrome Core's Chrome UI (sidenav, header, breadcrumbs) release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Stateful side nav] Implement search solution dynamic links
8 participants