Command Palette: Maintain page state when changing theme (#59787)

* use same function as the change theme keybindings

* rename toggleTheme service to just theme
This commit is contained in:
Ashley Harrison
2022-12-05 16:12:56 +00:00
committed by GitHub
parent c6840cfdec
commit 46adfb596d
3 changed files with 11 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import React from 'react';
import { isIconName, NavModelItem } from '@grafana/data';
import { locationService } from '@grafana/runtime';
import { Icon } from '@grafana/ui';
import { changeTheme } from 'app/core/services/theme';
const SECTION_PAGES = 'Pages';
const SECTION_ACTIONS = 'Actions';
@@ -82,10 +83,7 @@ export default (navBarTree: NavModelItem[]) => {
name: 'Dark',
keywords: 'dark theme',
section: '',
perform: () => {
locationService.push({ search: '?theme=dark' });
location.reload();
},
perform: () => changeTheme('dark'),
parent: 'preferences/theme',
},
{
@@ -93,10 +91,7 @@ export default (navBarTree: NavModelItem[]) => {
name: 'Light',
keywords: 'light theme',
section: '',
perform: () => {
locationService.push({ search: '?theme=light' });
location.reload();
},
perform: () => changeTheme('light'),
parent: 'preferences/theme',
},
];