Command Palette: Links now work when grafana is served under a subpath (#60033)

strip base when pushing urls to locationService
This commit is contained in:
Ashley Harrison 2022-12-08 15:00:07 +00:00 committed by GitHub
parent e6743a7e9a
commit a3681a3353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
import { Action, Priority } from 'kbar';
import React from 'react';
import { isIconName, NavModelItem } from '@grafana/data';
import { isIconName, locationUtil, NavModelItem } from '@grafana/data';
import { locationService } from '@grafana/runtime';
import { Icon } from '@grafana/ui';
import { changeTheme } from 'app/core/services/theme';
@ -35,7 +35,7 @@ function navTreeToActions(navTree: NavModelItem[], parent?: NavModelItem): Actio
id: idForNavItem(navItem),
name: text, // TODO: translate
section: isCreateAction ? SECTION_ACTIONS : SECTION_PAGES,
perform: url ? () => locationService.push(url) : undefined,
perform: url ? () => locationService.push(locationUtil.stripBaseFromUrl(url)) : undefined,
parent: parent && idForNavItem(parent),
// Only show icons for top level items