mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(ui): migrated linear view exposed fields to builder form on load
This commit is contained in:
@@ -74,10 +74,13 @@ export const zWorkflowV3 = z.object({
|
||||
category: zWorkflowCategory.default('user'),
|
||||
version: z.literal('3.0.0'),
|
||||
}),
|
||||
form: z.object({
|
||||
elements: z.record(z.lazy(() => zFormElement)),
|
||||
layout: z.array(z.lazy(() => zElementId)),
|
||||
}),
|
||||
form: z
|
||||
.object({
|
||||
elements: z.record(z.lazy(() => zFormElement)),
|
||||
layout: z.array(z.lazy(() => zElementId)),
|
||||
})
|
||||
// Catch must be a function else changes to the workflows parsed with this schema will mutate the catch value D:
|
||||
.catch(() => ({ elements: {}, layout: [] })),
|
||||
});
|
||||
export type WorkflowV3 = z.infer<typeof zWorkflowV3>;
|
||||
// #endregion
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
isModelIdentifierFieldInputInstance,
|
||||
} from 'features/nodes/types/field';
|
||||
import type { WorkflowV3 } from 'features/nodes/types/workflow';
|
||||
import { isWorkflowInvocationNode } from 'features/nodes/types/workflow';
|
||||
import { buildNodeFieldElement, isWorkflowInvocationNode } from 'features/nodes/types/workflow';
|
||||
import { getNeedsUpdate } from 'features/nodes/util/node/nodeUpdate';
|
||||
import { t } from 'i18next';
|
||||
import { keyBy } from 'lodash-es';
|
||||
@@ -226,5 +226,27 @@ export const validateWorkflow = async (
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (_workflow.exposedFields.length > 0 && Object.values(_workflow.form.elements).length === 0) {
|
||||
// Migrated exposed fields to form elements
|
||||
for (const { nodeId, fieldName } of _workflow.exposedFields) {
|
||||
const node = keyedNodes[nodeId];
|
||||
if (!node) {
|
||||
continue;
|
||||
}
|
||||
const nodeTemplate = templates[node.data.type];
|
||||
if (!nodeTemplate) {
|
||||
continue;
|
||||
}
|
||||
const fieldTemplate = nodeTemplate.inputs[fieldName];
|
||||
if (!fieldTemplate) {
|
||||
continue;
|
||||
}
|
||||
const element = buildNodeFieldElement(nodeId, fieldName, fieldTemplate.type);
|
||||
_workflow.form.elements[element.id] = element;
|
||||
_workflow.form.layout.push(element.id);
|
||||
}
|
||||
}
|
||||
|
||||
return { workflow: _workflow, warnings };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user