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

refactor: simplify theme configuration and defaulting #7625

Merged
merged 11 commits into from
Aug 16, 2024

Conversation

virajsanghvi
Copy link
Collaborator

@virajsanghvi virajsanghvi commented Aug 6, 2024

Description

Reduces the amount of logic needed to add a new theme, reduces the number of files to be touched, + documents the process. There should be no change in experience.

Additionally, it appears we were persisting the label value in some places, while using the version string in others. This worked because we only ever checked that themeTag versions matched 'v7', but v8/next was the else case so it just so happened to work correctly. This tries to use the version string consistently, while keeping the label used for persisting to advanced settings (because I couldn't find an easy way to translate persisted values for existing configurations).

Unfortunately, due to need to run in different contexts, I had to write this to the least common denominator, so changes across the board are still necessary.

Note: There is an existing bug with browser based settings that doesn't respect the user selected setting in the topnav theme selector (even though the selected theme is actually defined). This isn't a released feature and not making things worse, so didn't address. Bug opened: #7689

Issues Resolved

N/A

Screenshot

Context Screenshot
v7 light image
v7 dark image
v8 light image
v8 dark image

Testing the changes

Most of the lines were already covered. The user header theme selection doesn't appear to be. Patch codecov was higher so I didn't add, but can if desired.

To test I:

  • With user theme configuration turned off, made sure I could select the theme from advanced settings and see the correct result and css files were loaded as expected, and that returning to advanced settings the correct theme was selected
  • With user theme configuration turned on, made sure sure I could select the theme from top nav and see correct result and css files were loaded as expected, and that returning to the selector, the correct theme was selected
  • Added a new theme (locally), and validated the above scenarios
  • Bootstrapping/building locally still succeeds

Changelog

  • refactor: simplify theme configuration and defaulting
  • deprecate: Deprecating CssDistFilename exports in favor of themeCssDistFilenames in @osd/ui-shared-deps

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link
Contributor

github-actions bot commented Aug 6, 2024

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 79.06977% with 9 lines in your changes missing coverage. Please review.

Project coverage is 63.76%. Comparing base (765527a) to head (26be38c).
Report is 200 commits behind head on main.

Files with missing lines Patch % Lines
...dvanced_settings/public/header_user_theme_menu.tsx 0.00% 6 Missing ⚠️
packages/osd-ui-shared-deps/theme.ts 60.00% 0 Missing and 2 partials ⚠️
src/core/public/ui_settings/ui_settings_client.ts 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7625      +/-   ##
==========================================
+ Coverage   63.74%   63.76%   +0.01%     
==========================================
  Files        3637     3640       +3     
  Lines       80448    80491      +43     
  Branches    12792    12802      +10     
==========================================
+ Hits        51285    51325      +40     
- Misses      26029    26031       +2     
- Partials     3134     3135       +1     
Flag Coverage Δ
Linux_1 29.88% <64.86%> (+0.05%) ⬆️
Linux_2 55.86% <96.87%> (+0.04%) ⬆️
Linux_3 40.41% <52.50%> (+0.02%) ⬆️
Linux_4 31.32% <55.81%> (+0.02%) ⬆️
Windows_1 29.89% <64.86%> (+0.05%) ⬆️
Windows_2 55.82% <96.87%> (+0.04%) ⬆️
Windows_3 40.42% <52.50%> (+0.03%) ⬆️
Windows_4 31.32% <55.81%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

❌ Entry Too Long

Entry is 165 characters long, which is 65 characters longer than the maximum allowed length of 100 characters. Please revise your entry to be within the maximum length.

@virajsanghvi virajsanghvi added backport 2.x look & feel Look and Feel Improvements v2.17.0 labels Aug 16, 2024
@virajsanghvi virajsanghvi merged commit bcdbbef into opensearch-project:main Aug 16, 2024
73 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

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-7625-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 bcdbbef7b5ef42b10bdf9aa65ef8b96c126dba82
# Push it to GitHub
git push --set-upstream origin backport/backport-7625-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-7625-to-2.x.

virajsanghvi added a commit to virajsanghvi/OpenSearch-Dashboards that referenced this pull request Aug 18, 2024
…ject#7625)

---------

Signed-off-by: Viraj Sanghvi <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit bcdbbef)
AMoo-Miki pushed a commit that referenced this pull request Aug 19, 2024
---------

Signed-off-by: Viraj Sanghvi <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit bcdbbef)
Qxisylolo pushed a commit to Qxisylolo/OpenSearch-Dashboards that referenced this pull request Aug 20, 2024
…ject#7625)


---------

Signed-off-by: Viraj Sanghvi <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants