Skip to content

Commit 7f658c5

Browse files
committed
feat: enhance resource conflict handling with redeploy functionality and UI improvements
1 parent c9f566f commit 7f658c5

6 files changed

Lines changed: 64 additions & 27 deletions

File tree

src/Shared/Components/CICDHistory/ResourceConflictDeployDialog.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { URLS } from '@Common/Constants'
55
import { showError } from '@Common/Helper'
66
import { ToastManager, ToastVariantType } from '@Shared/Services'
77

8+
import { ButtonStyleType } from '../Button'
89
import { ConfirmationModal, ConfirmationModalVariantType } from '../ConfirmationModal'
10+
import { Icon } from '../Icon'
911
import { resourceConflictRedeploy } from './service'
1012
import { ResourceConflictDeployDialogProps, ResourceConflictDeployDialogURLParamsType } from './types'
1113

@@ -20,14 +22,15 @@ const ResourceConflictDeployDialog = ({ appName, environmentName, handleClose }:
2022
await resourceConflictRedeploy({
2123
pipelineId,
2224
triggerId,
25+
appId,
2326
})
2427
ToastManager.showToast({
2528
variant: ToastVariantType.success,
2629
title: 'Redeploy initiated',
2730
description: `Redeployment for application '${appName}' in environment '${environmentName}' has been initiated successfully.`,
2831
})
2932
handleClose()
30-
history.push(`${URLS.APP}/${appId}/details/${envId}`)
33+
history.push(`${URLS.APPLICATION_MANAGEMENT_APP}/${appId}/details/${envId}`)
3134
} catch (error) {
3235
showError(error)
3336
} finally {
@@ -37,7 +40,8 @@ const ResourceConflictDeployDialog = ({ appName, environmentName, handleClose }:
3740

3841
return (
3942
<ConfirmationModal
40-
variant={ConfirmationModalVariantType.warning}
43+
variant={ConfirmationModalVariantType.custom}
44+
Icon={<Icon name="ic-warning" color={null} size={48} />}
4145
title="Take resource ownership and redeploy"
4246
subtitle={`Ensure the resources belong to the '${appName}' application and the '${environmentName}' environment to avoid destructive changes.`}
4347
handleClose={handleClose}
@@ -50,6 +54,7 @@ const ResourceConflictDeployDialog = ({ appName, environmentName, handleClose }:
5054
isLoading,
5155
text: 'Re-deploy',
5256
onClick: handleDeploy,
57+
style: ButtonStyleType.warning,
5358
},
5459
}}
5560
/>

src/Shared/Components/CICDHistory/ResourceConflictDetailsModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ const ResourceConflictDetailsModal = ({ appName, environmentName, handleClose }:
3939
await resourceConflictRedeploy({
4040
pipelineId,
4141
triggerId,
42+
appId,
4243
})
4344
ToastManager.showToast({
4445
variant: ToastVariantType.success,
4546
title: 'Redeploy initiated',
4647
description: `Redeployment for application '${appName}' in environment '${environmentName}' has been initiated successfully.`,
4748
})
4849
handleClose()
49-
history.push(`${URLS.APP}/${appId}/details/${envId}`)
50+
history.push(`${URLS.APPLICATION_MANAGEMENT_APP}/${appId}/details/${envId}`)
5051
} catch (error) {
5152
showError(error)
5253
} finally {

src/Shared/Components/CICDHistory/TriggerDetails.tsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ const TriggerDetails = memo(
472472
setResourceConflictModal(ResourceConflictModalType.DEPLOY_DIALOG)
473473
}
474474

475+
const handleShowResourceConflictDetailsModal = () => {
476+
setResourceConflictModal(ResourceConflictModalType.RESOURCE_DETAIL_MODAL)
477+
}
478+
475479
const handleCloseRedeployModal = () => {
476480
setResourceConflictModal(null)
477481
}
@@ -483,8 +487,9 @@ const TriggerDetails = memo(
483487
text="Some Resources"
484488
variant={ButtonVariantType.text}
485489
size={ComponentSizeType.medium}
490+
onClick={handleShowResourceConflictDetailsModal}
486491
/>
487-
492+
&nbsp;
488493
<span className="cn-9 fw-4 fs-13 lh-20 dc__word-break">
489494
have ownership conflict. Take resource ownership and re-deploy
490495
</span>
@@ -628,22 +633,24 @@ const TriggerDetails = memo(
628633
clusterId={executionInfo?.workerDetails.clusterId || DEFAULT_CLUSTER_ID}
629634
workerPodName={workerPodName}
630635
namespace={namespace}
631-
/>
636+
>
637+
{showResourceConflictInfoBlock && (
638+
<div className="py-12 pr-12">
639+
<InfoBlock
640+
description={renderInfoBlockDescription()}
641+
buttonProps={{
642+
dataTestId: 'resource-conflict-re-deploy',
643+
text: 'Re-deploy',
644+
startIcon: <Icon name="ic-rocket-launch" color={null} />,
645+
onClick: handleShowRedeployModal,
646+
variant: ButtonVariantType.text,
647+
size: ComponentSizeType.medium,
648+
}}
649+
/>
650+
</div>
651+
)}
652+
</WorkerStatus>
632653
</div>
633-
634-
{showResourceConflictInfoBlock && (
635-
<div className="display-grid trigger-details__grid py-4">
636-
<InfoBlock
637-
description={renderInfoBlockDescription()}
638-
buttonProps={{
639-
dataTestId: 'resource-conflict-re-deploy',
640-
text: 'Re-deploy',
641-
startIcon: <Icon name="ic-rocket-launch" color={null} />,
642-
onClick: handleShowRedeployModal,
643-
}}
644-
/>
645-
</div>
646-
)}
647654
</div>
648655
</div>
649656

src/Shared/Components/CICDHistory/WorkerStatus.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const WorkerStatus = memo(
4141
titleClassName = 'cn-9 fs-13 fw-4 lh-20',
4242
viewWorkerPodClassName = 'fs-13',
4343
hideShowMoreMessageButton = false,
44+
children,
4445
}: WorkerStatusType): JSX.Element | null => {
4546
if (!message && !podStatus) {
4647
return null
@@ -98,6 +99,8 @@ const WorkerStatus = memo(
9899
hideShowMore={hideShowMoreMessageButton}
99100
/>
100101
)}
102+
103+
{children}
101104
</div>
102105
</>
103106
)

src/Shared/Components/CICDHistory/service.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
/* eslint-disable dot-notation */
1818
import moment from 'moment'
1919

20-
import { get, getUrlWithSearchParams, ResponseType, ROUTES, sanitizeUserApprovalMetadata, trash } from '../../../Common'
20+
import {
21+
get,
22+
getUrlWithSearchParams,
23+
post,
24+
ResponseType,
25+
ROUTES,
26+
sanitizeUserApprovalMetadata,
27+
trash,
28+
} from '../../../Common'
2129
import { DATE_TIME_FORMAT_STRING, DEPLOYMENT_HISTORY_CONFIGURATION_LIST_MAP, EXTERNAL_TYPES } from '../../constants'
2230
import { decode, getUniqueId, isNullOrUndefined } from '../../Helpers'
2331
import { ResourceKindType, ResourceVersionType } from '../../types'
@@ -28,8 +36,9 @@ import {
2836
DeploymentStatusDetailsResponse,
2937
FetchIdDataStatus,
3038
ModuleConfigResponse,
31-
ResourceConflictDeployDialogURLParamsType,
3239
ResourceConflictItemType,
40+
ResourceConflictRedeployParamsType,
41+
ResourceConflictRedeployPayloadType,
3342
TriggerDetailsResponseType,
3443
TriggerHistoryParamsType,
3544
} from './types'
@@ -295,12 +304,13 @@ export const getTriggerHistory = async ({
295304
export const getModuleConfigured = (moduleName: string): Promise<ModuleConfigResponse> =>
296305
get(`${ROUTES.MODULE_CONFIGURED}?name=${moduleName}`)
297306

298-
export const resourceConflictRedeploy = async ({
299-
pipelineId,
300-
triggerId,
301-
}: Pick<ResourceConflictDeployDialogURLParamsType, 'pipelineId' | 'triggerId'>) =>
302-
// TODO: Fix the route
303-
get(`cd-pipeline/re-deploy/${pipelineId}/${triggerId}`)
307+
export const resourceConflictRedeploy = async ({ pipelineId, triggerId, appId }: ResourceConflictRedeployParamsType) =>
308+
post<never, ResourceConflictRedeployPayloadType>(ROUTES.CD_TRIGGER_POST, {
309+
pipelineId: +pipelineId,
310+
wfrId: +triggerId,
311+
appId: +appId,
312+
redeployHelmReleaseWithTakeOwnership: true,
313+
})
304314

305315
export const getResourceConflictDetails = async (): Promise<ResponseType<ResourceConflictItemType[]>> => ({
306316
code: 200,

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ export interface WorkerStatusType
409409
* @default false
410410
*/
411411
hideShowMoreMessageButton?: boolean
412+
children?: ReactNode
412413
}
413414

414415
export type FinishedType = { artifact: string; type: HistoryComponentType } & (
@@ -903,3 +904,13 @@ export interface CIPipelineSourceConfigInterface {
903904
primaryBranchAfterRegex?: string
904905
rootClassName?: string
905906
}
907+
908+
export interface ResourceConflictRedeployParamsType
909+
extends Pick<ResourceConflictDeployDialogURLParamsType, 'pipelineId' | 'triggerId' | 'appId'> {}
910+
911+
export interface ResourceConflictRedeployPayloadType {
912+
pipelineId: number
913+
appId: number
914+
wfrId: number
915+
redeployHelmReleaseWithTakeOwnership: true
916+
}

0 commit comments

Comments
 (0)