mirror of
				https://github.com/lingble/twenty.git
				synced 2025-10-31 04:37:56 +00:00 
			
		
		
		
	 1aa961dedf
			
		
	
	1aa961dedf
	
	
	
		
			
			- add outputSchema in workflow step settings - use outputSchemas to compute step available variables https://github.com/user-attachments/assets/6b851d8e-625c-49ff-b29c-074cd86cbfee
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
 | |
| import { ApolloClient, useApolloClient, useMutation } from '@apollo/client';
 | |
| 
 | |
| import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
 | |
| import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
 | |
| import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordFromCache';
 | |
| import { DEACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/deactivateWorkflowVersion';
 | |
| import {
 | |
|   ActivateWorkflowVersionMutation,
 | |
|   ActivateWorkflowVersionMutationVariables,
 | |
| } from '~/generated/graphql';
 | |
| 
 | |
| export const useDeactivateWorkflowVersion = () => {
 | |
|   const apolloMetadataClient = useApolloMetadataClient();
 | |
|   const apolloClient = useApolloClient();
 | |
|   const [mutate] = useMutation<
 | |
|     ActivateWorkflowVersionMutation,
 | |
|     ActivateWorkflowVersionMutationVariables
 | |
|   >(DEACTIVATE_WORKFLOW_VERSION, {
 | |
|     client: apolloMetadataClient ?? ({} as ApolloClient<any>),
 | |
|   });
 | |
| 
 | |
|   const { objectMetadataItem: objectMetadataItemWorkflowVersion } =
 | |
|     useObjectMetadataItem({
 | |
|       objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
 | |
|     });
 | |
| 
 | |
|   const deactivateWorkflowVersion = async (workflowVersionId: string) => {
 | |
|     await mutate({
 | |
|       variables: {
 | |
|         workflowVersionId,
 | |
|       },
 | |
|       update: () => {
 | |
|         modifyRecordFromCache({
 | |
|           cache: apolloClient.cache,
 | |
|           recordId: workflowVersionId,
 | |
|           objectMetadataItem: objectMetadataItemWorkflowVersion,
 | |
|           fieldModifiers: {
 | |
|             status: () => 'DEACTIVATED',
 | |
|           },
 | |
|         });
 | |
|       },
 | |
|     });
 | |
|   };
 | |
| 
 | |
|   return { deactivateWorkflowVersion };
 | |
| };
 |