Skip to content

Commit e10a7c3

Browse files
committed
Merge branch 'fix/bulk-cd' of https://github.com/devtron-labs/dashboard into fix/build-deploy-trigger
2 parents 8e7d7aa + eba48c0 commit e10a7c3

File tree

6 files changed

+80
-53
lines changed

6 files changed

+80
-53
lines changed

src/components/app/details/triggerView/DeployImageModal/BulkDeployModal.tsx

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ const BulkDeployModal = ({
243243
...prev,
244244
[selectedAppId]: {
245245
...prev[selectedAppId],
246+
materialResponse: response[selectedAppId]?.materialResponse,
246247
warningMessage,
247248
materialError,
248249
deploymentWindowMetadata,
@@ -258,6 +259,10 @@ const BulkDeployModal = ({
258259
}))
259260
}
260261

262+
const reloadMaterials = async () => {
263+
await reloadOrSearchSelectedApp()
264+
}
265+
261266
const handleLoadOlderImages = async () => {
262267
try {
263268
// Even if user changes selectedAppId this will persist since a state closure
@@ -459,29 +464,31 @@ const BulkDeployModal = ({
459464
const handleTagChange: DeployImageContentProps['handleTagChange'] = (tagOption) => {
460465
setSelectedImageTagOption(tagOption)
461466

462-
const selectedApp = appInfoMap[selectedAppId]
463-
const updatedMaterials = getUpdatedMaterialsForTagSelection(
464-
tagOption.value,
465-
selectedApp.materialResponse?.materials || [],
466-
)
467-
const { tagsWarning, updatedMaterials: newMaterials } = updatedMaterials
467+
setAppInfoMap((prev) => {
468+
const updatedAppInfoMap = structuredClone(prev)
469+
Object.values(updatedAppInfoMap).forEach((appDetails) => {
470+
const { tagsWarning, updatedMaterials } = getUpdatedMaterialsForTagSelection(
471+
tagOption.value,
472+
appDetails.materialResponse?.materials || [],
473+
)
468474

469-
const { tagsWarning: previousTagWarning } = getUpdatedMaterialsForTagSelection(
470-
selectedImageTagOption.value,
471-
selectedApp.materialResponse?.materials || [],
472-
)
475+
const { tagsWarning: previousTagWarning } = getUpdatedMaterialsForTagSelection(
476+
selectedImageTagOption.value,
477+
appDetails.materialResponse?.materials || [],
478+
)
473479

474-
setAppInfoMap((prev) => ({
475-
...prev,
476-
[selectedAppId]: {
477-
...prev[selectedAppId],
478-
materialResponse: {
479-
...prev[selectedAppId].materialResponse,
480-
materials: newMaterials,
481-
},
482-
warningMessage: previousTagWarning ? tagsWarning : prev[selectedAppId].warningMessage,
483-
},
484-
}))
480+
updatedAppInfoMap[appDetails.appId] = {
481+
...appDetails,
482+
materialResponse: {
483+
...appDetails.materialResponse,
484+
materials: updatedMaterials,
485+
},
486+
warningMessage:
487+
previousTagWarning || !appDetails.warningMessage ? tagsWarning : appDetails.warningMessage,
488+
}
489+
})
490+
return updatedAppInfoMap
491+
})
485492
}
486493

487494
const changeApp: DeployImageContentProps['changeApp'] = (appId) => {
@@ -614,7 +621,7 @@ const BulkDeployModal = ({
614621
appName={appName}
615622
isSecurityModuleInstalled={isSecurityModuleInstalled}
616623
envName={envName}
617-
reloadMaterials={reloadOrSearchSelectedApp}
624+
reloadMaterials={reloadMaterials}
618625
parentEnvironmentName={parentEnvironmentName}
619626
isVirtualEnvironment={isVirtualEnvironment}
620627
loadOlderImages={handleLoadOlderImages}

src/components/app/details/triggerView/DeployImageModal/BulkTriggerSidebar.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ const BulkTriggerSidebar = ({
6666
return false
6767
}
6868

69+
if (selectedTagName === BULK_DEPLOY_ACTIVE_IMAGE_TAG.value) {
70+
return !(selectedImage.deployed && selectedImage.latest)
71+
}
72+
73+
if (selectedTagName === BULK_DEPLOY_LATEST_IMAGE_TAG.value) {
74+
return selectedImage.index !== 0
75+
}
76+
6977
return !selectedImage.imageReleaseTags?.some((tagDetails) => tagDetails.tagName === selectedTagName)
7078
})
7179

src/components/app/details/triggerView/DeployImageModal/DeployImageContent.tsx

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,32 @@ const DeployImageContent = ({
518518
)
519519
})
520520

521+
const renderMaterialListEmptyState = () => (
522+
<div className="flexbox-col flex-grow-1 dc__overflow-auto h-100">
523+
<MaterialListEmptyState
524+
isRollbackTrigger={isRollbackTrigger}
525+
stageType={stageType}
526+
appId={appId}
527+
isSearchApplied={isSearchApplied}
528+
policyConsequences={policyConsequences}
529+
isTriggerBlockedDueToPlugin={isTriggerBlockedDueToPlugin}
530+
configurePluginURL={configurePluginURL}
531+
isConsumedImagePresent={consumedImage.length > 0}
532+
envName={envName}
533+
materialResponse={materialResponse}
534+
isExceptionUser={isExceptionUser}
535+
isLoadingMore={isLoadingOlderImages}
536+
viewAllImages={viewAllImages}
537+
triggerType={triggerType}
538+
loadOlderImages={loadOlderImages}
539+
onSearchApply={onSearchApply}
540+
eligibleImagesCount={eligibleImagesCount}
541+
handleEnableFiltersView={handleShowConfiguredFilters}
542+
handleAllImagesView={handleAllImagesView}
543+
/>
544+
</div>
545+
)
546+
521547
const renderContent = () => {
522548
if (isBulkTrigger) {
523549
if (showFiltersView) {
@@ -599,33 +625,9 @@ const DeployImageContent = ({
599625
</div>
600626
</div>
601627

602-
{materialList.length === 0 ? (
603-
<div className="flexbox-col flex-grow-1 dc__overflow-auto h-100">
604-
<MaterialListEmptyState
605-
isRollbackTrigger={isRollbackTrigger}
606-
stageType={stageType}
607-
appId={appId}
608-
isSearchApplied={isSearchApplied}
609-
policyConsequences={policyConsequences}
610-
isTriggerBlockedDueToPlugin={isTriggerBlockedDueToPlugin}
611-
configurePluginURL={configurePluginURL}
612-
isConsumedImagePresent={consumedImage.length > 0}
613-
envName={envName}
614-
materialResponse={materialResponse}
615-
isExceptionUser={isExceptionUser}
616-
isLoadingMore={isLoadingOlderImages}
617-
viewAllImages={viewAllImages}
618-
triggerType={triggerType}
619-
loadOlderImages={loadOlderImages}
620-
onSearchApply={onSearchApply}
621-
eligibleImagesCount={eligibleImagesCount}
622-
handleEnableFiltersView={handleShowConfiguredFilters}
623-
handleAllImagesView={handleAllImagesView}
624-
/>
625-
</div>
626-
) : (
627-
renderMaterialList(materialList, false)
628-
)}
628+
{materialList.length === 0
629+
? renderMaterialListEmptyState()
630+
: renderMaterialList(materialList, false)}
629631

630632
{!areNoMoreImagesPresent && !!materialList?.length && (
631633
<button
@@ -659,6 +661,10 @@ const DeployImageContent = ({
659661
return renderConfiguredFilters()
660662
}
661663

664+
if (materials.length === 0 && !isBulkTrigger) {
665+
return renderMaterialListEmptyState()
666+
}
667+
662668
return (
663669
<>
664670
{!showFiltersView &&
@@ -687,7 +693,11 @@ const DeployImageContent = ({
687693
className={`flex-grow-1 dc__overflow-auto h-100 ${isPreOrPostCD || isBulkTrigger ? 'display-grid cd-material__container-with-sidebar' : 'flexbox-col flex-grow-1'}`}
688694
>
689695
{renderSidebar()}
690-
<div className="flexbox-col py-16 px-20 dc__overflow-auto flex-grow-1">{renderContent()}</div>
696+
<div
697+
className={`flexbox-col dc__overflow-auto flex-grow-1 ${isBulkTrigger && showFiltersView ? '' : 'py-16 px-20 '}`}
698+
>
699+
{renderContent()}
700+
</div>
691701
</div>
692702
</>
693703
)

src/components/app/details/triggerView/DeployImageModal/DeployImageModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ const DeployImageModal = ({
130130
initialSearch: searchImageTag,
131131
}),
132132
[searchImageTag],
133+
!isTriggerBlockedDueToPlugin,
133134
)
134135

135136
const [, moduleInfoRes] = useAsync(() => getModuleInfo(ModuleNameMap.SECURITY))

src/components/app/details/triggerView/DeployImageModal/MaterialListEmptyState.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const MaterialListEmptyState = ({
4242
const isApprovalConfigured = getIsApprovalPolicyConfigured(
4343
materialResponse?.deploymentApprovalInfo?.approvalConfigData,
4444
)
45-
const areNoMoreImagesPresent = materialResponse && materialResponse.materials.length >= materialResponse.totalCount
45+
const areNoMoreImagesPresent = materialResponse && material.length >= materialResponse.totalCount
4646
const resourceFilters = materialResponse?.resourceFilters ?? []
4747

4848
const clearSearch = () => {

src/components/app/details/triggerView/DeployImageModal/utils.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ export const getBulkCDDetailsMapFromResponse: GetBulkCDDetailsMapFromResponseTyp
520520
cdMaterialResponseList.forEach((materialResponse, index) => {
521521
const { appId } = validWorkflows[index]
522522

523-
if (materialResponse.status === PromiseAllStatusType.FULFILLED) {
523+
if (materialResponse.status === PromiseAllStatusType.FULFILLED && materialResponse.value) {
524524
const { tagsWarning, updatedMaterials } = getUpdatedMaterialsForTagSelection(
525525
selectedTagName,
526526
materialResponse.value.materials,
@@ -552,7 +552,8 @@ export const getBulkCDDetailsMapFromResponse: GetBulkCDDetailsMapFromResponseTyp
552552
materialResponse: {} as CDMaterialResponseType,
553553
deploymentWindowMetadata: {} as DeploymentWindowProfileMetaData,
554554
deployViewState: structuredClone(INITIAL_DEPLOY_VIEW_STATE),
555-
materialError: materialResponse.reason,
555+
materialError:
556+
materialResponse.status === PromiseAllStatusType.REJECTED ? materialResponse.reason : null,
556557
areMaterialsLoading: false,
557558
}
558559
}

0 commit comments

Comments
 (0)