1
1
import * as React from 'react' ;
2
2
import * as _ from 'lodash' ;
3
3
import { useTranslation } from 'react-i18next' ;
4
- import { Stack , StackItem , Card , CardTitle , SplitItem , Split , Label } from '@patternfly/react-core' ;
4
+ import {
5
+ Stack ,
6
+ StackItem ,
7
+ Card ,
8
+ CardTitle ,
9
+ CardBody ,
10
+ SplitItem ,
11
+ Split ,
12
+ Label ,
13
+ } from '@patternfly/react-core' ;
5
14
import { ExternalLink , ResourceIcon } from '@console/internal/components/utils' ;
15
+ import { ConsoleLinkModel } from '@console/internal/models' ;
16
+ import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook' ;
17
+ import { K8sResourceKind , referenceForModel } from '@console/internal/module/k8s' ;
6
18
import GitOpsServiceDetailsSection from './GitOpsServiceDetailsSection' ;
7
19
import { GitOpsEnvironment } from '../utils/gitops-types' ;
8
20
import './GitOpsDetails.scss' ;
9
21
10
22
interface GitOpsDetailsProps {
11
23
envs : GitOpsEnvironment [ ] ;
24
+ appName : string ;
12
25
}
13
26
14
- const GitOpsDetails : React . FC < GitOpsDetailsProps > = ( { envs } ) => {
27
+ const GitOpsDetails : React . FC < GitOpsDetailsProps > = ( { envs, appName } ) => {
15
28
const { t } = useTranslation ( ) ;
29
+ const [ consoleLinks ] = useK8sWatchResource < K8sResourceKind [ ] > ( {
30
+ isList : true ,
31
+ kind : referenceForModel ( ConsoleLinkModel ) ,
32
+ optional : true ,
33
+ } ) ;
34
+ const argocdLink = _ . find (
35
+ consoleLinks ,
36
+ ( link : K8sResourceKind ) =>
37
+ link . metadata ?. name === 'argocd' && link . spec ?. location === 'ApplicationMenu' ,
38
+ ) ;
16
39
return (
17
40
< div className = "odc-gitops-details" >
18
41
{ _ . map (
@@ -23,27 +46,24 @@ const GitOpsDetails: React.FC<GitOpsDetailsProps> = ({ envs }) => {
23
46
< StackItem >
24
47
< Card >
25
48
< CardTitle className = "odc-gitops-details__env-section__header" >
26
- < Stack hasGutter >
27
- < StackItem >
28
- < Split style = { { alignItems : 'center' } } hasGutter >
29
- < SplitItem
30
- className = "odc-gitops-details__env-section__title co-truncate co-nowrap"
31
- isFilled
32
- >
33
- { env . environment }
34
- </ SplitItem >
35
- < SplitItem >
36
- < Label
37
- className = "odc-gitops-details__env-section__timestamp"
38
- color = "grey"
39
- >
40
- < span style = { { color : 'var(--pf-global--palette--black-600)' } } >
41
- { env . timestamp }
42
- </ span >
43
- </ Label >
44
- </ SplitItem >
45
- </ Split >
46
- </ StackItem >
49
+ < Split style = { { alignItems : 'center' } } hasGutter >
50
+ < SplitItem
51
+ className = "odc-gitops-details__env-section__title co-truncate co-nowrap"
52
+ isFilled
53
+ >
54
+ { env . environment }
55
+ </ SplitItem >
56
+ < SplitItem >
57
+ < Label className = "odc-gitops-details__env-section__timestamp" color = "grey" >
58
+ < span style = { { color : 'var(--pf-global--palette--black-600)' } } >
59
+ { env . timestamp }
60
+ </ span >
61
+ </ Label >
62
+ </ SplitItem >
63
+ </ Split >
64
+ </ CardTitle >
65
+ < CardBody >
66
+ < Stack >
47
67
< StackItem className = "co-truncate co-nowrap" >
48
68
{ env . cluster ? (
49
69
< ExternalLink
@@ -58,13 +78,22 @@ const GitOpsDetails: React.FC<GitOpsDetailsProps> = ({ envs }) => {
58
78
) }
59
79
</ StackItem >
60
80
< StackItem className = "co-truncate co-nowrap" >
61
- < span className = "co-resource-item" >
81
+ < span className = "co-resource-item odc-gitops-details__env-section__co-resource-item " >
62
82
< ResourceIcon kind = "Project" />
63
83
< span className = "co-resource-item__resource-name" > { env . environment } </ span >
64
84
</ span >
65
85
</ StackItem >
86
+ { env . environment && argocdLink && (
87
+ < StackItem className = "co-truncate co-nowrap" >
88
+ < ExternalLink
89
+ href = { `${ argocdLink . spec . href } /applications/${ env . environment } -${ appName } ` }
90
+ text = "Argo CD"
91
+ additionalClassName = "odc-gitops-details__env-section__argocd-link"
92
+ />
93
+ </ StackItem >
94
+ ) }
66
95
</ Stack >
67
- </ CardTitle >
96
+ </ CardBody >
68
97
</ Card >
69
98
</ StackItem >
70
99
< GitOpsServiceDetailsSection services = { env . services } />
0 commit comments