Scaffold empty workflow (#6926)

- Create a workflow version when the user visits an empty workflow.
- If the trigger is not defined yet and the user selects either the
standard object type or the event type first, we automatically select
the first option of the other value. Indeed, every state update is
automatically saved on the backend and we need both standard object and
event types to save the event name.
- Introduces a change in the backend. I removed the assertions that
throw when a workflow version is not complete, that is, when it doesn't
have a defined trigger, which is the case when scaffolding a new
workflow with a first empty workflow version.
- We should keep validating the workflow versions, at least when we
publish them. That should be done in a second step.
This commit is contained in:
Baptiste Devessier
2024-09-12 17:01:10 +02:00
committed by GitHub
parent 3c4168759a
commit 3548751be2
26 changed files with 548 additions and 269 deletions

View File

@ -23,7 +23,10 @@ const getStepDefinitionOrThrow = ({
if (stepId === TRIGGER_STEP_ID) {
if (!isDefined(currentVersion.trigger)) {
throw new Error('Expected to find the definition of the trigger');
return {
type: 'trigger',
definition: undefined,
} as const;
}
return {
@ -33,7 +36,9 @@ const getStepDefinitionOrThrow = ({
}
if (!isDefined(currentVersion.steps)) {
throw new Error('Expected to find an array of steps');
throw new Error(
'Malformed workflow version: missing steps information; be sure to create at least one step before trying to edit one',
);
}
const selectedNodePosition = findStepPositionOrThrow({
@ -74,7 +79,7 @@ export const RightDrawerWorkflowEditStepContent = ({
return (
<WorkflowEditTriggerForm
trigger={stepDefinition.definition}
onUpdateTrigger={updateTrigger}
onTriggerUpdate={updateTrigger}
/>
);
}
@ -82,7 +87,7 @@ export const RightDrawerWorkflowEditStepContent = ({
return (
<WorkflowEditActionForm
action={stepDefinition.definition}
onUpdateAction={updateStep}
onActionUpdate={updateStep}
/>
);
};