index.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { nanoid } from 'nanoid';
  2. import { FlowNodeRegistry } from '../../typings';
  3. import iconEnd from '../../assets/icon-end.jpg';
  4. import { formMeta } from './form-meta';
  5. export const EndNodeRegistry: FlowNodeRegistry = {
  6. type: 'end',
  7. meta: {
  8. isNodeEnd: true, // Mark as end
  9. selectable: false, // End node cannot select
  10. copyDisable: true, // End node canot copy
  11. },
  12. info: {
  13. icon: iconEnd,
  14. description:
  15. 'The final node of the workflow, used to return the result information after the workflow is run.',
  16. },
  17. /**
  18. * Render node via formMeta
  19. */
  20. formMeta,
  21. canAdd(ctx, from) {
  22. // You can only add to the last node of the branch
  23. return from.isLast;
  24. },
  25. canDelete(ctx, node) {
  26. return node.parent === ctx.document.root;
  27. },
  28. onAdd(ctx, from) {
  29. return {
  30. id: `end_${nanoid()}`,
  31. type: 'end',
  32. data: {
  33. title: 'End',
  34. outputs: {
  35. type: 'object',
  36. properties: {
  37. result: {
  38. type: 'string',
  39. },
  40. },
  41. },
  42. },
  43. };
  44. },
  45. };