@@ -24,6 +24,8 @@ import {singleLineRenderer as markedSingleLine} from 'sentry/utils/marked';
24
24
import withLatestContext from 'sentry/utils/withLatestContext' ;
25
25
// eslint-disable-next-line no-restricted-imports
26
26
import withSentryRouter from 'sentry/utils/withSentryRouter' ;
27
+ import { makeAlertsPathname } from 'sentry/views/alerts/pathnames' ;
28
+ import { makeProjectsPathname } from 'sentry/views/projects/pathname' ;
27
29
28
30
import type { ChildProps , Result , ResultItem } from './types' ;
29
31
import { strGetFn } from './utils' ;
@@ -61,9 +63,14 @@ async function createOrganizationResults(
61
63
}
62
64
async function createProjectResults (
63
65
projectsPromise : Promise < Project [ ] > ,
64
- orgId ?: string
66
+ organization ?: Organization
65
67
) : Promise < ResultItem [ ] > {
66
68
const projects = ( await projectsPromise ) || [ ] ;
69
+
70
+ if ( ! organization ) {
71
+ return [ ] ;
72
+ }
73
+
67
74
return projects . flatMap ( project => {
68
75
const projectResults : ResultItem [ ] = [
69
76
{
@@ -72,15 +79,19 @@ async function createProjectResults(
72
79
model : project ,
73
80
sourceType : 'project' ,
74
81
resultType : 'settings' ,
75
- to : `/settings/${ orgId } /projects/${ project . slug } /` ,
82
+ to : `/settings/${ organization . slug } /projects/${ project . slug } /` ,
76
83
} ,
77
84
{
78
85
title : t ( '%s Alerts' , project . slug ) ,
79
86
description : t ( 'List of project alert rules' ) ,
80
87
model : project ,
81
88
sourceType : 'project' ,
82
89
resultType : 'route' ,
83
- to : `/organizations/${ orgId } /alerts/rules/?project=${ project . id } ` ,
90
+ to :
91
+ makeAlertsPathname ( {
92
+ path : '/rules/' ,
93
+ organization,
94
+ } ) + `?project=${ project . id } ` ,
84
95
} ,
85
96
] ;
86
97
@@ -90,7 +101,11 @@ async function createProjectResults(
90
101
model : project ,
91
102
sourceType : 'project' ,
92
103
resultType : 'route' ,
93
- to : `/organizations/${ orgId } /projects/${ project . slug } /?project=${ project . id } ` ,
104
+ to :
105
+ makeProjectsPathname ( {
106
+ orgSlug : organization . slug ,
107
+ path : `/${ project . slug } /` ,
108
+ } ) + `?project=${ project . id } ` ,
94
109
} ) ;
95
110
96
111
return projectResults ;
@@ -469,7 +484,7 @@ class ApiSource extends Component<Props, State> {
469
484
] = requests ;
470
485
const searchResults = await Promise . all ( [
471
486
createOrganizationResults ( organizations ! ) ,
472
- createProjectResults ( projects ! , orgId ) ,
487
+ createProjectResults ( projects ! , organization ) ,
473
488
createTeamResults ( teams ! , orgId ) ,
474
489
createMemberResults ( members ! , orgId ) ,
475
490
createIntegrationResults ( integrations ! , orgId ) ,
0 commit comments