-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathResourceConflictDeployDialog.tsx
More file actions
64 lines (58 loc) · 2.43 KB
/
ResourceConflictDeployDialog.tsx
File metadata and controls
64 lines (58 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { useState } from 'react'
import { useHistory, useParams } from 'react-router-dom'
import { URLS } from '@Common/Constants'
import { showError } from '@Common/Helper'
import { ToastManager, ToastVariantType } from '@Shared/Services'
import { ButtonStyleType } from '../Button'
import { ConfirmationModal, ConfirmationModalVariantType } from '../ConfirmationModal'
import { Icon } from '../Icon'
import { resourceConflictRedeploy } from './service'
import { ResourceConflictDeployDialogProps, ResourceConflictDeployDialogURLParamsType } from './types'
const ResourceConflictDeployDialog = ({ appName, environmentName, handleClose }: ResourceConflictDeployDialogProps) => {
const history = useHistory()
const { appId, envId, pipelineId, triggerId } = useParams<ResourceConflictDeployDialogURLParamsType>()
const [isLoading, setIsLoading] = useState(false)
const handleDeploy = async () => {
setIsLoading(true)
try {
await resourceConflictRedeploy({
pipelineId,
triggerId,
appId,
})
ToastManager.showToast({
variant: ToastVariantType.success,
title: 'Redeploy initiated',
description: `Redeployment for application '${appName}' in environment '${environmentName}' has been initiated successfully.`,
})
handleClose()
history.push(`${URLS.APP}/${appId}/details/${envId}`)
} catch (error) {
showError(error)
} finally {
setIsLoading(false)
}
}
return (
<ConfirmationModal
variant={ConfirmationModalVariantType.custom}
Icon={<Icon name="ic-warning" color={null} size={48} />}
title="Take resource ownership and redeploy"
subtitle={`Ensure the resources belong to the '${appName}' application and the '${environmentName}' environment to avoid destructive changes.`}
handleClose={handleClose}
buttonConfig={{
secondaryButtonConfig: {
text: 'Cancel',
onClick: handleClose,
},
primaryButtonConfig: {
isLoading,
text: 'Re-deploy',
onClick: handleDeploy,
style: ButtonStyleType.warning,
},
}}
/>
)
}
export default ResourceConflictDeployDialog