Allow to stop running workflow (#15270)
https://github.com/user-attachments/assets/599154e4-8743-471b-b05a-721b635bcf4e On stoppage: - if no running steps, mark pending as failed and end the workflow - if running steps, set as stopping and exit. Going to the next step, as the workflow is not running anymore, it will naturally stop
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useRegisterObjectOperation } from '@/object-record/hooks/useRegisterObjectOperation';
|
||||
import { useStopWorkflowRunMutation } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useStopWorkflowRun = () => {
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
const [mutate] = useStopWorkflowRunMutation({
|
||||
client: apolloCoreClient,
|
||||
});
|
||||
const { registerObjectOperation } = useRegisterObjectOperation();
|
||||
|
||||
const stopWorkflowRun = async (workflowRunId: string) => {
|
||||
const { data } = await mutate({
|
||||
variables: {
|
||||
workflowRunId,
|
||||
},
|
||||
});
|
||||
|
||||
registerObjectOperation('workflowRun', {
|
||||
type: 'update-one',
|
||||
result: {
|
||||
updatedRecord: data?.stopWorkflowRun,
|
||||
updateInput: { id: workflowRunId },
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return { stopWorkflowRun };
|
||||
};
|
||||
Reference in New Issue
Block a user