The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Only suggest the Send to Inbox step in the Form warning when that step is enabled (#27687)
Félix Malfait63fee3c6f35e
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/WorkflowEditActionFormBuilder.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/WorkflowEditActionFormBuilder.tsxindex 57335aafde0..d6bc841347d 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/WorkflowEditActionFormBuilder.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/WorkflowEditActionFormBuilder.tsx@@ -18,6 +18,7 @@ import { WorkflowEditActionFormFieldSettings } from '@/workflow/workflow-steps/wimport { type WorkflowFormActionField } from '@/workflow/workflow-steps/workflow-actions/form-action/types/WorkflowFormActionField';import { getDefaultFormFieldSettings } from '@/workflow/workflow-steps/workflow-actions/form-action/utils/getDefaultFormFieldSettings';import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';import { styled } from '@linaria/react';import { useLingui } from '@lingui/react/macro';import { isNonEmptyString } from '@sniptt/guards';@@ -36,6 +37,7 @@ import {import { useTheme, themeCssVariables } from 'twenty-ui/theme';import { useDebouncedCallback } from 'use-debounce';import { v4 } from 'uuid';+import { FeatureFlagKey } from '~/generated-metadata/graphql';import { openUrlInNewTab } from '~/utils/openUrlInNewTab';export type WorkflowEditActionFormBuilderProps = {@@ -175,6 +177,9 @@ export const WorkflowEditActionFormBuilder = ({const [isCalloutVisible, setIsCalloutVisible] = useState<boolean>(true);const [selectedField, setSelectedField] = useState<string | null>(null);const [hoveredField, setHoveredField] = useState<string | null>(null);+ const isSendChatMessageEnabled = useIsFeatureEnabled(+ FeatureFlagKey.IS_WORKFLOW_SEND_CHAT_MESSAGE_ENABLED,+ );const isFieldSelected = (fieldName: string) => selectedField === fieldName;@@ -274,7 +279,11 @@ export const WorkflowEditActionFormBuilder = ({/>}title={t`Forms are meant for manual triggers`}- description={t`A form opens for the person who launches the workflow and is filled in on the spot. With this trigger, it only shows in the workflow run. To ask someone for an answer or an approval in their inbox, use a Send to Inbox step instead.`}+ description={+ isSendChatMessageEnabled+ ? t`A form opens for the person who launches the workflow and is filled in on the spot. With this trigger, it only shows in the workflow run. To ask someone for an answer or an approval in their inbox, use a Send to Inbox step instead.`+ : t`A form opens for the person who launches the workflow and is filled in on the spot. With this trigger, it only shows in the workflow run.`+ }closeLabel={t`Close`}onDismiss={() => setIsCalloutVisible(false)}action={diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormBuilder.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormBuilder.stories.tsxindex b6cf052cd92..20fa88f28cf 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormBuilder.stories.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormBuilder.stories.tsx@@ -1,4 +1,6 @@import { type WorkflowFormAction } from '@/workflow/types/Workflow';+import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';+import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';import { WorkflowEditActionFormBuilder } from '@/workflow/workflow-steps/workflow-actions/form-action/components/WorkflowEditActionFormBuilder';import { type Meta, type StoryObj } from '@storybook/react-vite';import { expect, fn, userEvent, waitFor, within } from 'storybook/test';@@ -10,6 +12,8 @@ import { WorkflowStepActionDrawerDecorator } from '~/testing/decorators/Workflowimport { WorkflowStepDecorator } from '~/testing/decorators/WorkflowStepDecorator';import { graphqlMocks } from '~/testing/graphqlMocks';import { getWorkflowNodeIdMock } from '~/testing/mock-data/workflow';+import { mockCurrentWorkspace } from '~/testing/mock-data/users';+import { FeatureFlagKey } from '~/generated-metadata/graphql';import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';const DEFAULT_ACTION = {@@ -85,6 +89,59 @@ export const Default: Story = {},};+export const NonManualTrigger: Story = {+ args: {+ triggerType: 'DATABASE_EVENT',+ actionOptions: {+ onActionUpdate: fn(),+ },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ expect(+ await canvas.findByText('Forms are meant for manual triggers'),+ ).toBeVisible();+ expect(+ await canvas.findByText(/it only shows in the workflow run\./),+ ).toBeVisible();+ expect(canvas.queryByText(/Send to Inbox/)).not.toBeInTheDocument();+ },+};++export const NonManualTriggerWithSendToInbox: Story = {+ args: {+ triggerType: 'DATABASE_EVENT',+ actionOptions: {+ onActionUpdate: fn(),+ },+ },+ beforeEach: () => {+ const previousWorkspace = jotaiStore.get(currentWorkspaceState.atom);++ jotaiStore.set(currentWorkspaceState.atom, {+ ...mockCurrentWorkspace,+ featureFlags: [+ {+ key: FeatureFlagKey.IS_WORKFLOW_SEND_CHAT_MESSAGE_ENABLED,+ value: true,+ },+ ],+ });++ return () => {+ jotaiStore.set(currentWorkspaceState.atom, previousWorkspace);+ };+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ expect(+ await canvas.findByText(/use a Send to Inbox step instead\./),+ ).toBeVisible();+ },+};+export const DeleteFields: Story = {args: {actionOptions: {