@@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom';
4
4
import { CodebaseKubeObject } from '../../../../k8s/groups/EDP/Codebase' ;
5
5
import { CodebaseBranchKubeObject } from '../../../../k8s/groups/EDP/CodebaseBranch' ;
6
6
import { CODEBASE_BRANCH_LABEL_SELECTOR_CODEBASE_NAME } from '../../../../k8s/groups/EDP/CodebaseBranch/labels' ;
7
+ import { CodebaseBranchKubeObjectInterface } from '../../../../k8s/groups/EDP/CodebaseBranch/types' ;
7
8
import { useGitServerByCodebaseQuery } from '../../../../k8s/groups/EDP/GitServer/hooks/useGitServerByCodebaseQuery' ;
8
9
import {
9
10
generateBuildPipelineRef ,
@@ -26,16 +27,6 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
26
27
props : { codebaseGitServer : component ?. spec . gitServer } ,
27
28
} ) ;
28
29
29
- const reviewPipelineRefName = generateReviewPipelineRef ( {
30
- gitServer : gitServerByCodebase ,
31
- component : component ,
32
- } ) ;
33
-
34
- const buildPipelineRefName = generateBuildPipelineRef ( {
35
- gitServer : gitServerByCodebase ,
36
- component : component ,
37
- } ) ;
38
-
39
30
const [ codebaseBranches , codebaseBranchesError ] = CodebaseBranchKubeObject . useList ( {
40
31
namespace,
41
32
labelSelector : `${ CODEBASE_BRANCH_LABEL_SELECTOR_CODEBASE_NAME } =${ name } ` ,
@@ -46,6 +37,8 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
46
37
? null
47
38
: codebaseBranches ?. sort ( ( a ) => ( isDefaultBranch ( component , a ) ? - 1 : 1 ) ) ;
48
39
40
+ const defaultBranch : CodebaseBranchKubeObjectInterface = sortedCodebaseBranches ?. [ 0 ] ;
41
+
49
42
const DataContextValue = React . useMemo (
50
43
( ) => ( {
51
44
component : {
@@ -55,8 +48,18 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
55
48
} ,
56
49
pipelines : {
57
50
data : {
58
- review : reviewPipelineRefName ,
59
- build : buildPipelineRefName ,
51
+ review :
52
+ defaultBranch ?. spec ?. pipelines ?. review ||
53
+ generateReviewPipelineRef ( {
54
+ gitServer : gitServerByCodebase ,
55
+ component : component ,
56
+ } ) ,
57
+ build :
58
+ defaultBranch ?. spec ?. pipelines ?. build ||
59
+ generateBuildPipelineRef ( {
60
+ gitServer : gitServerByCodebase ,
61
+ component : component ,
62
+ } ) ,
60
63
} ,
61
64
error : error ,
62
65
isLoading : component === null ,
@@ -73,15 +76,15 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
73
76
} ,
74
77
} ) ,
75
78
[
76
- buildPipelineRefName ,
77
79
codebaseBranches ,
78
80
codebaseBranchesError ,
79
81
component ,
82
+ defaultBranch ?. spec ?. pipelines ?. build ,
83
+ defaultBranch ?. spec ?. pipelines ?. review ,
80
84
error ,
81
85
gitServerByCodebase ,
82
86
gitServerByCodebaseError ,
83
87
gitServerByCodebaseIsLoading ,
84
- reviewPipelineRefName ,
85
88
sortedCodebaseBranches ,
86
89
]
87
90
) ;
0 commit comments