Fix error when workflows aren't enabled (#11388)

Fix Uncaught Error: Workflow is not enabled. If you want to use it,
please enable it in the lab.
<img width="505" alt="erroractionmenu"
src="https://github.com/user-attachments/assets/66e60219-20fb-4b00-90e4-d6bd640be774"
/>

This error was due to using the hook `useWorkflowWithCurrentVersion`
outside of a workflow object. Adding a skip parameter wasn't enough
because the `useFindOneRecord` uses `useObjectMetadataItem` which throws
if workflows aren't enabled.
This commit is contained in:
Raphaël Bosi
2025-04-04 14:26:19 +02:00
committed by GitHub
parent 27256c960e
commit ad2357a6fd
6 changed files with 75 additions and 16 deletions

View File

@ -9,7 +9,6 @@ import { isDefined } from 'twenty-shared/utils';
export const useWorkflowWithCurrentVersion = (
workflowId: string | undefined,
skip = false,
): WorkflowWithCurrentVersion | undefined => {
const { record: workflow } = useFindOneRecord<Workflow>({
objectNameSingular: CoreObjectNameSingular.Workflow,
@ -21,7 +20,7 @@ export const useWorkflowWithCurrentVersion = (
lastPublishedVersionId: true,
versions: true,
},
skip: !isDefined(workflowId) || skip,
skip: !isDefined(workflowId),
});
return useMemo(() => {