1
1
import * as React from 'react' ;
2
- import {
3
- PipelineRunEventType ,
4
- PipelineRunLabel ,
5
- PipelineRunType ,
6
- } from '../../../../consts/pipelinerun' ;
2
+ import { PipelineRunLabel , PipelineRunType } from '../../../../consts/pipelinerun' ;
7
3
import { useComponents } from '../../../../hooks/useComponents' ;
8
4
import { useIntegrationTestScenarios } from '../../../../hooks/useIntegrationTestScenarios' ;
9
5
import { usePipelineRunsForCommit } from '../../../../hooks/usePipelineRuns' ;
10
- import { useReleasePlans } from '../../../../hooks/useReleasePlans' ;
11
- import { useReleases } from '../../../../hooks/useReleases' ;
12
- import { useSnapshots } from '../../../../hooks/useSnapshots' ;
13
6
import { Commit , ComponentKind , PipelineRunKind } from '../../../../types' ;
14
- import { ReleaseKind , ReleasePlanKind } from '../../../../types/coreBuildService' ;
15
- import {
16
- conditionsRunStatus ,
17
- pipelineRunStatus ,
18
- runStatus ,
19
- } from '../../../../utils/pipeline-utils' ;
7
+ import { pipelineRunStatus , runStatus } from '../../../../utils/pipeline-utils' ;
20
8
import { DEFAULT_NODE_HEIGHT } from '../../../topology/const' ;
21
9
import { getLabelWidth } from '../../../topology/utils' ;
22
10
import { useWorkspaceInfo } from '../../../Workspace/useWorkspaceInfo' ;
@@ -41,7 +29,6 @@ export const useCommitWorkflowData = (
41
29
commit : Commit ,
42
30
) : [ nodes : CommitWorkflowNodeModel [ ] , loaded : boolean , errors : unknown [ ] ] => {
43
31
const { namespace, workspace } = useWorkspaceInfo ( ) ;
44
- const [ mvpFeature ] = [ false ] ;
45
32
46
33
const applicationName = commit ?. application || '' ;
47
34
const [ components , componentsLoaded ] = useComponents ( namespace , workspace , applicationName ) ;
@@ -50,11 +37,6 @@ export const useCommitWorkflowData = (
50
37
workspace ,
51
38
applicationName ,
52
39
) ;
53
- const [ releasePlans , releasePlansLoaded , releasePlansError ] = useReleasePlans (
54
- namespace ,
55
- workspace ,
56
- ) ;
57
- const [ releases , releasesLoaded , releasesError ] = useReleases ( namespace , workspace ) ;
58
40
const [ pipelines , pipelinesLoaded , pipelinesError ] = usePipelineRunsForCommit (
59
41
namespace ,
60
42
workspace ,
@@ -81,16 +63,8 @@ export const useCommitWorkflowData = (
81
63
[ pipelines , pipelinesLoaded ] ,
82
64
) ;
83
65
84
- const [ snapshots , sloaded , serror ] = useSnapshots ( namespace , commit . sha ) ;
85
-
86
- const allResourcesLoaded : boolean =
87
- componentsLoaded &&
88
- integrationTestsLoaded &&
89
- pipelinesLoaded &&
90
- releasesLoaded &&
91
- sloaded &&
92
- releasePlansLoaded ;
93
- const allErrors = [ releasePlansError , releasesError , pipelinesError , serror ] . filter ( ( e ) => ! ! e ) ;
66
+ const allResourcesLoaded : boolean = componentsLoaded && integrationTestsLoaded && pipelinesLoaded ;
67
+ const allErrors = [ pipelinesError ] . filter ( ( e ) => ! ! e ) ;
94
68
95
69
const commitComponents = React . useMemo (
96
70
( ) =>
@@ -203,120 +177,6 @@ export const useCommitWorkflowData = (
203
177
nodes . push ( ...appTestNodes ) ;
204
178
const appTestNodesWidth = appTestNodes . reduce ( ( max , node ) => Math . max ( max , node . width ) , 0 ) ;
205
179
appTestNodes . forEach ( ( n ) => ( n . width = appTestNodesWidth ) ) ;
206
-
207
- const currentSnapshotName = getLatestResource (
208
- snapshots . filter (
209
- ( s ) =>
210
- s . metadata . labels [ PipelineRunLabel . COMPONENT ] === compName &&
211
- s . metadata . labels [ PipelineRunLabel . TEST_SERVICE_EVENT_TYPE_LABEL ] ===
212
- PipelineRunEventType . PUSH ,
213
- ) ,
214
- ) ?. metadata ?. name ;
215
-
216
- if ( ! mvpFeature ) {
217
- const latestRelease : ReleaseKind = getLatestResource (
218
- releases . filter ( ( r ) => r . spec . snapshot === currentSnapshotName ) ,
219
- ) ;
220
-
221
- const releaseStatus : runStatus =
222
- releases . length === 0
223
- ? undefined
224
- : latestRelease && latestRelease ?. status
225
- ? conditionsRunStatus ( latestRelease . status . conditions )
226
- : runStatus . Succeeded ;
227
-
228
- const releaseNodes : CommitWorkflowNodeModel [ ] = releases . length
229
- ? releases . map ( ( release ) => {
230
- const releaseName = release . metadata . name ;
231
-
232
- const releaseNode : CommitWorkflowNodeModel = {
233
- id : addPrefixToResourceName ( compName , releaseName ) ,
234
- label : releaseName ,
235
- type : NodeType . WORKFLOW_NODE ,
236
- width : getLabelWidth ( releaseName ) ,
237
- height : DEFAULT_NODE_HEIGHT ,
238
- data : {
239
- status : releaseStatus ,
240
- workflowType : CommitWorkflowNodeType . RELEASE ,
241
- resource : release ,
242
- application : commit . application ,
243
- } ,
244
- } ;
245
- return releaseNode ;
246
- } )
247
- : [
248
- {
249
- id : `${ name } -release` ,
250
- label : 'No releases set' ,
251
- type : NodeType . WORKFLOW_NODE ,
252
- width : getLabelWidth ( 'No releases set' ) ,
253
- height : DEFAULT_NODE_HEIGHT ,
254
- data : {
255
- status : runStatus . Pending ,
256
- workflowType : CommitWorkflowNodeType . RELEASE ,
257
- application : commit . application ,
258
- } ,
259
- } ,
260
- ] ;
261
- nodes . push ( ...releaseNodes ) ;
262
- const releaseNodesWidth = releaseNodes . reduce ( ( max , node ) => Math . max ( max , node . width ) , 0 ) ;
263
- releaseNodes . forEach ( ( n ) => ( n . width = releaseNodesWidth ) ) ;
264
- const releaseNodeIds = releaseNodes . map ( ( n ) => n . id ) ;
265
-
266
- const releasePlanStatus : ( rp : ReleasePlanKind ) => runStatus =
267
- releasePlans . length === 0
268
- ? undefined
269
- : ( rp ) => {
270
- const matchedRelease = getLatestResource (
271
- releases . filter ( ( r ) => r . spec . releasePlan === rp . metadata . name ) ,
272
- ) ;
273
- return matchedRelease
274
- ? pipelineRunStatus ( matchedRelease as PipelineRunKind )
275
- : runStatus . Pending ;
276
- } ;
277
-
278
- const managedEnvNodes : CommitWorkflowNodeModel [ ] = releasePlans . length
279
- ? releasePlans . map ( ( managedEnv ) => {
280
- const managedEnvName = managedEnv . metadata . name ;
281
-
282
- const managedEnvNode : CommitWorkflowNodeModel = {
283
- id : addPrefixToResourceName ( compName , managedEnvName ) ,
284
- label : managedEnvName ,
285
- type : NodeType . WORKFLOW_NODE ,
286
- width : getLabelWidth ( managedEnvName ) ,
287
- height : DEFAULT_NODE_HEIGHT ,
288
- runAfterTasks : releaseNodeIds ,
289
- data : {
290
- status : releasePlanStatus ( managedEnv ) ,
291
- workflowType : CommitWorkflowNodeType . MANAGED_ENVIRONMENT ,
292
- resource : managedEnv ,
293
- application : commit . application ,
294
- } ,
295
- } ;
296
- return managedEnvNode ;
297
- } )
298
- : [
299
- {
300
- id : `${ name } -managed-environments` ,
301
- label : 'No managed environments set' ,
302
- type : NodeType . WORKFLOW_NODE ,
303
- width : getLabelWidth ( 'No managed environments set' ) ,
304
- height : DEFAULT_NODE_HEIGHT ,
305
- runAfterTasks : releaseNodeIds ,
306
- data : {
307
- status : runStatus . Pending ,
308
- workflowType : CommitWorkflowNodeType . MANAGED_ENVIRONMENT ,
309
- application : commit . application ,
310
- } ,
311
- } ,
312
- ] ;
313
- nodes . push ( ...managedEnvNodes ) ;
314
- const managedEnvNodesWidth = managedEnvNodes . reduce (
315
- ( max , node ) => Math . max ( max , node . width ) ,
316
- 0 ,
317
- ) ;
318
- managedEnvNodes . forEach ( ( n ) => ( n . width = managedEnvNodesWidth ) ) ;
319
- }
320
180
} ) ;
321
181
322
182
return nodes ;
@@ -329,10 +189,6 @@ export const useCommitWorkflowData = (
329
189
buildPipelines ,
330
190
testPipelines ,
331
191
integrationTests ,
332
- snapshots ,
333
- mvpFeature ,
334
- releases ,
335
- releasePlans ,
336
192
] ) ;
337
193
338
194
if ( ! allResourcesLoaded || workflowNodes . length === 0 || allErrors . length > 0 ) {
0 commit comments