diff --git a/public/app/features/search/service/unified.test.ts b/public/app/features/search/service/unified.test.ts index 8841418cd5a..f013ca91ca7 100644 --- a/public/app/features/search/service/unified.test.ts +++ b/public/app/features/search/service/unified.test.ts @@ -146,7 +146,7 @@ describe('Unified Storage Searcher', () => { folder: 'General', tags: ['monitoring', 'performance'], field: { errors_today: 1 }, - url: '/dashboards/1', + url: '/dashboards/1/main-dashboard-title', }, { resource: 'dashboard', @@ -156,7 +156,7 @@ describe('Unified Storage Searcher', () => { folder: 'General', tags: ['monitoring', 'performance'], field: { errors_today: 2 }, - url: '/dashboards/1', + url: '/dashboards/1/main-dashboard-title', }, ]; @@ -184,7 +184,7 @@ describe('Unified Storage Searcher', () => { folder: 'General', tags: ['monitoring', 'performance'], field: { errors_today: 1 }, - url: '/dashboards/1', + url: '/dashboards/1/main-dashboard-title', }, ]; diff --git a/public/app/features/search/service/unified.ts b/public/app/features/search/service/unified.ts index c1755c10517..2746ca81748 100644 --- a/public/app/features/search/service/unified.ts +++ b/public/app/features/search/service/unified.ts @@ -3,6 +3,7 @@ import { isEmpty } from 'lodash'; import { DataFrame, DataFrameView, getDisplayProcessor, SelectableValue, toDataFrame } from '@grafana/data'; import { config, getBackendSrv } from '@grafana/runtime'; import { TermCount } from 'app/core/components/TagFilter/TagFilter'; +import kbn from 'app/core/utils/kbn'; import { getAPINamespace } from '../../../api/utils'; @@ -321,7 +322,7 @@ export function toDashboardResults(rsp: SearchAPIResponse, sort: string): DataFr return { ...hit, uid: hit.name, - url: toURL(hit.resource, hit.name), + url: toURL(hit.resource, hit.name, hit.title), tags: hit.tags || [], folder: hit.folder || 'general', location, @@ -369,7 +370,7 @@ async function loadLocationInfo(): Promise> { locationInfo[hit.name] = { name: hit.title, kind: 'folder', - url: toURL('folders', hit.name), + url: toURL('folders', hit.name, hit.title), }; } return locationInfo; @@ -377,9 +378,10 @@ async function loadLocationInfo(): Promise> { return rsp; } -function toURL(resource: string, name: string): string { +function toURL(resource: string, name: string, title: string): string { if (resource === 'folders') { return `/dashboards/f/${name}`; } - return `/d/${name}`; + const slug = kbn.slugifyForUrl(title); + return `/d/${name}/${slug}`; }