Display loader on deleting deployment
This commit is contained in:
parent
1ae2c5b1e1
commit
30b493e567
@ -1,22 +1,36 @@
|
|||||||
import ConfirmDialog, {
|
import ConfirmDialog, {
|
||||||
ConfirmDialogProps,
|
ConfirmDialogProps,
|
||||||
} from 'components/shared/ConfirmDialog';
|
} from 'components/shared/ConfirmDialog';
|
||||||
|
import { ArrowRightCircleFilledIcon, LoadingIcon } from 'components/shared/CustomIcon';
|
||||||
|
|
||||||
|
interface DeleteDeploymentDialogProps extends ConfirmDialogProps {
|
||||||
|
isConfirmButtonLoading?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export const DeleteDeploymentDialog = ({
|
export const DeleteDeploymentDialog = ({
|
||||||
open,
|
open,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
handleConfirm,
|
handleConfirm,
|
||||||
|
isConfirmButtonLoading,
|
||||||
...props
|
...props
|
||||||
}: ConfirmDialogProps) => {
|
}: DeleteDeploymentDialogProps) => {
|
||||||
return (
|
return (
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
{...props}
|
{...props}
|
||||||
dialogTitle="Delete deployment?"
|
dialogTitle="Delete deployment?"
|
||||||
handleCancel={handleCancel}
|
handleCancel={handleCancel}
|
||||||
open={open}
|
open={open}
|
||||||
confirmButtonTitle="Yes, delete deployment"
|
confirmButtonTitle={isConfirmButtonLoading ? "Deleting deployment" : "Yes, delete deployment"}
|
||||||
handleConfirm={handleConfirm}
|
handleConfirm={handleConfirm}
|
||||||
confirmButtonProps={{ variant: 'danger' }}
|
confirmButtonProps={{
|
||||||
|
variant: 'danger',
|
||||||
|
disabled: isConfirmButtonLoading,
|
||||||
|
rightIcon: isConfirmButtonLoading ? (
|
||||||
|
<LoadingIcon className="animate-spin" />
|
||||||
|
) : (
|
||||||
|
<ArrowRightCircleFilledIcon />
|
||||||
|
),
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<p className="text-sm text-elements-high-em">
|
<p className="text-sm text-elements-high-em">
|
||||||
Once deleted, the deployment will not be accessible.
|
Once deleted, the deployment will not be accessible.
|
||||||
|
@ -48,6 +48,7 @@ export const DeploymentMenu = ({
|
|||||||
const [changeToProduction, setChangeToProduction] = useState(false);
|
const [changeToProduction, setChangeToProduction] = useState(false);
|
||||||
const [redeployToProduction, setRedeployToProduction] = useState(false);
|
const [redeployToProduction, setRedeployToProduction] = useState(false);
|
||||||
const [deleteDeploymentDialog, setDeleteDeploymentDialog] = useState(false);
|
const [deleteDeploymentDialog, setDeleteDeploymentDialog] = useState(false);
|
||||||
|
const [isConfirmDeleteLoading, setIsConfirmDeleteLoading] = useState(false);
|
||||||
const [rollbackDeployment, setRollbackDeployment] = useState(false);
|
const [rollbackDeployment, setRollbackDeployment] = useState(false);
|
||||||
const [assignDomainDialog, setAssignDomainDialog] = useState(false);
|
const [assignDomainDialog, setAssignDomainDialog] = useState(false);
|
||||||
const [isConfirmButtonLoading, setConfirmButtonLoadingLoading] =
|
const [isConfirmButtonLoading, setConfirmButtonLoadingLoading] =
|
||||||
@ -118,16 +119,11 @@ export const DeploymentMenu = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteDeployment = async () => {
|
const deleteDeployment = async () => {
|
||||||
toast({
|
const isDeleted = await client.deleteDeployment(deployment.id);
|
||||||
id: 'deleting_deployment',
|
|
||||||
title: 'Deleting deployment....',
|
|
||||||
variant: 'success',
|
|
||||||
onDismiss: dismiss,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
setIsConfirmDeleteLoading(false);
|
||||||
setDeleteDeploymentDialog((preVal) => !preVal);
|
setDeleteDeploymentDialog((preVal) => !preVal);
|
||||||
|
|
||||||
const isDeleted = await client.deleteDeployment(deployment.id);
|
|
||||||
if (isDeleted) {
|
if (isDeleted) {
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
toast({
|
toast({
|
||||||
@ -271,8 +267,12 @@ export const DeploymentMenu = ({
|
|||||||
/>
|
/>
|
||||||
<DeleteDeploymentDialog
|
<DeleteDeploymentDialog
|
||||||
open={deleteDeploymentDialog}
|
open={deleteDeploymentDialog}
|
||||||
handleConfirm={deleteDeployment}
|
handleConfirm={async () => {
|
||||||
|
setIsConfirmDeleteLoading(true);
|
||||||
|
await deleteDeployment();
|
||||||
|
}}
|
||||||
handleCancel={() => setDeleteDeploymentDialog((preVal) => !preVal)}
|
handleCancel={() => setDeleteDeploymentDialog((preVal) => !preVal)}
|
||||||
|
isConfirmButtonLoading={isConfirmDeleteLoading}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user