fix(ui): start workflow w/ single column as root

This commit is contained in:
psychedelicious
2025-01-25 21:40:56 +11:00
parent 9a2d8844a2
commit ddda915ebd

View File

@@ -13,6 +13,7 @@ import type {
import type { FieldIdentifier } from 'features/nodes/types/field';
import { isInvocationNode } from 'features/nodes/types/invocation';
import {
buildContainer,
type ContainerElement,
type FormElement,
isContainerElement,
@@ -25,18 +26,26 @@ import type { SQLiteDirection, WorkflowRecordOrderBy } from 'services/api/types'
import { selectNodesSlice } from './selectors';
const blankWorkflow: Omit<WorkflowV3, 'nodes' | 'edges'> = {
name: '',
author: '',
description: '',
version: '',
contact: '',
tags: '',
notes: '',
exposedFields: [],
meta: { version: '3.0.0', category: 'user' },
id: undefined,
form: undefined,
const getBlankWorkflow = (): Omit<WorkflowV3, 'nodes' | 'edges'> => {
const rootElement = buildContainer('column', []);
return {
name: '',
author: '',
description: '',
version: '',
contact: '',
tags: '',
notes: '',
exposedFields: [],
meta: { version: '3.0.0', category: 'user' },
id: undefined,
form: {
elements: {
[rootElement.id]: rootElement,
},
rootElementId: rootElement.id,
},
};
};
const initialWorkflowState: WorkflowState = {
@@ -49,7 +58,7 @@ const initialWorkflowState: WorkflowState = {
orderDirection: 'DESC',
categorySections: {},
formMode: 'view',
...blankWorkflow,
...getBlankWorkflow(),
};
export const workflowSlice = createSlice({