Dashboards: Fixes view & edit keyboard shortcuts when grafana is behind a subpath (#93955)

DashboardScene: Fixes view & edit keyboard shortcuts when grafana is behind a subpath
This commit is contained in:
Torkel Ödegaard 2024-09-30 12:19:24 +02:00 committed by GitHub
parent e6c962e37c
commit 1c14c85b97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
import { SetPanelAttentionEvent } from '@grafana/data';
import { locationUtil, SetPanelAttentionEvent } from '@grafana/data';
import { config, locationService } from '@grafana/runtime';
import { sceneGraph, VizPanel } from '@grafana/scenes';
import appEvents from 'app/core/app_events';
@ -43,7 +43,8 @@ export function setupKeyboardShortcuts(scene: DashboardScene) {
key: 'v',
onTrigger: withFocusedPanel(scene, (vizPanel: VizPanel) => {
if (!scene.state.viewPanelScene) {
locationService.push(getViewPanelUrl(vizPanel));
const url = locationUtil.stripBaseFromUrl(getViewPanelUrl(vizPanel));
locationService.push(url);
}
}),
});
@ -173,7 +174,8 @@ export function setupKeyboardShortcuts(scene: DashboardScene) {
if (sceneRoot instanceof DashboardScene) {
const panelId = getPanelIdForVizPanel(vizPanel);
if (!scene.state.editPanel) {
locationService.push(getEditPanelUrl(panelId));
const url = locationUtil.stripBaseFromUrl(getEditPanelUrl(panelId));
locationService.push(url);
}
}
}),