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

Command Palette: Maintain page state when changing theme #59787

Merged
merged 2 commits into from Dec 5, 2022
Merged

Conversation

ashharrison90
Copy link
Contributor

What is this feature?

  • stops doing a full page reload when changing the theme

Why do we need this feature?

  • allows us to maintain state in e.g. Explore

Who is this feature for?

  • everyone! 🙌

Which issue(s) does this PR fix?:

Fixes #56840

Special notes for your reviewer:

@@ -7,11 +7,10 @@ import { contextSrv } from '../core';

import { PreferencesService } from './PreferencesService';

export async function toggleTheme(runtimeOnly: boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we want to rename this file too?

Copy link
Contributor

@gelicia gelicia left a comment

Choose a reason for hiding this comment

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

Looks awesome! It looks like this approach avoids the bugs you see when toggling themes with keybindings (c t, c r)as well.

@ashharrison90
Copy link
Contributor Author

@gelicia it uses exactly the same function as the c t keybindings now (so should have the same bugs 😅 )... but we did just recently fix some bugs with c t here so maybe that's why they're fixed?

@gelicia
Copy link
Contributor

gelicia commented Dec 5, 2022

@gelicia it uses exactly the same function as the c t keybindings now (so should have the same bugs 😅 )... but we did just recently fix some bugs with c t here so maybe that's why they're fixed?

Hmm yeah it is using the same code but I still see the partial theme on the home screen using the keybindings and not the command palette.
Screen Shot 2022-12-05 at 8 07 50 AM

@ashharrison90
Copy link
Contributor Author

@gelicia is that using c r instead of c t? 🤔

command palette and c t should behave exactly the same. c r is a little weird because it doesn't make any backend call, so you end up with this half state... that's part of the reason why we haven't documented it anywhere as well 😬

@gelicia
Copy link
Contributor

gelicia commented Dec 5, 2022

c r is a little weird because it doesn't make any backend call, so you end up with this half state... that's part of the reason why we haven't documented it anywhere as well 😬

Ah got it, didn't realize there was a distinction between the keybindings. Thanks!

@ashharrison90 ashharrison90 merged commit 46adfb5 into main Dec 5, 2022
@ashharrison90 ashharrison90 deleted the ash/56840 branch December 5, 2022 16:12
@grafanabot
Copy link
Contributor

The backport to v9.3.x failed:

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

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-59787-to-v9.3.x origin/v9.3.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 46adfb596ddb09e6d003e4845eb4a3be6473f8f6
# Push it to GitHub
git push --set-upstream origin backport-59787-to-v9.3.x
git switch main
# Remove the local backport branch
git branch -D backport-59787-to-v9.3.x

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

@grafanabot grafanabot added the backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. label Dec 5, 2022
ashharrison90 added a commit that referenced this pull request Dec 5, 2022
* use same function as the change theme keybindings

* rename toggleTheme service to just theme

(cherry picked from commit 46adfb5)
ashharrison90 added a commit that referenced this pull request Dec 12, 2022
…9841)

* use same function as the change theme keybindings

* rename toggleTheme service to just theme

(cherry picked from commit 46adfb5)
GuYounes pushed a commit to paul-wurth/BIXpert that referenced this pull request Feb 8, 2023
…) (grafana#59841)

* use same function as the change theme keybindings

* rename toggleTheme service to just theme

(cherry picked from commit 46adfb5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/frontend area/ui/theme backport v9.3.x backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. enterprise-ok type/bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Command Palette: Explore state is reset after theme changing
3 participants