1
1
import { Node , PipelineNodeModel , RunStatus } from '@patternfly/react-topology' ;
2
+ import {
3
+ APPLICATION_DETAILS_PATH ,
4
+ APPLICATION_RELEASE_DETAILS_PATH ,
5
+ INTEGRATION_TEST_DETAILS_PATH ,
6
+ PIPELINERUN_LIST_PATH ,
7
+ } from '@routes/paths' ;
2
8
import { PipelineRunLabel } from '../../../../../../consts/pipelinerun' ;
3
9
import { ComponentKind , PipelineRunKind } from '../../../../../../types' ;
4
10
import { GitOpsDeploymentHealthStatus } from '../../../../../../types/gitops-deployment' ;
@@ -76,7 +82,7 @@ export const statusToRunStatus = (status: string): RunStatus => {
76
82
77
83
export const getLinkDataForElement = (
78
84
element : Node < PipelineNodeModel , WorkflowNodeModelData > ,
79
- workspace : string ,
85
+ namespace : string ,
80
86
) : { tab ?: string ; path ?: string ; filter ?: { name : string ; value : string } } => {
81
87
const { workflowType, isDisabled, groupNode, status, resources } = element . getData ( ) ;
82
88
const label = element . getLabel ( ) ;
@@ -107,19 +113,23 @@ export const getLinkDataForElement = (
107
113
case WorkflowNodeType . APPLICATION_TEST :
108
114
return ! groupNode && ! isDisabled
109
115
? {
110
- path : `/workspaces/${ workspace } /applications/${
111
- element . getData ( ) . application
112
- } /integrationtests/${ label } `,
116
+ path : INTEGRATION_TEST_DETAILS_PATH . createPath ( {
117
+ workspaceName : namespace ,
118
+ applicationName : element . getData ( ) . application ,
119
+ integrationTestName : label ,
120
+ } ) ,
113
121
}
114
122
: {
115
123
tab : 'integrationtests' ,
116
124
} ;
117
125
case WorkflowNodeType . RELEASE :
118
126
return ! groupNode && ! isDisabled
119
127
? {
120
- path : `/workspaces/${ workspace } /applications/${
121
- element . getData ( ) . application
122
- } /releases/${ label } `,
128
+ path : APPLICATION_RELEASE_DETAILS_PATH . createPath ( {
129
+ workspaceName : namespace ,
130
+ applicationName : element . getData ( ) . application ,
131
+ releaseName : label ,
132
+ } ) ,
123
133
}
124
134
: { tab : 'releases' } ;
125
135
default :
@@ -131,17 +141,23 @@ export const getLinkDataForElement = (
131
141
132
142
export const getLinksForElement = (
133
143
element : Node < PipelineNodeModel , WorkflowNodeModelData > ,
134
- workspace : string ,
144
+ namespace : string ,
135
145
) : { elementRef : string ; pipelinesRef : string ; appRef : string } => {
136
- const linkData = getLinkDataForElement ( element , workspace ) ;
146
+ const linkData = getLinkDataForElement ( element , namespace ) ;
137
147
138
- const appPath = `/workspaces/${ workspace } /applications/${ element . getData ( ) . application } ` ;
148
+ const appPath = APPLICATION_DETAILS_PATH . createPath ( {
149
+ workspaceName : namespace ,
150
+ applicationName : element . getData ( ) . application ,
151
+ } ) ;
139
152
const tabPath = linkData . tab ? `/${ linkData . tab } ` : '' ;
140
153
const filter = linkData . filter ? `?${ linkData . filter . name } =${ linkData . filter . value } ` : '' ;
141
154
142
155
return {
143
156
elementRef : linkData . path ? linkData . path : `${ appPath } ${ tabPath } ${ filter } ` ,
144
- pipelinesRef : `${ appPath } /activity/pipelineruns` ,
157
+ pipelinesRef : PIPELINERUN_LIST_PATH . createPath ( {
158
+ workspaceName : namespace ,
159
+ applicationName : element . getData ( ) . application ,
160
+ } ) ,
145
161
appRef : appPath ,
146
162
} ;
147
163
} ;
0 commit comments