Skip to content

[Stateful sidenav] User profile opt in/out#179270

Merged
sebelga merged 29 commits intoelastic:mainfrom
sebelga:stateful-sidenav/user-profile-toggle
Apr 2, 2024
Merged

[Stateful sidenav] User profile opt in/out#179270
sebelga merged 29 commits intoelastic:mainfrom
sebelga:stateful-sidenav/user-profile-toggle

Conversation

@sebelga
Copy link
Copy Markdown
Contributor

@sebelga sebelga commented Mar 22, 2024

As part of the onboarding users to the new "solution" navigation, we want to allow the user to opt out and revert to the current "classic" navigation.

In this PR I've added a toggle in the user profile dropdown to allow reverting to the "classic" navigation.

How to test

  • Add the following setting in kibana.yml
navigation.solutionNavigation.featureOn: true
navigation.solutionNavigation.enabled: true
navigation.solutionNavigation.optInStatus: visible
navigation.solutionNavigation.defaultSolution: es
xpack.cloud.id: "ftr_fake_cloud_id:aGVsbG8uY29tOjQ0MyRFUzEyM2FiYyRrYm4xMjNhYmM="
xpack.cloud.base_url: "https://cloud.elastic.co"
xpack.cloud.deployment_url: "/deployments/deploymentId"
xpack.cloud.organization_url: "/account/"
xpack.cloud.billing_url: "/billing/"
xpack.cloud.profile_url: "/user/settings/"
xpack.cloud.performance_url: "/performance/"
xpack.cloud.users_and_roles_url: "/users-and-roles/"
  • Lauch Kibana
  • There should be a toggle in the user menu to opt out or back in of the new navigation

Screenthot

Screenshot 2024-03-22 at 16 30 43

Note on implementation changes

I've also changed the way the project navigation is initiated by requiring an id to be passed. This simplified the implementation to detect if we try to initiate a navigation tree multiple times.

@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 22, 2024

/ci

@sebelga sebelga self-assigned this Mar 22, 2024
@sebelga sebelga added release_note:skip Skip the PR/issue when compiling release notes Feature:Chrome Core's Chrome UI (sidenav, header, breadcrumbs) labels Mar 22, 2024
@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 22, 2024

/ci

@sebelga sebelga force-pushed the stateful-sidenav/user-profile-toggle branch from a574e06 to 1105ebf Compare March 24, 2024 19:03
@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 24, 2024

/ci

2 similar comments
@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 25, 2024

/ci

@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 25, 2024

/ci

@sebelga sebelga force-pushed the stateful-sidenav/user-profile-toggle branch from fb6929c to 60cc59a Compare March 25, 2024 17:42
@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 25, 2024

/ci

@sebelga sebelga force-pushed the stateful-sidenav/user-profile-toggle branch from b729482 to a0db6b4 Compare March 25, 2024 22:18
@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 25, 2024

/ci

@sebelga sebelga force-pushed the stateful-sidenav/user-profile-toggle branch from a0db6b4 to 7e94b65 Compare March 26, 2024 09:19
@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 26, 2024

/ci

Copy link
Copy Markdown
Contributor

@kc13greiner kc13greiner left a comment

Choose a reason for hiding this comment

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

Still reviewing/testing! but wanted to bring up using uiSettingsClient for theme asap

@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 26, 2024

wanted to bring up using uiSettingsClient for theme asap

Thanks for reviewing @kc13greiner. This PR is not about dark mode toggle. I just slightly refactored the file to make it clearer and fix an issue when interacting with multiple user profile settings.

If you think a different approach should be done for the dark mode toggle it would be better to open a separate issue and address it in a different PR.

Copy link
Copy Markdown
Contributor

@kc13greiner kc13greiner left a comment

Choose a reason for hiding this comment

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

Im not sure how it should default if UserProfiles is not available, but currently it doesn't let the user toggle it/its stuck in "new mode"

const chrome = core.chrome as InternalChromeStart;

if (security) {
this.userProfileOptOut$ = security.userProfiles.userProfileLoaded$.pipe(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

UserProfiles isn't guaranteed to be available (not sure exactly where to link this discussion 😅 )

How should this feature behave in this case? I.e. anonymous user

Screenshot 2024-03-26 at 12 18 50 PM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

UserProfiles isn't guaranteed to be available (not sure exactly where to link this discussion 😅 )

I tried to outline all cases when user doesn't have a profile (== profile id) here #175431 (comment) (TL;DR: anonymous users, interactive users authenticated via HTTP proxy, non-interactive users or HTTP clients).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @azasypkin . I think for this use case with user facing UI we can discard non-interactive users or HTTP clients.
As you can see on this change, I disable the user profile (updating a new enabled$ Observable) if we receive a 404 when fetching the profile. This correspond to this logic on the server.

@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 26, 2024

Im not sure how it should default if UserProfiles is not available, but currently it doesn't let the user toggle it/its stuck in "new mode"

Can you provide me the steps to reproduce this config (with security but without user profile)?

@kc13greiner
Copy link
Copy Markdown
Contributor

Im not sure how it should default if UserProfiles is not available, but currently it doesn't let the user toggle it/its stuck in "new mode"

Can you provide me the steps to reproduce this config (with security but without user profile)?

Of course! The following will setup an anonymous user in KB:

in your kibana.yml:

xpack.security.authc.providers:
  basic.basic1:
    order: 0
  anonymous.anonymous1:
    order: 1
    credentials:
      username: "anonymous_user"
      password: "changeme"

Login first as elastic/changeme, navigate to the Users page.

Create a user anonymous_user/changeme (or however you chose to list it in the config above)

Logout, then when at the login page, click the Login as Guest option

More info available here!

@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Mar 27, 2024

Thanks for the info @kc13greiner, I handled the case for anonymous users with no user profile data in 88f0ee0
Can you have another look? Cheers 👍

Copy link
Copy Markdown
Member

@efegurkan efegurkan left a comment

Choose a reason for hiding this comment

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

LGTM!

code review only

@sebelga sebelga requested a review from kc13greiner March 28, 2024 10:27
@kc13greiner
Copy link
Copy Markdown
Contributor

ACK: will review shortly!

Copy link
Copy Markdown
Contributor

@kc13greiner kc13greiner left a comment

Choose a reason for hiding this comment

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

Thanks for making these changes, just a few remaining questions!

The case for anon user does work now, but I don't know if we'd want to show the toggle in the event of any non-successful retrieval of UserProfile.

Question: Can the observable logic be consolidated to just userProfile$ having data?

Copy link
Copy Markdown
Contributor

@Samiul-TheSoccerFan Samiul-TheSoccerFan 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.
If I turned on classic navigation, currently this is how the Search navigation menu looks like:
Screenshot 2024-03-28 at 5 01 22 PM

Is this expected?

@sebelga sebelga requested a review from kc13greiner April 1, 2024 10:25
@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Apr 1, 2024

Can the observable logic be consolidated to just userProfile$ having data?

The userProfileLoaded$ Observable that was put in place to inform consumers if the user profile has been loaded was mainly to avoid an annoying flickering of the whole UI when switching between a black header (classic nav) to a white one.
Indeed, until the user profile is loaded we don't know if the user has opted out or not. So undefined is not enough information. But undefined after the user profile is loaded has a different meaning.
Hope that clarifies why I implemented it the way it is.

currently this is how the Search navigation menu looks like

@Samiul-TheSoccerFan I am currently working in a PR that will bring the correct IA for oblt and search. I will also fix the issue you mention here so great catch, fix it's coming in a future PR 👍
As a reminder, all of the changes for the new nav are behind a feature flag and not released to any users.

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cloudLinks 43 44 +1
navigation 74 87 +13
total +14

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/user-profile-components 21 22 +1
serverless 23 24 +1
total +2

Async chunks

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

id before after diff
navigation 21.9KB 21.9KB +1.0B
security 579.7KB 579.9KB +179.0B
total +180.0B

Page load bundle

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

id before after diff
cloudLinks 15.5KB 16.0KB +499.0B
core 405.4KB 405.7KB +293.0B
navigation 16.2KB 21.4KB +5.3KB
security 65.6KB 66.6KB +1.1KB
securitySolutionServerless 36.1KB 36.1KB +11.0B
serverless 11.0KB 11.0KB +4.0B
serverlessObservability 26.7KB 26.7KB +7.0B
serverlessSearch 19.4KB 19.4KB +9.0B
total +7.2KB
Unknown metric groups

API count

id before after diff
@kbn/security-plugin-types-public 49 53 +4
@kbn/user-profile-components 80 81 +1
serverless 24 25 +1
total +6

References to deprecated APIs

id before after diff
navigation 0 2 +2

History

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

cc @sebelga

Copy link
Copy Markdown
Contributor

@kc13greiner kc13greiner left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation 🚀

@sebelga sebelga merged commit b61b944 into elastic:main Apr 2, 2024
@sebelga sebelga deleted the stateful-sidenav/user-profile-toggle branch April 2, 2024 08:51
@kibanamachine kibanamachine added v8.14.0 backport:skip This PR does not require backporting labels Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR 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 Platform AppEx-SharedUX (formerly Global Experience) t// v8.14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.