From b10d8313712c18d1e5ded634781e698cb4dcaabf Mon Sep 17 00:00:00 2001 From: martmull Date: Fri, 13 Dec 2024 11:16:29 +0100 Subject: [PATCH] 8726 workflow add a test button in workflow code step (#9016) - add test button to workflow code step - add test tab to workflow code step https://github.com/user-attachments/assets/e180a827-7321-49a2-8026-88490c557da2 ![image](https://github.com/user-attachments/assets/cacbd756-de3f-4141-a84c-8e1853f6556b) ![image](https://github.com/user-attachments/assets/ee170d81-8a22-4178-bd6d-11a0e8c73365) --- nx.json | 2 +- packages/twenty-front/project.json | 2 +- .../src/generated-metadata/graphql.ts | 2 - .../twenty-front/src/generated/graphql.tsx | 2 - .../src/hooks/usePreventOverlapCallback.ts | 32 -- .../components/CmdEnterActionButton.tsx | 30 ++ .../tasks/components/TaskGroups.tsx | 4 +- .../modules/app/components/SettingsRoutes.tsx | 8 +- .../components/FormAddressFieldInput.tsx | 12 +- .../components/FormBooleanFieldInput.tsx | 18 +- .../components/FormFieldInputContainer.tsx | 9 + ...r.tsx => FormFieldInputInputContainer.tsx} | 4 +- ...ner.tsx => FormFieldInputRowContainer.tsx} | 4 +- .../components/FormFullNameFieldInput.tsx | 12 +- ....tsx => FormNestedFieldInputContainer.tsx} | 5 +- .../components/FormNumberFieldInput.tsx | 18 +- .../components/FormSelectFieldInput.tsx | 18 +- .../components/FormTextFieldInput.tsx | 18 +- .../StyledFormFieldInputContainer.tsx | 7 - .../form-types/hooks/useTextVariableEditor.ts | 10 +- .../ServerlessFunctionExecutionResult.tsx | 73 ++++ .../constants/IndexFilePath.ts | 1 + .../hooks/useTestServerlessFunction.ts | 51 +++ ...efaultFunctionInputFromInputSchema.test.ts | 44 +++ .../getFunctionInputFromSourceCode.test.ts | 50 +++ .../__tests__/getFunctionInputSchema.test.ts | 67 ++++ .../__tests__/getFunctionOutputSchema.test.ts | 24 ++ ...faultFunctionInputAndFunctionInput.test.ts | 22 +- .../getDefaultFunctionInputFromInputSchema.ts | 24 ++ .../utils/getFunctionInputFromSourceCode.ts | 23 ++ .../utils/getFunctionInputSchema.ts | 86 ++-- .../utils/getFunctionOutputSchema.ts | 49 +++ ...rgeDefaultFunctionInputAndFunctionInput.ts | 32 ++ ...tingsAccountsCalendarChannelsContainer.tsx | 3 +- ...ttingsAccountsMessageChannelsContainer.tsx | 3 +- ...sServerlessFunctionsOutputMetadataInfo.tsx | 39 -- ...ettingsServerlessFunctionCodeEditorTab.tsx | 4 +- .../SettingsServerlessFunctionTestTab.tsx | 60 ++- ...ettingsServerlessFunctionTestTabEffect.tsx | 28 -- .../useServerlessFunctionUpdateFormState.ts | 14 + ...lessFunctionCodeEditorOutputParamsState.ts | 7 - .../settingsServerlessFunctionInputState.ts | 6 - .../settingsServerlessFunctionOutputState.ts | 18 - .../__tests__/getHighlightedDates.test.ts | 2 + .../components/RightDrawerFooter.tsx | 29 ++ .../components/ShowPageSubContainer.tsx | 28 +- .../ui/layout/tab/components/TabList.tsx | 37 +- .../TabListFromUrlOptionalEffect.tsx | 5 +- .../tab/hooks/__tests__/useTabList.test.tsx | 6 +- .../modules/ui/layout/tab/hooks/useTabList.ts | 6 +- .../WorkflowEditTriggerDatabaseEventForm.tsx | 154 ++++---- .../WorkflowEditTriggerManualForm.tsx | 88 +++-- .../components/WorkflowSingleRecordPicker.tsx | 12 +- .../workflow/components/WorkflowStepBody.tsx | 12 + .../components/WorkflowStepDetail.tsx | 2 +- ...ricFormBase.tsx => WorkflowStepHeader.tsx} | 64 ++- .../modules/workflow/hooks/useUpdateStep.ts | 6 +- .../serverlessFunctionTestDataFamilyState.ts | 30 ++ .../src/modules/workflow/types/InputSchema.ts | 6 +- ...efaultFunctionInputFromInputSchema.test.ts | 29 -- .../getDefaultFunctionInputFromInputSchema.ts | 22 -- .../WorkflowEditActionFormCreateRecord.tsx | 100 ++--- .../WorkflowEditActionFormDeleteRecord.tsx | 90 +++-- .../WorkflowEditActionFormSendEmail.tsx | 190 ++++----- ...rkflowEditActionFormServerlessFunction.tsx | 373 +++++++++--------- ...EditActionFormServerlessFunctionFields.tsx | 85 ++++ .../WorkflowEditActionFormUpdateRecord.tsx | 90 +++-- ...rgeDefaultFunctionInputAndFunctionInput.ts | 32 -- .../src/pages/auth/PasswordReset.tsx | 4 +- .../admin-panel/SettingsAdminFeatureFlags.tsx | 4 +- .../data-model/SettingsObjectDetailPage.tsx | 3 +- .../ResetServerlessFunctionStatesEffect.tsx | 27 -- .../SettingsServerlessFunctionDetail.tsx | 112 ++---- ...ettingsServerlessFunctionDetailWrapper.tsx | 11 - .../graphql/utils/graphql-errors.util.ts | 2 +- .../base-typescript-project-input-schema.ts | 4 + .../update-workflow-version-step-input.dto.ts | 7 - .../workflow-version-step.resolver.ts | 7 +- .../dtos/serverless-function.dto.ts | 2 +- .../serverless-function.entity.ts | 2 +- .../code-introspection.service.spec.ts | 138 ------- .../code-introspection.exception.ts | 12 - .../code-introspection.module.ts | 9 - .../code-introspection.service.ts | 157 -------- .../workflow/common/workflow-common.module.ts | 2 - ...workflow-version-step.workspace-service.ts | 40 +- .../types/input-schema.type.ts | 6 +- .../types/output-schema.type.ts | 4 +- .../workflow-builder.module.ts | 2 - .../workflow-builder.workspace-service.ts | 84 +--- .../code/code.workflow-action.ts | 2 +- .../src/input/button/components/Button.tsx | 4 +- .../code-editor/components/CodeEditor.tsx | 58 ++- .../src/theme/constants/BorderDark.ts | 1 + .../src/theme/constants/BorderLight.ts | 1 + 95 files changed, 1537 insertions(+), 1611 deletions(-) delete mode 100644 packages/twenty-front/src/hooks/usePreventOverlapCallback.ts create mode 100644 packages/twenty-front/src/modules/action-menu/components/CmdEnterActionButton.tsx create mode 100644 packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormFieldInputContainer.tsx rename packages/twenty-front/src/modules/object-record/record-field/form-types/components/{StyledFormFieldInputInputContainer.tsx => FormFieldInputInputContainer.tsx} (87%) rename packages/twenty-front/src/modules/object-record/record-field/form-types/components/{StyledFormFieldInputRowContainer.tsx => FormFieldInputRowContainer.tsx} (77%) rename packages/twenty-front/src/modules/object-record/record-field/form-types/components/{StyledFormCompositeFieldInputContainer.tsx => FormNestedFieldInputContainer.tsx} (71%) delete mode 100644 packages/twenty-front/src/modules/object-record/record-field/form-types/components/StyledFormFieldInputContainer.tsx create mode 100644 packages/twenty-front/src/modules/serverless-functions/components/ServerlessFunctionExecutionResult.tsx create mode 100644 packages/twenty-front/src/modules/serverless-functions/constants/IndexFilePath.ts create mode 100644 packages/twenty-front/src/modules/serverless-functions/hooks/useTestServerlessFunction.ts create mode 100644 packages/twenty-front/src/modules/serverless-functions/utils/__tests__/getDefaultFunctionInputFromInputSchema.test.ts create mode 100644 packages/twenty-front/src/modules/serverless-functions/utils/__tests__/getFunctionInputFromSourceCode.test.ts create mode 100644 packages/twenty-front/src/modules/serverless-functions/utils/__tests__/getFunctionInputSchema.test.ts create mode 100644 packages/twenty-front/src/modules/serverless-functions/utils/__tests__/getFunctionOutputSchema.test.ts rename packages/twenty-front/src/modules/{workflow/workflow-actions => serverless-functions}/utils/__tests__/mergeDefaultFunctionInputAndFunctionInput.test.ts (52%) create mode 100644 packages/twenty-front/src/modules/serverless-functions/utils/getDefaultFunctionInputFromInputSchema.ts create mode 100644 packages/twenty-front/src/modules/serverless-functions/utils/getFunctionInputFromSourceCode.ts rename packages/twenty-front/src/modules/{workflow => serverless-functions}/utils/getFunctionInputSchema.ts (64%) create mode 100644 packages/twenty-front/src/modules/serverless-functions/utils/getFunctionOutputSchema.ts create mode 100644 packages/twenty-front/src/modules/serverless-functions/utils/mergeDefaultFunctionInputAndFunctionInput.ts delete mode 100644 packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsOutputMetadataInfo.tsx delete mode 100644 packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTabEffect.tsx delete mode 100644 packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionCodeEditorOutputParamsState.ts delete mode 100644 packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionInputState.ts delete mode 100644 packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionOutputState.ts create mode 100644 packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerFooter.tsx create mode 100644 packages/twenty-front/src/modules/workflow/components/WorkflowStepBody.tsx rename packages/twenty-front/src/modules/workflow/components/{WorkflowEditGenericFormBase.tsx => WorkflowStepHeader.tsx} (63%) create mode 100644 packages/twenty-front/src/modules/workflow/states/serverlessFunctionTestDataFamilyState.ts delete mode 100644 packages/twenty-front/src/modules/workflow/utils/__tests__/getDefaultFunctionInputFromInputSchema.test.ts delete mode 100644 packages/twenty-front/src/modules/workflow/utils/getDefaultFunctionInputFromInputSchema.ts create mode 100644 packages/twenty-front/src/modules/workflow/workflow-actions/components/WorkflowEditActionFormServerlessFunctionFields.tsx delete mode 100644 packages/twenty-front/src/modules/workflow/workflow-actions/utils/mergeDefaultFunctionInputAndFunctionInput.ts delete mode 100644 packages/twenty-front/src/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect.tsx delete mode 100644 packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetailWrapper.tsx create mode 100644 packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project-input-schema.ts delete mode 100644 packages/twenty-server/src/modules/code-introspection/__tests__/code-introspection.service.spec.ts delete mode 100644 packages/twenty-server/src/modules/code-introspection/code-introspection.exception.ts delete mode 100644 packages/twenty-server/src/modules/code-introspection/code-introspection.module.ts delete mode 100644 packages/twenty-server/src/modules/code-introspection/code-introspection.service.ts rename packages/twenty-server/src/modules/{code-introspection => workflow/workflow-builder}/types/input-schema.type.ts (76%) diff --git a/nx.json b/nx.json index 19c6f5462c..4dad794675 100644 --- a/nx.json +++ b/nx.json @@ -112,7 +112,7 @@ "outputs": ["{projectRoot}/{options.output-dir}"], "options": { "cwd": "{projectRoot}", - "command": "VITE_DISABLE_ESLINT_CHECKER=true storybook build", + "command": "VITE_DISABLE_TYPESCRIPT_CHECKER=true VITE_DISABLE_ESLINT_CHECKER=true storybook build", "output-dir": "storybook-static", "config-dir": ".storybook" } diff --git a/packages/twenty-front/project.json b/packages/twenty-front/project.json index 549e2c6956..0c9a8e2f75 100644 --- a/packages/twenty-front/project.json +++ b/packages/twenty-front/project.json @@ -69,7 +69,7 @@ "test": {}, "storybook:build": { "options": { - "env": { "NODE_OPTIONS": "--max_old_space_size=7000" } + "env": { "NODE_OPTIONS": "--max_old_space_size=8000" } }, "configurations": { "docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } }, diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index 986bad155b..58c136673f 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -1569,8 +1569,6 @@ export type UpdateServerlessFunctionInput = { }; export type UpdateWorkflowVersionStepInput = { - /** Boolean to check if we need to update stepOutput */ - shouldUpdateStepOutput?: InputMaybe; /** Step to update in JSON format */ step: Scalars['JSON']['input']; /** Workflow version ID */ diff --git a/packages/twenty-front/src/generated/graphql.tsx b/packages/twenty-front/src/generated/graphql.tsx index 2113798b76..07b3bbcc02 100644 --- a/packages/twenty-front/src/generated/graphql.tsx +++ b/packages/twenty-front/src/generated/graphql.tsx @@ -1277,8 +1277,6 @@ export type UpdateServerlessFunctionInput = { }; export type UpdateWorkflowVersionStepInput = { - /** Boolean to check if we need to update stepOutput */ - shouldUpdateStepOutput?: InputMaybe; /** Step to update in JSON format */ step: Scalars['JSON']; /** Workflow version ID */ diff --git a/packages/twenty-front/src/hooks/usePreventOverlapCallback.ts b/packages/twenty-front/src/hooks/usePreventOverlapCallback.ts deleted file mode 100644 index 0cd1c5b898..0000000000 --- a/packages/twenty-front/src/hooks/usePreventOverlapCallback.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useDebouncedCallback } from 'use-debounce'; - -export const usePreventOverlapCallback = ( - callback: () => Promise, - wait?: number, -) => { - const [isRunning, setIsRunning] = useState(false); - const [pendingRun, setPendingRun] = useState(false); - - const handleCallback = async () => { - if (isRunning) { - setPendingRun(true); - return; - } - setIsRunning(true); - try { - await callback(); - } finally { - setIsRunning(false); - } - }; - - useEffect(() => { - if (!isRunning && pendingRun) { - setPendingRun(false); - callback(); - } - }, [callback, isRunning, pendingRun, setPendingRun]); - - return useDebouncedCallback(handleCallback, wait); -}; diff --git a/packages/twenty-front/src/modules/action-menu/components/CmdEnterActionButton.tsx b/packages/twenty-front/src/modules/action-menu/components/CmdEnterActionButton.tsx new file mode 100644 index 0000000000..ae21df17c4 --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/components/CmdEnterActionButton.tsx @@ -0,0 +1,30 @@ +import { Button } from 'twenty-ui'; +import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys'; +import { Key } from 'ts-key-enum'; +import { RightDrawerHotkeyScope } from '@/ui/layout/right-drawer/types/RightDrawerHotkeyScope'; + +export const CmdEnterActionButton = ({ + title, + onClick, +}: { + title: string; + onClick: () => void; +}) => { + useScopedHotkeys( + [`${Key.Control}+${Key.Enter}`, `${Key.Meta}+${Key.Enter}`], + () => onClick(), + RightDrawerHotkeyScope.RightDrawer, + [onClick], + ); + + return ( +