@@ -11,6 +11,7 @@ import {
11
11
stopPropagation ,
12
12
useAsync ,
13
13
getRandomColor ,
14
+ noop ,
14
15
} from '@devtron-labs/devtron-fe-common-lib'
15
16
import { EditableTextArea , RadioGroup , handleUTCTime , importComponentFromFELibrary } from '../../common'
16
17
import { AppOverviewProps , EditAppRequest , JobPipeline } from '../types'
@@ -33,10 +34,10 @@ import { getAppConfig, getGitProviderIcon } from './utils'
33
34
import { EnvironmentList } from './EnvironmentList'
34
35
import { MAX_LENGTH_350 } from '../../../config/constantMessaging'
35
36
import { getModuleInfo } from '../../v2/devtronStackManager/DevtronStackManager.service'
36
- import { OVERVIEW_TABS , TAB_SEARCH_KEY } from './constants'
37
+ import { MODAL_STATE , OVERVIEW_TABS , TAB_SEARCH_KEY } from './constants'
37
38
const MandatoryTagWarning = importComponentFromFELibrary ( 'MandatoryTagWarning' )
38
39
const Catalog = importComponentFromFELibrary ( 'Catalog' )
39
- // const DependencyList = importComponentFromFELibrary('DependencyList')
40
+ const DependencyList = importComponentFromFELibrary ( 'DependencyList' )
40
41
41
42
type AvailableTabs = typeof OVERVIEW_TABS [ keyof typeof OVERVIEW_TABS ]
42
43
@@ -46,6 +47,8 @@ export default function AppOverview({ appMetaInfo, getAppMetaInfoRes, filteredEn
46
47
const history = useHistory ( )
47
48
const searchParams = new URLSearchParams ( location . search )
48
49
const activeTab = searchParams . get ( TAB_SEARCH_KEY ) as AvailableTabs
50
+ const isUpdateDependencyModalOpen =
51
+ activeTab === OVERVIEW_TABS . DEPENDENCIES && searchParams . get ( MODAL_STATE . key ) === MODAL_STATE . value
49
52
const config = getAppConfig ( appType )
50
53
const isJobOverview = appType === 'job'
51
54
const isHelmChart = appType === 'helm-chart'
@@ -61,11 +64,10 @@ export default function AppOverview({ appMetaInfo, getAppMetaInfoRes, filteredEn
61
64
const [ newUpdatedOn , setNewUpdatedOn ] = useState < string > ( )
62
65
const [ newUpdatedBy , setNewUpdatedBy ] = useState < string > ( )
63
66
const [ jobPipelines , setJobPipelines ] = useState < JobPipeline [ ] > ( [ ] )
67
+ // Added this state to handle the disabled and hidden state basis the loading of the dependency list inside DependencyList component
68
+ const [ isEditDependencyButtonDisabled , setIsEditDependencyButtonDisabled ] = useState ( false )
64
69
const [ reloadMandatoryProjects , setReloadMandatoryProjects ] = useState < boolean > ( true )
65
- const [ , isArgoInstalled ] = useAsync (
66
- ( ) => getModuleInfo ( ModuleNameMap . ARGO_CD ) ,
67
- [ ] ,
68
- )
70
+ const [ , isArgoInstalled ] = useAsync ( ( ) => getModuleInfo ( ModuleNameMap . ARGO_CD ) , [ ] )
69
71
const resourceName = config . resourceName
70
72
71
73
let _moment : moment . Moment
@@ -76,6 +78,15 @@ export default function AppOverview({ appMetaInfo, getAppMetaInfoRes, filteredEn
76
78
history . replace ( { search : searchParams . toString ( ) } )
77
79
}
78
80
81
+ const toggleUpdateDependencyModal = ( ) => {
82
+ if ( isUpdateDependencyModalOpen ) {
83
+ searchParams . delete ( MODAL_STATE . key )
84
+ } else {
85
+ searchParams . set ( MODAL_STATE . key , MODAL_STATE . value )
86
+ }
87
+ history . replace ( { search : searchParams . toString ( ) } )
88
+ }
89
+
79
90
useEffect ( ( ) => {
80
91
// add a default tab if not set
81
92
if ( ! activeTab || ! Object . values ( OVERVIEW_TABS ) . includes ( activeTab ) ) {
@@ -460,24 +471,49 @@ export default function AppOverview({ appMetaInfo, getAppMetaInfoRes, filteredEn
460
471
const contentToRender = {
461
472
[ OVERVIEW_TABS . ABOUT ] : renderAppDescription ,
462
473
[ OVERVIEW_TABS . ENVIRONMENTS ] : ( ) => < EnvironmentList appId = { + appId } filteredEnvIds = { filteredEnvIds } /> ,
463
- // [OVERVIEW_TABS.DEPENDENCIES]: () => DependencyList ? <DependencyList appId={+appId} isArgoInstalled={isArgoInstalled} /> : null,
474
+ [ OVERVIEW_TABS . DEPENDENCIES ] : ( ) =>
475
+ DependencyList ? (
476
+ < DependencyList
477
+ resourceId = { + appId }
478
+ resourceType = { appType }
479
+ isArgoInstalled = { isArgoInstalled }
480
+ resourceName = { appMetaInfo . appName }
481
+ isUpdateModalOpen = { isUpdateDependencyModalOpen }
482
+ toggleUpdateModalOpen = { toggleUpdateDependencyModal }
483
+ toggleButtonDisabledState = { setIsEditDependencyButtonDisabled }
484
+ />
485
+ ) : null ,
464
486
}
465
487
466
488
return (
467
489
< div className = "app-overview-wrapper flexbox-col dc__gap-12" >
468
- < RadioGroup
469
- className = "gui-yaml-switch gui-yaml-switch--lg gui-yaml-switch-window-bg flex-justify-start dc__no-background-imp"
470
- name = "overview-tabs"
471
- initialTab = { activeTab }
472
- disabled = { false }
473
- onChange = { ( e ) => {
474
- setActiveTab ( e . target . value )
475
- } }
476
- >
477
- < RadioGroup . Radio value = { OVERVIEW_TABS . ABOUT } > About</ RadioGroup . Radio >
478
- < RadioGroup . Radio value = { OVERVIEW_TABS . ENVIRONMENTS } > Environments</ RadioGroup . Radio >
479
- { /* {DependencyList && <RadioGroup.Radio value={OVERVIEW_TABS.DEPENDENCIES}>Dependencies</RadioGroup.Radio> } */ }
480
- </ RadioGroup >
490
+ < div className = "flex flex-justify dc__gap-8" >
491
+ < RadioGroup
492
+ className = "gui-yaml-switch gui-yaml-switch--lg gui-yaml-switch-window-bg flex-justify-start dc__no-background-imp"
493
+ name = "overview-tabs"
494
+ initialTab = { activeTab }
495
+ disabled = { false }
496
+ onChange = { ( e ) => {
497
+ setActiveTab ( e . target . value )
498
+ } }
499
+ >
500
+ < RadioGroup . Radio value = { OVERVIEW_TABS . ABOUT } > About</ RadioGroup . Radio >
501
+ < RadioGroup . Radio value = { OVERVIEW_TABS . ENVIRONMENTS } > Environments</ RadioGroup . Radio >
502
+ { DependencyList && (
503
+ < RadioGroup . Radio value = { OVERVIEW_TABS . DEPENDENCIES } > Dependencies</ RadioGroup . Radio >
504
+ ) }
505
+ </ RadioGroup >
506
+ { activeTab === OVERVIEW_TABS . DEPENDENCIES && (
507
+ < button
508
+ type = "button"
509
+ className = { `cta flex h-28 dc__gap-4 ${ isEditDependencyButtonDisabled ? 'disabled-opacity' : '' } ` }
510
+ onClick = { isEditDependencyButtonDisabled ? noop : toggleUpdateDependencyModal }
511
+ >
512
+ < EditIcon className = "mw-14 icon-dim-14 scn-0 dc__no-svg-fill" />
513
+ Edit Dependency
514
+ </ button >
515
+ ) }
516
+ </ div >
481
517
< div className = "flexbox-col dc__gap-12" > { contentToRender [ activeTab ] ?.( ) } </ div >
482
518
</ div >
483
519
)
0 commit comments