@haiiro/docuflow 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { AppPath, enqueueSnackbar, navigate } from 'twenty-sdk/front-component';
4
4
  import { Button } from 'twenty-ui/primitives/input';
5
5
  import { useTheme } from 'twenty-ui/theme';
6
6
 
7
- import { callAppRoute, createRecord, getErrorMessage, listRecords } from 'src/front/api';
7
+ import { callAppRoute, createRecord, deleteRecord, getErrorMessage, listRecords } from 'src/front/api';
8
8
  import { useAsync, useDebouncedValue } from 'src/front/hooks/use-async';
9
9
  import { DataTable, DocflowRoot, Message, SplitView, TextField, Toolbar } from 'src/front/ui/components';
10
10
  import { FormFieldInputs } from 'src/front/ui/form-field-inputs';
@@ -15,6 +15,7 @@ import { findMissingRequiredFields } from 'src/shared/form/form-fields.util';
15
15
  import { logDocflow, logDocflowError } from 'src/shared/log.util';
16
16
  import {
17
17
  buildLaunchParameters,
18
+ isLaunchableTrigger,
18
19
  isLaunchParametersStep,
19
20
  parseLaunchFields,
20
21
  } from 'src/shared/workflow/launch-step.util';
@@ -71,7 +72,7 @@ const loadProcesses = async (searchQuery: string): Promise<DocflowProcess[]> =>
71
72
  return workflows.flatMap((workflow) => {
72
73
  const version = versions.find((candidate) => candidate.workflowId === workflow.id);
73
74
 
74
- if (version === undefined || version.trigger?.type !== 'MANUAL') {
75
+ if (version === undefined || !isLaunchableTrigger(version.trigger)) {
75
76
  return [];
76
77
  }
77
78
 
@@ -181,10 +182,32 @@ const DocflowProcesses = () => {
181
182
  const searchQuery = useDebouncedValue(searchInput, SEARCH_DEBOUNCE_MS);
182
183
  const [panel, setPanel] = useState<Panel>({ kind: 'closed' });
183
184
  const [isCreating, setIsCreating] = useState(false);
184
- const { data: processes, loading, error } = useAsync(() => loadProcesses(searchQuery), [searchQuery]);
185
+ const { data: processes, loading, error, reload } = useAsync(() => loadProcesses(searchQuery), [searchQuery]);
185
186
  const selectedVersionId = panel.kind === 'process' ? panel.workflowVersionId : undefined;
186
187
  const selectedProcess = processes?.find((process) => process.workflowVersionId === selectedVersionId);
187
188
 
189
+ // The process goes to the Twenty trash ("Рабочие процессы → Удалённые"),
190
+ // its runs and tasks stay.
191
+ const handleDeleteProcess = async (workflowVersionId: string) => {
192
+ const process = processes?.find((candidate) => candidate.workflowVersionId === workflowVersionId);
193
+
194
+ if (process === undefined) {
195
+ return;
196
+ }
197
+
198
+ try {
199
+ await deleteRecord('workflows', process.workflowId);
200
+ setPanel((current) =>
201
+ current.kind === 'process' && current.workflowVersionId === workflowVersionId ? { kind: 'closed' } : current,
202
+ );
203
+ await enqueueSnackbar({ message: `Процесс «${process.name}» удалён`, variant: 'success' });
204
+ await reload();
205
+ } catch (deleteError) {
206
+ logDocflowError('process: delete failed', deleteError, { workflowId: process.workflowId });
207
+ await enqueueSnackbar({ message: getErrorMessage(deleteError, 'Не удалось удалить процесс'), variant: 'error' });
208
+ }
209
+ };
210
+
188
211
  // As "Создать" of the standard list: a process with a manual trigger in the
189
212
  // docflow section, opened in the editor. Launch parameters are set later
190
213
  // with the process's "Параметры запуска" command.
@@ -270,6 +293,7 @@ const DocflowProcesses = () => {
270
293
  ]}
271
294
  selectedRowId={selectedVersionId}
272
295
  onRowClick={(workflowVersionId) => setPanel({ kind: 'process', workflowVersionId })}
296
+ onDeleteRow={handleDeleteProcess}
273
297
  rows={processes.map((process) => {
274
298
  const parameterCount = process.launchFields.length;
275
299