@@ -7,12 +7,9 @@ import {
7
7
ButtonVariantType,
8
8
CDMaterialSidebarType,
9
9
CDMaterialType,
10
- CommonNodeAttr,
11
10
ComponentSizeType,
12
11
DEPLOYMENT_WINDOW_TYPE,
13
12
DeploymentNodeType,
14
- ErrorScreenManager,
15
- GenericEmptyState,
16
13
getGitCommitInfo,
17
14
getIsApprovalPolicyConfigured,
18
15
getIsMaterialInfoAvailable,
@@ -32,13 +29,12 @@ import {
32
29
useMainContext,
33
30
} from '@devtron-labs/devtron-fe-common-lib'
34
31
35
- import emptyPreDeploy from '@Images/empty-pre-deploy.webp'
36
- import { BULK_CD_MESSAGING } from '@Components/ApplicationGroup/Constants'
37
32
import { importComponentFromFELibrary } from '@Components/common'
38
33
39
34
import { TriggerViewContext } from '../config'
40
35
import { TRIGGER_VIEW_PARAMS } from '../Constants'
41
36
import { FilterConditionViews, HandleRuntimeParamChange, TriggerViewContextType } from '../types'
37
+ import BulkDeployEmptyState from './BulkDeployEmptyState'
42
38
import BulkTriggerSidebar from './BulkTriggerSidebar'
43
39
import ImageSelectionCTA from './ImageSelectionCTA'
44
40
import MaterialListEmptyState from './MaterialListEmptyState'
@@ -64,8 +60,6 @@ const RuntimeParameters = importComponentFromFELibrary('RuntimeParameters', null
64
60
const SecurityModalSidebar = importComponentFromFELibrary('SecurityModalSidebar', null, 'function')
65
61
const CDMaterialInfo = importComponentFromFELibrary('CDMaterialInfo')
66
62
const ConfiguredFilters = importComponentFromFELibrary('ConfiguredFilters')
67
- const TriggerBlockEmptyState = importComponentFromFELibrary('TriggerBlockEmptyState', null, 'function')
68
- const MissingPluginBlockState = importComponentFromFELibrary('MissingPluginBlockState', null, 'function')
69
63
70
64
const DeployImageContent = ({
71
65
appId,
@@ -99,6 +93,7 @@ const DeployImageContent = ({
99
93
handleTagChange,
100
94
changeApp,
101
95
}: DeployImageContentProps) => {
96
+ // WARNING: Pls try not to create a useState in this component, it is supposed to be a dumb component.
102
97
const history = useHistory()
103
98
const { isSuperAdmin } = useMainContext()
104
99
const { onClickApprovalNode } = useContext<TriggerViewContextType>(TriggerViewContext)
@@ -144,9 +139,11 @@ const DeployImageContent = ({
144
139
})
145
140
const selectImageTitle = isRollbackTrigger ? 'Select from previously deployed images' : 'Select Image'
146
141
const titleText = isApprovalConfigured && !isExceptionUser ? 'Approved images' : selectImageTitle
147
- const showActionBar = FilterActionBar && !isSearchApplied && !!resourceFilters?.length && !showConfiguredFilters
142
+ const showActionBar = !! FilterActionBar && !isSearchApplied && !!resourceFilters?.length && !showConfiguredFilters
148
143
const areNoMoreImagesPresent = materials.length >= materialResponse?.totalCount
149
144
145
+ const showFiltersView = !!(ConfiguredFilters && (showConfiguredFilters || showAppliedFilters))
146
+
150
147
const handleSidebarTabChange: RuntimeParamsSidebarProps['handleSidebarTabChange'] = (e) => {
151
148
setDeployViewState((prevState) => ({
152
149
...prevState,
@@ -348,7 +345,7 @@ const DeployImageContent = ({
348
345
)
349
346
}
350
347
351
- if (isPreOrPostCD) {
348
+ if (isPreOrPostCD && !showFiltersView ) {
352
349
return (
353
350
<RuntimeParamsSidebar
354
351
areTabsDisabled={false}
@@ -363,16 +360,26 @@ const DeployImageContent = ({
363
360
return null
364
361
}
365
362
363
+ const renderConfiguredFilters = () => (
364
+ <ConfiguredFilters
365
+ isFromBulkCD={isBulkTrigger}
366
+ resourceFilters={showConfiguredFilters ? resourceFilters : appliedFilterList}
367
+ handleDisableFiltersView={showConfiguredFilters ? handleExitFiltersView : handleDisableAppliedFiltersView}
368
+ envName={envName}
369
+ closeModal={handleClose}
370
+ />
371
+ )
372
+
366
373
const renderGitMaterialInfo = (materialData: CDMaterialType) => (
367
374
<>
368
375
{materialData.materialInfo.map((mat: MaterialInfo, index) => {
369
376
const _gitCommit = getGitCommitInfo(mat)
370
377
371
378
if (
379
+ CDMaterialInfo &&
372
380
(materialData.appliedFilters?.length > 0 ||
373
381
materialData.deploymentBlockedState?.isBlocked ||
374
- materialData.deploymentWindowArtifactMetadata?.type) &&
375
- CDMaterialInfo
382
+ materialData.deploymentWindowArtifactMetadata?.type)
376
383
) {
377
384
return (
378
385
<CDMaterialInfo
@@ -508,47 +515,12 @@ const DeployImageContent = ({
508
515
)
509
516
})
510
517
511
- const renderEmptyView = (): JSX.Element => {
512
- const selectedApp = appInfoMap[+appId]
513
-
514
- if (selectedApp.triggerBlockedInfo?.blockedBy === TriggerBlockType.MANDATORY_TAG) {
515
- return <TriggerBlockEmptyState stageType={stageType} appId={appId} />
516
- }
517
-
518
- if (isTriggerBlockedDueToPlugin) {
519
- // It can't be CD
520
- const commonNodeAttrType: CommonNodeAttr['type'] =
521
- stageType === DeploymentNodeType.PRECD ? 'PRECD' : 'POSTCD'
522
-
523
- return (
524
- <MissingPluginBlockState
525
- configurePluginURL={selectedApp?.configurePluginURL}
526
- nodeType={commonNodeAttrType}
527
- />
528
- )
529
- }
530
-
531
- if (selectedApp.materialError) {
532
- return (
533
- <ErrorScreenManager
534
- code={selectedApp.materialError.code}
535
- reload={reloadMaterials}
536
- on404Redirect={handleClose}
537
- />
538
- )
539
- }
540
-
541
- return (
542
- <GenericEmptyState
543
- image={emptyPreDeploy}
544
- title={`${selectedApp?.appName} ${BULK_CD_MESSAGING[stageType].title}`}
545
- subTitle={BULK_CD_MESSAGING[stageType].subTitle}
546
- />
547
- )
548
- }
549
-
550
518
const renderContent = () => {
551
519
if (isBulkTrigger) {
520
+ if (showFiltersView) {
521
+ return renderConfiguredFilters()
522
+ }
523
+
552
524
const { areMaterialsLoading, triggerBlockedInfo, materialError } = appInfoMap[+appId] || {}
553
525
if (currentSidebarTab === CDMaterialSidebarType.IMAGE && areMaterialsLoading) {
554
526
return <MaterialListSkeleton />
@@ -562,7 +534,16 @@ const DeployImageContent = ({
562
534
materialError ||
563
535
selectedApp?.stageNotAvailable
564
536
) {
565
- return renderEmptyView()
537
+ return (
538
+ <BulkDeployEmptyState
539
+ selectedApp={selectedApp}
540
+ stageType={stageType}
541
+ appId={appId}
542
+ isTriggerBlockedDueToPlugin={isTriggerBlockedDueToPlugin}
543
+ handleClose={handleClose}
544
+ reloadMaterials={reloadMaterials}
545
+ />
546
+ )
566
547
}
567
548
}
568
549
@@ -587,7 +568,7 @@ const DeployImageContent = ({
587
568
<span className="flex dc__align-start">{titleText}</span>
588
569
)}
589
570
590
- <span className="flexbox dc__align-items-center h-32 dc__gap-4">
571
+ <div className="flexbox dc__align-items-center h-32 dc__gap-4">
591
572
{showSearchBar || isSearchApplied ? (
592
573
renderSearch()
593
574
) : (
@@ -612,7 +593,7 @@ const DeployImageContent = ({
612
593
showAriaLabelInTippy={false}
613
594
size={ComponentSizeType.small}
614
595
/>
615
- </span >
596
+ </div >
616
597
</div>
617
598
618
599
{materialList.length === 0 ? (
@@ -628,7 +609,6 @@ const DeployImageContent = ({
628
609
isConsumedImagePresent={consumedImage.length > 0}
629
610
envName={envName}
630
611
materialResponse={materialResponse}
631
- // TODO: Move to util and remove prop
632
612
isExceptionUser={isExceptionUser}
633
613
isLoadingMore={isLoadingOlderImages}
634
614
viewAllImages={viewAllImages}
@@ -672,34 +652,25 @@ const DeployImageContent = ({
672
652
)
673
653
}
674
654
675
- if (ConfiguredFilters && (showConfiguredFilters || showAppliedFilters)) {
676
- return (
677
- <ConfiguredFilters
678
- isFromBulkCD={isBulkTrigger}
679
- resourceFilters={showConfiguredFilters ? resourceFilters : appliedFilterList}
680
- handleDisableFiltersView={
681
- showConfiguredFilters ? handleExitFiltersView : handleDisableAppliedFiltersView
682
- }
683
- envName={envName}
684
- closeModal={handleClose}
685
- />
686
- )
655
+ if (showFiltersView && !isBulkTrigger) {
656
+ return renderConfiguredFilters()
687
657
}
688
658
689
659
return (
690
660
<>
691
- {isApprovalConfigured &&
661
+ {!showFiltersView &&
662
+ isApprovalConfigured &&
692
663
!isExceptionUser &&
693
664
ApprovedImagesMessage &&
694
665
(isRollbackTrigger || materials.length - Number(isConsumedImageAvailable) > 0) && (
695
666
<InfoBlock
696
667
borderConfig={{ top: false }}
697
668
borderRadiusConfig={{ top: false, bottom: false, left: false, right: false }}
698
- // TODO: Look if need to show this in bulk?
699
669
description={<ApprovedImagesMessage viewAllImages={viewAllImages} />}
700
670
/>
701
671
)}
702
- {!isBulkTrigger &&
672
+ {!showFiltersView &&
673
+ !isBulkTrigger &&
703
674
MaintenanceWindowInfoBar &&
704
675
deploymentWindowMetadata.type === DEPLOYMENT_WINDOW_TYPE.MAINTENANCE &&
705
676
deploymentWindowMetadata.isActive && (
0 commit comments