The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
feat(workflow): browse and restore core workflow versions from the side panel (#25199)
Thomas Trompettebabb8fdb2148
diff --git a/packages/twenty-front/src/generated/graphql.ts b/packages/twenty-front/src/generated/graphql.tsindex fa56d7109f9..5d5b5c57047 100644--- a/packages/twenty-front/src/generated/graphql.ts+++ b/packages/twenty-front/src/generated/graphql.ts@@ -132,6 +132,25 @@ export enum CoreWorkflowStatus {DRAFT = 'DRAFT'}+export type CoreWorkflowVersionDto = {+ __typename?: 'CoreWorkflowVersionDTO';+ createdAt: Scalars['String']['output'];+ id: Scalars['UUID']['output'];+ label: Scalars['String']['output'];+ status: CoreWorkflowVersionStatus;+ steps?: Maybe<Scalars['JSON']['output']>;+ trigger?: Maybe<Scalars['JSON']['output']>;+ workspaceWorkflowId: Scalars['UUID']['output'];+ workspaceWorkflowVersionId?: Maybe<Scalars['UUID']['output']>;+};++export enum CoreWorkflowVersionStatus {+ ACTIVE = 'ACTIVE',+ ARCHIVED = 'ARCHIVED',+ DEACTIVATED = 'DEACTIVATED',+ DRAFT = 'DRAFT'+}+export type CreateDraftFromWorkflowVersionInput = {/** Workflow ID */workflowId: Scalars['UUID']['input'];@@ -432,6 +451,8 @@ export type ObjectRecordFilterInput = {export type Query = {__typename?: 'Query';+ coreWorkflowVersion?: Maybe<CoreWorkflowVersionDto>;+ coreWorkflowVersions: Array<CoreWorkflowVersionDto>;coreWorkflows: CoreWorkflowConnection;dpaAgreements: Array<DpaAgreement>;dpaPreview: DpaDocument;@@ -456,6 +477,16 @@ export type Query = {};+export type QueryCoreWorkflowVersionArgs = {+ workspaceWorkflowVersionId: Scalars['UUID']['input'];+};+++export type QueryCoreWorkflowVersionsArgs = {+ workspaceWorkflowId: Scalars['UUID']['input'];+};++export type QueryCoreWorkflowsArgs = {after?: InputMaybe<Scalars['String']['input']>;filter?: InputMaybe<CoreWorkflowFilterInput>;@@ -892,6 +923,20 @@ export type GetCoreWorkflowsQueryVariables = Exact<{export type GetCoreWorkflowsQuery = { __typename?: 'Query', coreWorkflows: { __typename?: 'CoreWorkflowConnection', totalCount: number, edges: Array<{ __typename?: 'CoreWorkflowEdge', cursor: string, node: { __typename?: 'CoreWorkflowDTO', id: any, name?: string | null, statuses: Array<CoreWorkflowStatus>, workspaceWorkflowId?: any | null, updatedAt: string } }>, pageInfo: { __typename?: 'CoreWorkflowPageInfo', endCursor?: string | null, hasNextPage: boolean } } };+export type GetCoreWorkflowVersionQueryVariables = Exact<{+ workspaceWorkflowVersionId: Scalars['UUID']['input'];+}>;+++export type GetCoreWorkflowVersionQuery = { __typename?: 'Query', coreWorkflowVersion?: { __typename?: 'CoreWorkflowVersionDTO', id: any, label: string, status: CoreWorkflowVersionStatus, workspaceWorkflowVersionId?: any | null, workspaceWorkflowId: any, trigger?: any | null, steps?: any | null, createdAt: string } | null };++export type GetCoreWorkflowVersionsQueryVariables = Exact<{+ workspaceWorkflowId: Scalars['UUID']['input'];+}>;+++export type GetCoreWorkflowVersionsQuery = { __typename?: 'Query', coreWorkflowVersions: Array<{ __typename?: 'CoreWorkflowVersionDTO', id: any, label: string, status: CoreWorkflowVersionStatus, workspaceWorkflowVersionId?: any | null, workspaceWorkflowId: any, createdAt: string }> };+export type WorkflowDiffFragmentFragment = { __typename?: 'WorkflowVersionStepChanges', triggerDiff?: any | null, stepsDiff?: any | null };export type ActivateWorkflowVersionMutationVariables = Exact<{@@ -1053,6 +1098,8 @@ export const GetTimelineCalendarEventsFromObjectRecordDocument = {"kind":"Documeexport const GetTimelineThreadsFromObjectRecordDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTimelineThreadsFromObjectRecord"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"objectNameSingular"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"recordId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"page"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"pageSize"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"getTimelineThreadsFromObjectRecord"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"objectNameSingular"},"value":{"kind":"Variable","name":{"kind":"Name","value":"objectNameSingular"}}},{"kind":"Argument","name":{"kind":"Name","value":"recordId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"recordId"}}},{"kind":"Argument","name":{"kind":"Name","value":"page"},"value":{"kind":"Variable","name":{"kind":"Name","value":"page"}}},{"kind":"Argument","name":{"kind":"Name","value":"pageSize"},"value":{"kind":"Variable","name":{"kind":"Name","value":"pageSize"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TimelineThreadsWithTotalFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ParticipantFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TimelineThreadParticipant"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"personId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceMemberId"}},{"kind":"Field","name":{"kind":"Name","value":"firstName"}},{"kind":"Field","name":{"kind":"Name","value":"lastName"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"avatarUrl"}},{"kind":"Field","name":{"kind":"Name","value":"handle"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TimelineThreadFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TimelineThread"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"read"}},{"kind":"Field","name":{"kind":"Name","value":"visibility"}},{"kind":"Field","name":{"kind":"Name","value":"firstParticipant"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ParticipantFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"lastTwoParticipants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ParticipantFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"lastMessageReceivedAt"}},{"kind":"Field","name":{"kind":"Name","value":"lastMessageBody"}},{"kind":"Field","name":{"kind":"Name","value":"subject"}},{"kind":"Field","name":{"kind":"Name","value":"numberOfMessagesInThread"}},{"kind":"Field","name":{"kind":"Name","value":"participantCount"}},{"kind":"Field","name":{"kind":"Name","value":"lastMessageIsDraft"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TimelineThreadsWithTotalFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TimelineThreadsWithTotal"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"totalNumberOfThreads"}},{"kind":"Field","name":{"kind":"Name","value":"relatedPersonIds"}},{"kind":"Field","name":{"kind":"Name","value":"timelineThreads"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TimelineThreadFragment"}}]}}]}}]} as unknown as DocumentNode<GetTimelineThreadsFromObjectRecordQuery, GetTimelineThreadsFromObjectRecordQueryVariables>;export const SearchDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Search"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"searchInput"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"limit"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"excludedObjectNameSingulars"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"includedObjectNameSingulars"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"ObjectRecordFilterInput"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"search"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"searchInput"},"value":{"kind":"Variable","name":{"kind":"Name","value":"searchInput"}}},{"kind":"Argument","name":{"kind":"Name","value":"limit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"limit"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}},{"kind":"Argument","name":{"kind":"Name","value":"excludedObjectNameSingulars"},"value":{"kind":"Variable","name":{"kind":"Name","value":"excludedObjectNameSingulars"}}},{"kind":"Argument","name":{"kind":"Name","value":"includedObjectNameSingulars"},"value":{"kind":"Variable","name":{"kind":"Name","value":"includedObjectNameSingulars"}}},{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"recordId"}},{"kind":"Field","name":{"kind":"Name","value":"objectNameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"objectLabelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"imageUrl"}},{"kind":"Field","name":{"kind":"Name","value":"tsRankCD"}},{"kind":"Field","name":{"kind":"Name","value":"tsRank"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}}]}}]}}]} as unknown as DocumentNode<SearchQuery, SearchQueryVariables>;export const GetCoreWorkflowsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflows"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"orderBy"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"CoreWorkflowOrderByField"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"orderByDirection"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"CoreWorkflowOrderByDirection"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"CoreWorkflowFilterInput"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflows"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}},{"kind":"Argument","name":{"kind":"Name","value":"orderBy"},"value":{"kind":"Variable","name":{"kind":"Name","value":"orderBy"}}},{"kind":"Argument","name":{"kind":"Name","value":"orderByDirection"},"value":{"kind":"Variable","name":{"kind":"Name","value":"orderByDirection"}}},{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"statuses"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowsQuery, GetCoreWorkflowsQueryVariables>;+export const GetCoreWorkflowVersionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflowVersion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflowVersion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceWorkflowVersionId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"trigger"}},{"kind":"Field","name":{"kind":"Name","value":"steps"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowVersionQuery, GetCoreWorkflowVersionQueryVariables>;+export const GetCoreWorkflowVersionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflowVersions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflowVersions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceWorkflowId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowVersionsQuery, GetCoreWorkflowVersionsQueryVariables>;export const ActivateWorkflowVersionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ActivateWorkflowVersion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workflowVersionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activateWorkflowVersion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workflowVersionId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workflowVersionId"}}}]}]}}]} as unknown as DocumentNode<ActivateWorkflowVersionMutation, ActivateWorkflowVersionMutationVariables>;export const ComputeStepOutputSchemaDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ComputeStepOutputSchema"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ComputeStepOutputSchemaInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"computeStepOutputSchema"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}]}]}}]} as unknown as DocumentNode<ComputeStepOutputSchemaMutation, ComputeStepOutputSchemaMutationVariables>;export const CreateDraftFromWorkflowVersionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateDraftFromWorkflowVersion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateDraftFromWorkflowVersionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createDraftFromWorkflowVersion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"trigger"}},{"kind":"Field","name":{"kind":"Name","value":"steps"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<CreateDraftFromWorkflowVersionMutation, CreateDraftFromWorkflowVersionMutationVariables>;diff --git a/packages/twenty-front/src/modules/command-menu-item/engine-command/record/single-record/workflow/components/SeeVersionsWorkflowSingleRecordCommand.tsx b/packages/twenty-front/src/modules/command-menu-item/engine-command/record/single-record/workflow/components/SeeVersionsWorkflowSingleRecordCommand.tsxindex 490bb70d8ed..bf5dcf29d85 100644--- a/packages/twenty-front/src/modules/command-menu-item/engine-command/record/single-record/workflow/components/SeeVersionsWorkflowSingleRecordCommand.tsx+++ b/packages/twenty-front/src/modules/command-menu-item/engine-command/record/single-record/workflow/components/SeeVersionsWorkflowSingleRecordCommand.tsx@@ -1,22 +1,39 @@+import {+ AppPath,+ FeatureFlagKey,+ ViewFilterOperand,+} from 'twenty-shared/types';+import { isDefined } from 'twenty-shared/utils';++import { HeadlessEngineCommandWrapperEffect } from '@/command-menu-item/engine-command/components/HeadlessEngineCommandWrapperEffect';import { HeadlessNavigateEngineCommand } from '@/command-menu-item/engine-command/components/HeadlessNavigateEngineCommand';import { useHeadlessCommandContextApi } from '@/command-menu-item/engine-command/hooks/useHeadlessCommandContextApi';import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';-import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';-import { AppPath, ViewFilterOperand } from 'twenty-shared/types';-import { isDefined } from 'twenty-shared/utils';+import { useOpenCoreWorkflowVersionsSidePanel } from '@/object-core/workflows/versions/hooks/useOpenCoreWorkflowVersionsSidePanel';+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';export const SeeVersionsWorkflowSingleRecordCommand = () => {const { selectedRecords } = useHeadlessCommandContextApi();+ const { openCoreWorkflowVersionsSidePanel } =+ useOpenCoreWorkflowVersionsSidePanel();+ const isWorkflowCoreIndexPageEnabled = useIsFeatureEnabled(+ FeatureFlagKey.IS_WORKFLOW_CORE_INDEX_PAGE_ENABLED,+ );const recordId = selectedRecords[0]?.id;- const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(- recordId ?? '',- );if (!isDefined(recordId)) {throw new Error('Record ID is required to see versions workflow');}+ if (isWorkflowCoreIndexPageEnabled) {+ return (+ <HeadlessEngineCommandWrapperEffect+ execute={() => openCoreWorkflowVersionsSidePanel(recordId)}+ />+ );+ }+return (<HeadlessNavigateEngineCommandto={AppPath.RecordIndexPage}@@ -25,7 +42,7 @@ export const SeeVersionsWorkflowSingleRecordCommand = () => {filter: {workflow: {[ViewFilterOperand.IS]: {- selectedRecordIds: [workflowWithCurrentVersion?.id],+ selectedRecordIds: [recordId],},},},diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionCard.tsx b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionCard.tsxnew file mode 100644index 00000000000..dac3e26b9cb--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionCard.tsx@@ -0,0 +1,53 @@+import { styled } from '@linaria/react';+import { isDefined } from 'twenty-shared/utils';++import { CoreWorkflowVersionDiagramEffect } from '@/object-core/workflows/versions/components/CoreWorkflowVersionDiagramEffect';+import { useCoreWorkflowVersion } from '@/object-core/workflows/versions/hooks/useCoreWorkflowVersion';+import { getWorkflowVisualizerComponentInstanceId } from '@/workflow/utils/getWorkflowVisualizerComponentInstanceId';+import { WorkflowDiagramCanvasReadonly } from '@/workflow/workflow-diagram/components/WorkflowDiagramCanvasReadonly';+import { WorkflowVisualizerComponentInstanceContext } from '@/workflow/workflow-diagram/states/contexts/WorkflowVisualizerComponentInstanceContext';++const StyledContainer = styled.div`+ display: flex;+ flex-direction: column;+ height: 100%;+`;++export const CoreWorkflowVersionCard = ({+ workspaceWorkflowVersionId,+}: {+ workspaceWorkflowVersionId: string;+}) => {+ const { coreWorkflowVersion } = useCoreWorkflowVersion(+ workspaceWorkflowVersionId,+ );++ if (!isDefined(coreWorkflowVersion)) {+ return null;+ }++ return (+ <WorkflowVisualizerComponentInstanceContext.Provider+ value={{+ instanceId: getWorkflowVisualizerComponentInstanceId({+ recordId: workspaceWorkflowVersionId,+ }),+ }}+ >+ <CoreWorkflowVersionDiagramEffect+ workflowId={coreWorkflowVersion.workspaceWorkflowId}+ workspaceWorkflowVersionId={workspaceWorkflowVersionId}+ label={coreWorkflowVersion.label}+ status={coreWorkflowVersion.status}+ createdAt={coreWorkflowVersion.createdAt}+ trigger={coreWorkflowVersion.trigger ?? null}+ steps={coreWorkflowVersion.steps ?? null}+ />+ <StyledContainer>+ <WorkflowDiagramCanvasReadonly+ versionStatus={coreWorkflowVersion.status}+ />+ </StyledContainer>+ </WorkflowVisualizerComponentInstanceContext.Provider>+ );+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionDiagramEffect.tsx b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionDiagramEffect.tsxnew file mode 100644index 00000000000..d4a00fb3abe--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionDiagramEffect.tsx@@ -0,0 +1,87 @@+import { useEffect } from 'react';++import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';+import { flowComponentState } from '@/workflow/states/flowComponentState';+import {+ type WorkflowAction,+ type WorkflowTrigger,+ type WorkflowVersionStatus,+} from '@/workflow/types/Workflow';+import { workflowVisualizerWorkflowIdComponentState } from '@/workflow/states/workflowVisualizerWorkflowIdComponentState';+import { workflowVisualizerWorkflowVersionIdComponentState } from '@/workflow/states/workflowVisualizerWorkflowVersionIdComponentState';+import { workflowDiagramComponentState } from '@/workflow/workflow-diagram/states/workflowDiagramComponentState';+import { generateWorkflowDiagram } from '@/workflow/workflow-diagram/utils/generateWorkflowDiagram';+import { useStepsOutputSchema } from '@/workflow/workflow-variables/hooks/useStepsOutputSchema';++export const CoreWorkflowVersionDiagramEffect = ({+ workflowId,+ workspaceWorkflowVersionId,+ label,+ status,+ createdAt,+ trigger,+ steps,+}: {+ workflowId: string;+ workspaceWorkflowVersionId: string;+ label: string;+ status: WorkflowVersionStatus;+ createdAt: string;+ trigger: WorkflowTrigger | null;+ steps: WorkflowAction[] | null;+}) => {+ const setFlow = useSetAtomComponentState(flowComponentState);+ const setWorkflowDiagram = useSetAtomComponentState(+ workflowDiagramComponentState,+ );+ const setWorkflowVisualizerWorkflowId = useSetAtomComponentState(+ workflowVisualizerWorkflowIdComponentState,+ );+ const setWorkflowVisualizerWorkflowVersionId = useSetAtomComponentState(+ workflowVisualizerWorkflowVersionIdComponentState,+ );+ const { populateStepsOutputSchema } = useStepsOutputSchema();++ useEffect(() => {+ setFlow({+ workflowVersionId: workspaceWorkflowVersionId,+ trigger,+ steps,+ });+ setWorkflowVisualizerWorkflowId(workflowId);+ setWorkflowVisualizerWorkflowVersionId(workspaceWorkflowVersionId);+ setWorkflowDiagram(+ generateWorkflowDiagram({+ trigger: trigger ?? undefined,+ steps: steps ?? [],+ workflowContext: 'workflow-version',+ }),+ );+ populateStepsOutputSchema({+ __typename: 'WorkflowVersion',+ id: workspaceWorkflowVersionId,+ name: label,+ workflowId,+ status,+ createdAt,+ updatedAt: createdAt,+ trigger,+ steps,+ });+ }, [+ createdAt,+ label,+ populateStepsOutputSchema,+ status,+ setFlow,+ setWorkflowDiagram,+ setWorkflowVisualizerWorkflowId,+ setWorkflowVisualizerWorkflowVersionId,+ steps,+ trigger,+ workflowId,+ workspaceWorkflowVersionId,+ ]);++ return null;+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionRestoreButton.tsx b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionRestoreButton.tsxnew file mode 100644index 00000000000..11ec62a91ed--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionRestoreButton.tsx@@ -0,0 +1,58 @@+import { useLingui } from '@lingui/react/macro';+import { Button } from 'twenty-ui/input';++import { RESTORE_CORE_WORKFLOW_VERSION_MODAL_ID } from '@/object-core/workflows/versions/constants/RestoreCoreWorkflowVersionModalId';+import { useRestoreCoreWorkflowVersionAsDraft } from '@/object-core/workflows/versions/hooks/useRestoreCoreWorkflowVersionAsDraft';+import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';+import { useModal } from '@/ui/layout/modal/hooks/useModal';++export const CoreWorkflowVersionRestoreButton = ({+ workflowId,+ workspaceWorkflowVersionId,+}: {+ workflowId: string;+ workspaceWorkflowVersionId: string;+}) => {+ const { t } = useLingui();+ const { openModal } = useModal();+ const {+ restoreCoreWorkflowVersionAsDraft,+ isRestoring,+ hasExistingDraft,+ isLoadingCoreWorkflowVersions,+ } = useRestoreCoreWorkflowVersionAsDraft({+ workflowId,+ workspaceWorkflowVersionId,+ });++ const handleRestoreClick = () => {+ if (hasExistingDraft) {+ openModal(RESTORE_CORE_WORKFLOW_VERSION_MODAL_ID);++ return;+ }++ restoreCoreWorkflowVersionAsDraft();+ };++ return (+ <>+ <Button+ title={t`Restore`}+ variant="primary"+ accent="blue"+ size="small"+ disabled={isRestoring || isLoadingCoreWorkflowVersions}+ onClick={handleRestoreClick}+ />+ <ConfirmationModal+ modalInstanceId={RESTORE_CORE_WORKFLOW_VERSION_MODAL_ID}+ title={t`A draft already exists`}+ subtitle={t`A draft already exists for this workflow. Are you sure you want to erase it?`}+ confirmButtonText={t`Override Draft`}+ loading={isRestoring}+ onConfirmClick={restoreCoreWorkflowVersionAsDraft}+ />+ </>+ );+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionsListItem.tsx b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionsListItem.tsxnew file mode 100644index 00000000000..dcabe80080c--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionsListItem.tsx@@ -0,0 +1,77 @@+import { styled } from '@linaria/react';+import { useLingui } from '@lingui/react/macro';+import { themeCssVariables } from 'twenty-ui/theme-constants';+import { Tag } from 'twenty-ui/data-display';++import { CORE_WORKFLOW_VERSION_STATUS_TAG_PROPS } from '@/object-core/workflows/versions/constants/CoreWorkflowVersionStatusTagProps';+import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';+import { type CoreWorkflowVersionStatus } from '~/generated/graphql';++const StyledRow = styled.div<{ isSelectable: boolean }>`+ align-items: center;+ border-radius: ${themeCssVariables.border.radius.sm};+ cursor: ${({ isSelectable }) => (isSelectable ? 'pointer' : 'default')};+ display: flex;+ gap: ${themeCssVariables.spacing[2]};+ justify-content: space-between;+ opacity: ${({ isSelectable }) => (isSelectable ? 1 : 0.5)};+ padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};++ &:hover {+ background-color: ${({ isSelectable }) =>+ isSelectable+ ? themeCssVariables.background.transparent.light+ : 'transparent'};+ }+`;++const StyledLabel = styled.span`+ color: ${themeCssVariables.font.color.primary};+ font-size: ${themeCssVariables.font.size.md};+`;++const StyledDate = styled.span`+ color: ${themeCssVariables.font.color.tertiary};+ font-size: ${themeCssVariables.font.size.md};+ margin-right: auto;+`;++type CoreWorkflowVersionsListItemProps = {+ id: string;+ label: string;+ createdAt: string;+ status: CoreWorkflowVersionStatus;+ isSelectable: boolean;+ onSelect: () => void;+};++export const CoreWorkflowVersionsListItem = ({+ id,+ label,+ createdAt,+ status,+ isSelectable,+ onSelect,+}: CoreWorkflowVersionsListItemProps) => {+ const { t } = useLingui();+ const tagProps = CORE_WORKFLOW_VERSION_STATUS_TAG_PROPS[status];++ return (+ <SelectableListItem itemId={id} onEnter={onSelect}>+ <StyledRow+ isSelectable={isSelectable}+ onClick={isSelectable ? onSelect : undefined}+ >+ <StyledLabel>{label}</StyledLabel>+ <StyledDate>+ {new Date(createdAt).toLocaleDateString(undefined, {+ year: 'numeric',+ month: 'long',+ day: 'numeric',+ })}+ </StyledDate>+ <Tag color={tagProps.color} text={t(tagProps.label)} />+ </StyledRow>+ </SelectableListItem>+ );+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionPage.tsx b/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionPage.tsxnew file mode 100644index 00000000000..41b22cb6135--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionPage.tsx@@ -0,0 +1,60 @@+import { styled } from '@linaria/react';+import { useLingui } from '@lingui/react/macro';+import { isDefined } from 'twenty-shared/utils';+import { Tag } from 'twenty-ui/data-display';+import { themeCssVariables } from 'twenty-ui/theme-constants';++import { CoreWorkflowVersionCard } from '@/object-core/workflows/versions/components/CoreWorkflowVersionCard';+import { CoreWorkflowVersionRestoreButton } from '@/object-core/workflows/versions/components/CoreWorkflowVersionRestoreButton';+import { CORE_WORKFLOW_VERSION_STATUS_TAG_PROPS } from '@/object-core/workflows/versions/constants/CoreWorkflowVersionStatusTagProps';+import { useCoreWorkflowVersion } from '@/object-core/workflows/versions/hooks/useCoreWorkflowVersion';+import { useSidePanelWorkflowVersionIdOrThrow } from '@/side-panel/pages/workflow/step/view/hooks/useSidePanelWorkflowVersionIdOrThrow';++const StyledContainer = styled.div`+ display: flex;+ flex-direction: column;+ height: 100%;+`;++const StyledActions = styled.div`+ align-items: center;+ border-bottom: 1px solid ${themeCssVariables.border.color.light};+ display: flex;+ gap: ${themeCssVariables.spacing[2]};+ padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[3]};+`;++const StyledSpacer = styled.div`+ margin-left: auto;+`;++export const SidePanelCoreWorkflowVersionPage = () => {+ const { t } = useLingui();+ const workspaceWorkflowVersionId = useSidePanelWorkflowVersionIdOrThrow();+ const { coreWorkflowVersion } = useCoreWorkflowVersion(+ workspaceWorkflowVersionId,+ );++ if (!isDefined(coreWorkflowVersion)) {+ return null;+ }++ const tagProps =+ CORE_WORKFLOW_VERSION_STATUS_TAG_PROPS[coreWorkflowVersion.status];++ return (+ <StyledContainer>+ <StyledActions>+ <Tag color={tagProps.color} text={t(tagProps.label)} />+ <StyledSpacer />+ <CoreWorkflowVersionRestoreButton+ workflowId={coreWorkflowVersion.workspaceWorkflowId}+ workspaceWorkflowVersionId={workspaceWorkflowVersionId}+ />+ </StyledActions>+ <CoreWorkflowVersionCard+ workspaceWorkflowVersionId={workspaceWorkflowVersionId}+ />+ </StyledContainer>+ );+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionsPage.tsx b/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionsPage.tsxnew file mode 100644index 00000000000..3f5e0e0f529--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionsPage.tsx@@ -0,0 +1,71 @@+import { useLingui } from '@lingui/react/macro';+import { isDefined } from 'twenty-shared/utils';++import { CoreWorkflowVersionsListItem } from '@/object-core/workflows/versions/components/CoreWorkflowVersionsListItem';+import { useCoreWorkflowVersions } from '@/object-core/workflows/versions/hooks/useCoreWorkflowVersions';+import { useOpenCoreWorkflowVersionSidePanel } from '@/object-core/workflows/versions/hooks/useOpenCoreWorkflowVersionSidePanel';+import { useSidePanelWorkflowIdOrThrow } from '@/side-panel/pages/workflow/hooks/useSidePanelWorkflowIdOrThrow';+import { SidePanelGroup } from '@/side-panel/components/SidePanelGroup';+import { SidePanelList } from '@/side-panel/components/SidePanelList';+import { styled } from '@linaria/react';+import { themeCssVariables } from 'twenty-ui/theme-constants';++const StyledError = styled.div`+ color: ${themeCssVariables.font.color.secondary};+ font-size: ${themeCssVariables.font.size.md};+ padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};+`;++export const SidePanelCoreWorkflowVersionsPage = () => {+ const { t } = useLingui();+ const workflowId = useSidePanelWorkflowIdOrThrow();+ const { coreWorkflowVersions, loading, error } =+ useCoreWorkflowVersions(workflowId);+ const { openCoreWorkflowVersionSidePanel } =+ useOpenCoreWorkflowVersionSidePanel();++ const selectableCoreWorkflowVersionIds = coreWorkflowVersions+ .filter(({ workspaceWorkflowVersionId }) =>+ isDefined(workspaceWorkflowVersionId),+ )+ .map(({ id }) => id);++ return (+ <SidePanelList+ selectableItemIds={selectableCoreWorkflowVersionIds}+ loading={loading}+ noResults={+ !loading && !isDefined(error) && coreWorkflowVersions.length === 0+ }+ >+ {isDefined(error) && (+ <StyledError>{t`Could not load versions.`}</StyledError>+ )}+ <SidePanelGroup heading={t`Versions`}>+ {coreWorkflowVersions.map((coreWorkflowVersion) => (+ <CoreWorkflowVersionsListItem+ key={coreWorkflowVersion.id}+ id={coreWorkflowVersion.id}+ label={coreWorkflowVersion.label}+ createdAt={coreWorkflowVersion.createdAt}+ status={coreWorkflowVersion.status}+ isSelectable={isDefined(+ coreWorkflowVersion.workspaceWorkflowVersionId,+ )}+ onSelect={() => {+ if (!isDefined(coreWorkflowVersion.workspaceWorkflowVersionId)) {+ return;+ }++ openCoreWorkflowVersionSidePanel({+ workspaceWorkflowVersionId:+ coreWorkflowVersion.workspaceWorkflowVersionId,+ pageTitle: coreWorkflowVersion.label,+ });+ }}+ />+ ))}+ </SidePanelGroup>+ </SidePanelList>+ );+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/constants/CoreWorkflowVersionStatusTagProps.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/constants/CoreWorkflowVersionStatusTagProps.tsnew file mode 100644index 00000000000..88f66c1582f--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/constants/CoreWorkflowVersionStatusTagProps.ts@@ -0,0 +1,18 @@+import { type MessageDescriptor } from '@lingui/core';+import { msg } from '@lingui/core/macro';+import { type ThemeColor } from 'twenty-ui/theme';++import { CoreWorkflowVersionStatus } from '~/generated/graphql';++export const CORE_WORKFLOW_VERSION_STATUS_TAG_PROPS: Record<+ CoreWorkflowVersionStatus,+ { label: MessageDescriptor; color: ThemeColor }+> = {+ [CoreWorkflowVersionStatus.DRAFT]: { label: msg`Draft`, color: 'yellow' },+ [CoreWorkflowVersionStatus.ACTIVE]: { label: msg`Active`, color: 'green' },+ [CoreWorkflowVersionStatus.DEACTIVATED]: {+ label: msg`Deactivated`,+ color: 'gray',+ },+ [CoreWorkflowVersionStatus.ARCHIVED]: { label: msg`Archived`, color: 'gray' },+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/constants/RestoreCoreWorkflowVersionModalId.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/constants/RestoreCoreWorkflowVersionModalId.tsnew file mode 100644index 00000000000..4158b4a7a16--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/constants/RestoreCoreWorkflowVersionModalId.ts@@ -0,0 +1,2 @@+export const RESTORE_CORE_WORKFLOW_VERSION_MODAL_ID =+ 'restore-core-workflow-version-modal';diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersion.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersion.tsnew file mode 100644index 00000000000..cbae12dc9d1--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersion.ts@@ -0,0 +1,18 @@+import { gql } from '@apollo/client';++export const GET_CORE_WORKFLOW_VERSION = gql`+ query GetCoreWorkflowVersion($workspaceWorkflowVersionId: UUID!) {+ coreWorkflowVersion(+ workspaceWorkflowVersionId: $workspaceWorkflowVersionId+ ) {+ id+ label+ status+ workspaceWorkflowVersionId+ workspaceWorkflowId+ trigger+ steps+ createdAt+ }+ }+`;diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersions.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersions.tsnew file mode 100644index 00000000000..bdf934fee47--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersions.ts@@ -0,0 +1,14 @@+import { gql } from '@apollo/client';++export const GET_CORE_WORKFLOW_VERSIONS = gql`+ query GetCoreWorkflowVersions($workspaceWorkflowId: UUID!) {+ coreWorkflowVersions(workspaceWorkflowId: $workspaceWorkflowId) {+ id+ label+ status+ workspaceWorkflowVersionId+ workspaceWorkflowId+ createdAt+ }+ }+`;diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useCoreWorkflowVersion.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useCoreWorkflowVersion.tsnew file mode 100644index 00000000000..5bca0da14f1--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useCoreWorkflowVersion.ts@@ -0,0 +1,20 @@+import { useQuery } from '@apollo/client/react';++import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';+import { GetCoreWorkflowVersionDocument } from '~/generated/graphql';++export const useCoreWorkflowVersion = (workspaceWorkflowVersionId: string) => {+ const apolloCoreClient = useApolloCoreClient();++ const { data, loading, error } = useQuery(GetCoreWorkflowVersionDocument, {+ client: apolloCoreClient,+ fetchPolicy: 'cache-and-network',+ variables: { workspaceWorkflowVersionId },+ });++ return {+ coreWorkflowVersion: data?.coreWorkflowVersion ?? null,+ loading,+ error,+ };+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useCoreWorkflowVersions.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useCoreWorkflowVersions.tsnew file mode 100644index 00000000000..67dd3c3abf1--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useCoreWorkflowVersions.ts@@ -0,0 +1,24 @@+import { useQuery } from '@apollo/client/react';++import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';+import { GetCoreWorkflowVersionsDocument } from '~/generated/graphql';++export const useCoreWorkflowVersions = (workflowId: string) => {+ const apolloCoreClient = useApolloCoreClient();++ const { data, loading, error, refetch } = useQuery(+ GetCoreWorkflowVersionsDocument,+ {+ client: apolloCoreClient,+ fetchPolicy: 'cache-and-network',+ variables: { workspaceWorkflowId: workflowId },+ },+ );++ return {+ coreWorkflowVersions: data?.coreWorkflowVersions ?? [],+ loading,+ error,+ refetchCoreWorkflowVersions: refetch,+ };+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useOpenCoreWorkflowVersionSidePanel.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useOpenCoreWorkflowVersionSidePanel.tsnew file mode 100644index 00000000000..1cf60feaa41--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useOpenCoreWorkflowVersionSidePanel.ts@@ -0,0 +1,39 @@+import { useStore } from 'jotai';+import { v4 } from 'uuid';++import { SidePanelPages } from 'twenty-shared/types';+import { IconVersions } from 'twenty-ui/icon';++import { useNavigateSidePanel } from '@/side-panel/hooks/useNavigateSidePanel';+import { sidePanelWorkflowVersionIdComponentState } from '@/side-panel/pages/workflow/states/sidePanelWorkflowVersionIdComponentState';++export const useOpenCoreWorkflowVersionSidePanel = () => {+ const store = useStore();+ const { navigateSidePanel } = useNavigateSidePanel();++ const openCoreWorkflowVersionSidePanel = ({+ workspaceWorkflowVersionId,+ pageTitle,+ }: {+ workspaceWorkflowVersionId: string;+ pageTitle: string;+ }) => {+ const pageId = v4();++ store.set(+ sidePanelWorkflowVersionIdComponentState.atomFamily({+ instanceId: pageId,+ }),+ workspaceWorkflowVersionId,+ );++ navigateSidePanel({+ page: SidePanelPages.WorkflowVersion,+ pageTitle,+ pageIcon: IconVersions,+ pageId,+ });+ };++ return { openCoreWorkflowVersionSidePanel };+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useOpenCoreWorkflowVersionsSidePanel.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useOpenCoreWorkflowVersionsSidePanel.tsnew file mode 100644index 00000000000..98e7aeb3e7c--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useOpenCoreWorkflowVersionsSidePanel.ts@@ -0,0 +1,34 @@+import { useStore } from 'jotai';+import { v4 } from 'uuid';++import { useLingui } from '@lingui/react/macro';+import { SidePanelPages } from 'twenty-shared/types';+import { IconVersions } from 'twenty-ui/icon';++import { useNavigateSidePanel } from '@/side-panel/hooks/useNavigateSidePanel';+import { sidePanelWorkflowIdComponentState } from '@/side-panel/pages/workflow/states/sidePanelWorkflowIdComponentState';++export const useOpenCoreWorkflowVersionsSidePanel = () => {+ const { t } = useLingui();+ const store = useStore();+ const { navigateSidePanel } = useNavigateSidePanel();++ const openCoreWorkflowVersionsSidePanel = (workflowId: string) => {+ const pageId = v4();++ store.set(+ sidePanelWorkflowIdComponentState.atomFamily({ instanceId: pageId }),+ workflowId,+ );++ navigateSidePanel({+ page: SidePanelPages.WorkflowVersions,+ pageTitle: t`Workflow versions`,+ pageIcon: IconVersions,+ pageId,+ resetNavigationStack: true,+ });+ };++ return { openCoreWorkflowVersionsSidePanel };+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useRestoreCoreWorkflowVersionAsDraft.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useRestoreCoreWorkflowVersionAsDraft.tsnew file mode 100644index 00000000000..4cf086144f7--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/hooks/useRestoreCoreWorkflowVersionAsDraft.ts@@ -0,0 +1,73 @@+import { useLingui } from '@lingui/react/macro';+import { useState } from 'react';+import { AppPath, CoreObjectNameSingular } from 'twenty-shared/types';+import { isDefined } from 'twenty-shared/utils';++import { useCoreWorkflowVersions } from '@/object-core/workflows/versions/hooks/useCoreWorkflowVersions';+import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';+import { useCreateDraftFromWorkflowVersion } from '@/workflow/hooks/useCreateDraftFromWorkflowVersion';+import { CoreWorkflowVersionStatus } from '~/generated/graphql';+import { useNavigateApp } from '~/hooks/useNavigateApp';++export const useRestoreCoreWorkflowVersionAsDraft = ({+ workflowId,+ workspaceWorkflowVersionId,+}: {+ workflowId: string;+ workspaceWorkflowVersionId: string;+}) => {+ const { t } = useLingui();+ const [isRestoring, setIsRestoring] = useState(false);+ const { coreWorkflowVersions, loading: isLoadingCoreWorkflowVersions } =+ useCoreWorkflowVersions(workflowId);+ const { createDraftFromWorkflowVersion } =+ useCreateDraftFromWorkflowVersion();+ const { enqueueErrorSnackBar } = useSnackBar();+ const navigate = useNavigateApp();++ const hasExistingDraft = coreWorkflowVersions.some(+ (coreWorkflowVersion) =>+ coreWorkflowVersion.status === CoreWorkflowVersionStatus.DRAFT,+ );++ const restoreCoreWorkflowVersionAsDraft = async () => {+ if (isRestoring) {+ return;+ }++ setIsRestoring(true);++ try {+ const draftWorkflowVersionId = await createDraftFromWorkflowVersion({+ workflowId,+ workflowVersionIdToCopy: workspaceWorkflowVersionId,+ });++ if (!isDefined(draftWorkflowVersionId)) {+ enqueueErrorSnackBar({+ message: t`Could not restore this version as draft.`,+ });++ return;+ }++ navigate(AppPath.RecordShowPage, {+ objectNameSingular: CoreObjectNameSingular.Workflow,+ objectRecordId: workflowId,+ });+ } catch {+ enqueueErrorSnackBar({+ message: t`Could not restore this version as draft.`,+ });+ } finally {+ setIsRestoring(false);+ }+ };++ return {+ restoreCoreWorkflowVersionAsDraft,+ isRestoring,+ hasExistingDraft,+ isLoadingCoreWorkflowVersions,+ };+};diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions.tsnew file mode 100644index 00000000000..b7809baf9b3--- /dev/null+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions.ts@@ -0,0 +1,15 @@+import { type ApolloClient } from '@apollo/client';++import { GetCoreWorkflowVersionsDocument } from '~/generated/graphql';++export const invalidateCoreWorkflowVersions = async (+ apolloCoreClient: ApolloClient,+) => {+ apolloCoreClient.cache.evict({+ id: 'ROOT_QUERY',+ fieldName: 'coreWorkflowVersions',+ });+ await apolloCoreClient.refetchQueries({+ include: [GetCoreWorkflowVersionsDocument],+ });+};diff --git a/packages/twenty-front/src/modules/side-panel/constants/SidePanelPagesConfig.tsx b/packages/twenty-front/src/modules/side-panel/constants/SidePanelPagesConfig.tsxindex d63adc675ed..baa2da046a6 100644--- a/packages/twenty-front/src/modules/side-panel/constants/SidePanelPagesConfig.tsx+++ b/packages/twenty-front/src/modules/side-panel/constants/SidePanelPagesConfig.tsx@@ -2,6 +2,8 @@ import { SidePanelCommandMenuItemDisplayPage } from '@/command-menu-item/displayimport { SidePanelCommandMenuItemEditPage } from '@/command-menu-item/edit/components/SidePanelCommandMenuItemEditPage';import { SidePanelNavigationMenuItemEditPage } from '@/navigation-menu-item/edit/side-panel/components/SidePanelNavigationMenuItemEditPage';import { SidePanelCoreWorkflowFiltersPage } from '@/object-core/workflows/components/SidePanelCoreWorkflowFiltersPage';+import { SidePanelCoreWorkflowVersionPage } from '@/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionPage';+import { SidePanelCoreWorkflowVersionsPage } from '@/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionsPage';import { SidePanelSettingsMetadataTranslationsPage } from '@/settings/translations/components/SidePanelSettingsMetadataTranslationsPage';import { SidePanelRoutedPage } from '@/side-panel/routing/components/SidePanelRoutedPage';import { SidePanelNewSidebarItemPage } from '@/navigation-menu-item/edit/side-panel/components/SidePanelNewSidebarItemPage';@@ -101,4 +103,6 @@ export const SIDE_PANEL_PAGES_CONFIG = new Map<],[SidePanelPages.RoutedPage, <SidePanelRoutedPage />],[SidePanelPages.WorkflowCoreFilters, <SidePanelCoreWorkflowFiltersPage />],+ [SidePanelPages.WorkflowVersions, <SidePanelCoreWorkflowVersionsPage />],+ [SidePanelPages.WorkflowVersion, <SidePanelCoreWorkflowVersionPage />],]);diff --git a/packages/twenty-front/src/modules/workflow/hooks/useActivateWorkflowVersion.ts b/packages/twenty-front/src/modules/workflow/hooks/useActivateWorkflowVersion.tsindex 74e0f17075e..88c54ed9f3a 100644--- a/packages/twenty-front/src/modules/workflow/hooks/useActivateWorkflowVersion.ts+++ b/packages/twenty-front/src/modules/workflow/hooks/useActivateWorkflowVersion.ts@@ -1,3 +1,4 @@+import { invalidateCoreWorkflowVersions } from '@/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions';import { useMutation } from '@apollo/client/react';import { triggerUpdateRecordOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffect';@@ -162,6 +163,8 @@ export const useActivateWorkflowVersion = () => {}},});++ await invalidateCoreWorkflowVersions(apolloCoreClient);};return { activateWorkflowVersion };diff --git a/packages/twenty-front/src/modules/workflow/hooks/useCreateDraftFromWorkflowVersion.ts b/packages/twenty-front/src/modules/workflow/hooks/useCreateDraftFromWorkflowVersion.tsindex 7ab71fed250..ac98814d6b5 100644--- a/packages/twenty-front/src/modules/workflow/hooks/useCreateDraftFromWorkflowVersion.ts+++ b/packages/twenty-front/src/modules/workflow/hooks/useCreateDraftFromWorkflowVersion.ts@@ -1,3 +1,4 @@+import { invalidateCoreWorkflowVersions } from '@/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions';import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';import { CoreObjectNameSingular } from 'twenty-shared/types';import { useFindManyRecordsQuery } from '@/object-record/hooks/useFindManyRecordsQuery';@@ -47,6 +48,8 @@ export const useCreateDraftFromWorkflowVersion = () => {],});+ await invalidateCoreWorkflowVersions(apolloCoreClient);+return result?.data?.createDraftFromWorkflowVersion.id;};diff --git a/packages/twenty-front/src/modules/workflow/hooks/useDeactivateWorkflowVersion.ts b/packages/twenty-front/src/modules/workflow/hooks/useDeactivateWorkflowVersion.tsindex f311e4b3d7e..d6a258e7e4e 100644--- a/packages/twenty-front/src/modules/workflow/hooks/useDeactivateWorkflowVersion.ts+++ b/packages/twenty-front/src/modules/workflow/hooks/useDeactivateWorkflowVersion.ts@@ -1,3 +1,4 @@+import { invalidateCoreWorkflowVersions } from '@/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions';import { useMutation } from '@apollo/client/react';import { triggerUpdateRecordOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffect';@@ -125,6 +126,8 @@ export const useDeactivateWorkflowVersion = () => {}},});++ await invalidateCoreWorkflowVersions(apolloCoreClient);};return { deactivateWorkflowVersion };diff --git a/packages/twenty-front/src/modules/workflow/hooks/useDeleteOneWorkflowVersion.ts b/packages/twenty-front/src/modules/workflow/hooks/useDeleteOneWorkflowVersion.tsindex 5e3e2308de6..6cfe9a1f9c0 100644--- a/packages/twenty-front/src/modules/workflow/hooks/useDeleteOneWorkflowVersion.ts+++ b/packages/twenty-front/src/modules/workflow/hooks/useDeleteOneWorkflowVersion.ts@@ -1,3 +1,4 @@+import { invalidateCoreWorkflowVersions } from '@/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions';import { useCallback } from 'react';import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';@@ -100,6 +101,8 @@ export const useDeleteOneWorkflowVersion = () => {}) => {await deleteOneRecord(workflowVersionId);handleUpdate(workflowVersionId);++ await invalidateCoreWorkflowVersions(apolloCoreClient);};return { deleteOneWorkflowVersion };diff --git a/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.dto.ts b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.dto.tsnew file mode 100644index 00000000000..2b4aee390d9--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.dto.ts@@ -0,0 +1,39 @@+import { Field, ObjectType, registerEnumType } from '@nestjs/graphql';++import GraphQLJSON from 'graphql-type-json';++import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';+import { WorkflowVersionStatus } from 'src/engine/core-modules/workflow/entities/workflow-version.entity';+import { WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';+import { WorkflowTrigger } from 'src/modules/workflow/workflow-trigger/types/workflow-trigger.type';++registerEnumType(WorkflowVersionStatus, {+ name: 'CoreWorkflowVersionStatus',+});++@ObjectType('CoreWorkflowVersionDTO')+export class CoreWorkflowVersionDTO {+ @Field(() => UUIDScalarType)+ id: string;++ @Field(() => String)+ label: string;++ @Field(() => WorkflowVersionStatus)+ status: WorkflowVersionStatus;++ @Field(() => UUIDScalarType, { nullable: true })+ workspaceWorkflowVersionId: string | null;++ @Field(() => UUIDScalarType)+ workspaceWorkflowId: string;++ @Field(() => GraphQLJSON, { nullable: true })+ trigger: WorkflowTrigger | null;++ @Field(() => GraphQLJSON, { nullable: true })+ steps: WorkflowAction[] | null;++ @Field(() => String)+ createdAt: string;+}diff --git a/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.input.ts b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.input.tsnew file mode 100644index 00000000000..c38750d9c3f--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.input.ts@@ -0,0 +1,12 @@+import { ArgsType, Field } from '@nestjs/graphql';++import { IsUUID } from 'class-validator';++import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';++@ArgsType()+export class CoreWorkflowVersionArgs {+ @Field(() => UUIDScalarType)+ @IsUUID()+ workspaceWorkflowVersionId: string;+}diff --git a/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-versions.input.ts b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-versions.input.tsnew file mode 100644index 00000000000..2154ca39918--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-versions.input.ts@@ -0,0 +1,12 @@+import { ArgsType, Field } from '@nestjs/graphql';++import { IsUUID } from 'class-validator';++import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';++@ArgsType()+export class CoreWorkflowVersionsArgs {+ @Field(() => UUIDScalarType)+ @IsUUID()+ workspaceWorkflowId: string;+}diff --git a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow.resolver.ts b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow.resolver.tsindex e59a28e5af3..d485e9af6d7 100644--- a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow.resolver.ts@@ -7,8 +7,12 @@ import { CoreResolver } from 'src/engine/api/graphql/graphql-config/decorators/cimport { PreventNestToAutoLogGraphqlErrorsFilter } from 'src/engine/core-modules/graphql/filters/prevent-nest-to-auto-log-graphql-errors.filter';import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';import { CoreWorkflowConnectionDTO } from 'src/engine/core-modules/workflow/dtos/core-workflow-connection.dto';+import { CoreWorkflowVersionDTO } from 'src/engine/core-modules/workflow/dtos/core-workflow-version.dto';+import { CoreWorkflowVersionArgs } from 'src/engine/core-modules/workflow/dtos/core-workflow-version.input';+import { CoreWorkflowVersionsArgs } from 'src/engine/core-modules/workflow/dtos/core-workflow-versions.input';import { CoreWorkflowsArgs } from 'src/engine/core-modules/workflow/dtos/core-workflows.input';import { CoreWorkflowListService } from 'src/engine/core-modules/workflow/services/core-workflow-list.service';+import { CoreWorkflowVersionListService } from 'src/engine/core-modules/workflow/services/core-workflow-version-list.service';import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';import { SettingsPermissionGuard } from 'src/engine/guards/settings-permission.guard';@@ -30,6 +34,7 @@ import { PermissionsGraphqlApiExceptionFilter } from 'src/engine/metadata-moduleexport class CoreWorkflowResolver {constructor(private readonly coreWorkflowListService: CoreWorkflowListService,+ private readonly coreWorkflowVersionListService: CoreWorkflowVersionListService,) {}@Query(() => CoreWorkflowConnectionDTO)@@ -42,4 +47,28 @@ export class CoreWorkflowResolver {coreWorkflowsArgs,);}++ @Query(() => [CoreWorkflowVersionDTO])+ async coreWorkflowVersions(+ @AuthWorkspace() { id: workspaceId }: WorkspaceEntity,+ @Args() { workspaceWorkflowId }: CoreWorkflowVersionsArgs,+ ): Promise<CoreWorkflowVersionDTO[]> {+ return this.coreWorkflowVersionListService.findManyByWorkspaceWorkflowId({+ workspaceId,+ workspaceWorkflowId,+ });+ }++ @Query(() => CoreWorkflowVersionDTO, { nullable: true })+ async coreWorkflowVersion(+ @AuthWorkspace() { id: workspaceId }: WorkspaceEntity,+ @Args() { workspaceWorkflowVersionId }: CoreWorkflowVersionArgs,+ ): Promise<CoreWorkflowVersionDTO | null> {+ return this.coreWorkflowVersionListService.findOneByWorkspaceWorkflowVersionId(+ {+ workspaceId,+ workspaceWorkflowVersionId,+ },+ );+ }}diff --git a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-version-list.service.ts b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-version-list.service.tsnew file mode 100644index 00000000000..f455b2f265a--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-version-list.service.ts@@ -0,0 +1,160 @@+import { Injectable } from '@nestjs/common';++import { isDefined } from 'twenty-shared/utils';+import { In } from 'typeorm';++import { WorkflowVersionEntity } from 'src/engine/core-modules/workflow/entities/workflow-version.entity';+import { type CoreWorkflowVersionDTO } from 'src/engine/core-modules/workflow/dtos/core-workflow-version.dto';+import { buildCoreWorkflowVersionLabel } from 'src/engine/core-modules/workflow/utils/build-core-workflow-version-label.util';+import { InjectWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/inject-workspace-scoped-repository.decorator';+import { WorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/workspace-scoped-repository';+import { WorkspaceOrmManager } from 'src/engine/twenty-orm/workspace-orm.manager';+import { buildSystemAuthContext } from 'src/engine/twenty-orm/utils/build-system-auth-context.util';+import { type WorkflowVersionWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-version.workspace-entity';++@Injectable()+export class CoreWorkflowVersionListService {+ constructor(+ @InjectWorkspaceScopedRepository(WorkflowVersionEntity)+ private readonly coreWorkflowVersionRepository: WorkspaceScopedRepository<WorkflowVersionEntity>,+ private readonly workspaceOrmManager: WorkspaceOrmManager,+ ) {}++ async findManyByWorkspaceWorkflowId({+ workspaceId,+ workspaceWorkflowId,+ }: {+ workspaceId: string;+ workspaceWorkflowId: string;+ }): Promise<CoreWorkflowVersionDTO[]> {+ const coreWorkflowVersions = await this.coreWorkflowVersionRepository.find(+ workspaceId,+ {+ where: { workflowId: workspaceWorkflowId },+ order: { createdAt: 'ASC', id: 'ASC' },+ select: { id: true, status: true, createdAt: true },+ },+ );++ const workspaceVersionIdByCoreVersionId =+ await this.findWorkspaceVersionIdByCoreVersionId({+ workspaceId,+ workspaceWorkflowId,+ coreWorkflowVersionIds: coreWorkflowVersions.map(+ (coreWorkflowVersion) => coreWorkflowVersion.id,+ ),+ });++ return coreWorkflowVersions+ .map((coreWorkflowVersion, index) => ({+ id: coreWorkflowVersion.id,+ label: buildCoreWorkflowVersionLabel(index + 1),+ status: coreWorkflowVersion.status,+ workspaceWorkflowVersionId:+ workspaceVersionIdByCoreVersionId[coreWorkflowVersion.id] ?? null,+ workspaceWorkflowId,+ trigger: null,+ steps: null,+ createdAt: coreWorkflowVersion.createdAt.toISOString(),+ }))+ .reverse();+ }++ async findOneByWorkspaceWorkflowVersionId({+ workspaceId,+ workspaceWorkflowVersionId,+ }: {+ workspaceId: string;+ workspaceWorkflowVersionId: string;+ }): Promise<CoreWorkflowVersionDTO | null> {+ const authContext = buildSystemAuthContext(workspaceId);++ const workspaceWorkflowVersion =+ await this.workspaceOrmManager.executeInWorkspaceContext(+ async () =>+ this.workspaceOrmManager+ .getRepository<WorkflowVersionWorkspaceEntity>('workflowVersion', {+ shouldBypassPermissionChecks: true,+ })+ .findOne({+ where: { id: workspaceWorkflowVersionId },+ select: { id: true, workflowId: true },+ }),+ authContext,+ );++ if (!isDefined(workspaceWorkflowVersion)) {+ return null;+ }++ const coreWorkflowVersions = await this.findManyByWorkspaceWorkflowId({+ workspaceId,+ workspaceWorkflowId: workspaceWorkflowVersion.workflowId,+ });++ const coreWorkflowVersionMetadata = coreWorkflowVersions.find(+ (coreWorkflowVersion) =>+ coreWorkflowVersion.workspaceWorkflowVersionId ===+ workspaceWorkflowVersionId,+ );++ if (!isDefined(coreWorkflowVersionMetadata)) {+ return null;+ }++ const coreWorkflowVersionContent =+ await this.coreWorkflowVersionRepository.findOne(workspaceId, {+ where: { id: coreWorkflowVersionMetadata.id },+ select: { id: true, triggers: true, steps: true },+ });++ return {+ ...coreWorkflowVersionMetadata,+ trigger: coreWorkflowVersionContent?.triggers?.[0] ?? null,+ steps: coreWorkflowVersionContent?.steps ?? null,+ };+ }++ private async findWorkspaceVersionIdByCoreVersionId({+ workspaceId,+ workspaceWorkflowId,+ coreWorkflowVersionIds,+ }: {+ workspaceId: string;+ workspaceWorkflowId: string;+ coreWorkflowVersionIds: string[];+ }): Promise<Record<string, string>> {+ if (coreWorkflowVersionIds.length === 0) {+ return {};+ }++ const authContext = buildSystemAuthContext(workspaceId);++ return this.workspaceOrmManager.executeInWorkspaceContext(async () => {+ const workspaceWorkflowVersions = await this.workspaceOrmManager+ .getRepository<WorkflowVersionWorkspaceEntity>('workflowVersion', {+ shouldBypassPermissionChecks: true,+ })+ .find({+ where: {+ workflowId: workspaceWorkflowId,+ coreWorkflowVersionId: In(coreWorkflowVersionIds),+ },+ select: { id: true, coreWorkflowVersionId: true },+ });++ return Object.fromEntries(+ workspaceWorkflowVersions.flatMap((workspaceWorkflowVersion) =>+ isDefined(workspaceWorkflowVersion.coreWorkflowVersionId)+ ? [+ [+ workspaceWorkflowVersion.coreWorkflowVersionId,+ workspaceWorkflowVersion.id,+ ],+ ]+ : [],+ ),+ );+ }, authContext);+ }+}diff --git a/packages/twenty-server/src/engine/core-modules/workflow/utils/__tests__/build-core-workflow-version-label.util.spec.ts b/packages/twenty-server/src/engine/core-modules/workflow/utils/__tests__/build-core-workflow-version-label.util.spec.tsnew file mode 100644index 00000000000..9c53e60f484--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/workflow/utils/__tests__/build-core-workflow-version-label.util.spec.ts@@ -0,0 +1,8 @@+import { buildCoreWorkflowVersionLabel } from 'src/engine/core-modules/workflow/utils/build-core-workflow-version-label.util';++describe('buildCoreWorkflowVersionLabel', () => {+ it('should number versions from the oldest', () => {+ expect(buildCoreWorkflowVersionLabel(1)).toBe('v1');+ expect(buildCoreWorkflowVersionLabel(12)).toBe('v12');+ });+});diff --git a/packages/twenty-server/src/engine/core-modules/workflow/utils/build-core-workflow-version-label.util.ts b/packages/twenty-server/src/engine/core-modules/workflow/utils/build-core-workflow-version-label.util.tsnew file mode 100644index 00000000000..e7522437264--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/workflow/utils/build-core-workflow-version-label.util.ts@@ -0,0 +1,3 @@+export const buildCoreWorkflowVersionLabel = (+ positionFromOldest: number,+): string => `v${positionFromOldest}`;diff --git a/packages/twenty-server/src/engine/core-modules/workflow/workflow-api.module.ts b/packages/twenty-server/src/engine/core-modules/workflow/workflow-api.module.tsindex 3f3ed8665ab..6227ec51dab 100644--- a/packages/twenty-server/src/engine/core-modules/workflow/workflow-api.module.ts+++ b/packages/twenty-server/src/engine/core-modules/workflow/workflow-api.module.ts@@ -10,8 +10,11 @@ import { WorkflowVersionEdgeResolver } from 'src/engine/core-modules/workflow/reimport { WorkflowVersionStepResolver } from 'src/engine/core-modules/workflow/resolvers/workflow-version-step.resolver';import { WorkflowVersionResolver } from 'src/engine/core-modules/workflow/resolvers/workflow-version.resolver';import { CoreWorkflowListService } from 'src/engine/core-modules/workflow/services/core-workflow-list.service';+import { CoreWorkflowVersionListService } from 'src/engine/core-modules/workflow/services/core-workflow-version-list.service';+import { WorkflowVersionEntity } from 'src/engine/core-modules/workflow/entities/workflow-version.entity';import { WorkflowVersionCoreModule } from 'src/engine/core-modules/workflow/workflow-version-core.module';import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';+import { provideWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/provide-workspace-scoped-repository';import { ConnectedAccountMetadataModule } from 'src/engine/metadata-modules/connected-account/connected-account-metadata.module';import { WorkspaceManyOrAllFlatEntityMapsCacheModule } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module';import { LogicFunctionModule } from 'src/engine/metadata-modules/logic-function/logic-function.module';@@ -26,7 +29,7 @@ import { WorkflowTriggerModule } from 'src/modules/workflow/workflow-trigger/wor@Module({imports: [- TypeOrmModule.forFeature([WorkspaceEntity]),+ TypeOrmModule.forFeature([WorkspaceEntity, WorkflowVersionEntity]),WorkflowTriggerModule,WorkflowBuilderModule,WorkflowCommonModule,@@ -50,6 +53,8 @@ import { WorkflowTriggerModule } from 'src/modules/workflow/workflow-trigger/worWorkflowVersionResolver,CoreWorkflowResolver,CoreWorkflowListService,+ CoreWorkflowVersionListService,+ provideWorkspaceScopedRepository(WorkflowVersionEntity),],})export class WorkflowApiModule {}diff --git a/packages/twenty-shared/src/types/SidePanelPages.ts b/packages/twenty-shared/src/types/SidePanelPages.tsindex 41070818bdc..d0278b81d6a 100644--- a/packages/twenty-shared/src/types/SidePanelPages.ts+++ b/packages/twenty-shared/src/types/SidePanelPages.ts@@ -34,6 +34,8 @@ export enum SidePanelPages {ComposeCalendarEvent = 'compose-calendar-event',CreateRelatedRecord = 'create-related-record',SendCampaignTest = 'send-campaign-test',+ WorkflowVersions = 'workflow-versions',+ WorkflowVersion = 'workflow-version',EmailBlockSettings = 'email-block-settings',SettingsMetadataTranslations = 'settings-metadata-translations',RoutedPage = 'routed-page',