690 extract shouldberegistered from the useaction hooks (#11355)

Closes https://github.com/twentyhq/core-team-issues/issues/690

This PR is the first part of a refactoring on the actions system
https://github.com/twentyhq/core-team-issues/issues/683. It:
- Removes `shouldBeRegistered` from the useAction hook
- Instead `shouldBeRegistered` becomes a function to which we can pass
parameters which describe the context of the app (the object, the
selected record, information about favorites ...). It returns a boolean.
- `useShouldActionBeRegisteredParams` returns the parameters to pass to
the `shouldBeRegistered`
- Introduces a way to inherit actions from the default config and to
overwrite its properties, closing
https://github.com/twentyhq/core-team-issues/issues/72

Some tests testing if an action was registered correctly have been
removed, we should add them back at the end of the global refactoring.
This commit is contained in:
Raphaël Bosi
2025-04-02 17:58:14 +02:00
committed by GitHub
parent bc57e98949
commit 5e905180c8
65 changed files with 931 additions and 1943 deletions

View File

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