diff --git a/ui/src/features/freightline/freightline.tsx b/ui/src/features/freightline/freightline.tsx index 35f0a089b..669bf2159 100644 --- a/ui/src/features/freightline/freightline.tsx +++ b/ui/src/features/freightline/freightline.tsx @@ -132,6 +132,7 @@ export const Freightline = ({ state.select(FreightlineAction.ManualApproval, undefined, id); }} refetchFreight={refetchFreight} + inUse={stagesPerFreight[id]?.length > 0} /> )} 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 ( + + deleteAction({ + name: freight.metadata?.name || '', + project + }) + } + okText='Delete' + okButtonProps={{ loading: isPending, danger: true }} + > + + Are you sure you want to delete freight{' '} + {alias ? alias : freight?.metadata?.name}? + + } + className='mb-4' + showIcon={false} + /> + + ); +}; diff --git a/ui/src/features/project/pipelines/freight-action-menu.tsx b/ui/src/features/project/pipelines/freight-action-menu.tsx index 2d4fe836f..434db79fc 100644 --- a/ui/src/features/project/pipelines/freight-action-menu.tsx +++ b/ui/src/features/project/pipelines/freight-action-menu.tsx @@ -3,7 +3,8 @@ import { faClipboard, faCopy, faEllipsisV, - faPencil + faPencil, + faTrashAlt } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Dropdown, message } from 'antd'; @@ -12,18 +13,21 @@ import { useModal } from '@ui/features/common/modal/use-modal'; import { getAlias } from '@ui/features/common/utils'; import { Freight } from '@ui/gen/v1alpha1/generated_pb'; +import { DeleteFreightModal } from './delete-freight-modal'; import { UpdateFreightAliasModal } from './update-freight-alias-modal'; export const FreightActionMenu = ({ freight, approveAction, refetchFreight, - hide + hide, + inUse }: { freight: Freight; approveAction: () => void; refetchFreight: () => void; hide?: boolean; + inUse?: boolean; }) => { const { show } = useModal(); @@ -96,6 +100,27 @@ export const FreightActionMenu = ({ /> )); } + }, + { + key: '5', + disabled: inUse, + label: ( + <> + Delete + + ), + onClick: () => { + show((p) => ( + { + refetchFreight(); + p.hide(); + }} + /> + )); + } } ] }}