@haiiro/docuflow 0.0.8 → 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';
@@ -182,10 +182,32 @@ const DocflowProcesses = () => {
182
182
  const searchQuery = useDebouncedValue(searchInput, SEARCH_DEBOUNCE_MS);
183
183
  const [panel, setPanel] = useState<Panel>({ kind: 'closed' });
184
184
  const [isCreating, setIsCreating] = useState(false);
185
- const { data: processes, loading, error } = useAsync(() => loadProcesses(searchQuery), [searchQuery]);
185
+ const { data: processes, loading, error, reload } = useAsync(() => loadProcesses(searchQuery), [searchQuery]);
186
186
  const selectedVersionId = panel.kind === 'process' ? panel.workflowVersionId : undefined;
187
187
  const selectedProcess = processes?.find((process) => process.workflowVersionId === selectedVersionId);
188
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
+
189
211
  // As "Создать" of the standard list: a process with a manual trigger in the
190
212
  // docflow section, opened in the editor. Launch parameters are set later
191
213
  // with the process's "Параметры запуска" command.
@@ -271,6 +293,7 @@ const DocflowProcesses = () => {
271
293
  ]}
272
294
  selectedRowId={selectedVersionId}
273
295
  onRowClick={(workflowVersionId) => setPanel({ kind: 'process', workflowVersionId })}
296
+ onDeleteRow={handleDeleteProcess}
274
297
  rows={processes.map((process) => {
275
298
  const parameterCount = process.launchFields.length;
276
299