b11f77df2a
## PR Description - Uses `expr-eval` to enable front components (SDK plugins) to define conditional availability as declarative expressions. - Moves shared types and constants to `twenty-shared` - Introduces a `conditionalAvailabilityExpression` field on `CommandMenuItemEntity`, allowing command menu items to store an `expr-eval` compatible expression string that is evaluated against a CommandMenuContext to determine if the item should be shown. - Creates an esbuild transform plugin `conditional-availability-transform-plugin` in `twenty-sdk` that converts TypeScript conditional availability expressions into `expr-eval` compatible syntax at build time, so SDK developers can write natural TS expressions that get transformed to evaluable strings. - Removes deprecated `forceRegisteredActionsByKey` state and its usage. - Creates `useCommandMenuContext` hook that builds the full `CommandMenuContext` object from React state, which is then passed to `useCommandMenuItemFrontComponentActions` for evaluating conditional availability expressions.
38 lines
995 B
TypeScript
38 lines
995 B
TypeScript
import { CoreObjectNameSingular } from 'twenty-shared/types';
|
|
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
|
|
import { type Workflow, type WorkflowVersion } from '@/workflow/types/Workflow';
|
|
|
|
export const useWorkflowVersion = (workflowVersionId?: string) => {
|
|
const { record: workflowVersion } = useFindOneRecord<
|
|
WorkflowVersion & {
|
|
workflow: Omit<Workflow, 'versions'> & {
|
|
versions: Array<{ __typename: string }>;
|
|
};
|
|
}
|
|
>({
|
|
objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
|
|
objectRecordId: workflowVersionId,
|
|
recordGqlFields: {
|
|
id: true,
|
|
name: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
workflowId: true,
|
|
trigger: true,
|
|
steps: true,
|
|
status: true,
|
|
workflow: {
|
|
id: true,
|
|
name: true,
|
|
statuses: true,
|
|
versions: {
|
|
totalCount: true,
|
|
},
|
|
},
|
|
},
|
|
skip: !workflowVersionId,
|
|
});
|
|
|
|
return workflowVersion;
|
|
};
|