Feat (core): Make theme settings user-specific and user-configurable#5652
Feat (core): Make theme settings user-specific and user-configurable#5652ananzh merged 34 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: Josh Romero <rmerqg@amazon.com>
Signed-off-by: Josh Romero <rmerqg@amazon.com>
Signed-off-by: Josh Romero <rmerqg@amazon.com>
Signed-off-by: Josh Romero <rmerqg@amazon.com>
1. Add optional `preferBrowserSetting` to UISettings that should be defined client-side 2. Make `theme:darkMode` and `theme:version` prefer browser settings 3. Update UISettings client-side client to check localstorage for settings that prefer browser settings 4. Refactor logos to be responsive to browser-defined theme mode 5. Add a new `startup` script that handles theme/dark mode (injected as blocking script to head) 6. Remove theme/mode-specific logic from injected Styles and Fonts (move logic to `startup` script instead, define all font-faces) 7. Only inject theme values necessary for loading/error screens via `startup` 8. Update branding metadata to pass the correct dark mode Signed-off-by: Josh Romero <rmerqg@amazon.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5652 +/- ##
==========================================
- Coverage 67.79% 67.69% -0.10%
==========================================
Files 3413 3414 +1
Lines 66755 66838 +83
Branches 10861 10872 +11
==========================================
- Hits 45254 45247 -7
- Misses 18857 18919 +62
- Partials 2644 2672 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Josh Romero <rmerqg@amazon.com>
Ah, right - this is the part I forgot. Let me manually retest to make sure I didn't miss something here. |
Signed-off-by: Josh Romero <rmerqg@amazon.com>
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-5652-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 876224bd9018d5b1dc25f033734676d150f21fc4
# Push it to GitHub
git push --set-upstream origin backport/backport-5652-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.xThen, create a pull request where the |
…and user-configurable (opensearch-project#5652) Backport PR: opensearch-project#5652 From opensearch-project#5652 * feat (core): make theme UI settings client-side 1. Add optional `preferBrowserSetting` to UISettings that should be defined client-side 2. Make `theme:darkMode` and `theme:version` prefer browser settings 3. Update UISettings client-side client to check localstorage for settings that prefer browser settings 4. Refactor logos to be responsive to browser-defined theme mode 5. Add a new `startup` script that handles theme/dark mode (injected as blocking script to head) 6. Remove theme/mode-specific logic from injected Styles and Fonts (move logic to `startup` script instead, define all font-faces) 7. Only inject theme values necessary for loading/error screens via `startup` 8. Update branding metadata to pass the correct dark mode 9. Add a new control for admin Enable user control. This setting is enabled as default. When this setting is disabled, admin can disable any user control and we will have the exact previous behavior. --------- Signed-off-by: Josh Romero <rmerqg@amazon.com>
…and user-configurable (#5652) (#6681) Backport PR: #5652 From #5652 * feat (core): make theme UI settings client-side 1. Add optional `preferBrowserSetting` to UISettings that should be defined client-side 2. Make `theme:darkMode` and `theme:version` prefer browser settings 3. Update UISettings client-side client to check localstorage for settings that prefer browser settings 4. Refactor logos to be responsive to browser-defined theme mode 5. Add a new `startup` script that handles theme/dark mode (injected as blocking script to head) 6. Remove theme/mode-specific logic from injected Styles and Fonts (move logic to `startup` script instead, define all font-faces) 7. Only inject theme values necessary for loading/error screens via `startup` 8. Update branding metadata to pass the correct dark mode 9. Add a new control for admin Enable user control. This setting is enabled as default. When this setting is disabled, admin can disable any user control and we will have the exact previous behavior. --------- Signed-off-by: Josh Romero <rmerqg@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com>
|
do we have functional test automation for test coverage? |
…pecific and user-configurable (opensearch-project#5652) (opensearch-project#6681)" This reverts commit 815d2bd. Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
…pensearch-project#5652) * feat (core): make theme UI settings client-side 1. Add optional `preferBrowserSetting` to UISettings that should be defined client-side 2. Make `theme:darkMode` and `theme:version` prefer browser settings 3. Update UISettings client-side client to check localstorage for settings that prefer browser settings 4. Refactor logos to be responsive to browser-defined theme mode 5. Add a new `startup` script that handles theme/dark mode (injected as blocking script to head) 6. Remove theme/mode-specific logic from injected Styles and Fonts (move logic to `startup` script instead, define all font-faces) 7. Only inject theme values necessary for loading/error screens via `startup` 8. Update branding metadata to pass the correct dark mode 9. Add a new control for admin Enable user control. This setting is enabled as default. When this setting is disabled, admin can disable any user control and we will have the exact previous behavior. --------- Signed-off-by: Josh Romero <rmerqg@amazon.com>
|
@kavilla I saw you reverted the manual backports to 2.x without comment. Could you kindly share if this feature is still intended to come with 2.x or if it requires update to 3.x |
Description
The purpose of this PR is to make theme settings (dark mode and theme version) settable by device, rather than cluster-wide. This allows different users (or users on different devices) to use different themes and light/dark mode. It also adds a new global nav element for global access to theming controls. These changes, however, can be toggled off in advanced settings if the previous behavior is desired/preferred.
This is an iterative step toward user-specific settings that can be saved/shared across devices, and it should unblock #4454.
The biggest change is that it's no longer possible for any server system or component to know the theme version or dark mode settings, because the source of truth for theme settings resides client-side (stored in localstorage).
Notes for reviewers:
core/server/renderingto see how server-defined templates and styles are made theme/mode agnosticlegacy/ui/ui_render. Unlike the existing script. This startup script is required to provide the theming info needed by the loading/error screen prior to starting the react app. Theme info not required by the loading page stays in the existing bootstrap script, which also pulls in some of the conditional theming logic that can no longer be done in the templates.ui_settingsservice was updated (both server and client). We define a new propertypreferBrowserSettingwhich indicates settings that have a local storage source of truth. Thepublicclient then reads and writes those settings appropriately. Note that this means even editing theme settings from the Advanced Setting page will no longer update the cluster setting - it will also just be considered device-specific.Issues Resolved
Fixes #4462
Screenshot
user-theme-demo.mov
Testing the changes
See video above, but some scenarios to verify:
Enable user controlsetting is disabled, all theming behavior should work as previously (advanced settings controls enabled), with no user appearance menu.Enable user controlis enabledui_settings_clientwill get the theme values that represent the state of those settings, not necessarily the settings value (for backwards compatibility). E.g. if user settings are enabled and set to "Use browser settings", consumers callinguiClient.get('theme:darkMode')should get backtrueif that was the browser setting at page load/application start.ui_settings_clientwill always get server/saved object default values, which may not reflect app stateCheck List
yarn test:jestyarn test:jest_integration