@@ -2,6 +2,7 @@ import * as React from 'react';
22import { RouteComponentProps } from 'react-router' ;
33import classNames from 'classnames' ;
44
5+ import { useArgoServer } from '@gitops/hooks/useArgoServer' ;
56import { useResourceActionsProvider } from '@gitops/hooks/useResourceActionsProvider' ;
67import HealthStatus from '@gitops/Statuses/HealthStatus' ;
78import SyncStatus from '@gitops/Statuses/SyncStatus' ;
@@ -15,7 +16,6 @@ import {
1516 ResourceLink ,
1617 RowFilter ,
1718 RowFilterItem ,
18- useK8sModel ,
1919 useListPageFilter ,
2020} from '@openshift-console/dynamic-plugin-sdk' ;
2121import {
@@ -33,7 +33,7 @@ import { DataViewTh, DataViewTr } from '@patternfly/react-data-view/dist/esm/Dat
3333import { CubesIcon } from '@patternfly/react-icons' ;
3434import { Tbody , Td , Tr } from '@patternfly/react-table' ;
3535
36- import { ArgoServer , getArgoServer } from '../../utils/gitops' ;
36+ import { getApplicationArgoUrl } from '../../utils/gitops' ;
3737import ArgoCDLink from '../shared/ArgoCDLink/ArgoCDLink' ;
3838import { GitOpsDataViewTable , useGitOpsDataViewSort } from '../shared/DataView' ;
3939
@@ -47,21 +47,8 @@ type ApplicationResourcesTabProps = RouteComponentProps<{
4747} ;
4848
4949const ApplicationResourcesTab : React . FC < ApplicationResourcesTabProps > = ( { obj } ) => {
50- const [ model ] = useK8sModel ( { group : 'route.openshift.io' , version : 'v1' , kind : 'Route' } ) ;
51-
52- const [ argoServer , setArgoServer ] = React . useState < ArgoServer > ( { host : '' , protocol : '' } ) ;
53-
54- React . useEffect ( ( ) => {
55- ( async ( ) => {
56- getArgoServer ( model , obj )
57- . then ( ( server ) => {
58- setArgoServer ( server ) ;
59- } )
60- . catch ( ( err ) => {
61- console . error ( 'Error:' , err ) ;
62- } ) ;
63- } ) ( ) ;
64- } , [ model , obj ] ) ;
50+ const argoServer = useArgoServer ( obj ) ;
51+ const argoUrl = getApplicationArgoUrl ( argoServer , obj ) ;
6552
6653 let resources : ApplicationResourceStatus [ ] ;
6754 if ( obj ?. status ?. resources ) {
@@ -91,17 +78,7 @@ const ApplicationResourcesTab: React.FC<ApplicationResourcesTabProps> = ({ obj }
9178 const memoizedFilteredResources = React . useMemo ( ( ) => [ ...filteredData ] , [ filteredData ] ) ;
9279 const isEmptyResources = memoizedFilteredResources . length === 0 ;
9380
94- const rows = useResourceRowsDV (
95- memoizedFilteredResources ,
96- obj ,
97- argoServer . protocol +
98- '://' +
99- argoServer . host +
100- '/applications/' +
101- obj ?. metadata ?. namespace +
102- '/' +
103- obj ?. metadata ?. name ,
104- ) ;
81+ const rows = useResourceRowsDV ( memoizedFilteredResources , obj , argoUrl ) ;
10582
10683 const empty = (
10784 < Tbody >
@@ -134,19 +111,7 @@ const ApplicationResourcesTab: React.FC<ApplicationResourcesTabProps> = ({ obj }
134111 </ Flex >
135112 < PageBody >
136113 < Flex style = { { marginTop : '15px' } } flex = { { default : 'flexDefault' } } >
137- < FlexItem >
138- < ArgoCDLink
139- href = {
140- argoServer . protocol +
141- '://' +
142- argoServer . host +
143- '/applications/' +
144- obj ?. metadata ?. namespace +
145- '/' +
146- obj ?. metadata ?. name
147- }
148- />
149- </ FlexItem >
114+ < FlexItem > { argoUrl ? < ArgoCDLink href = { argoUrl } /> : < > </ > } </ FlexItem >
150115 </ Flex >
151116 < >
152117 { obj . metadata && (
0 commit comments