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

Per User Dark Mode Preference #151507

Merged
merged 69 commits into from
Apr 25, 2023

Conversation

kc13greiner
Copy link
Contributor

@kc13greiner kc13greiner commented Feb 16, 2023

Summary

Allow user's to set their desired theme on their User Profile

How to test

Login as a non-cloud user, navigate to User Profile:
Screenshot 2023-02-28 at 1 40 34 PM

Release Note

Users can now select their theme preference for Kibana in their User Profile

kc13greiner and others added 23 commits February 13, 2023 15:36

return result;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The following methods are left stubbed to complete the interface. While not used currently, the savedObjectsClient is available here for a future iteration of User Settings that may be stored/migrated to SO

Copy link
Member

Choose a reason for hiding this comment

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

Is the intention to create one SO per user to hold other User Settings? What's the benefit we'd get from doing so instead of storing every User Setting in the user's profile? Any known limitations?

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 don't think there are any limitations for for simple settings, like Dark Mode, being stored in the User Profile, but Im sure there could arise a scenario that wouldn't work.

In my initial meeting with the core team and discussions on my brainstorming doc, the team expressed that there might be a need to store User Settings in SO eventually, or at least, be able to migrate the settings from User Profiles to SO in the future.

I wanted the client to behave like the regular/global client so I included the methods stubbed so they would fulfill the interface and be available if we do need to move that direction

return UiSettingsClientFactory.create(options) as ClientType<T>;
};
}

private getUserClientFactory<T extends UiSettingsScope>(): (
savedObjectsClient: SavedObjectsClientContract,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

userSettingsServiceStart,
uiSettingServiceStart,
}: SetupUiSettingsServiceParams) {
uiSettingServiceStart.setUserProfileSettingsClientFactoryProvider(() => () => {
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 was following the ClientFactoryProvider patter I saw utilized with the SO client, but this could probably be simplified.

@ryankeairns ryankeairns requested a review from a team March 1, 2023 18:58
@ryankeairns
Copy link
Contributor

Awesome start! I have added the design team as reviewers once you are ready. @MichaelMarcialis in particular worked on the profile screen design.

description={
<FormattedMessage
id="xpack.security.accountManagement.userProfile.themeFormGroupDescription"
defaultMessage="Select the interface theme that you wish to apply across the platform."
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest cutting this down a bit. Here are some suggestions:

Select the appearance of your interface.
Select the theme to apply across the interface.
Select the them to apply across the platform.
Choose between a light or dark theme, or use the default system setting. (ok this is longer, but it is more specific)

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've switched it to the first option! Thanks for the suggestions.

<FormLabel for="data.userSettings.darkMode">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.userSettings.theme"
defaultMessage="Theme mode"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this just say "Mode"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in latest commit!

legend={i18n.translate(
'xpack.security.accountManagement.userProfile.userSettings.themeGroupDescription',
{
defaultMessage: 'Kibana Theme',
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know where this appears, but can we eliminate the word "Kibana"? Maybe "Elastic theme"? We typically use sentence case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to Elastic theme

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis 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 those changes, @kc13greiner! I'm leaving two last comments below for your re-review, but nothing that appears to be a show-stopper. Approving now so I don't hold you up, assuming you're able to address them.

/>
}
>
<EuiFlexItem>
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this EuiFlexItem can be removed (now that the parent EuiFlexGroup was removed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in latest commit!

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

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-user-settings-server - 6 +6
@kbn/core-user-settings-server-internal - 4 +4
@kbn/core-user-settings-server-mocks - 3 +3
total +13

Async chunks

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

id before after diff
security 563.4KB 565.8KB +2.5KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/core-user-settings-server-internal - 1 +1
Unknown metric groups

API count

id before after diff
@kbn/core-lifecycle-server 33 34 +1
@kbn/core-user-settings-server - 6 +6
@kbn/core-user-settings-server-internal - 4 +4
@kbn/core-user-settings-server-mocks - 3 +3
total +14

ESLint disabled line counts

id before after diff
enterpriseSearch 17 19 +2
securitySolution 397 400 +3
total +5

Total ESLint disabled count

id before after diff
enterpriseSearch 18 20 +2
securitySolution 477 480 +3
total +5

History

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

@kc13greiner kc13greiner merged commit b66df87 into elastic:main Apr 25, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 25, 2023
@legrego legrego mentioned this pull request Apr 25, 2023
@gchaps gchaps mentioned this pull request Apr 25, 2023
19 tasks
@EricPSU
Copy link

EricPSU commented Apr 25, 2023

@kc13greiner ::thumbs-up::

@formgeist
Copy link
Contributor

Just for reference; I noticed there were some inconsistencies in the how dark mode was handled if it had been set in the Space vs. the user profile. #156362

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 release_note:feature Makes this part of the condensed release notes Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce a User Settings Service