-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(backport release-0.7): feat(ui): ability to delete freight (#2111)
Co-authored-by: Remington Breeze <[email protected]> Co-authored-by: Kent Rancourt <[email protected]>
- Loading branch information
1 parent
8672d1a
commit 9f5b269
Showing
3 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
ui/src/features/project/pipelines/delete-freight-modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useMutation } from '@connectrpc/connect-query'; | ||
import { Alert, Modal, message } from 'antd'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { ModalComponentProps } from '@ui/features/common/modal/modal-context'; | ||
import { getAlias } from '@ui/features/common/utils'; | ||
import { deleteFreight } from '@ui/gen/service/v1alpha1/service-KargoService_connectquery'; | ||
import { Freight } from '@ui/gen/v1alpha1/generated_pb'; | ||
|
||
import { onError } from '../pipelines/utils/util'; | ||
|
||
export const DeleteFreightModal = ({ | ||
visible, | ||
hide, | ||
onDelete, | ||
freight | ||
}: ModalComponentProps & { onDelete: () => void; freight: Freight }) => { | ||
const { name: project } = useParams(); | ||
const { mutate: deleteAction, isPending } = useMutation(deleteFreight, { | ||
onError, | ||
onSuccess: () => { | ||
message.success('Freight successfully deleted'); | ||
onDelete(); | ||
} | ||
}); | ||
|
||
const alias = getAlias(freight); | ||
|
||
return ( | ||
<Modal | ||
destroyOnClose | ||
open={visible} | ||
title='Confirm Delete' | ||
onCancel={hide} | ||
onOk={() => | ||
deleteAction({ | ||
name: freight.metadata?.name || '', | ||
project | ||
}) | ||
} | ||
okText='Delete' | ||
okButtonProps={{ loading: isPending, danger: true }} | ||
> | ||
<Alert | ||
type='error' | ||
banner | ||
message={ | ||
<div> | ||
Are you sure you want to delete freight{' '} | ||
<span className='font-semibold'>{alias ? alias : freight?.metadata?.name}</span>? | ||
</div> | ||
} | ||
className='mb-4' | ||
showIcon={false} | ||
/> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters