Add link on snack bar (#9873)
Add link to workflow execution <img width="639" alt="Capture d’écran 2025-01-27 à 18 15 34" src="https://github.com/user-attachments/assets/f2a1b3b5-7bf6-4b33-bba7-bf8907f6bcc6" />
This commit is contained in:
@ -68,7 +68,6 @@ export const RecordShowPageWorkflowHeader = ({
|
||||
|
||||
await runWorkflowVersion({
|
||||
workflowVersionId: workflowWithCurrentVersion.currentVersion.id,
|
||||
workflowName: workflowWithCurrentVersion.name,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
@ -3,7 +3,6 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { RUN_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/runWorkflowVersion';
|
||||
import { useApolloClient, useMutation } from '@apollo/client';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import { capitalize } from 'twenty-shared';
|
||||
import { IconSettingsAutomation } from 'twenty-ui';
|
||||
import {
|
||||
RunWorkflowVersionMutation,
|
||||
@ -25,18 +24,27 @@ export const useRunWorkflowVersion = () => {
|
||||
|
||||
const runWorkflowVersion = async ({
|
||||
workflowVersionId,
|
||||
workflowName,
|
||||
payload,
|
||||
}: {
|
||||
workflowVersionId: string;
|
||||
workflowName: string;
|
||||
payload?: Record<string, any>;
|
||||
}) => {
|
||||
await mutate({
|
||||
const { data } = await mutate({
|
||||
variables: { input: { workflowVersionId, payload } },
|
||||
});
|
||||
|
||||
enqueueSnackBar(`${capitalize(workflowName)} starting...`, {
|
||||
const workflowRunId = data?.runWorkflowVersion?.workflowRunId;
|
||||
|
||||
if (!workflowRunId) {
|
||||
enqueueSnackBar('Workflow run failed', {
|
||||
variant: SnackBarVariant.Error,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const link = `/object/workflowRun/${workflowRunId}`;
|
||||
|
||||
enqueueSnackBar('Workflow is running...', {
|
||||
variant: SnackBarVariant.Success,
|
||||
icon: (
|
||||
<IconSettingsAutomation
|
||||
@ -44,6 +52,10 @@ export const useRunWorkflowVersion = () => {
|
||||
color={theme.snackBar.success.color}
|
||||
/>
|
||||
),
|
||||
link: {
|
||||
href: link,
|
||||
text: 'View execution details',
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user