Skip to content

Commit 2bb1aed

Browse files
committed
fix: remove toast notifications from redeploy functions and update artifactId handling
1 parent b907e3f commit 2bb1aed

5 files changed

Lines changed: 22 additions & 27 deletions

File tree

src/Shared/Components/CICDHistory/ResourceConflictDeployDialog.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useHistory, useParams } from 'react-router-dom'
33

44
import { URLS } from '@Common/Constants'
55
import { showError } from '@Common/Helper'
6-
import { ToastManager, ToastVariantType } from '@Shared/Services'
76

87
import { ButtonStyleType } from '../Button'
98
import { ConfirmationModal, ConfirmationModalVariantType } from '../ConfirmationModal'
@@ -24,12 +23,6 @@ const ResourceConflictDeployDialog = ({ appName, environmentName, handleClose }:
2423
triggerId,
2524
appId,
2625
})
27-
ToastManager.showToast({
28-
variant: ToastVariantType.success,
29-
title: 'Redeploy initiated',
30-
description: `Redeployment for application '${appName}' in environment '${environmentName}' has been initiated successfully.`,
31-
})
32-
handleClose()
3326
history.push(`${URLS.APP}/${appId}/details/${envId}`)
3427
} catch (error) {
3528
showError(error)

src/Shared/Components/CICDHistory/ResourceConflictDetailsModal.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { URLS } from '@Common/Constants'
66
import { Drawer } from '@Common/Drawer'
77
import { showError, stopPropagation } from '@Common/Helper'
88
import { ComponentSizeType } from '@Shared/constants'
9-
import { ToastManager, ToastVariantType } from '@Shared/Services'
109

1110
import { APIResponseHandler } from '../APIResponseHandler'
1211
import { Button, ButtonStyleType, ButtonVariantType } from '../Button'
@@ -43,12 +42,6 @@ const ResourceConflictDetailsModal = ({ appName, environmentName, handleClose }:
4342
triggerId,
4443
appId,
4544
})
46-
ToastManager.showToast({
47-
variant: ToastVariantType.success,
48-
title: 'Redeploy initiated',
49-
description: `Redeployment for application '${appName}' in environment '${environmentName}' has been initiated successfully.`,
50-
})
51-
handleClose()
5245
history.push(`${URLS.APP}/${appId}/details/${envId}`)
5346
} catch (error) {
5447
showError(error)
@@ -119,11 +112,7 @@ const ResourceConflictDetailsModal = ({ appName, environmentName, handleClose }:
119112
text="Re-deploy"
120113
startIcon={<Icon name="ic-rocket-launch" color={null} />}
121114
isLoading={isDeploying}
122-
disabled={
123-
!!resourceConflictDetailsError ||
124-
isLoadingResourceData ||
125-
resourceConflictDetails?.length === 0
126-
}
115+
disabled={!resourceConflictDetails?.length}
127116
onClick={handleDeploy}
128117
/>
129118
</div>

src/Shared/Components/CICDHistory/TriggerDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ const TriggerDetails = memo(
468468
stage === DeploymentStageType.DEPLOY &&
469469
errorMessage?.includes(RESOURCE_CONFLICT_DEPLOY_ERROR)
470470

471-
const handleShowRedeployModal = () => {
471+
const handleShowRedeployDialog = () => {
472472
setResourceConflictModal(ResourceConflictModalType.DEPLOY_DIALOG)
473473
}
474474

@@ -643,7 +643,7 @@ const TriggerDetails = memo(
643643
dataTestId: 'resource-conflict-re-deploy',
644644
text: 'Re-deploy',
645645
startIcon: <Icon name="ic-rocket-launch" color={null} />,
646-
onClick: handleShowRedeployModal,
646+
onClick: handleShowRedeployDialog,
647647
variant: ButtonVariantType.text,
648648
size: ComponentSizeType.medium,
649649
}}

src/Shared/Components/CICDHistory/TriggerOutput.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ const TriggerOutput = ({
261261
)
262262

263263
const targetPlatforms = sanitizeTargetPlatforms(triggerDetails?.targetPlatforms)
264-
const artifactId = triggerDetailsResult?.result?.artifactId || triggerDetails?.artifactId
265264

266265
// Function to sync the trigger details as trigger details is also fetched with another api
267266
const syncState = (syncTriggerId: number, syncTriggerDetail: History, syncTriggerDetailsError: ServerError) => {
@@ -308,10 +307,12 @@ const TriggerOutput = ({
308307
() =>
309308
getTagDetails({
310309
pipelineId,
311-
artifactId,
310+
artifactId: triggerDetailsResult?.result?.artifactId || triggerDetails?.artifactId,
312311
}),
313312
[pipelineId, triggerId],
314-
areTagDetailsRequired && !!pipelineId && !!artifactId,
313+
areTagDetailsRequired &&
314+
!!pipelineId &&
315+
(!!triggerDetailsResult?.result?.artifactId || !!triggerDetails?.artifactId),
315316
)
316317

317318
useEffect(() => {
@@ -429,7 +430,7 @@ const TriggerOutput = ({
429430
setFullScreenView={setFullScreenView}
430431
deploymentAppType={deploymentAppType}
431432
isBlobStorageConfigured={isBlobStorageConfigured}
432-
artifactId={artifactId}
433+
artifactId={triggerDetailsResult?.result?.artifactId}
433434
ciPipelineId={triggerDetailsResult?.result?.ciPipelineId}
434435
appReleaseTags={appReleaseTags}
435436
tagsEditable={tagsEditable}

src/Shared/Components/CICDHistory/service.tsx

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

20+
import { ToastManager, ToastVariantType } from '@Shared/Services'
2021
import { GVKType, K8S_EMPTY_GROUP } from '@Pages/ResourceBrowser'
2122

2223
import {
@@ -309,14 +310,25 @@ export const getTriggerHistory = async ({
309310
export const getModuleConfigured = (moduleName: string): Promise<ModuleConfigResponse> =>
310311
get(`${ROUTES.MODULE_CONFIGURED}?name=${moduleName}`)
311312

312-
export const resourceConflictRedeploy = async ({ pipelineId, triggerId, appId }: ResourceConflictRedeployParamsType) =>
313-
post<never, ResourceConflictRedeployPayloadType>(ROUTES.CD_TRIGGER_POST, {
313+
export const resourceConflictRedeploy = async ({
314+
pipelineId,
315+
triggerId,
316+
appId,
317+
}: ResourceConflictRedeployParamsType) => {
318+
await post<never, ResourceConflictRedeployPayloadType>(ROUTES.CD_TRIGGER_POST, {
314319
pipelineId: +pipelineId,
315320
wfrIdForDeploymentWithSpecificTrigger: +triggerId,
316321
appId: +appId,
317322
redeployHelmReleaseWithTakeOwnership: true,
318323
})
319324

325+
ToastManager.showToast({
326+
variant: ToastVariantType.success,
327+
title: 'Redeployment initiated',
328+
description: 'Redeployment for application has been successfully initiated.',
329+
})
330+
}
331+
320332
export const getResourceConflictDetails = async ({
321333
appId,
322334
pipelineId,

0 commit comments

Comments
 (0)