Add delete workflow action
[MAILPOET-4540]
This commit is contained in:
@ -1,7 +1,12 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { DropdownMenu } from '@wordpress/components';
|
||||
import { moreVertical } from '@wordpress/icons';
|
||||
import { useDuplicateButton, useRestoreButton, useTrashButton } from '../menu';
|
||||
import {
|
||||
useDeleteButton,
|
||||
useDuplicateButton,
|
||||
useRestoreButton,
|
||||
useTrashButton,
|
||||
} from '../menu';
|
||||
import { Workflow } from '../../workflow';
|
||||
|
||||
type Props = {
|
||||
@ -14,8 +19,9 @@ export function More({ workflow }: Props): JSX.Element {
|
||||
const duplicate = useDuplicateButton(workflow);
|
||||
const trash = useTrashButton(workflow);
|
||||
const restore = useRestoreButton(workflow);
|
||||
const del = useDeleteButton(workflow);
|
||||
|
||||
const menuItems = [duplicate, trash, restore].filter((item) => item);
|
||||
const menuItems = [duplicate, trash, restore, del].filter((item) => item);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -0,0 +1,22 @@
|
||||
import { useDispatch } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Item } from './item';
|
||||
import { storeName } from '../../store';
|
||||
import { Workflow, WorkflowStatus } from '../../workflow';
|
||||
|
||||
export const useDeleteButton = (workflow: Workflow): Item | undefined => {
|
||||
const { deleteWorkflow } = useDispatch(storeName);
|
||||
|
||||
if (workflow.status !== WorkflowStatus.TRASH) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
key: 'delete',
|
||||
control: {
|
||||
title: __('Delete permanently', 'mailpoet'),
|
||||
icon: null,
|
||||
onClick: () => deleteWorkflow(workflow),
|
||||
},
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user