diff --git a/packages/twenty-front/src/modules/action-menu/actions/global-actions/workflow-run-actions/components/WorkflowRunActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/global-actions/workflow-run-actions/components/WorkflowRunActionEffect.tsx index 7a9f78d869..e990911d74 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/global-actions/workflow-run-actions/components/WorkflowRunActionEffect.tsx +++ b/packages/twenty-front/src/modules/action-menu/actions/global-actions/workflow-run-actions/components/WorkflowRunActionEffect.tsx @@ -34,7 +34,9 @@ export const WorkflowRunActionEffect = () => { position: index, Icon: IconSettingsAutomation, onClick: async () => { - await runWorkflowVersion(activeWorkflowVersion.id); + await runWorkflowVersion({ + workflowVersionId: activeWorkflowVersion.id, + }); enqueueSnackBar('', { variant: SnackBarVariant.Success, diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionEffect.tsx index 9c8d509e3e..f724a7087c 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionEffect.tsx +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionEffect.tsx @@ -65,7 +65,10 @@ export const WorkflowRunRecordActionEffect = ({ return; } - await runWorkflowVersion(activeWorkflowVersion.id, selectedRecord); + await runWorkflowVersion({ + workflowVersionId: activeWorkflowVersion.id, + payload: selectedRecord, + }); enqueueSnackBar('', { variant: SnackBarVariant.Success, diff --git a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx index 2f4bae71a6..7eb9f8360d 100644 --- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx +++ b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx @@ -15,6 +15,7 @@ import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; import { SHOW_PAGE_ADD_BUTTON_DROPDOWN_ID } from '@/ui/layout/show-page/constants/ShowPageAddButtonDropdownId'; import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; +import { isWorkflowSubObjectMetadata } from '@/object-metadata/utils/isWorkflowSubObjectMetadata'; import { Dropdown } from '../../dropdown/components/Dropdown'; import { DropdownMenu } from '../../dropdown/components/DropdownMenu'; @@ -54,7 +55,8 @@ export const ShowPageAddButton = ({ activityTargetObject.targetObjectNameSingular === CoreObjectNameSingular.Task || activityTargetObject.targetObjectNameSingular === - CoreObjectNameSingular.Note + CoreObjectNameSingular.Note || + isWorkflowSubObjectMetadata(activityTargetObject.targetObjectNameSingular) ) { return; } diff --git a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx index 9c82c08b68..a0fb80c220 100644 --- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx +++ b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx @@ -15,6 +15,7 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState'; +import { isObjectMetadataReadOnly } from '@/object-metadata/utils/isObjectMetadataReadOnly'; import { useDestroyOneRecord } from '@/object-record/hooks/useDestroyOneRecord'; import { useRestoreManyRecords } from '@/object-record/hooks/useRestoreManyRecords'; import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; @@ -28,9 +29,11 @@ const StyledContainer = styled.div` export const ShowPageMoreButton = ({ recordId, objectNameSingular, + isRemote, }: { recordId: string; objectNameSingular: string; + isRemote: boolean; }) => { const { closeDropdown, toggleDropdown } = useDropdown('more-show-page'); const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState); @@ -66,6 +69,15 @@ export const ShowPageMoreButton = ({ recordStoreFamilyState(recordId), ); + if ( + isObjectMetadataReadOnly({ + isRemote, + nameSingular: objectNameSingular, + }) + ) { + return; + } + return ( @@ -34,7 +49,41 @@ export const RecordShowPageWorkflowHeader = ({ variant="secondary" Icon={IconPlayerPlay} disabled={isWaitingForWorkflowWithCurrentVersion} - onClick={() => {}} + onClick={async () => { + assertWorkflowWithCurrentVersionIsDefined(workflowWithCurrentVersion); + + if (!canWorkflowBeTested) { + enqueueSnackBar( + 'Trigger type should be Manual - when no record(s) are selected', + { + variant: SnackBarVariant.Error, + title: 'Workflow cannot be tested', + icon: ( + + ), + }, + ); + return; + } + + await runWorkflowVersion({ + workflowVersionId: workflowWithCurrentVersion.currentVersion.id, + }); + + enqueueSnackBar('', { + variant: SnackBarVariant.Success, + title: `${capitalize(workflowWithCurrentVersion.name)} starting...`, + icon: ( + + ), + }); + }} /> {workflowWithCurrentVersion?.currentVersion?.status === 'DRAFT' && diff --git a/packages/twenty-front/src/modules/workflow/components/RecordShowPageWorkflowVersionHeader.tsx b/packages/twenty-front/src/modules/workflow/components/RecordShowPageWorkflowVersionHeader.tsx index 03c9c5a520..08c388b49e 100644 --- a/packages/twenty-front/src/modules/workflow/components/RecordShowPageWorkflowVersionHeader.tsx +++ b/packages/twenty-front/src/modules/workflow/components/RecordShowPageWorkflowVersionHeader.tsx @@ -82,7 +82,7 @@ export const RecordShowPageWorkflowVersionHeader = ({ <> {showUseAsDraftButton ? (