@fluidgrids/fe-sdk 0.0.0-stage → 2026.1203.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +564 -2
- package/dist/ActivityOptionsFields-C2u-hY2U.js +142 -0
- package/dist/AiStudioPage-B_hNTj-_.js +1137 -0
- package/dist/ApprovalInboxPage-ClITra3n.js +1312 -0
- package/dist/ChoiceSelect-LkK-uS9J.js +65 -0
- package/dist/ConfirmActionDialog-DHWTDRbp.js +31 -0
- package/dist/ConnectionFormDialog-C0kDgcrZ.js +153 -0
- package/dist/CreateFluidgridsTagDocument-Dtp9KPLJ.js +1055 -0
- package/dist/DataSinkDashboardPage-b4ezeqa6.js +278 -0
- package/dist/DataTablesPage-C1d9YGHz.js +5575 -0
- package/dist/DateTimeField-B1qR4ruo.js +51 -0
- package/dist/Disclosure-BNKij7-v.js +45 -0
- package/dist/ElementLibraryPage-8jNO6YmE.js +2256 -0
- package/dist/ElementLibrarySequenceDocument-B-W8SPzn.js +3979 -0
- package/dist/EnsureThemeProvider-BvlNjAd0.js +24 -0
- package/dist/EntityTagBadge-1OlP6p0c.js +25 -0
- package/dist/EntityTagPicker-BBrU5cE0.js +137 -0
- package/dist/ExecuteStepDocument-B4j1mdRT.js +189 -0
- package/dist/ExecutionDetailDocument-D6QuM-kp.js +875 -0
- package/dist/ExecutionDetailPage-D4CBtFdo.js +12217 -0
- package/dist/ExecutionDetailPage-DvQ667OE.d.ts +10 -0
- package/dist/ExecutionStatusBadge-BsDVor9t.js +221 -0
- package/dist/ExecutionsListDocument-Dan7ZiqB.js +459 -0
- package/dist/ExecutionsListPage-B3XT8ITL.js +4307 -0
- package/dist/FailureTriagePanel-DOJMaJ0n.js +1285 -0
- package/dist/FileDownloadUrlDocument-CVOYKcL5.js +92 -0
- package/dist/FluidGridsDocsLink-bX0Hnhxr.js +66 -0
- package/dist/FluidGridsMark-CE2blT7K.js +74 -0
- package/dist/HeldLoadRegion-BtTxbvOW.js +34 -0
- package/dist/HistoryPage-BLoRpJ1R.d.ts +6 -0
- package/dist/HistoryPage-BSBISXoj.js +2835 -0
- package/dist/Icon-BtQ0HXLh.js +160 -0
- package/dist/InsightsPage-D7ybj8N9.js +11245 -0
- package/dist/IsolationSetting-vy911E8b.js +1153 -0
- package/dist/LibraryParts-DOeNgR8A.js +413 -0
- package/dist/ManagedAiPolicyAuthority-BxwJ3ptd.js +40 -0
- package/dist/ManagedAiPolicyAuthority-DM3t3wNr.d.ts +18 -0
- package/dist/ManagedAiPolicyAuthorityContext-CNkxIOZ1.js +10 -0
- package/dist/McpTriggerServers-BCPCAOWB.js +459 -0
- package/dist/MissingNodesInstallModal-rO_SEDrC.js +224 -0
- package/dist/NavigationV2Provider-DCDt35eG.js +17 -0
- package/dist/NodeSchemaIntrospectionDocument-C1vAIcHd.js +95 -0
- package/dist/NodesPage-DEbnz9iU.d.ts +6 -0
- package/dist/NodesPage-O7KeeKtd.js +653 -0
- package/dist/OfflineIcon-TwMKYWjA.js +207 -0
- package/dist/OpenTemplateAsCodeButton-BhWJWIF3.js +94 -0
- package/dist/PaidTemplateConfirm-_G3ag6S4.js +28 -0
- package/dist/PublishCustomNodeAction-CIySbK4c.js +134 -0
- package/dist/RecordTaskDialog-BkpCDvhR.js +2078 -0
- package/dist/RunActionsMenu-DodOgIQm.js +59 -0
- package/dist/RunnerStatusPill-C1v967iq.js +24 -0
- package/dist/RunnersPage-dB0RSdY_.js +1929 -0
- package/dist/SandboxRuntimeExhaustedNotice-BFOIF93C.js +120 -0
- package/dist/SchedulesPage-DPWr1yvf.js +1607 -0
- package/dist/SearchBox-BGtYjvfs.js +49 -0
- package/dist/SequenceEditor-CFiHeHkR.js +497 -0
- package/dist/SettingsPage-0CQBNPZV.js +8695 -0
- package/dist/StewardPages-DAJhepen.js +47 -0
- package/dist/StewardRunImportPanel-Kva2DO0u.js +2844 -0
- package/dist/StoreTemplateCardCompact-CHn5kP7A.js +2166 -0
- package/dist/TagFilterSelect-CyA8QrS7.js +42 -0
- package/dist/TaskQueuesPage-DdnDCyat.js +3571 -0
- package/dist/TechnicalDetails-B0Oi4aZw.js +19 -0
- package/dist/TemplateConfigurationModal-CdvCYJLM.js +332 -0
- package/dist/TemplateDetailPanel-CbiKciuB.js +222 -0
- package/dist/TemplatePreview-cx7-NOeG.js +868 -0
- package/dist/TemplatesPage-BG3H-6v6.d.ts +10 -0
- package/dist/TemplatesPage-BVQpGYIV.js +3251 -0
- package/dist/TerminateExecutionDocument-B_HKNVrN.js +581 -0
- package/dist/TranslationBridge-Bd4aJKMs.d.ts +11 -0
- package/dist/TranslationBridge-Da-TPgQm.js +68 -0
- package/dist/TriggerWorkflowDocument-D9Km2Vv2.js +460 -0
- package/dist/UiSequencePickerSequenceDocument-BSYnSDV7.js +607 -0
- package/dist/UiStepScreenshot-Qh4QMyUp.js +146 -0
- package/dist/UsageTimeSeriesDocument-DcInx9-z.js +177 -0
- package/dist/VariablesPage-ChfGuW22.js +2243 -0
- package/dist/VersionDiffDialog-Bd2AeUwf.js +1702 -0
- package/dist/VersionLifecycleBar-BBeWVtz-.js +143 -0
- package/dist/WebhookDeliveriesPage-D66bua0j.js +1563 -0
- package/dist/WorkflowBuilder-B6wQD1TK.js +539 -0
- package/dist/WorkflowBuilder-DR4ku8Tr.js +1611 -0
- package/dist/WorkflowDefinitionDocument-DZLbTPUZ.js +321 -0
- package/dist/WorkflowEmbed-BXfFGy0i.js +708 -0
- package/dist/WorkflowEmbed-Cbqe1s1z.d.ts +6 -0
- package/dist/WorkflowPinnedDataDocument-BODT5omd.js +782 -0
- package/dist/WorkflowProposalCard-BruukdeF.js +96 -0
- package/dist/WorkflowProposalDocument-BdUbsrd0.js +620 -0
- package/dist/WorkflowSearchRedirect-C7zJ2MKH.js +40 -0
- package/dist/WorkflowSettingsDrawer-MVU1BKfY.d.ts +18 -0
- package/dist/WorkflowSettingsDrawer-gazs97WR.js +196 -0
- package/dist/WorkflowShareDialog-e8jJtLjU.js +469 -0
- package/dist/WorkflowVersionsDocument-DRVOp8Uj.js +3213 -0
- package/dist/WorkflowsList--hR2_8gf.js +4593 -0
- package/dist/WorkflowsList-CcNDQge5.d.ts +6 -0
- package/dist/WorkflowsListPageDocument-CnzcQm_o.js +934 -0
- package/dist/addonCatalog-CbZS4deh.js +58 -0
- package/dist/addonCatalog-sjlonAmR.d.ts +15 -0
- package/dist/addons.d.ts +3 -0
- package/dist/addons.js +4 -0
- package/dist/agent-form-Bfvm32j1.js +83 -0
- package/dist/agent-tools.d.ts +3 -0
- package/dist/agent-tools.js +5 -0
- package/dist/agentTools-CyL7DLOF.js +320 -0
- package/dist/ai-usage-BrxDgvdR.js +240 -0
- package/dist/aiCreditsBridge-BuE92tKo.js +49 -0
- package/dist/api-BKq-nIOZ.js +2286 -0
- package/dist/api-Ol7I8NxE.js +8289 -0
- package/dist/apollo-type-policies.d.ts +11 -0
- package/dist/apollo-type-policies.js +64 -0
- package/dist/askAboutBridge-ByYsQams.js +106 -0
- package/dist/askQuestions-Cmx7VnMm.js +742 -0
- package/dist/assert-rules-lfYEMc99.js +318 -0
- package/dist/assistant.d.ts +94 -0
- package/dist/assistant.js +99 -0
- package/dist/attach-node-helpers-HDKQOtrD.js +32 -0
- package/dist/badge-CXfPhoMH.js +26 -0
- package/dist/basil.generated-BK-EHbwN.js +10 -0
- package/dist/browser-steps-DMpS5TyB.js +533 -0
- package/dist/builderTimings-pvGnK1m-.js +510 -0
- package/dist/button-DG7y_FVJ.js +48 -0
- package/dist/canvasNoteTools-BxuP_AYO.js +137 -0
- package/dist/card-Bomy_1UG.js +44 -0
- package/dist/catalogGrid-BOrfMgi-.js +41 -0
- package/dist/channel-CPyQ1NR1.js +212 -0
- package/dist/chips-CvNrYJZa.js +27 -0
- package/dist/client-holder-C0M5Cfwl.js +68 -0
- package/dist/cn-QqidFIgr.js +10 -0
- package/dist/code-editor-diagnostics-Zr0cIcx1.js +46 -0
- package/dist/code-editor-field-x_JrY8KR.js +113 -0
- package/dist/codec-client-DPuD6mw7.js +515 -0
- package/dist/conditionBuilder-DwfEF0Q-.js +1144 -0
- package/dist/config-DO68jw5k.js +322 -0
- package/dist/constants-DgbVc24O.d.ts +296 -0
- package/dist/constants-DlRnHBfQ.js +217 -0
- package/dist/convert-browser-action-pfecelF7.js +347 -0
- package/dist/convert-dialog-B_o22NiJ.js +382 -0
- package/dist/create-workflow-first-Azg3JUdX.js +120 -0
- package/dist/definition-canvas-Bsda-rDT.js +31 -0
- package/dist/dialog-BVd152GS.js +94 -0
- package/dist/durable-nodes-BXyYCLxT.js +91 -0
- package/dist/duration-CDb7-mT_.js +33 -0
- package/dist/edge-mapper-wEAdGVU2.js +4477 -0
- package/dist/element-library-DkSlg_VE.js +727 -0
- package/dist/entities-I_0kio3q.js +38 -0
- package/dist/error-advice-QLr5NCm7.js +65 -0
- package/dist/errors-ClKb5sEt.js +188 -0
- package/dist/executions.d.ts +3 -0
- package/dist/executions.js +5 -0
- package/dist/feature-flags-B2qetXKd.js +385 -0
- package/dist/field-label-DPZRmE_B.js +153 -0
- package/dist/firstWorkflow-C_h0KMB2.js +133 -0
- package/dist/flags.d.ts +3 -0
- package/dist/flags.js +4 -0
- package/dist/flow-builder-DIvLOhz0.js +28038 -0
- package/dist/flow-store-holder-CUN7Terz.js +52 -0
- package/dist/fluent.generated-CA_e6-4l.js +14 -0
- package/dist/fluidgridsEvents-bbEQbwU6.js +175 -0
- package/dist/fluidgridsTheme-DUhvOgoy.js +297 -0
- package/dist/global-client-BQPuFrFa.js +433 -0
- package/dist/global-operations-BG6YgxrM.js +136 -0
- package/dist/graphql-types-UTYtujY9.js +21358 -0
- package/dist/history.d.ts +3 -0
- package/dist/history.js +4 -0
- package/dist/index-AoJAa5vU.d.ts +164958 -0
- package/dist/index-DEMT3iAM.d.ts +120 -0
- package/dist/index-ROZzNGyY.d.ts +76 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +8123 -0
- package/dist/ion.generated-mbajjcAg.js +10 -0
- package/dist/label-Lzb8ZXf_.js +29 -0
- package/dist/labels-rXd9gYQz.js +1236 -0
- package/dist/liveCanvas-D5ytXDp8.js +103 -0
- package/dist/logos.generated-X6_0kjVR.js +21 -0
- package/dist/logs-panel-Cw0DkG0l.js +468 -0
- package/dist/lucide.generated-B6NVd3GT.js +29 -0
- package/dist/marksStore-a9oIMMot.js +175 -0
- package/dist/mcp-trigger-D0nRdvq5.js +307 -0
- package/dist/mdi.generated-D1BV74d6.js +292 -0
- package/dist/menus-CU3hDGYl.js +160 -0
- package/dist/mynaui.generated-DMWr5cXz.js +66 -0
- package/dist/navigation-v2.d.ts +3 -0
- package/dist/navigation-v2.js +5 -0
- package/dist/node-detail-view-Cgm5H1P-.js +1372 -0
- package/dist/node-editor-tab-body-CZ0fVuVP.js +187 -0
- package/dist/node-operation-selection-CdV3KI_V.js +3534 -0
- package/dist/node-registry-refresh-s3okf83X.js +27 -0
- package/dist/node-role-TMbnkmeP.js +132 -0
- package/dist/node-type-icon-BZa8n4iG.js +33 -0
- package/dist/nodes.d.ts +3 -0
- package/dist/nodes.js +4 -0
- package/dist/notesKey-5EaREBGA.js +12 -0
- package/dist/observability.d.ts +3 -0
- package/dist/observability.js +5 -0
- package/dist/offset-pages-zghoClB3.js +55 -0
- package/dist/operations-BBmT9ToP.js +663 -0
- package/dist/operations-WxRJWeqO.js +3133 -0
- package/dist/output-files-Ba8bu5lv.js +196 -0
- package/dist/page-operation-DrWuhd6Y.js +129 -0
- package/dist/page-twins.d.ts +13 -0
- package/dist/page-twins.js +186 -0
- package/dist/pageControlSpecs-DZJ9K37m.js +134 -0
- package/dist/pageControlsBridge-0pX9s-3k.js +54 -0
- package/dist/pageControlsBridge-DAuT3w7L.d.ts +36 -0
- package/dist/panels-PfBBAToE.js +346 -0
- package/dist/parts-B7fBcw-B.js +346 -0
- package/dist/popover-Dms9Vz3j.js +3389 -0
- package/dist/preloadable-lazy-Pp47mqQ9.js +65 -0
- package/dist/proactive.d.ts +66 -0
- package/dist/proactive.js +237 -0
- package/dist/quick-config-panel-DFd77xho.js +451 -0
- package/dist/quota-DeA_CJ2e.js +175 -0
- package/dist/quota.d.ts +3 -0
- package/dist/quota.js +4 -0
- package/dist/read-only-context-Dt9N9SIG.js +18 -0
- package/dist/relative-time-Dxt8ZIIu.js +55 -0
- package/dist/results-CwK_yDxK.js +325 -0
- package/dist/rolldown-runtime-hDbaFkMy.js +18 -0
- package/dist/route-data.d.ts +12 -0
- package/dist/route-data.js +69 -0
- package/dist/route-match-C-0_EnAt.d.ts +5 -0
- package/dist/route-match-DMkUICYV.js +41 -0
- package/dist/route-preload-C4DlGoCd.js +120 -0
- package/dist/run-display-UjLAoYqQ.js +81 -0
- package/dist/run-history-arGiHzGU.js +285 -0
- package/dist/run-list-links-DJn4Mf1T.js +98 -0
- package/dist/run-mode-USmM0-Uo.js +82 -0
- package/dist/run-parity-CWXqEJqM.js +144 -0
- package/dist/runsQuota-B6SyTbne.js +100 -0
- package/dist/runsQuota-DsniKiSg.d.ts +20 -0
- package/dist/safe-expression-Cw7-SCsm.js +1251 -0
- package/dist/save-status-store-C7nEYpfb.js +631 -0
- package/dist/schedule-panel-B4GYXzXQ.js +13774 -0
- package/dist/schedule-rules-ggVKRkBH.js +358 -0
- package/dist/secrets-Re_wSiE3.js +153 -0
- package/dist/settings.d.ts +4 -0
- package/dist/settings.js +6 -0
- package/dist/shared-DAWGGMSM.js +177 -0
- package/dist/sidebar-node-editor-6eSSgCzc.js +178 -0
- package/dist/solar.generated-CGYuUQAC.js +10 -0
- package/dist/stableTabbedDialog-BBhrfXGe.js +20 -0
- package/dist/start-url-CT6Yz96K.js +24 -0
- package/dist/status-CessxGpm.js +55 -0
- package/dist/store-icon-OctYp5zP.js +155 -0
- package/dist/styles-WGmTnZ2n.js +26 -0
- package/dist/styles.css +139 -0
- package/dist/svg-spinners.generated-CIPT7IhM.js +10 -0
- package/dist/template-code-CzN6JWNV.js +191 -0
- package/dist/template-graph-DLF9dygU.js +20 -0
- package/dist/template-preview-DcIIKOOL.js +32 -0
- package/dist/template-price-CdUHZRMF.js +40 -0
- package/dist/templates.d.ts +3 -0
- package/dist/templates.js +5 -0
- package/dist/theme-provider-CntfC4_i.js +23 -0
- package/dist/transient-DgZfhDfN.js +57 -0
- package/dist/typed-calls-C5tO03wq.js +26 -0
- package/dist/ui-script-By74Guk3.js +1094 -0
- package/dist/ui-script-editor-CqPu2bCN.js +2447 -0
- package/dist/ui-step-fix-8uM2_Hft.js +67 -0
- package/dist/ui-step-fix-store-CcO1FdRx.js +19 -0
- package/dist/ui-step-run-context-o7bLE6KP.js +46 -0
- package/dist/ui-target-editor-D2JhB_lD.js +673 -0
- package/dist/uiMarkTools-CSznnO1i.js +1054 -0
- package/dist/upgradePrompt-BAFBKKW5.js +72 -0
- package/dist/use-bare-node-registry-O6mKJO_n.js +11498 -0
- package/dist/use-browser-available-hj8wc3Kb.js +241 -0
- package/dist/use-edge-mapper-schemas-Bonofxow.js +496 -0
- package/dist/use-extension-bridge-B9ZreOkQ.js +608 -0
- package/dist/use-mobile-BTqCUjzS.js +27 -0
- package/dist/use-sdk-query-C697xZVv.js +116 -0
- package/dist/use-workflow-code-editor-CFoRFrZ5.js +753 -0
- package/dist/useActionParam-B2tU2BlY.js +85 -0
- package/dist/useAgentTokenStream-Bko_J0d0.js +4217 -0
- package/dist/useBrowserClients-3v95-gSh.js +103 -0
- package/dist/useCodeWorkflowInsights-w0tz9Ap_.js +600 -0
- package/dist/useConnections-DsgEJs05.js +439 -0
- package/dist/useDebouncedValue-BFekcv6n.js +18 -0
- package/dist/useDurableParity-8fnMZmBc.js +1787 -0
- package/dist/useEntityTags-D0spL6Ut.js +460 -0
- package/dist/useExecutions-2u5nGJJk.js +681 -0
- package/dist/useFluidGridsAnalytics-VM8lAi2x.js +238 -0
- package/dist/useGlobalStoreClient-BTdhkA2I.js +24 -0
- package/dist/useHumanRequests-zlYDp3l1.js +221 -0
- package/dist/useNavigationV2-C2WeqN7d.js +29 -0
- package/dist/useNavigationV2-DANUmg12.d.ts +9 -0
- package/dist/useObservability-BRlQ0tOA.js +285 -0
- package/dist/useRequestedProposal-B7uPXfZB.js +51 -0
- package/dist/useRunHistory-CXCMUPyf.js +2759 -0
- package/dist/useRunLive-D0JvVZT2.js +1060 -0
- package/dist/useRunnerList-Dbi59i1K.js +446 -0
- package/dist/useRunners-URUc5quU.js +173 -0
- package/dist/useRunsPage-DG656UCK.js +2709 -0
- package/dist/useVariables-BIelxcWr.js +463 -0
- package/dist/useVersionHistoryData-CTjqVw7l.js +292 -0
- package/dist/useWorkflowCodeExport-pqxyLHD1.js +522 -0
- package/dist/useWorkflowListExport-hcZNvTaB.js +232 -0
- package/dist/useWorkflowOrganization-CpBbOrs7.js +1772 -0
- package/dist/useWorkflowProposal-BH0VdNMA.js +3280 -0
- package/dist/useWorkflows-Cvg-Z_IE.js +1606 -0
- package/dist/utils-fvBb5qOD.js +89 -0
- package/dist/webhook-deliveries-AvQujaZy.js +99 -0
- package/dist/workflow-builder-CJygVkVv.d.ts +2 -0
- package/dist/workflow-builder.d.ts +3 -0
- package/dist/workflow-builder.js +8 -0
- package/dist/workflow-code-transfer-Bsy0JKAZ.js +323 -0
- package/dist/workflow-embed.d.ts +3 -0
- package/dist/workflow-embed.js +4 -0
- package/dist/workflow-git-sync--K9ZsPDC.js +263 -0
- package/dist/workflow-host.d.ts +6 -0
- package/dist/workflow-host.js +11 -0
- package/dist/workflow-pages-D-7ByLTB.d.ts +68 -0
- package/dist/workflow-pages.d.ts +3 -0
- package/dist/workflow-pages.js +115 -0
- package/dist/workflow-preview-canvas-CO8yzdE3.js +848 -0
- package/dist/workflow-preview.d.ts +65 -0
- package/dist/workflow-preview.js +4 -0
- package/dist/workflow-route.d.ts +33 -0
- package/dist/workflow-route.js +4 -0
- package/dist/workflow-save-state-D0l-DkLf.js +767 -0
- package/dist/workflow-transfer-CQnQC-ke.js +104 -0
- package/dist/workflowRouteData-BkfVOc-O.js +169 -0
- package/dist/workflows-list.d.ts +10 -0
- package/dist/workflows-list.js +5 -0
- package/package.json +320 -4
|
@@ -0,0 +1,2447 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
|
|
3
|
+
import { t as useIsMobile } from "./use-mobile-BTqCUjzS.js";
|
|
4
|
+
import { A as walkDraft, C as stepAtPath, D as uiScriptProblems, E as stepSentence, O as uiScriptText, S as setStepField, T as stepPathIn, _ as readableStepNumber, a as changeStepAction, b as replaceStep, c as emptyUiScript, d as isEmptyUiScript, f as isSavableUiScript, g as readUiScriptSetting, i as blockSteps, j as UI_STEP_ACTION_TEXTS, l as insertStep, m as newStep, n as MAIN_BLOCK, o as draftElements, p as moveStep, r as STEP_BLOCKS, s as duplicateStep, t as CLEANUP_BLOCK, u as isDraftStep, v as removeStep, x as serialiseUiScript, y as renameScriptInput } from "./ui-script-By74Guk3.js";
|
|
5
|
+
import { Cn as noteRecordedNodeEdit, Sn as followRecordedNode, hn as pathToExpression, j as useRunGuard, ot as FIELD_PATH_MIME } from "./use-bare-node-registry-O6mKJO_n.js";
|
|
6
|
+
import { a as uiInputClass, i as uiIconButton, n as UiTargetQuickField, o as uiLinkButton, r as BufferedInput, s as uiSmallLabel, t as UiTargetMethodsEditor } from "./ui-target-editor-D2JhB_lD.js";
|
|
7
|
+
import { t as readTyped } from "./typed-calls-C5tO03wq.js";
|
|
8
|
+
import { n as UiSequencePickerSequencesDocument, r as UiSequencePickerApplicationsDocument, t as UiSequencePickerSequenceDocument } from "./UiSequencePickerSequenceDocument-BSYnSDV7.js";
|
|
9
|
+
import { U as useFlowStore } from "./node-operation-selection-CdV3KI_V.js";
|
|
10
|
+
import { r as useSaveStatusStore } from "./save-status-store-C7nEYpfb.js";
|
|
11
|
+
import { t as useUiStepFixStore } from "./ui-step-fix-store-CcO1FdRx.js";
|
|
12
|
+
import { t as fixIsSaved } from "./ui-step-fix-8uM2_Hft.js";
|
|
13
|
+
import { n as UiStepScreenshot } from "./UiStepScreenshot-Qh4QMyUp.js";
|
|
14
|
+
import { n as useUiStepRunner } from "./ui-step-run-context-o7bLE6KP.js";
|
|
15
|
+
import { v as useRpaWebEnabled } from "./feature-flags-B2qetXKd.js";
|
|
16
|
+
import { t as useFluidGridsAnalytics } from "./useFluidGridsAnalytics-VM8lAi2x.js";
|
|
17
|
+
import { t as canUseBridgeHere } from "./use-extension-bridge-B9ZreOkQ.js";
|
|
18
|
+
import { i as firstPageOf, r as appendRecording, t as RecordMoreDialog } from "./RecordTaskDialog-BkpCDvhR.js";
|
|
19
|
+
import { Children, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
20
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import { useShallow } from "zustand/shallow";
|
|
22
|
+
import { ChevronDown, ChevronRight, CircleDot, MonitorSmartphone, MoreHorizontal, Play, Plus, X } from "lucide-react";
|
|
23
|
+
import { cn } from "@burdenoff/fe-libs/utils";
|
|
24
|
+
import { ThemedSelect } from "@burdenoff/fe-libs/ui";
|
|
25
|
+
|
|
26
|
+
// src/builder/components/ndv/ui-script-editor/ui-value-input.tsx
|
|
27
|
+
/**
|
|
28
|
+
* One value of a UI script step (a URL, the text to type, an option): plain
|
|
29
|
+
* text, one of the script's inputs, one of its variables, or (for anything
|
|
30
|
+
* else) the expression as JSON. Script expressions are JSON trees the browser
|
|
31
|
+
* evaluates; workflow data reaches them through the script's inputs, which the
|
|
32
|
+
* node maps to workflow values (`inputs` setting). Dropping a field from the
|
|
33
|
+
* data panel onto a value does that in one go: it declares an input named
|
|
34
|
+
* after the field, maps it to the field, and points the value at the input.
|
|
35
|
+
*/
|
|
36
|
+
const VALUE_MODES = [
|
|
37
|
+
"text",
|
|
38
|
+
"input",
|
|
39
|
+
"var",
|
|
40
|
+
"json"
|
|
41
|
+
];
|
|
42
|
+
function isValueMode(value) {
|
|
43
|
+
return VALUE_MODES.includes(value);
|
|
44
|
+
}
|
|
45
|
+
function isRecord$5(value) {
|
|
46
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
47
|
+
}
|
|
48
|
+
/** How a value is shown: as text, an input, a variable or JSON. */
|
|
49
|
+
function valueMode(value) {
|
|
50
|
+
if (value === void 0 || typeof value === "string") return "text";
|
|
51
|
+
if (isRecord$5(value) && typeof value.input === "string" && !value.path) return "input";
|
|
52
|
+
if (isRecord$5(value) && typeof value.var === "string" && !value.path) return "var";
|
|
53
|
+
return "json";
|
|
54
|
+
}
|
|
55
|
+
/** The value switched to another mode, keeping what can be kept. */
|
|
56
|
+
function valueInMode(value, mode, names) {
|
|
57
|
+
if (mode === valueMode(value)) return value;
|
|
58
|
+
switch (mode) {
|
|
59
|
+
case "text": return typeof value === "number" || typeof value === "boolean" ? String(value) : "";
|
|
60
|
+
case "input": return { input: names.inputs[0] ?? "" };
|
|
61
|
+
case "var": return { var: names.variables[0] ?? "" };
|
|
62
|
+
default: return value === void 0 ? "" : value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** A script input name made from a dropped field path (`$json.invoice.number` gives `number`). */
|
|
66
|
+
function inputNameFromPath(path) {
|
|
67
|
+
const cleaned = (path.split(/[.[\]]/).filter(Boolean).pop() ?? "value").replace(/[^A-Za-z0-9_]/g, "_");
|
|
68
|
+
return (/^[A-Za-z_]/.test(cleaned) ? cleaned : `v_${cleaned}`).slice(0, 64) || "value";
|
|
69
|
+
}
|
|
70
|
+
function UiValueInput({ label, value, onChange, inputs, variables, onDropField, placeholder, testId, readOnly }) {
|
|
71
|
+
const tr = useTr();
|
|
72
|
+
const [asJson, setAsJson] = useState(() => valueMode(value) === "json");
|
|
73
|
+
const mode = asJson ? "json" : valueMode(value);
|
|
74
|
+
const [jsonText, setJsonText] = useState(() => mode === "json" ? JSON.stringify(value) : "");
|
|
75
|
+
const [jsonInvalid, setJsonInvalid] = useState(false);
|
|
76
|
+
const [firstWritten] = useState(() => JSON.stringify(value) ?? "");
|
|
77
|
+
const written = useRef(firstWritten);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const current = JSON.stringify(value) ?? "";
|
|
80
|
+
if (current === written.current) return;
|
|
81
|
+
written.current = current;
|
|
82
|
+
setAsJson(valueMode(value) === "json");
|
|
83
|
+
setJsonText(valueMode(value) === "json" ? current : "");
|
|
84
|
+
setJsonInvalid(false);
|
|
85
|
+
}, [value]);
|
|
86
|
+
const write = (next) => {
|
|
87
|
+
written.current = JSON.stringify(next) ?? "";
|
|
88
|
+
onChange(next);
|
|
89
|
+
};
|
|
90
|
+
const onDrop = (event) => {
|
|
91
|
+
const path = event.dataTransfer.getData(FIELD_PATH_MIME);
|
|
92
|
+
if (!path || !onDropField || readOnly) return;
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
event.stopPropagation();
|
|
95
|
+
const next = onDropField(path);
|
|
96
|
+
setAsJson(valueMode(next) === "json");
|
|
97
|
+
write(next);
|
|
98
|
+
};
|
|
99
|
+
const names = {
|
|
100
|
+
inputs,
|
|
101
|
+
variables
|
|
102
|
+
};
|
|
103
|
+
const select = (next) => {
|
|
104
|
+
setAsJson(next === "json");
|
|
105
|
+
const changed = next === "json" ? value ?? "" : valueInMode(value, next, names);
|
|
106
|
+
if (next === "json") setJsonText(JSON.stringify(changed));
|
|
107
|
+
write(changed);
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
110
|
+
className: "flex flex-col gap-0.5",
|
|
111
|
+
onDragOver: onDropField ? (event) => event.preventDefault() : void 0,
|
|
112
|
+
onDrop: onDropField ? onDrop : void 0,
|
|
113
|
+
"data-testid": testId,
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsx("span", {
|
|
116
|
+
className: uiSmallLabel,
|
|
117
|
+
children: label
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsxs("div", {
|
|
120
|
+
className: "flex min-w-0 items-center gap-1",
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ jsxs(ThemedSelect, {
|
|
123
|
+
value: mode,
|
|
124
|
+
disabled: readOnly,
|
|
125
|
+
"aria-label": tr("fluidgrids.builder.uiScript.value.kind", "Kind of value"),
|
|
126
|
+
onChange: (event) => isValueMode(event.target.value) && select(event.target.value),
|
|
127
|
+
className: cn(uiInputClass, "w-28 shrink-0"),
|
|
128
|
+
"data-testid": `${testId}-mode`,
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ jsx("option", {
|
|
131
|
+
value: "text",
|
|
132
|
+
children: tr("fluidgrids.builder.uiScript.value.text", "Text")
|
|
133
|
+
}),
|
|
134
|
+
/* @__PURE__ */ jsx("option", {
|
|
135
|
+
value: "input",
|
|
136
|
+
children: tr("fluidgrids.builder.uiScript.value.input", "Input")
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ jsx("option", {
|
|
139
|
+
value: "var",
|
|
140
|
+
children: tr("fluidgrids.builder.uiScript.value.variable", "Variable")
|
|
141
|
+
}),
|
|
142
|
+
/* @__PURE__ */ jsx("option", {
|
|
143
|
+
value: "json",
|
|
144
|
+
children: tr("fluidgrids.builder.uiScript.value.expression", "Expression")
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
}),
|
|
148
|
+
mode === "text" && /* @__PURE__ */ jsx("input", {
|
|
149
|
+
type: "text",
|
|
150
|
+
value: typeof value === "string" ? value : "",
|
|
151
|
+
placeholder,
|
|
152
|
+
readOnly,
|
|
153
|
+
"aria-label": label,
|
|
154
|
+
onChange: (event) => write(event.target.value),
|
|
155
|
+
className: cn("rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50", "min-w-0 flex-1"),
|
|
156
|
+
"data-testid": `${testId}-text`
|
|
157
|
+
}),
|
|
158
|
+
(mode === "input" || mode === "var") && /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
159
|
+
value: isRecord$5(value) ? String(mode === "input" ? value.input : value.var) : "",
|
|
160
|
+
disabled: readOnly,
|
|
161
|
+
"aria-label": label,
|
|
162
|
+
onChange: (event) => write(mode === "input" ? { input: event.target.value } : { var: event.target.value }),
|
|
163
|
+
className: cn("rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50", "min-w-0 flex-1"),
|
|
164
|
+
"data-testid": `${testId}-name`,
|
|
165
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
166
|
+
value: "",
|
|
167
|
+
children: mode === "input" ? tr("fluidgrids.builder.uiScript.value.pickInput", "Choose an input") : tr("fluidgrids.builder.uiScript.value.pickVariable", "Choose a variable")
|
|
168
|
+
}), (mode === "input" ? inputs : variables).map((name) => /* @__PURE__ */ jsx("option", {
|
|
169
|
+
value: name,
|
|
170
|
+
children: name
|
|
171
|
+
}, name))]
|
|
172
|
+
}),
|
|
173
|
+
mode === "json" && /* @__PURE__ */ jsx("input", {
|
|
174
|
+
type: "text",
|
|
175
|
+
value: jsonText,
|
|
176
|
+
readOnly,
|
|
177
|
+
"aria-label": label,
|
|
178
|
+
"aria-invalid": jsonInvalid,
|
|
179
|
+
onChange: (event) => {
|
|
180
|
+
setJsonText(event.target.value);
|
|
181
|
+
try {
|
|
182
|
+
write(JSON.parse(event.target.value));
|
|
183
|
+
setJsonInvalid(false);
|
|
184
|
+
} catch {
|
|
185
|
+
setJsonInvalid(true);
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
className: cn("rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50", "min-w-0 flex-1 font-mono"),
|
|
189
|
+
"data-testid": `${testId}-json`
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
}),
|
|
193
|
+
mode === "json" && jsonInvalid && /* @__PURE__ */ jsx("span", {
|
|
194
|
+
className: "text-[11px] text-[var(--color-status-error-text)]",
|
|
195
|
+
children: tr("fluidgrids.builder.uiScript.value.invalidJson", "Not valid JSON yet. An expression is a JSON tree such as {\"op\": \"concat\", \"args\": [{\"input\": \"first\"}, \" \", {\"input\": \"last\"}]}.")
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/builder/components/ndv/ui-script-editor/ui-script-io.tsx
|
|
202
|
+
/**
|
|
203
|
+
* The script's inputs and outputs (spec 05 section 2, contracts section 3):
|
|
204
|
+
* inputs are values the workflow gives the script when the node starts, each
|
|
205
|
+
* mapped in the node's `inputs` setting to a workflow value or expression;
|
|
206
|
+
* outputs are values the script returns, read from its variables. Secrets are
|
|
207
|
+
* never inputs: a Type secret step names a connection instead.
|
|
208
|
+
*/
|
|
209
|
+
function isRecord$4(value) {
|
|
210
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
211
|
+
}
|
|
212
|
+
/** The draft's entries of a list field (`inputs`, `outputs`, `variables`) with a name. */
|
|
213
|
+
function namedEntries(draft, field) {
|
|
214
|
+
const list = draft[field];
|
|
215
|
+
return Array.isArray(list) ? list.filter((entry) => isRecord$4(entry) && typeof entry.name === "string") : [];
|
|
216
|
+
}
|
|
217
|
+
/** The draft with a list field replaced; an empty list removes it. */
|
|
218
|
+
function withEntries(draft, field, entries) {
|
|
219
|
+
const next = { ...draft };
|
|
220
|
+
if (entries.length === 0) delete next[field];
|
|
221
|
+
else next[field] = [...entries];
|
|
222
|
+
return next;
|
|
223
|
+
}
|
|
224
|
+
/** A name not used yet in a list: `input1`, `input2`, … */
|
|
225
|
+
function freshName(prefix, used) {
|
|
226
|
+
const taken = new Set(used);
|
|
227
|
+
for (let n = used.length + 1;; n++) {
|
|
228
|
+
const name = `${prefix}${n}`;
|
|
229
|
+
if (!taken.has(name)) return name;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** The variable names steps set (`saveAs`, `set`, for-each items) and the declared ones. */
|
|
233
|
+
function variableNames(draft, steps) {
|
|
234
|
+
const names = new Set(namedEntries(draft, "variables").map((v) => v.name));
|
|
235
|
+
for (const { step } of steps) {
|
|
236
|
+
for (const field of [
|
|
237
|
+
"saveAs",
|
|
238
|
+
"as",
|
|
239
|
+
"index"
|
|
240
|
+
]) {
|
|
241
|
+
const value = step[field];
|
|
242
|
+
if (typeof value === "string" && value) names.add(value);
|
|
243
|
+
}
|
|
244
|
+
if (step.action === "set" && typeof step.name === "string" && step.name) names.add(step.name);
|
|
245
|
+
}
|
|
246
|
+
return [...names];
|
|
247
|
+
}
|
|
248
|
+
/** An input's name: written when the field is left, and only when it is free. */
|
|
249
|
+
function InputNameField({ name, onRename, testId, readOnly }) {
|
|
250
|
+
const tr = useTr();
|
|
251
|
+
const [text, setText] = useState(name);
|
|
252
|
+
const [refused, setRefused] = useState(false);
|
|
253
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
254
|
+
className: "flex w-28 shrink-0 flex-col",
|
|
255
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
256
|
+
type: "text",
|
|
257
|
+
value: text,
|
|
258
|
+
readOnly,
|
|
259
|
+
"aria-invalid": refused,
|
|
260
|
+
"aria-label": tr("fluidgrids.builder.uiScript.inputs.name", "Input name"),
|
|
261
|
+
onChange: (event) => {
|
|
262
|
+
setText(event.target.value);
|
|
263
|
+
setRefused(false);
|
|
264
|
+
},
|
|
265
|
+
onBlur: () => {
|
|
266
|
+
if (onRename(text.trim())) return;
|
|
267
|
+
setRefused(true);
|
|
268
|
+
setText(name);
|
|
269
|
+
},
|
|
270
|
+
className: cn(uiInputClass, "w-full"),
|
|
271
|
+
"data-testid": testId
|
|
272
|
+
}), refused && /* @__PURE__ */ jsx("span", {
|
|
273
|
+
className: "text-[10px] text-[var(--color-status-error-text)]",
|
|
274
|
+
role: "alert",
|
|
275
|
+
children: tr("fluidgrids.builder.uiScript.inputs.nameTaken", "Use a name no other input has.")
|
|
276
|
+
})]
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
/** The workflow value an input is mapped to, as text. */
|
|
280
|
+
function MappedValue({ value, readOnly, onChange, testId }) {
|
|
281
|
+
const tr = useTr();
|
|
282
|
+
let text = "";
|
|
283
|
+
if (typeof value === "string") text = value;
|
|
284
|
+
else if (value !== void 0) text = JSON.stringify(value);
|
|
285
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
286
|
+
className: "text-xs text-muted-foreground",
|
|
287
|
+
children: "←"
|
|
288
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
289
|
+
type: "text",
|
|
290
|
+
value: text,
|
|
291
|
+
readOnly,
|
|
292
|
+
placeholder: "{{ $json.invoiceNumber }}",
|
|
293
|
+
"aria-label": tr("fluidgrids.builder.uiScript.inputs.value", "Value from the workflow"),
|
|
294
|
+
onChange: (event) => onChange(event.target.value),
|
|
295
|
+
className: cn(uiInputClass, "min-w-0 flex-1 font-mono"),
|
|
296
|
+
"data-testid": testId
|
|
297
|
+
})] });
|
|
298
|
+
}
|
|
299
|
+
/** The script's outputs: each named after a variable read when it ends. */
|
|
300
|
+
function UiScriptOutputs({ draft, write, variables, asArguments, testIdPrefix, readOnly }) {
|
|
301
|
+
const tr = useTr();
|
|
302
|
+
const outputs = namedEntries(draft, "outputs");
|
|
303
|
+
const setOutput = (index, entry) => write(withEntries(draft, "outputs", outputs.map((current, i) => i === index ? entry : current)));
|
|
304
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
305
|
+
className: "flex flex-col gap-1",
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ jsx("span", {
|
|
308
|
+
className: uiSmallLabel,
|
|
309
|
+
children: tr("fluidgrids.builder.uiScript.outputs.title", "Outputs")
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ jsx("span", {
|
|
312
|
+
className: "text-[11px] text-muted-foreground",
|
|
313
|
+
children: asArguments ? tr("fluidgrids.builder.uiScript.arguments.outputsHint", "Values the sequence returns to the step that calls it, read from its variables when it ends.") : tr("fluidgrids.builder.uiScript.outputs.hint", "Values the script returns to the workflow, read from its variables when it ends.")
|
|
314
|
+
}),
|
|
315
|
+
outputs.map((output, index) => /* @__PURE__ */ jsxs("div", {
|
|
316
|
+
className: "flex min-w-0 items-center gap-1",
|
|
317
|
+
"data-testid": `${testIdPrefix}-ui-output-${index}`,
|
|
318
|
+
children: [
|
|
319
|
+
/* @__PURE__ */ jsx("input", {
|
|
320
|
+
type: "text",
|
|
321
|
+
value: output.name,
|
|
322
|
+
readOnly,
|
|
323
|
+
"aria-label": tr("fluidgrids.builder.uiScript.outputs.name", "Output name"),
|
|
324
|
+
onChange: (event) => setOutput(index, {
|
|
325
|
+
...output,
|
|
326
|
+
name: event.target.value
|
|
327
|
+
}),
|
|
328
|
+
className: cn(uiInputClass, "w-28 shrink-0"),
|
|
329
|
+
"data-testid": `${testIdPrefix}-ui-output-${index}-name`
|
|
330
|
+
}),
|
|
331
|
+
/* @__PURE__ */ jsx("span", {
|
|
332
|
+
className: "text-xs text-muted-foreground",
|
|
333
|
+
children: "←"
|
|
334
|
+
}),
|
|
335
|
+
/* @__PURE__ */ jsxs(ThemedSelect, {
|
|
336
|
+
value: isRecord$4(output.value) && typeof output.value.var === "string" ? output.value.var : "",
|
|
337
|
+
disabled: readOnly,
|
|
338
|
+
"aria-label": tr("fluidgrids.builder.uiScript.outputs.variable", "Variable"),
|
|
339
|
+
onChange: (event) => setOutput(index, {
|
|
340
|
+
...output,
|
|
341
|
+
value: { var: event.target.value }
|
|
342
|
+
}),
|
|
343
|
+
className: cn(uiInputClass, "min-w-0 flex-1"),
|
|
344
|
+
"data-testid": `${testIdPrefix}-ui-output-${index}-variable`,
|
|
345
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
346
|
+
value: "",
|
|
347
|
+
children: tr("fluidgrids.builder.uiScript.value.pickVariable", "Choose a variable")
|
|
348
|
+
}), variables.map((name) => /* @__PURE__ */ jsx("option", {
|
|
349
|
+
value: name,
|
|
350
|
+
children: name
|
|
351
|
+
}, name))]
|
|
352
|
+
}),
|
|
353
|
+
/* @__PURE__ */ jsx("button", {
|
|
354
|
+
type: "button",
|
|
355
|
+
disabled: readOnly,
|
|
356
|
+
onClick: () => write(withEntries(draft, "outputs", outputs.filter((_, i) => i !== index))),
|
|
357
|
+
"aria-label": tr("fluidgrids.builder.uiScript.outputs.remove", "Remove output"),
|
|
358
|
+
className: uiIconButton,
|
|
359
|
+
"data-testid": `${testIdPrefix}-ui-output-${index}-remove`,
|
|
360
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
|
|
361
|
+
})
|
|
362
|
+
]
|
|
363
|
+
}, index)),
|
|
364
|
+
/* @__PURE__ */ jsxs("button", {
|
|
365
|
+
type: "button",
|
|
366
|
+
disabled: readOnly,
|
|
367
|
+
onClick: () => write(withEntries(draft, "outputs", [...outputs, {
|
|
368
|
+
name: freshName("output", outputs.map((output) => output.name)),
|
|
369
|
+
value: { var: variables[0] ?? "" }
|
|
370
|
+
}])),
|
|
371
|
+
className: uiLinkButton,
|
|
372
|
+
"data-testid": `${testIdPrefix}-ui-output-add`,
|
|
373
|
+
children: [/* @__PURE__ */ jsx(Plus, { className: "size-3.5" }), tr("fluidgrids.builder.uiScript.outputs.add", "Add an output")]
|
|
374
|
+
})
|
|
375
|
+
]
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function UiScriptInputsOutputs({ draft, write, mapping, onMappingChange, variables, mappingEditable = true, asArguments = false, testIdPrefix, readOnly }) {
|
|
379
|
+
const tr = useTr();
|
|
380
|
+
const inputs = namedEntries(draft, "inputs");
|
|
381
|
+
const setInput = (index, entry) => write(withEntries(draft, "inputs", inputs.map((current, i) => i === index ? entry : current)));
|
|
382
|
+
/** Renames an input (and what reads it); refused when the name is empty or taken. */
|
|
383
|
+
const renameInput = (index, name) => {
|
|
384
|
+
const previous = inputs[index];
|
|
385
|
+
if (!previous) return false;
|
|
386
|
+
if (name === previous.name) return true;
|
|
387
|
+
if (!name || inputs.some((input) => input.name === name)) return false;
|
|
388
|
+
write(renameScriptInput(draft, previous.name, name));
|
|
389
|
+
if (mappingEditable && previous.name in mapping) {
|
|
390
|
+
const next = { ...mapping };
|
|
391
|
+
next[name] = next[previous.name];
|
|
392
|
+
delete next[previous.name];
|
|
393
|
+
onMappingChange(next);
|
|
394
|
+
}
|
|
395
|
+
return true;
|
|
396
|
+
};
|
|
397
|
+
const removeInput = (index) => {
|
|
398
|
+
const removed = inputs[index];
|
|
399
|
+
write(withEntries(draft, "inputs", inputs.filter((_, i) => i !== index)));
|
|
400
|
+
if (mappingEditable && removed && removed.name in mapping) {
|
|
401
|
+
const next = { ...mapping };
|
|
402
|
+
delete next[removed.name];
|
|
403
|
+
onMappingChange(next);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
407
|
+
className: "grid grid-cols-1 gap-3 lg:grid-cols-2",
|
|
408
|
+
"data-testid": `${testIdPrefix}-ui-io`,
|
|
409
|
+
children: [/* @__PURE__ */ jsxs("section", {
|
|
410
|
+
className: "flex flex-col gap-1",
|
|
411
|
+
children: [
|
|
412
|
+
/* @__PURE__ */ jsx("span", {
|
|
413
|
+
className: uiSmallLabel,
|
|
414
|
+
children: asArguments ? tr("fluidgrids.builder.uiScript.arguments.title", "Arguments") : tr("fluidgrids.builder.uiScript.inputs.title", "Inputs")
|
|
415
|
+
}),
|
|
416
|
+
/* @__PURE__ */ jsx("span", {
|
|
417
|
+
className: "text-[11px] text-muted-foreground",
|
|
418
|
+
children: asArguments ? tr("fluidgrids.builder.uiScript.arguments.hint", "Values each workflow passes when it calls this sequence. Never put passwords or keys here: a step types a secret from a connection.") : tr("fluidgrids.builder.uiScript.inputs.hint", "Values the workflow gives the script, such as an invoice number from the trigger. Never put passwords or keys here.")
|
|
419
|
+
}),
|
|
420
|
+
inputs.map((input, index) => /* @__PURE__ */ jsxs("div", {
|
|
421
|
+
className: "flex min-w-0 items-center gap-1",
|
|
422
|
+
"data-testid": `${testIdPrefix}-ui-input-${index}`,
|
|
423
|
+
children: [
|
|
424
|
+
/* @__PURE__ */ jsx(InputNameField, {
|
|
425
|
+
name: input.name,
|
|
426
|
+
onRename: (name) => renameInput(index, name),
|
|
427
|
+
testId: `${testIdPrefix}-ui-input-${index}-name`,
|
|
428
|
+
readOnly
|
|
429
|
+
}, input.name),
|
|
430
|
+
asArguments ? /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }) : /* @__PURE__ */ jsx(MappedValue, {
|
|
431
|
+
value: mapping[input.name],
|
|
432
|
+
readOnly: readOnly || !mappingEditable,
|
|
433
|
+
onChange: (text) => onMappingChange({
|
|
434
|
+
...mapping,
|
|
435
|
+
[input.name]: text
|
|
436
|
+
}),
|
|
437
|
+
testId: `${testIdPrefix}-ui-input-${index}-value`
|
|
438
|
+
}),
|
|
439
|
+
/* @__PURE__ */ jsxs("label", {
|
|
440
|
+
className: "flex shrink-0 items-center gap-1 text-[11px]",
|
|
441
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
442
|
+
type: "checkbox",
|
|
443
|
+
checked: input.required === true,
|
|
444
|
+
disabled: readOnly,
|
|
445
|
+
onChange: (event) => setInput(index, {
|
|
446
|
+
...input,
|
|
447
|
+
required: event.target.checked ? true : void 0
|
|
448
|
+
}),
|
|
449
|
+
"data-testid": `${testIdPrefix}-ui-input-${index}-required`
|
|
450
|
+
}), tr("fluidgrids.builder.uiScript.inputs.required", "Required")]
|
|
451
|
+
}),
|
|
452
|
+
/* @__PURE__ */ jsx("button", {
|
|
453
|
+
type: "button",
|
|
454
|
+
disabled: readOnly,
|
|
455
|
+
onClick: () => removeInput(index),
|
|
456
|
+
"aria-label": tr("fluidgrids.builder.uiScript.inputs.remove", "Remove input"),
|
|
457
|
+
className: uiIconButton,
|
|
458
|
+
"data-testid": `${testIdPrefix}-ui-input-${index}-remove`,
|
|
459
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
|
|
460
|
+
})
|
|
461
|
+
]
|
|
462
|
+
}, index)),
|
|
463
|
+
/* @__PURE__ */ jsxs("button", {
|
|
464
|
+
type: "button",
|
|
465
|
+
disabled: readOnly,
|
|
466
|
+
onClick: () => write(withEntries(draft, "inputs", [...inputs, {
|
|
467
|
+
name: freshName("input", inputs.map((input) => input.name)),
|
|
468
|
+
type: "text"
|
|
469
|
+
}])),
|
|
470
|
+
className: uiLinkButton,
|
|
471
|
+
"data-testid": `${testIdPrefix}-ui-input-add`,
|
|
472
|
+
children: [/* @__PURE__ */ jsx(Plus, { className: "size-3.5" }), asArguments ? tr("fluidgrids.builder.uiScript.arguments.add", "Add an argument") : tr("fluidgrids.builder.uiScript.inputs.add", "Add an input")]
|
|
473
|
+
})
|
|
474
|
+
]
|
|
475
|
+
}), /* @__PURE__ */ jsx(UiScriptOutputs, {
|
|
476
|
+
draft,
|
|
477
|
+
write,
|
|
478
|
+
variables,
|
|
479
|
+
asArguments,
|
|
480
|
+
testIdPrefix,
|
|
481
|
+
readOnly
|
|
482
|
+
})]
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// src/builder/components/ndv/ui-script-editor/ui-call-block.tsx
|
|
487
|
+
/**
|
|
488
|
+
* A call block (spec 19, M1 rule 3): the step runs a shared sequence from the
|
|
489
|
+
* Element library at a pinned version, with each of its arguments mapped to a
|
|
490
|
+
* value of this script. The worker inlines the sequence when it compiles the
|
|
491
|
+
* script, so the call never runs a version the workflow did not pin. A newer
|
|
492
|
+
* version is taken only when someone picks it here (or applies it from the
|
|
493
|
+
* Element library, P1-13).
|
|
494
|
+
*/
|
|
495
|
+
/** How many applications and sequences the picker lists (the service's page). */
|
|
496
|
+
const PICKER_PAGE_SIZE = 50;
|
|
497
|
+
/** How long the picker waits after a keystroke in a search box before it asks. */
|
|
498
|
+
const SEARCH_DELAY_MS = 300;
|
|
499
|
+
function isRecord$3(value) {
|
|
500
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
501
|
+
}
|
|
502
|
+
/** The argument names a sequence version declares (`UiScriptInput[]`). */
|
|
503
|
+
function sequenceArgumentNames(argumentsJson) {
|
|
504
|
+
if (!Array.isArray(argumentsJson)) return [];
|
|
505
|
+
return argumentsJson.filter(isRecord$3).map((argument) => argument.name).filter((name) => typeof name === "string" && !!name);
|
|
506
|
+
}
|
|
507
|
+
/** The arguments a call step maps, by name. */
|
|
508
|
+
function callArguments(step) {
|
|
509
|
+
return isRecord$3(step.args) ? step.args : {};
|
|
510
|
+
}
|
|
511
|
+
/** The call step pointed at a sequence version: arguments it no longer declares are dropped. */
|
|
512
|
+
function callStepFor(step, sequence) {
|
|
513
|
+
const names = new Set(sequenceArgumentNames(sequence.current.arguments));
|
|
514
|
+
const kept = Object.fromEntries(Object.entries(callArguments(step)).filter(([name]) => names.has(name)));
|
|
515
|
+
let next = setStepField(step, "sequenceId", sequence.id);
|
|
516
|
+
next = setStepField(next, "version", sequence.currentVersion);
|
|
517
|
+
return setStepField(next, "args", Object.keys(kept).length > 0 ? kept : void 0);
|
|
518
|
+
}
|
|
519
|
+
function UiCallBlock({ step, onStep, inputs, variables, onDropField, testId, readOnly }) {
|
|
520
|
+
const tr = useTr();
|
|
521
|
+
const [applications, setApplications] = useState({ state: "loading" });
|
|
522
|
+
const [applicationId, setApplicationId] = useState("");
|
|
523
|
+
const [applicationSearch, setApplicationSearch] = useState("");
|
|
524
|
+
const [sequenceSearch, setSequenceSearch] = useState("");
|
|
525
|
+
const [moreApplications, setMoreApplications] = useState(false);
|
|
526
|
+
const [moreSequences, setMoreSequences] = useState(false);
|
|
527
|
+
const [sequences, setSequences] = useState({
|
|
528
|
+
state: "ready",
|
|
529
|
+
items: []
|
|
530
|
+
});
|
|
531
|
+
const [pinned, setPinned] = useState(null);
|
|
532
|
+
const sequenceId = typeof step.sequenceId === "string" ? step.sequenceId : "";
|
|
533
|
+
const version = typeof step.version === "number" ? step.version : 1;
|
|
534
|
+
useEffect(() => {
|
|
535
|
+
let live = true;
|
|
536
|
+
const timer = setTimeout(() => {
|
|
537
|
+
readTyped(UiSequencePickerApplicationsDocument, {
|
|
538
|
+
first: 50,
|
|
539
|
+
...applicationSearch.trim() ? { search: applicationSearch.trim() } : {}
|
|
540
|
+
}).then((data) => {
|
|
541
|
+
if (!live) return;
|
|
542
|
+
setApplications({
|
|
543
|
+
state: "ready",
|
|
544
|
+
items: data.uiApplications.nodes
|
|
545
|
+
});
|
|
546
|
+
setMoreApplications(data.uiApplications.pageInfo.hasNextPage);
|
|
547
|
+
}).catch(() => {
|
|
548
|
+
if (live) setApplications({ state: "failed" });
|
|
549
|
+
});
|
|
550
|
+
}, applicationSearch ? 300 : 0);
|
|
551
|
+
return () => {
|
|
552
|
+
live = false;
|
|
553
|
+
clearTimeout(timer);
|
|
554
|
+
};
|
|
555
|
+
}, [applicationSearch]);
|
|
556
|
+
useEffect(() => {
|
|
557
|
+
if (!sequenceId) return void 0;
|
|
558
|
+
let live = true;
|
|
559
|
+
readTyped(UiSequencePickerSequenceDocument, { id: sequenceId }).then((data) => {
|
|
560
|
+
const sequence = data.uiSharedSequence;
|
|
561
|
+
if (!live || !sequence) return;
|
|
562
|
+
setPinned(sequence);
|
|
563
|
+
setApplicationId((current) => current || sequence.applicationId);
|
|
564
|
+
}).catch(() => {});
|
|
565
|
+
return () => {
|
|
566
|
+
live = false;
|
|
567
|
+
};
|
|
568
|
+
}, [sequenceId]);
|
|
569
|
+
useEffect(() => {
|
|
570
|
+
if (!applicationId) return void 0;
|
|
571
|
+
let live = true;
|
|
572
|
+
setSequences({ state: "loading" });
|
|
573
|
+
const timer = setTimeout(() => {
|
|
574
|
+
readTyped(UiSequencePickerSequencesDocument, {
|
|
575
|
+
applicationId,
|
|
576
|
+
first: 50,
|
|
577
|
+
...sequenceSearch.trim() ? { search: sequenceSearch.trim() } : {}
|
|
578
|
+
}).then((data) => {
|
|
579
|
+
if (!live) return;
|
|
580
|
+
setSequences({
|
|
581
|
+
state: "ready",
|
|
582
|
+
items: data.uiSharedSequences.nodes
|
|
583
|
+
});
|
|
584
|
+
setMoreSequences(data.uiSharedSequences.pageInfo.hasNextPage);
|
|
585
|
+
}).catch(() => {
|
|
586
|
+
if (live) setSequences({ state: "failed" });
|
|
587
|
+
});
|
|
588
|
+
}, sequenceSearch ? 300 : 0);
|
|
589
|
+
return () => {
|
|
590
|
+
live = false;
|
|
591
|
+
clearTimeout(timer);
|
|
592
|
+
};
|
|
593
|
+
}, [applicationId, sequenceSearch]);
|
|
594
|
+
const listed = sequences.state === "ready" ? sequences.items.find((sequence) => sequence.id === sequenceId) : void 0;
|
|
595
|
+
const loaded = listed ?? (pinned?.id === sequenceId ? pinned : void 0);
|
|
596
|
+
const args = callArguments(step);
|
|
597
|
+
const argumentNames = [.../* @__PURE__ */ new Set([...loaded ? sequenceArgumentNames(loaded.current.arguments) : [], ...Object.keys(args)])];
|
|
598
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
599
|
+
className: "flex flex-col gap-1.5",
|
|
600
|
+
"data-testid": testId,
|
|
601
|
+
children: [
|
|
602
|
+
/* @__PURE__ */ jsxs("div", {
|
|
603
|
+
className: "grid grid-cols-1 gap-1.5 sm:grid-cols-2",
|
|
604
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
605
|
+
className: "flex flex-col gap-0.5",
|
|
606
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
607
|
+
className: uiSmallLabel,
|
|
608
|
+
children: tr("fluidgrids.builder.uiScript.call.application", "Application")
|
|
609
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
610
|
+
value: applicationId,
|
|
611
|
+
disabled: readOnly || applications.state !== "ready",
|
|
612
|
+
onChange: (event) => setApplicationId(event.target.value),
|
|
613
|
+
className: uiInputClass,
|
|
614
|
+
"data-testid": `${testId}-application`,
|
|
615
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
616
|
+
value: "",
|
|
617
|
+
children: applications.state === "loading" ? tr("fluidgrids.builder.uiScript.call.loading", "Loading…") : tr("fluidgrids.builder.uiScript.call.pickApplication", "Choose an application")
|
|
618
|
+
}), applications.state === "ready" && applications.items.map((application) => /* @__PURE__ */ jsx("option", {
|
|
619
|
+
value: application.id,
|
|
620
|
+
children: application.name
|
|
621
|
+
}, application.id))]
|
|
622
|
+
})]
|
|
623
|
+
}), /* @__PURE__ */ jsxs("label", {
|
|
624
|
+
className: "flex flex-col gap-0.5",
|
|
625
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
626
|
+
className: uiSmallLabel,
|
|
627
|
+
children: tr("fluidgrids.builder.uiScript.call.sequence", "Shared sequence")
|
|
628
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
629
|
+
value: loaded ? loaded.id : "",
|
|
630
|
+
disabled: readOnly || !applicationId || sequences.state !== "ready",
|
|
631
|
+
onChange: (event) => {
|
|
632
|
+
const picked = sequences.state === "ready" ? sequences.items.find((sequence) => sequence.id === event.target.value) : void 0;
|
|
633
|
+
if (picked) onStep(callStepFor(step, picked));
|
|
634
|
+
},
|
|
635
|
+
className: uiInputClass,
|
|
636
|
+
"data-testid": `${testId}-sequence`,
|
|
637
|
+
children: [
|
|
638
|
+
/* @__PURE__ */ jsx("option", {
|
|
639
|
+
value: "",
|
|
640
|
+
children: tr("fluidgrids.builder.uiScript.call.pickSequence", "Choose a shared sequence")
|
|
641
|
+
}),
|
|
642
|
+
loaded && !listed && /* @__PURE__ */ jsx("option", {
|
|
643
|
+
value: loaded.id,
|
|
644
|
+
children: loaded.name
|
|
645
|
+
}),
|
|
646
|
+
sequences.state === "ready" && sequences.items.map((sequence) => /* @__PURE__ */ jsx("option", {
|
|
647
|
+
value: sequence.id,
|
|
648
|
+
children: sequence.name
|
|
649
|
+
}, sequence.id))
|
|
650
|
+
]
|
|
651
|
+
})]
|
|
652
|
+
})]
|
|
653
|
+
}),
|
|
654
|
+
/* @__PURE__ */ jsxs("div", {
|
|
655
|
+
className: "grid grid-cols-1 gap-1.5 sm:grid-cols-2",
|
|
656
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
657
|
+
type: "search",
|
|
658
|
+
value: applicationSearch,
|
|
659
|
+
readOnly,
|
|
660
|
+
placeholder: tr("fluidgrids.builder.uiScript.call.searchApplications", "Search applications"),
|
|
661
|
+
"aria-label": tr("fluidgrids.builder.uiScript.call.searchApplications", "Search applications"),
|
|
662
|
+
onChange: (event) => setApplicationSearch(event.target.value),
|
|
663
|
+
className: uiInputClass,
|
|
664
|
+
"data-testid": `${testId}-application-search`
|
|
665
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
666
|
+
type: "search",
|
|
667
|
+
value: sequenceSearch,
|
|
668
|
+
readOnly: readOnly || !applicationId,
|
|
669
|
+
placeholder: tr("fluidgrids.builder.uiScript.call.searchSequences", "Search shared sequences"),
|
|
670
|
+
"aria-label": tr("fluidgrids.builder.uiScript.call.searchSequences", "Search shared sequences"),
|
|
671
|
+
onChange: (event) => setSequenceSearch(event.target.value),
|
|
672
|
+
className: uiInputClass,
|
|
673
|
+
"data-testid": `${testId}-sequence-search`
|
|
674
|
+
})]
|
|
675
|
+
}),
|
|
676
|
+
(moreApplications || moreSequences) && /* @__PURE__ */ jsx("p", {
|
|
677
|
+
className: "text-[11px] text-muted-foreground",
|
|
678
|
+
"data-testid": `${testId}-more`,
|
|
679
|
+
children: tr("fluidgrids.builder.uiScript.call.more", "Only the first {{count}} are listed. Search to find the others.", { count: 50 })
|
|
680
|
+
}),
|
|
681
|
+
(applications.state === "failed" || sequences.state === "failed") && /* @__PURE__ */ jsx("p", {
|
|
682
|
+
className: "text-[11px] text-[var(--color-status-error-text)]",
|
|
683
|
+
role: "alert",
|
|
684
|
+
"data-testid": `${testId}-load-failed`,
|
|
685
|
+
children: tr("fluidgrids.builder.uiScript.call.loadFailed", "The Element library could not be read. You can still keep the sequence this step already calls.")
|
|
686
|
+
}),
|
|
687
|
+
sequenceId && /* @__PURE__ */ jsxs("div", {
|
|
688
|
+
className: "flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",
|
|
689
|
+
"data-testid": `${testId}-pinned`,
|
|
690
|
+
children: [/* @__PURE__ */ jsx("span", { children: tr("fluidgrids.builder.uiScript.call.pinned", "Calls {{name}} at version {{version}}", {
|
|
691
|
+
name: loaded?.name ?? sequenceId,
|
|
692
|
+
version
|
|
693
|
+
}) }), loaded && loaded.currentVersion !== version && /* @__PURE__ */ jsx("button", {
|
|
694
|
+
type: "button",
|
|
695
|
+
disabled: readOnly,
|
|
696
|
+
onClick: () => onStep(callStepFor(step, loaded)),
|
|
697
|
+
className: "flex items-center gap-1 text-xs text-primary hover:underline disabled:opacity-50",
|
|
698
|
+
"data-testid": `${testId}-update`,
|
|
699
|
+
children: tr("fluidgrids.builder.uiScript.call.update", "Use the latest version ({{version}})", { version: loaded.currentVersion })
|
|
700
|
+
})]
|
|
701
|
+
}),
|
|
702
|
+
argumentNames.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
703
|
+
className: "flex flex-col gap-1",
|
|
704
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
705
|
+
className: "text-[10px] font-semibold text-muted-foreground",
|
|
706
|
+
children: tr("fluidgrids.builder.uiScript.call.arguments", "Arguments")
|
|
707
|
+
}), argumentNames.map((name) => /* @__PURE__ */ jsx(UiValueInput, {
|
|
708
|
+
label: name,
|
|
709
|
+
value: args[name],
|
|
710
|
+
onChange: (next) => onStep(setStepField(step, "args", {
|
|
711
|
+
...args,
|
|
712
|
+
[name]: next
|
|
713
|
+
})),
|
|
714
|
+
inputs,
|
|
715
|
+
variables,
|
|
716
|
+
onDropField,
|
|
717
|
+
testId: `${testId}-arg-${name}`,
|
|
718
|
+
readOnly
|
|
719
|
+
}, name))]
|
|
720
|
+
}),
|
|
721
|
+
/* @__PURE__ */ jsx("span", {
|
|
722
|
+
className: cn("text-[11px] text-muted-foreground"),
|
|
723
|
+
children: tr("fluidgrids.builder.uiScript.call.secretHint", "A secret argument takes only a connection secret, such as login:password. Its value is never shown or stored here.")
|
|
724
|
+
})
|
|
725
|
+
]
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// src/builder/components/ndv/ui-script-editor/ui-step-fields.tsx
|
|
730
|
+
/**
|
|
731
|
+
* The everyday fields of one step (spec 19, M1): what it acts on and the
|
|
732
|
+
* values it uses, without selectors, waits or error codes. Flow blocks (if,
|
|
733
|
+
* for each, while, retry) show their own settings here; their steps are drawn
|
|
734
|
+
* by the step list below the block.
|
|
735
|
+
*/
|
|
736
|
+
/** Actions whose result can be kept under a name (`saveAs`). */
|
|
737
|
+
const RESULT_ACTIONS = /* @__PURE__ */ new Set([
|
|
738
|
+
"getText",
|
|
739
|
+
"getValue",
|
|
740
|
+
"getAttribute",
|
|
741
|
+
"elementExists",
|
|
742
|
+
"extract",
|
|
743
|
+
"extractList",
|
|
744
|
+
"getPageText",
|
|
745
|
+
"getPageHtml",
|
|
746
|
+
"screenshot"
|
|
747
|
+
]);
|
|
748
|
+
/** Actions that act on a required target. */
|
|
749
|
+
const TARGET_ACTIONS = /* @__PURE__ */ new Set([
|
|
750
|
+
"click",
|
|
751
|
+
"doubleClick",
|
|
752
|
+
"hover",
|
|
753
|
+
"clear",
|
|
754
|
+
"getText",
|
|
755
|
+
"getValue",
|
|
756
|
+
"getAttribute",
|
|
757
|
+
"elementExists",
|
|
758
|
+
"type",
|
|
759
|
+
"typeSecret",
|
|
760
|
+
"select",
|
|
761
|
+
"check"
|
|
762
|
+
]);
|
|
763
|
+
function TextField({ label, value, onChange, testId, readOnly, placeholder, inputMode }) {
|
|
764
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
765
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
766
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
767
|
+
className: uiSmallLabel,
|
|
768
|
+
children: label
|
|
769
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
770
|
+
type: "text",
|
|
771
|
+
inputMode,
|
|
772
|
+
value: typeof value === "string" || typeof value === "number" ? String(value) : "",
|
|
773
|
+
readOnly,
|
|
774
|
+
placeholder,
|
|
775
|
+
onChange: (event) => onChange(event.target.value),
|
|
776
|
+
className: cn(uiInputClass, "w-full"),
|
|
777
|
+
"data-testid": testId
|
|
778
|
+
})]
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
function CheckField({ label, checked, onChange, testId, readOnly }) {
|
|
782
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
783
|
+
className: "flex items-center gap-1.5 text-xs text-foreground",
|
|
784
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
785
|
+
type: "checkbox",
|
|
786
|
+
checked,
|
|
787
|
+
disabled: readOnly,
|
|
788
|
+
onChange: (event) => onChange(event.target.checked),
|
|
789
|
+
"data-testid": testId
|
|
790
|
+
}), label]
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
/** A positive whole number typed as text, or undefined when it is not one. */
|
|
794
|
+
function wholeNumber(text) {
|
|
795
|
+
const value = Number(text);
|
|
796
|
+
return text.trim() && Number.isInteger(value) && value >= 0 ? value : void 0;
|
|
797
|
+
}
|
|
798
|
+
/** The keys of a press keys step as typed: `Control+A`. */
|
|
799
|
+
function keysText(keys) {
|
|
800
|
+
return Array.isArray(keys) ? keys.filter((key) => typeof key === "string").join("+") : "";
|
|
801
|
+
}
|
|
802
|
+
/** Typed keys back into the step's list. */
|
|
803
|
+
function keysFromText(text) {
|
|
804
|
+
return text.split("+").map((key) => key.trim()).filter(Boolean);
|
|
805
|
+
}
|
|
806
|
+
/** How typed keys read once stored. */
|
|
807
|
+
function normalizeKeys(text) {
|
|
808
|
+
return keysText(keysFromText(text));
|
|
809
|
+
}
|
|
810
|
+
const WAIT_MODES = [
|
|
811
|
+
"target",
|
|
812
|
+
"text",
|
|
813
|
+
"urlContains",
|
|
814
|
+
"milliseconds"
|
|
815
|
+
];
|
|
816
|
+
function isWaitMode(value) {
|
|
817
|
+
return WAIT_MODES.includes(value);
|
|
818
|
+
}
|
|
819
|
+
/** What a wait step waits for. */
|
|
820
|
+
function waitMode(step) {
|
|
821
|
+
if (step.text !== void 0) return "text";
|
|
822
|
+
if (step.urlContains !== void 0) return "urlContains";
|
|
823
|
+
if (step.milliseconds !== void 0) return "milliseconds";
|
|
824
|
+
return "target";
|
|
825
|
+
}
|
|
826
|
+
/** A wait step switched to wait for something else (exactly one of the four). */
|
|
827
|
+
function withWaitMode(step, mode) {
|
|
828
|
+
let next = step;
|
|
829
|
+
for (const field of [
|
|
830
|
+
"target",
|
|
831
|
+
"text",
|
|
832
|
+
"urlContains",
|
|
833
|
+
"milliseconds",
|
|
834
|
+
"state"
|
|
835
|
+
]) next = setStepField(next, field, void 0);
|
|
836
|
+
switch (mode) {
|
|
837
|
+
case "text": return setStepField(next, "text", "");
|
|
838
|
+
case "urlContains": return setStepField(next, "urlContains", "");
|
|
839
|
+
case "milliseconds": return setStepField(next, "milliseconds", 1e3);
|
|
840
|
+
default: return setStepField(next, "target", { methods: [] });
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
/** Whether a condition block tests an element (`elementExists`) rather than a condition. */
|
|
844
|
+
function testsElement(step) {
|
|
845
|
+
return step.elementExists !== void 0;
|
|
846
|
+
}
|
|
847
|
+
function UiStepFields({ step, onStep, context, testId }) {
|
|
848
|
+
const tr = useTr();
|
|
849
|
+
const { inputs, variables, elementNames, onDropField, readOnly } = context;
|
|
850
|
+
const set = (field, value) => onStep(setStepField(step, field, value));
|
|
851
|
+
const value = (field, label, placeholder) => /* @__PURE__ */ jsx(UiValueInput, {
|
|
852
|
+
label,
|
|
853
|
+
value: step[field],
|
|
854
|
+
onChange: (next) => set(field, next),
|
|
855
|
+
inputs,
|
|
856
|
+
variables,
|
|
857
|
+
onDropField,
|
|
858
|
+
placeholder,
|
|
859
|
+
testId: `${testId}-${field}`,
|
|
860
|
+
readOnly
|
|
861
|
+
});
|
|
862
|
+
const target = (field, label) => {
|
|
863
|
+
const ref = step[field];
|
|
864
|
+
const key = typeof ref === "object" && ref !== null && "element" in ref ? String(ref.element) : "";
|
|
865
|
+
return /* @__PURE__ */ jsx(UiTargetQuickField, {
|
|
866
|
+
label,
|
|
867
|
+
target: ref,
|
|
868
|
+
elementName: elementNames[key],
|
|
869
|
+
elementChoices: elementNames,
|
|
870
|
+
onChange: (next) => set(field, next),
|
|
871
|
+
testId: `${testId}-${field}`,
|
|
872
|
+
readOnly
|
|
873
|
+
});
|
|
874
|
+
};
|
|
875
|
+
const elementLabel = tr("fluidgrids.builder.uiScript.field.element", "Element");
|
|
876
|
+
const fields = [];
|
|
877
|
+
if (TARGET_ACTIONS.has(step.action)) fields.push(target("target", elementLabel));
|
|
878
|
+
switch (step.action) {
|
|
879
|
+
case "navigate":
|
|
880
|
+
fields.push(value("url", tr("fluidgrids.builder.uiScript.field.url", "Address"), "https://portal.example.com/login"));
|
|
881
|
+
break;
|
|
882
|
+
case "type":
|
|
883
|
+
fields.push(value("text", tr("fluidgrids.builder.uiScript.field.value", "Value")), /* @__PURE__ */ jsx(CheckField, {
|
|
884
|
+
label: tr("fluidgrids.builder.uiScript.field.pressEnter", "Press Enter after typing"),
|
|
885
|
+
checked: step.pressEnter === true,
|
|
886
|
+
onChange: (next) => set("pressEnter", next ? true : void 0),
|
|
887
|
+
testId: `${testId}-pressEnter`,
|
|
888
|
+
readOnly
|
|
889
|
+
}, "pressEnter"));
|
|
890
|
+
break;
|
|
891
|
+
case "typeSecret":
|
|
892
|
+
fields.push(/* @__PURE__ */ jsx(TextField, {
|
|
893
|
+
label: tr("fluidgrids.builder.uiScript.field.secretRef", "Secret from a connection"),
|
|
894
|
+
placeholder: "login:password",
|
|
895
|
+
value: step.secretRef,
|
|
896
|
+
onChange: (next) => set("secretRef", next),
|
|
897
|
+
testId: `${testId}-secretRef`,
|
|
898
|
+
readOnly
|
|
899
|
+
}, "secretRef"), /* @__PURE__ */ jsx(TextField, {
|
|
900
|
+
label: tr("fluidgrids.builder.uiScript.field.expectedOrigin", "Only type it on this site"),
|
|
901
|
+
placeholder: "https://portal.example.com",
|
|
902
|
+
value: step.expectedOrigin,
|
|
903
|
+
onChange: (next) => set("expectedOrigin", next || void 0),
|
|
904
|
+
testId: `${testId}-expectedOrigin`,
|
|
905
|
+
readOnly
|
|
906
|
+
}, "expectedOrigin"));
|
|
907
|
+
break;
|
|
908
|
+
case "select": {
|
|
909
|
+
const values = Array.isArray(step.values) ? step.values : [""];
|
|
910
|
+
fields.push(/* @__PURE__ */ jsx(UiValueInput, {
|
|
911
|
+
label: tr("fluidgrids.builder.uiScript.field.option", "Option"),
|
|
912
|
+
value: values[0],
|
|
913
|
+
onChange: (next) => set("values", [next, ...values.slice(1)]),
|
|
914
|
+
inputs,
|
|
915
|
+
variables,
|
|
916
|
+
onDropField,
|
|
917
|
+
testId: `${testId}-values`,
|
|
918
|
+
readOnly
|
|
919
|
+
}, "values"));
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
case "check":
|
|
923
|
+
fields.push(/* @__PURE__ */ jsx(CheckField, {
|
|
924
|
+
label: tr("fluidgrids.builder.uiScript.field.checked", "Tick it (untick when off)"),
|
|
925
|
+
checked: step.checked !== false,
|
|
926
|
+
onChange: (next) => set("checked", next ? void 0 : false),
|
|
927
|
+
testId: `${testId}-checked`,
|
|
928
|
+
readOnly
|
|
929
|
+
}, "checked"));
|
|
930
|
+
break;
|
|
931
|
+
case "pressKey":
|
|
932
|
+
fields.push(/* @__PURE__ */ jsxs("label", {
|
|
933
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
934
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
935
|
+
className: uiSmallLabel,
|
|
936
|
+
children: tr("fluidgrids.builder.uiScript.field.keys", "Keys, pressed together")
|
|
937
|
+
}), /* @__PURE__ */ jsx(BufferedInput, {
|
|
938
|
+
value: keysText(step.keys),
|
|
939
|
+
normalize: normalizeKeys,
|
|
940
|
+
onText: (next) => set("keys", keysFromText(next)),
|
|
941
|
+
readOnly,
|
|
942
|
+
placeholder: "Enter, Control+A",
|
|
943
|
+
className: cn(uiInputClass, "w-full"),
|
|
944
|
+
"data-testid": `${testId}-keys`
|
|
945
|
+
})]
|
|
946
|
+
}, "keys"));
|
|
947
|
+
break;
|
|
948
|
+
case "scroll":
|
|
949
|
+
fields.push(/* @__PURE__ */ jsxs("label", {
|
|
950
|
+
className: "flex flex-col gap-0.5",
|
|
951
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
952
|
+
className: uiSmallLabel,
|
|
953
|
+
children: tr("fluidgrids.builder.uiScript.field.scrollTo", "Scroll to")
|
|
954
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
955
|
+
value: typeof step.to === "string" ? step.to : "bottom",
|
|
956
|
+
disabled: readOnly,
|
|
957
|
+
onChange: (event) => set("to", event.target.value),
|
|
958
|
+
className: uiInputClass,
|
|
959
|
+
"data-testid": `${testId}-to`,
|
|
960
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
961
|
+
value: "top",
|
|
962
|
+
children: tr("fluidgrids.builder.uiScript.field.top", "The top")
|
|
963
|
+
}), /* @__PURE__ */ jsx("option", {
|
|
964
|
+
value: "bottom",
|
|
965
|
+
children: tr("fluidgrids.builder.uiScript.field.bottom", "The bottom")
|
|
966
|
+
})]
|
|
967
|
+
})]
|
|
968
|
+
}, "to"));
|
|
969
|
+
break;
|
|
970
|
+
case "waitFor": {
|
|
971
|
+
const mode = waitMode(step);
|
|
972
|
+
fields.push(/* @__PURE__ */ jsxs("label", {
|
|
973
|
+
className: "flex flex-col gap-0.5",
|
|
974
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
975
|
+
className: uiSmallLabel,
|
|
976
|
+
children: tr("fluidgrids.builder.uiScript.field.waitFor", "Wait for")
|
|
977
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
978
|
+
value: mode,
|
|
979
|
+
disabled: readOnly,
|
|
980
|
+
onChange: (event) => isWaitMode(event.target.value) && onStep(withWaitMode(step, event.target.value)),
|
|
981
|
+
className: uiInputClass,
|
|
982
|
+
"data-testid": `${testId}-waitMode`,
|
|
983
|
+
children: [
|
|
984
|
+
/* @__PURE__ */ jsx("option", {
|
|
985
|
+
value: "target",
|
|
986
|
+
children: tr("fluidgrids.builder.uiScript.field.waitElement", "An element")
|
|
987
|
+
}),
|
|
988
|
+
/* @__PURE__ */ jsx("option", {
|
|
989
|
+
value: "text",
|
|
990
|
+
children: tr("fluidgrids.builder.uiScript.field.waitText", "A text")
|
|
991
|
+
}),
|
|
992
|
+
/* @__PURE__ */ jsx("option", {
|
|
993
|
+
value: "urlContains",
|
|
994
|
+
children: tr("fluidgrids.builder.uiScript.field.waitUrl", "The address to contain")
|
|
995
|
+
}),
|
|
996
|
+
/* @__PURE__ */ jsx("option", {
|
|
997
|
+
value: "milliseconds",
|
|
998
|
+
children: tr("fluidgrids.builder.uiScript.field.waitTime", "A fixed time (not recommended)")
|
|
999
|
+
})
|
|
1000
|
+
]
|
|
1001
|
+
})]
|
|
1002
|
+
}, "waitMode"));
|
|
1003
|
+
if (mode === "target") fields.push(target("target", elementLabel));
|
|
1004
|
+
if (mode === "text") fields.push(value("text", tr("fluidgrids.builder.uiScript.field.text", "Text")));
|
|
1005
|
+
if (mode === "urlContains") fields.push(value("urlContains", tr("fluidgrids.builder.uiScript.field.urlPart", "Part of the address")));
|
|
1006
|
+
if (mode === "milliseconds") fields.push(/* @__PURE__ */ jsx(TextField, {
|
|
1007
|
+
label: tr("fluidgrids.builder.uiScript.field.milliseconds", "Milliseconds"),
|
|
1008
|
+
inputMode: "numeric",
|
|
1009
|
+
value: step.milliseconds,
|
|
1010
|
+
onChange: (next) => set("milliseconds", wholeNumber(next)),
|
|
1011
|
+
testId: `${testId}-milliseconds`,
|
|
1012
|
+
readOnly
|
|
1013
|
+
}, "milliseconds"));
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
case "getAttribute":
|
|
1017
|
+
fields.push(/* @__PURE__ */ jsx(TextField, {
|
|
1018
|
+
label: tr("fluidgrids.builder.uiScript.field.attribute", "Attribute"),
|
|
1019
|
+
placeholder: "href",
|
|
1020
|
+
value: step.attribute,
|
|
1021
|
+
onChange: (next) => set("attribute", next),
|
|
1022
|
+
testId: `${testId}-attribute`,
|
|
1023
|
+
readOnly
|
|
1024
|
+
}, "attribute"));
|
|
1025
|
+
break;
|
|
1026
|
+
case "extractList":
|
|
1027
|
+
fields.push(target("item", tr("fluidgrids.builder.uiScript.field.item", "Each item")));
|
|
1028
|
+
fields.push(/* @__PURE__ */ jsx(TextField, {
|
|
1029
|
+
label: tr("fluidgrids.builder.uiScript.field.maxItems", "At most this many items"),
|
|
1030
|
+
inputMode: "numeric",
|
|
1031
|
+
value: step.maxItems,
|
|
1032
|
+
onChange: (next) => set("maxItems", wholeNumber(next)),
|
|
1033
|
+
testId: `${testId}-maxItems`,
|
|
1034
|
+
readOnly
|
|
1035
|
+
}, "maxItems"));
|
|
1036
|
+
break;
|
|
1037
|
+
case "screenshot":
|
|
1038
|
+
fields.push(/* @__PURE__ */ jsx(CheckField, {
|
|
1039
|
+
label: tr("fluidgrids.builder.uiScript.field.fullPage", "The whole page"),
|
|
1040
|
+
checked: step.fullPage === true,
|
|
1041
|
+
onChange: (next) => set("fullPage", next ? true : void 0),
|
|
1042
|
+
testId: `${testId}-fullPage`,
|
|
1043
|
+
readOnly
|
|
1044
|
+
}, "fullPage"));
|
|
1045
|
+
break;
|
|
1046
|
+
case "set":
|
|
1047
|
+
fields.push(/* @__PURE__ */ jsx(TextField, {
|
|
1048
|
+
label: tr("fluidgrids.builder.uiScript.field.variable", "Variable"),
|
|
1049
|
+
value: step.name,
|
|
1050
|
+
onChange: (next) => set("name", next),
|
|
1051
|
+
testId: `${testId}-name`,
|
|
1052
|
+
readOnly
|
|
1053
|
+
}, "name"), value("value", tr("fluidgrids.builder.uiScript.field.value", "Value")));
|
|
1054
|
+
break;
|
|
1055
|
+
case "log":
|
|
1056
|
+
fields.push(value("message", tr("fluidgrids.builder.uiScript.field.message", "Message")));
|
|
1057
|
+
break;
|
|
1058
|
+
case "if":
|
|
1059
|
+
case "while":
|
|
1060
|
+
fields.push(/* @__PURE__ */ jsxs("label", {
|
|
1061
|
+
className: "flex flex-col gap-0.5",
|
|
1062
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1063
|
+
className: uiSmallLabel,
|
|
1064
|
+
children: tr("fluidgrids.builder.uiScript.field.when", "When")
|
|
1065
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
1066
|
+
value: testsElement(step) ? "element" : "condition",
|
|
1067
|
+
disabled: readOnly,
|
|
1068
|
+
onChange: (event) => {
|
|
1069
|
+
const element = event.target.value === "element";
|
|
1070
|
+
let next = setStepField(step, "condition", element ? void 0 : true);
|
|
1071
|
+
next = setStepField(next, "elementExists", element ? { methods: [] } : void 0);
|
|
1072
|
+
onStep(next);
|
|
1073
|
+
},
|
|
1074
|
+
className: uiInputClass,
|
|
1075
|
+
"data-testid": `${testId}-when`,
|
|
1076
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
1077
|
+
value: "element",
|
|
1078
|
+
children: tr("fluidgrids.builder.uiScript.field.elementThere", "An element is there")
|
|
1079
|
+
}), /* @__PURE__ */ jsx("option", {
|
|
1080
|
+
value: "condition",
|
|
1081
|
+
children: tr("fluidgrids.builder.uiScript.field.condition", "A condition holds")
|
|
1082
|
+
})]
|
|
1083
|
+
})]
|
|
1084
|
+
}, "test"), testsElement(step) ? target("elementExists", elementLabel) : value("condition", tr("fluidgrids.builder.uiScript.field.conditionValue", "Condition")));
|
|
1085
|
+
if (step.action === "while") fields.push(/* @__PURE__ */ jsx(TextField, {
|
|
1086
|
+
label: tr("fluidgrids.builder.uiScript.field.maxIterations", "At most this many times"),
|
|
1087
|
+
inputMode: "numeric",
|
|
1088
|
+
value: step.maxIterations,
|
|
1089
|
+
onChange: (next) => set("maxIterations", wholeNumber(next)),
|
|
1090
|
+
testId: `${testId}-maxIterations`,
|
|
1091
|
+
readOnly
|
|
1092
|
+
}, "maxIterations"));
|
|
1093
|
+
break;
|
|
1094
|
+
case "forEach":
|
|
1095
|
+
fields.push(step.elements !== void 0 ? target("elements", tr("fluidgrids.builder.uiScript.field.eachElement", "Each element")) : value("in", tr("fluidgrids.builder.uiScript.field.list", "List")), /* @__PURE__ */ jsx(TextField, {
|
|
1096
|
+
label: tr("fluidgrids.builder.uiScript.field.as", "Call the current item"),
|
|
1097
|
+
value: step.as,
|
|
1098
|
+
onChange: (next) => set("as", next),
|
|
1099
|
+
testId: `${testId}-as`,
|
|
1100
|
+
readOnly
|
|
1101
|
+
}, "as"), /* @__PURE__ */ jsx(CheckField, {
|
|
1102
|
+
label: tr("fluidgrids.builder.uiScript.field.overElements", "Loop over elements on the page"),
|
|
1103
|
+
checked: step.elements !== void 0,
|
|
1104
|
+
onChange: (next) => {
|
|
1105
|
+
let changed = setStepField(step, "elements", next ? { methods: [] } : void 0);
|
|
1106
|
+
changed = setStepField(changed, "in", next ? void 0 : { list: [] });
|
|
1107
|
+
onStep(changed);
|
|
1108
|
+
},
|
|
1109
|
+
testId: `${testId}-overElements`,
|
|
1110
|
+
readOnly
|
|
1111
|
+
}, "overElements"));
|
|
1112
|
+
break;
|
|
1113
|
+
case "retryScope":
|
|
1114
|
+
fields.push(/* @__PURE__ */ jsx(TextField, {
|
|
1115
|
+
label: tr("fluidgrids.builder.uiScript.field.attempts", "Try this many more times"),
|
|
1116
|
+
inputMode: "numeric",
|
|
1117
|
+
value: step.attempts,
|
|
1118
|
+
onChange: (next) => set("attempts", wholeNumber(next)),
|
|
1119
|
+
testId: `${testId}-attempts`,
|
|
1120
|
+
readOnly
|
|
1121
|
+
}, "attempts"));
|
|
1122
|
+
break;
|
|
1123
|
+
case "call": fields.push(/* @__PURE__ */ jsx(UiCallBlock, {
|
|
1124
|
+
step,
|
|
1125
|
+
onStep,
|
|
1126
|
+
inputs,
|
|
1127
|
+
variables,
|
|
1128
|
+
onDropField,
|
|
1129
|
+
testId: `${testId}-call`,
|
|
1130
|
+
readOnly
|
|
1131
|
+
}, "call"));
|
|
1132
|
+
}
|
|
1133
|
+
if (RESULT_ACTIONS.has(step.action)) fields.push(/* @__PURE__ */ jsx(TextField, {
|
|
1134
|
+
label: tr("fluidgrids.builder.uiScript.field.saveAs", "Keep the result as"),
|
|
1135
|
+
placeholder: "status",
|
|
1136
|
+
value: step.saveAs,
|
|
1137
|
+
onChange: (next) => set("saveAs", next || void 0),
|
|
1138
|
+
testId: `${testId}-saveAs`,
|
|
1139
|
+
readOnly
|
|
1140
|
+
}, "saveAs"));
|
|
1141
|
+
if (fields.length === 0) return null;
|
|
1142
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1143
|
+
className: "grid grid-cols-1 gap-1.5 sm:grid-cols-2",
|
|
1144
|
+
"data-testid": `${testId}-fields`,
|
|
1145
|
+
children: Children.map(fields, (field) => /* @__PURE__ */ jsx("div", {
|
|
1146
|
+
className: "min-w-0",
|
|
1147
|
+
children: field
|
|
1148
|
+
}))
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// src/builder/components/ndv/ui-script-editor/ui-step-options.tsx
|
|
1153
|
+
/**
|
|
1154
|
+
* Levels 2 and 3 of one step (spec 19, M2):
|
|
1155
|
+
*
|
|
1156
|
+
* - {@link UiStepMoreOptions}, "More options": how long the step waits, what
|
|
1157
|
+
* it checks after acting, what a failure does, its input method and its
|
|
1158
|
+
* screenshots.
|
|
1159
|
+
* - {@link UiStepTechnicalDetails}, "Technical details": how each of its
|
|
1160
|
+
* elements is found (the target methods), and the step as JSON.
|
|
1161
|
+
*/
|
|
1162
|
+
function isRecord$2(value) {
|
|
1163
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1164
|
+
}
|
|
1165
|
+
/** Flow blocks and steps without a page action take no wait, verify or input options. */
|
|
1166
|
+
const NO_PAGE_OPTIONS = /* @__PURE__ */ new Set([
|
|
1167
|
+
"if",
|
|
1168
|
+
"forEach",
|
|
1169
|
+
"while",
|
|
1170
|
+
"retryScope",
|
|
1171
|
+
"set",
|
|
1172
|
+
"log",
|
|
1173
|
+
"call"
|
|
1174
|
+
]);
|
|
1175
|
+
/** The step's wait in seconds, as typed, or "" for the script's default. */
|
|
1176
|
+
function waitSeconds(step) {
|
|
1177
|
+
return secondsText(step.timeoutMs);
|
|
1178
|
+
}
|
|
1179
|
+
function secondsText(ms) {
|
|
1180
|
+
return typeof ms === "number" ? String(Math.round(ms / 100) / 10) : "";
|
|
1181
|
+
}
|
|
1182
|
+
/** How typed seconds read once stored. */
|
|
1183
|
+
function normalizeSeconds(text) {
|
|
1184
|
+
return secondsText(timeoutFromSeconds(text));
|
|
1185
|
+
}
|
|
1186
|
+
/** Seconds typed back into `timeoutMs`; empty or invalid text clears it. */
|
|
1187
|
+
function timeoutFromSeconds(text) {
|
|
1188
|
+
if (!text.trim()) return void 0;
|
|
1189
|
+
const seconds = Number(text);
|
|
1190
|
+
return Number.isFinite(seconds) && seconds >= 0 ? Math.round(seconds * 1e3) : void 0;
|
|
1191
|
+
}
|
|
1192
|
+
const VERIFY_KINDS = [
|
|
1193
|
+
"none",
|
|
1194
|
+
"elementVisible",
|
|
1195
|
+
"elementGone",
|
|
1196
|
+
"urlContains",
|
|
1197
|
+
"textPresent"
|
|
1198
|
+
];
|
|
1199
|
+
function isVerifyKind(value) {
|
|
1200
|
+
return typeof value === "string" && VERIFY_KINDS.includes(value);
|
|
1201
|
+
}
|
|
1202
|
+
function verifyKind(step) {
|
|
1203
|
+
const verify = step.verify;
|
|
1204
|
+
return isRecord$2(verify) && isVerifyKind(verify.kind) ? verify.kind : "none";
|
|
1205
|
+
}
|
|
1206
|
+
/** A new check of a kind, keeping its wait. */
|
|
1207
|
+
function newVerify(kind, previous) {
|
|
1208
|
+
if (kind === "none") return void 0;
|
|
1209
|
+
const timeoutMs = isRecord$2(previous) && typeof previous.timeoutMs === "number" ? { timeoutMs: previous.timeoutMs } : {};
|
|
1210
|
+
if (kind === "urlContains") return {
|
|
1211
|
+
kind,
|
|
1212
|
+
value: "",
|
|
1213
|
+
...timeoutMs
|
|
1214
|
+
};
|
|
1215
|
+
if (kind === "textPresent") return {
|
|
1216
|
+
kind,
|
|
1217
|
+
text: "",
|
|
1218
|
+
...timeoutMs
|
|
1219
|
+
};
|
|
1220
|
+
return {
|
|
1221
|
+
kind,
|
|
1222
|
+
target: { methods: [] },
|
|
1223
|
+
...timeoutMs
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
/** The targets a step holds, by field, for the technical details. */
|
|
1227
|
+
function stepTargetFields(step) {
|
|
1228
|
+
const fields = [];
|
|
1229
|
+
for (const field of [
|
|
1230
|
+
"target",
|
|
1231
|
+
"item",
|
|
1232
|
+
"next",
|
|
1233
|
+
"elementExists",
|
|
1234
|
+
"elements"
|
|
1235
|
+
]) if (step[field] !== void 0) fields.push({
|
|
1236
|
+
field,
|
|
1237
|
+
target: step[field]
|
|
1238
|
+
});
|
|
1239
|
+
if (isRecord$2(step.verify) && step.verify.target !== void 0) fields.push({
|
|
1240
|
+
field: "verify.target",
|
|
1241
|
+
target: step.verify.target
|
|
1242
|
+
});
|
|
1243
|
+
return fields;
|
|
1244
|
+
}
|
|
1245
|
+
/** The step with a target set by field (`verify.target` sets the check's target). */
|
|
1246
|
+
function withTargetField(step, field, target) {
|
|
1247
|
+
if (field === "verify.target") {
|
|
1248
|
+
const verify = isRecord$2(step.verify) ? step.verify : {};
|
|
1249
|
+
return setStepField(step, "verify", {
|
|
1250
|
+
...verify,
|
|
1251
|
+
target
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
return setStepField(step, field, target);
|
|
1255
|
+
}
|
|
1256
|
+
function UiStepMoreOptions({ step, onStep, elementNames, testId, readOnly }) {
|
|
1257
|
+
const tr = useTr();
|
|
1258
|
+
const set = (field, value) => onStep(setStepField(step, field, value));
|
|
1259
|
+
const pageOptions = !NO_PAGE_OPTIONS.has(step.action);
|
|
1260
|
+
const kind = verifyKind(step);
|
|
1261
|
+
const verify = isRecord$2(step.verify) ? step.verify : {};
|
|
1262
|
+
const retryAttempts = isRecord$2(step.retry) && typeof step.retry.attempts === "number" ? step.retry.attempts : 0;
|
|
1263
|
+
const onError = step.onError === "continue" ? "continue" : "fail";
|
|
1264
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1265
|
+
className: "grid grid-cols-1 gap-1.5 sm:grid-cols-2",
|
|
1266
|
+
"data-testid": `${testId}-more`,
|
|
1267
|
+
children: [
|
|
1268
|
+
pageOptions && /* @__PURE__ */ jsxs("label", {
|
|
1269
|
+
className: "flex flex-col gap-0.5",
|
|
1270
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1271
|
+
className: "text-[10px] font-semibold text-muted-foreground",
|
|
1272
|
+
children: tr("fluidgrids.builder.uiScript.options.wait", "Wait for the element up to (seconds)")
|
|
1273
|
+
}), /* @__PURE__ */ jsx(BufferedInput, {
|
|
1274
|
+
inputMode: "decimal",
|
|
1275
|
+
value: waitSeconds(step),
|
|
1276
|
+
normalize: normalizeSeconds,
|
|
1277
|
+
readOnly,
|
|
1278
|
+
placeholder: tr("fluidgrids.builder.uiScript.options.waitDefault", "30 on a new screen, else 10"),
|
|
1279
|
+
onText: (text) => set("timeoutMs", timeoutFromSeconds(text)),
|
|
1280
|
+
className: "rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50",
|
|
1281
|
+
"data-testid": `${testId}-timeout`
|
|
1282
|
+
})]
|
|
1283
|
+
}),
|
|
1284
|
+
pageOptions && /* @__PURE__ */ jsxs("label", {
|
|
1285
|
+
className: "flex flex-col gap-0.5",
|
|
1286
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1287
|
+
className: "text-[10px] font-semibold text-muted-foreground",
|
|
1288
|
+
children: tr("fluidgrids.builder.uiScript.options.verify", "After acting, check that")
|
|
1289
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
1290
|
+
value: kind,
|
|
1291
|
+
disabled: readOnly,
|
|
1292
|
+
onChange: (event) => isVerifyKind(event.target.value) && set("verify", newVerify(event.target.value, step.verify)),
|
|
1293
|
+
className: "rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50",
|
|
1294
|
+
"data-testid": `${testId}-verify`,
|
|
1295
|
+
children: [
|
|
1296
|
+
/* @__PURE__ */ jsx("option", {
|
|
1297
|
+
value: "none",
|
|
1298
|
+
children: tr("fluidgrids.builder.uiScript.options.verifyNone", "Nothing")
|
|
1299
|
+
}),
|
|
1300
|
+
/* @__PURE__ */ jsx("option", {
|
|
1301
|
+
value: "elementVisible",
|
|
1302
|
+
children: tr("fluidgrids.builder.uiScript.options.verifyVisible", "An element appears")
|
|
1303
|
+
}),
|
|
1304
|
+
/* @__PURE__ */ jsx("option", {
|
|
1305
|
+
value: "elementGone",
|
|
1306
|
+
children: tr("fluidgrids.builder.uiScript.options.verifyGone", "An element goes away")
|
|
1307
|
+
}),
|
|
1308
|
+
/* @__PURE__ */ jsx("option", {
|
|
1309
|
+
value: "urlContains",
|
|
1310
|
+
children: tr("fluidgrids.builder.uiScript.options.verifyUrl", "The address contains")
|
|
1311
|
+
}),
|
|
1312
|
+
/* @__PURE__ */ jsx("option", {
|
|
1313
|
+
value: "textPresent",
|
|
1314
|
+
children: tr("fluidgrids.builder.uiScript.options.verifyText", "A text is on the page")
|
|
1315
|
+
})
|
|
1316
|
+
]
|
|
1317
|
+
})]
|
|
1318
|
+
}),
|
|
1319
|
+
(kind === "elementVisible" || kind === "elementGone") && /* @__PURE__ */ jsx(UiTargetQuickField, {
|
|
1320
|
+
label: tr("fluidgrids.builder.uiScript.options.verifyElement", "Element"),
|
|
1321
|
+
target: verify.target,
|
|
1322
|
+
elementName: isRecord$2(verify.target) && typeof verify.target.element === "string" ? elementNames[verify.target.element] : void 0,
|
|
1323
|
+
onChange: (next) => set("verify", {
|
|
1324
|
+
...verify,
|
|
1325
|
+
target: next
|
|
1326
|
+
}),
|
|
1327
|
+
testId: `${testId}-verify-target`,
|
|
1328
|
+
readOnly
|
|
1329
|
+
}),
|
|
1330
|
+
(kind === "urlContains" || kind === "textPresent") && /* @__PURE__ */ jsxs("label", {
|
|
1331
|
+
className: "flex flex-col gap-0.5",
|
|
1332
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1333
|
+
className: "text-[10px] font-semibold text-muted-foreground",
|
|
1334
|
+
children: tr("fluidgrids.builder.uiScript.options.verifyValue", "Text")
|
|
1335
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
1336
|
+
type: "text",
|
|
1337
|
+
value: String((kind === "urlContains" ? verify.value : verify.text) ?? ""),
|
|
1338
|
+
readOnly,
|
|
1339
|
+
onChange: (event) => set("verify", {
|
|
1340
|
+
...verify,
|
|
1341
|
+
[kind === "urlContains" ? "value" : "text"]: event.target.value
|
|
1342
|
+
}),
|
|
1343
|
+
className: "rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50",
|
|
1344
|
+
"data-testid": `${testId}-verify-value`
|
|
1345
|
+
})]
|
|
1346
|
+
}),
|
|
1347
|
+
/* @__PURE__ */ jsxs("label", {
|
|
1348
|
+
className: "flex flex-col gap-0.5",
|
|
1349
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1350
|
+
className: uiSmallLabel,
|
|
1351
|
+
children: tr("fluidgrids.builder.uiScript.options.onError", "If the step fails")
|
|
1352
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
1353
|
+
value: onError,
|
|
1354
|
+
disabled: readOnly,
|
|
1355
|
+
onChange: (event) => set("onError", event.target.value === "continue" ? "continue" : void 0),
|
|
1356
|
+
className: uiInputClass,
|
|
1357
|
+
"data-testid": `${testId}-onError`,
|
|
1358
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
1359
|
+
value: "fail",
|
|
1360
|
+
children: tr("fluidgrids.builder.uiScript.options.fail", "Fail the node (default)")
|
|
1361
|
+
}), /* @__PURE__ */ jsx("option", {
|
|
1362
|
+
value: "continue",
|
|
1363
|
+
children: tr("fluidgrids.builder.uiScript.options.continue", "Continue with the next step")
|
|
1364
|
+
})]
|
|
1365
|
+
})]
|
|
1366
|
+
}),
|
|
1367
|
+
/* @__PURE__ */ jsxs("label", {
|
|
1368
|
+
className: "flex flex-col gap-0.5",
|
|
1369
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1370
|
+
className: uiSmallLabel,
|
|
1371
|
+
children: tr("fluidgrids.builder.uiScript.options.retry", "Retry this many times first")
|
|
1372
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
1373
|
+
type: "text",
|
|
1374
|
+
inputMode: "numeric",
|
|
1375
|
+
value: retryAttempts ? String(retryAttempts) : "",
|
|
1376
|
+
readOnly,
|
|
1377
|
+
placeholder: "0",
|
|
1378
|
+
onChange: (event) => {
|
|
1379
|
+
const attempts = wholeNumber(event.target.value);
|
|
1380
|
+
set("retry", attempts ? {
|
|
1381
|
+
...isRecord$2(step.retry) ? step.retry : {},
|
|
1382
|
+
attempts
|
|
1383
|
+
} : void 0);
|
|
1384
|
+
},
|
|
1385
|
+
className: uiInputClass,
|
|
1386
|
+
"data-testid": `${testId}-retry`
|
|
1387
|
+
})]
|
|
1388
|
+
}),
|
|
1389
|
+
pageOptions && /* @__PURE__ */ jsxs("label", {
|
|
1390
|
+
className: "flex flex-col gap-0.5",
|
|
1391
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1392
|
+
className: "text-[10px] font-semibold text-muted-foreground",
|
|
1393
|
+
children: tr("fluidgrids.builder.uiScript.options.inputMethod", "Input method")
|
|
1394
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
1395
|
+
value: typeof step.inputMethod === "string" ? step.inputMethod : "auto",
|
|
1396
|
+
disabled: readOnly,
|
|
1397
|
+
onChange: (event) => set("inputMethod", event.target.value === "auto" ? void 0 : event.target.value),
|
|
1398
|
+
className: "rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50",
|
|
1399
|
+
"data-testid": `${testId}-inputMethod`,
|
|
1400
|
+
children: [
|
|
1401
|
+
/* @__PURE__ */ jsx("option", {
|
|
1402
|
+
value: "auto",
|
|
1403
|
+
children: tr("fluidgrids.builder.uiScript.options.inputAuto", "Automatic (default)")
|
|
1404
|
+
}),
|
|
1405
|
+
/* @__PURE__ */ jsx("option", {
|
|
1406
|
+
value: "direct",
|
|
1407
|
+
children: tr("fluidgrids.builder.uiScript.options.inputDirect", "Simulated events")
|
|
1408
|
+
}),
|
|
1409
|
+
/* @__PURE__ */ jsx("option", {
|
|
1410
|
+
value: "hardware",
|
|
1411
|
+
children: tr("fluidgrids.builder.uiScript.options.inputHardware", "Hardware input")
|
|
1412
|
+
})
|
|
1413
|
+
]
|
|
1414
|
+
})]
|
|
1415
|
+
}),
|
|
1416
|
+
pageOptions && /* @__PURE__ */ jsxs("label", {
|
|
1417
|
+
className: "flex flex-col gap-0.5",
|
|
1418
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1419
|
+
className: "text-[10px] font-semibold text-muted-foreground",
|
|
1420
|
+
children: tr("fluidgrids.builder.uiScript.options.screenshots", "Screenshots")
|
|
1421
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
1422
|
+
value: typeof step.screenshot === "string" ? step.screenshot : "default",
|
|
1423
|
+
disabled: readOnly,
|
|
1424
|
+
onChange: (event) => set("screenshot", event.target.value === "default" ? void 0 : event.target.value),
|
|
1425
|
+
className: "rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50",
|
|
1426
|
+
"data-testid": `${testId}-screenshot`,
|
|
1427
|
+
children: [
|
|
1428
|
+
/* @__PURE__ */ jsx("option", {
|
|
1429
|
+
value: "default",
|
|
1430
|
+
children: tr("fluidgrids.builder.uiScript.options.screenshotDefault", "As the script says (on failure)")
|
|
1431
|
+
}),
|
|
1432
|
+
/* @__PURE__ */ jsx("option", {
|
|
1433
|
+
value: "onFailure",
|
|
1434
|
+
children: tr("fluidgrids.builder.uiScript.options.screenshotFailure", "On failure")
|
|
1435
|
+
}),
|
|
1436
|
+
/* @__PURE__ */ jsx("option", {
|
|
1437
|
+
value: "always",
|
|
1438
|
+
children: tr("fluidgrids.builder.uiScript.options.screenshotAlways", "Every time")
|
|
1439
|
+
}),
|
|
1440
|
+
/* @__PURE__ */ jsx("option", {
|
|
1441
|
+
value: "never",
|
|
1442
|
+
children: tr("fluidgrids.builder.uiScript.options.screenshotNever", "Never")
|
|
1443
|
+
})
|
|
1444
|
+
]
|
|
1445
|
+
})]
|
|
1446
|
+
}),
|
|
1447
|
+
/* @__PURE__ */ jsxs("label", {
|
|
1448
|
+
className: "flex items-center gap-1.5 text-xs",
|
|
1449
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
1450
|
+
type: "checkbox",
|
|
1451
|
+
checked: step.safeToRepeat === true,
|
|
1452
|
+
disabled: readOnly,
|
|
1453
|
+
onChange: (event) => set("safeToRepeat", event.target.checked ? true : void 0),
|
|
1454
|
+
"data-testid": `${testId}-safeToRepeat`
|
|
1455
|
+
}), tr("fluidgrids.builder.uiScript.options.safeToRepeat", "Safe to run again after an interruption")]
|
|
1456
|
+
}),
|
|
1457
|
+
/* @__PURE__ */ jsxs("label", {
|
|
1458
|
+
className: "flex items-center gap-1.5 text-xs",
|
|
1459
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
1460
|
+
type: "checkbox",
|
|
1461
|
+
checked: step.disabled === true,
|
|
1462
|
+
disabled: readOnly,
|
|
1463
|
+
onChange: (event) => set("disabled", event.target.checked ? true : void 0),
|
|
1464
|
+
"data-testid": `${testId}-disabled`
|
|
1465
|
+
}), tr("fluidgrids.builder.uiScript.options.disabled", "Skip this step")]
|
|
1466
|
+
})
|
|
1467
|
+
]
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
function UiStepTechnicalDetails({ step, onStep, testId, readOnly }) {
|
|
1471
|
+
const tr = useTr();
|
|
1472
|
+
const [json, setJson] = useState(() => JSON.stringify(step, null, 2));
|
|
1473
|
+
const [jsonInvalid, setJsonInvalid] = useState(false);
|
|
1474
|
+
const [firstShown] = useState(() => JSON.stringify(step));
|
|
1475
|
+
const shown = useRef(firstShown);
|
|
1476
|
+
useEffect(() => {
|
|
1477
|
+
const current = JSON.stringify(step);
|
|
1478
|
+
if (current === shown.current) return;
|
|
1479
|
+
shown.current = current;
|
|
1480
|
+
setJson(JSON.stringify(step, null, 2));
|
|
1481
|
+
setJsonInvalid(false);
|
|
1482
|
+
}, [step]);
|
|
1483
|
+
const targets = stepTargetFields(step);
|
|
1484
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1485
|
+
className: "flex flex-col gap-2",
|
|
1486
|
+
"data-testid": `${testId}-technical`,
|
|
1487
|
+
children: [targets.map(({ field, target }) => /* @__PURE__ */ jsxs("div", {
|
|
1488
|
+
className: "flex flex-col gap-1",
|
|
1489
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1490
|
+
className: uiSmallLabel,
|
|
1491
|
+
children: tr("fluidgrids.builder.uiScript.technical.targetOf", "How {{field}} is found", { field })
|
|
1492
|
+
}), /* @__PURE__ */ jsx(UiTargetMethodsEditor, {
|
|
1493
|
+
target,
|
|
1494
|
+
onChange: (next) => onStep(withTargetField(step, field, next)),
|
|
1495
|
+
testId: `${testId}-target-${field.replace(".", "-")}`,
|
|
1496
|
+
readOnly
|
|
1497
|
+
})]
|
|
1498
|
+
}, field)), /* @__PURE__ */ jsxs("label", {
|
|
1499
|
+
className: "flex flex-col gap-0.5",
|
|
1500
|
+
children: [
|
|
1501
|
+
/* @__PURE__ */ jsx("span", {
|
|
1502
|
+
className: uiSmallLabel,
|
|
1503
|
+
children: tr("fluidgrids.builder.uiScript.technical.json", "This step as JSON (id {{id}})", { id: typeof step.id === "string" ? step.id : "" })
|
|
1504
|
+
}),
|
|
1505
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
1506
|
+
value: json,
|
|
1507
|
+
rows: 6,
|
|
1508
|
+
spellCheck: false,
|
|
1509
|
+
readOnly,
|
|
1510
|
+
"aria-invalid": jsonInvalid,
|
|
1511
|
+
onChange: (event) => {
|
|
1512
|
+
setJson(event.target.value);
|
|
1513
|
+
try {
|
|
1514
|
+
const parsed = JSON.parse(event.target.value);
|
|
1515
|
+
if (isDraftStep(parsed)) {
|
|
1516
|
+
setJsonInvalid(false);
|
|
1517
|
+
shown.current = JSON.stringify(parsed);
|
|
1518
|
+
onStep(parsed);
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
} catch {}
|
|
1522
|
+
setJsonInvalid(true);
|
|
1523
|
+
},
|
|
1524
|
+
className: cn(uiInputClass, "w-full font-mono"),
|
|
1525
|
+
"data-testid": `${testId}-json`
|
|
1526
|
+
}),
|
|
1527
|
+
jsonInvalid && /* @__PURE__ */ jsx("span", {
|
|
1528
|
+
className: "text-[11px] text-[var(--color-status-error-text)]",
|
|
1529
|
+
children: tr("fluidgrids.builder.uiScript.technical.jsonInvalid", "Not a step yet: a JSON object with an action.")
|
|
1530
|
+
})
|
|
1531
|
+
]
|
|
1532
|
+
})]
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
// src/builder/components/ndv/ui-script-editor/ui-step-list.tsx
|
|
1537
|
+
/**
|
|
1538
|
+
* The step list of the Use Browser editor (spec 19, M1): each step as a
|
|
1539
|
+
* sentence with its number, a breakpoint marker, Run step and a "⋯" menu;
|
|
1540
|
+
* opened, its everyday fields, then More options and Technical details. Flow
|
|
1541
|
+
* blocks hold their steps as nested lists.
|
|
1542
|
+
*
|
|
1543
|
+
* Fully operable from the keyboard: every step row is a stop in the tab order
|
|
1544
|
+
* and also answers
|
|
1545
|
+
*
|
|
1546
|
+
* ArrowUp / ArrowDown the previous / next step (nested steps included)
|
|
1547
|
+
* Home / End the first / last step
|
|
1548
|
+
* Enter or Space open or close the step (the row is a button)
|
|
1549
|
+
* Alt+ArrowUp / ArrowDown move the step up / down within its block
|
|
1550
|
+
* Delete remove the step
|
|
1551
|
+
*/
|
|
1552
|
+
/** The key that remembers a step's open state: its id, else its path. */
|
|
1553
|
+
function stepKey(step, path) {
|
|
1554
|
+
return typeof step.id === "string" && step.id ? `id:${step.id}` : `path:${path}`;
|
|
1555
|
+
}
|
|
1556
|
+
/** Every step row of the editor, in document order. */
|
|
1557
|
+
function stepRows(root) {
|
|
1558
|
+
return root ? [...root.querySelectorAll("[data-ui-step-row]")] : [];
|
|
1559
|
+
}
|
|
1560
|
+
/** Focus a step row once the list has drawn it (after a move, add or delete). */
|
|
1561
|
+
function focusRow(root, path) {
|
|
1562
|
+
if (!root || path === void 0) return;
|
|
1563
|
+
stepRows(root).find((row) => row.dataset.uiStepRow === path)?.focus();
|
|
1564
|
+
}
|
|
1565
|
+
/** The path of the step `delta` places away in the same block, or undefined. */
|
|
1566
|
+
function siblingPath(path, delta) {
|
|
1567
|
+
const cut = path.lastIndexOf(".");
|
|
1568
|
+
const index = Number(cut < 0 ? path : path.slice(cut + 1)) + delta;
|
|
1569
|
+
return cut < 0 ? String(index) : `${path.slice(0, cut)}.${index}`;
|
|
1570
|
+
}
|
|
1571
|
+
/** The block names of a flow step, with their labels. */
|
|
1572
|
+
function blockLabel(name) {
|
|
1573
|
+
switch (name) {
|
|
1574
|
+
case "then": return {
|
|
1575
|
+
key: "fluidgrids.builder.uiScript.block.then",
|
|
1576
|
+
fallback: "Then"
|
|
1577
|
+
};
|
|
1578
|
+
case "else": return {
|
|
1579
|
+
key: "fluidgrids.builder.uiScript.block.else",
|
|
1580
|
+
fallback: "Otherwise"
|
|
1581
|
+
};
|
|
1582
|
+
default: return {
|
|
1583
|
+
key: "fluidgrids.builder.uiScript.block.steps",
|
|
1584
|
+
fallback: "Steps"
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
function StepMenu({ path, step, index, count, context, onClose }) {
|
|
1589
|
+
const tr = useTr();
|
|
1590
|
+
const { draft, write, run, readOnly, testIdPrefix } = context;
|
|
1591
|
+
const item = (id, label, action, disabled = false) => /* @__PURE__ */ jsx("button", {
|
|
1592
|
+
type: "button",
|
|
1593
|
+
role: "menuitem",
|
|
1594
|
+
disabled,
|
|
1595
|
+
onClick: () => {
|
|
1596
|
+
onClose();
|
|
1597
|
+
action();
|
|
1598
|
+
},
|
|
1599
|
+
className: "rounded px-2 py-1 text-left text-xs text-foreground hover:bg-muted disabled:opacity-50",
|
|
1600
|
+
"data-testid": `${testIdPrefix}-ui-step-${path}-menu-${id}`,
|
|
1601
|
+
children: label
|
|
1602
|
+
}, id);
|
|
1603
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1604
|
+
role: "menu",
|
|
1605
|
+
"aria-label": tr("fluidgrids.builder.uiScript.menu.label", "Step actions"),
|
|
1606
|
+
className: "flex flex-col gap-0.5 rounded-md border border-border bg-popover p-1 shadow-sm",
|
|
1607
|
+
onKeyDown: (event) => {
|
|
1608
|
+
if (event.key === "Escape") {
|
|
1609
|
+
event.stopPropagation();
|
|
1610
|
+
onClose();
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
"data-testid": `${testIdPrefix}-ui-step-${path}-menu`,
|
|
1614
|
+
children: [
|
|
1615
|
+
run && item("run-from", tr("fluidgrids.builder.uiScript.menu.runFromHere", "Run from here"), () => run({ startAt: path }), context.runBusy === true),
|
|
1616
|
+
item("duplicate", tr("fluidgrids.builder.uiScript.menu.duplicate", "Duplicate"), () => write(duplicateStep(draft, path), siblingPath(path, 1)), readOnly),
|
|
1617
|
+
item("up", tr("fluidgrids.builder.uiScript.menu.moveUp", "Move up"), () => write(moveStep(draft, path, -1), siblingPath(path, -1)), readOnly || index === 0),
|
|
1618
|
+
item("down", tr("fluidgrids.builder.uiScript.menu.moveDown", "Move down"), () => write(moveStep(draft, path, 1), siblingPath(path, 1)), readOnly || index === count - 1),
|
|
1619
|
+
item("breakpoint", step.breakpoint === true ? tr("fluidgrids.builder.uiScript.menu.removeBreakpoint", "Remove breakpoint") : tr("fluidgrids.builder.uiScript.menu.addBreakpoint", "Add breakpoint"), () => write(replaceStep(draft, path, setStepField(step, "breakpoint", step.breakpoint === true ? void 0 : true)), path), readOnly),
|
|
1620
|
+
item("delete", tr("fluidgrids.builder.uiScript.menu.delete", "Delete"), () => write(removeStep(draft, path)), readOnly)
|
|
1621
|
+
]
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
function UiStepItem({ step, path, index, count, context }) {
|
|
1625
|
+
const tr = useTr();
|
|
1626
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
1627
|
+
const { draft, write, open, setOpen, run, rootRef, testIdPrefix, readOnly } = context;
|
|
1628
|
+
const key = stepKey(step, path);
|
|
1629
|
+
const level = open.get(key) ?? 0;
|
|
1630
|
+
const number = readableStepNumber(path);
|
|
1631
|
+
const sentence = stepSentence(step, context.elements);
|
|
1632
|
+
const text = tr(sentence.key, sentence.fallback, sentence.vars);
|
|
1633
|
+
const onStep = (next) => write((current) => replaceStep(current, path, next));
|
|
1634
|
+
const testId = `${testIdPrefix}-ui-step-${path}`;
|
|
1635
|
+
const onKeyDown = (event) => {
|
|
1636
|
+
if (event.target !== event.currentTarget) return;
|
|
1637
|
+
const rows = stepRows(rootRef.current);
|
|
1638
|
+
const at = rows.indexOf(event.currentTarget);
|
|
1639
|
+
if (event.altKey && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
|
|
1640
|
+
event.preventDefault();
|
|
1641
|
+
if (readOnly) return;
|
|
1642
|
+
const delta = event.key === "ArrowUp" ? -1 : 1;
|
|
1643
|
+
const moved = moveStep(draft, path, delta);
|
|
1644
|
+
if (moved !== draft) write(moved, siblingPath(path, delta));
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
switch (event.key) {
|
|
1648
|
+
case "ArrowDown":
|
|
1649
|
+
event.preventDefault();
|
|
1650
|
+
rows[at + 1]?.focus();
|
|
1651
|
+
break;
|
|
1652
|
+
case "ArrowUp":
|
|
1653
|
+
event.preventDefault();
|
|
1654
|
+
rows[at - 1]?.focus();
|
|
1655
|
+
break;
|
|
1656
|
+
case "Home":
|
|
1657
|
+
event.preventDefault();
|
|
1658
|
+
rows[0]?.focus();
|
|
1659
|
+
break;
|
|
1660
|
+
case "End":
|
|
1661
|
+
event.preventDefault();
|
|
1662
|
+
rows[rows.length - 1]?.focus();
|
|
1663
|
+
break;
|
|
1664
|
+
case "Delete":
|
|
1665
|
+
event.preventDefault();
|
|
1666
|
+
if (readOnly) return;
|
|
1667
|
+
write(removeStep(draft, path), index < count - 1 ? path : index > 0 ? siblingPath(path, -1) : void 0);
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
1671
|
+
className: cn("flex flex-col gap-1 rounded-md border border-border p-1.5", context.problemPaths.has(path) && "border-[var(--color-status-warning-text)]"),
|
|
1672
|
+
"data-testid": testId,
|
|
1673
|
+
children: [
|
|
1674
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1675
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
1676
|
+
"data-testid": `${testId}-header`,
|
|
1677
|
+
children: [
|
|
1678
|
+
/* @__PURE__ */ jsx("button", {
|
|
1679
|
+
type: "button",
|
|
1680
|
+
tabIndex: -1,
|
|
1681
|
+
onClick: () => setOpen(key, level === 0 ? 1 : 0),
|
|
1682
|
+
"aria-label": level > 0 ? tr("fluidgrids.builder.uiScript.step.close", "Close the step") : tr("fluidgrids.builder.uiScript.step.open", "Open the step"),
|
|
1683
|
+
className: uiIconButton,
|
|
1684
|
+
"data-testid": `${testId}-toggle`,
|
|
1685
|
+
children: level > 0 ? /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5" })
|
|
1686
|
+
}),
|
|
1687
|
+
/* @__PURE__ */ jsxs("button", {
|
|
1688
|
+
type: "button",
|
|
1689
|
+
"aria-expanded": level > 0,
|
|
1690
|
+
"aria-label": tr("fluidgrids.builder.uiScript.step.rowLabel", "Step {{number}}: {{sentence}}", {
|
|
1691
|
+
number,
|
|
1692
|
+
sentence: text
|
|
1693
|
+
}),
|
|
1694
|
+
"data-ui-step-row": path,
|
|
1695
|
+
onKeyDown,
|
|
1696
|
+
onClick: () => setOpen(key, level === 0 ? 1 : 0),
|
|
1697
|
+
className: "flex min-w-0 flex-1 items-center gap-1.5 rounded px-0.5 text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",
|
|
1698
|
+
"data-testid": `${testId}-row`,
|
|
1699
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
1700
|
+
className: "flex shrink-0 items-center gap-0.5 text-[10px] font-semibold text-muted-foreground",
|
|
1701
|
+
children: [step.breakpoint === true && /* @__PURE__ */ jsx("span", {
|
|
1702
|
+
role: "img",
|
|
1703
|
+
"aria-label": tr("fluidgrids.builder.uiScript.step.breakpoint", "Breakpoint (test runs only)"),
|
|
1704
|
+
title: tr("fluidgrids.builder.uiScript.step.breakpoint", "Breakpoint (test runs only)"),
|
|
1705
|
+
"data-testid": `${testId}-breakpoint`,
|
|
1706
|
+
children: /* @__PURE__ */ jsx(CircleDot, { className: "size-3 text-[var(--color-status-error-text)]" })
|
|
1707
|
+
}), number]
|
|
1708
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1709
|
+
className: cn("min-w-0 flex-1 truncate text-xs text-foreground", step.disabled === true && "text-muted-foreground line-through"),
|
|
1710
|
+
title: text,
|
|
1711
|
+
"data-testid": `${testId}-sentence`,
|
|
1712
|
+
children: text
|
|
1713
|
+
})]
|
|
1714
|
+
}),
|
|
1715
|
+
run && /* @__PURE__ */ jsxs("button", {
|
|
1716
|
+
type: "button",
|
|
1717
|
+
disabled: context.runBusy === true,
|
|
1718
|
+
onClick: () => run({
|
|
1719
|
+
startAt: path,
|
|
1720
|
+
stopAfter: path
|
|
1721
|
+
}),
|
|
1722
|
+
className: "flex shrink-0 items-center gap-0.5 rounded px-1 py-0.5 text-[11px] text-primary hover:bg-muted disabled:opacity-50",
|
|
1723
|
+
"data-testid": `${testId}-run`,
|
|
1724
|
+
children: [/* @__PURE__ */ jsx(Play, { className: "size-3" }), tr("fluidgrids.builder.uiScript.step.run", "Run step")]
|
|
1725
|
+
}),
|
|
1726
|
+
/* @__PURE__ */ jsx("button", {
|
|
1727
|
+
type: "button",
|
|
1728
|
+
"aria-haspopup": "menu",
|
|
1729
|
+
"aria-expanded": menuOpen,
|
|
1730
|
+
"aria-label": tr("fluidgrids.builder.uiScript.menu.open", "More step actions"),
|
|
1731
|
+
onClick: () => setMenuOpen((current) => !current),
|
|
1732
|
+
className: uiIconButton,
|
|
1733
|
+
"data-testid": `${testId}-menu-open`,
|
|
1734
|
+
children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-3.5" })
|
|
1735
|
+
})
|
|
1736
|
+
]
|
|
1737
|
+
}),
|
|
1738
|
+
menuOpen && /* @__PURE__ */ jsx(StepMenu, {
|
|
1739
|
+
path,
|
|
1740
|
+
step,
|
|
1741
|
+
index,
|
|
1742
|
+
count,
|
|
1743
|
+
context,
|
|
1744
|
+
onClose: () => setMenuOpen(false)
|
|
1745
|
+
}),
|
|
1746
|
+
level > 0 && /* @__PURE__ */ jsxs("div", {
|
|
1747
|
+
className: "flex flex-col gap-1.5 pl-5",
|
|
1748
|
+
"data-testid": `${testId}-body`,
|
|
1749
|
+
children: [
|
|
1750
|
+
/* @__PURE__ */ jsxs("label", {
|
|
1751
|
+
className: "flex flex-col gap-0.5",
|
|
1752
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1753
|
+
className: "text-[10px] font-semibold text-muted-foreground",
|
|
1754
|
+
children: tr("fluidgrids.builder.uiScript.step.action", "Action")
|
|
1755
|
+
}), /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
1756
|
+
value: step.action,
|
|
1757
|
+
disabled: readOnly,
|
|
1758
|
+
onChange: (event) => onStep(changeStepAction(step, event.target.value)),
|
|
1759
|
+
className: "rounded border border-input bg-background px-1.5 py-1 text-xs text-foreground outline-none focus:border-primary disabled:opacity-50",
|
|
1760
|
+
"data-testid": `${testId}-action`,
|
|
1761
|
+
children: [!UI_STEP_ACTION_TEXTS.some((item) => item.action === step.action) && /* @__PURE__ */ jsx("option", {
|
|
1762
|
+
value: step.action,
|
|
1763
|
+
children: step.action
|
|
1764
|
+
}), UI_STEP_ACTION_TEXTS.map((item) => /* @__PURE__ */ jsx("option", {
|
|
1765
|
+
value: item.action,
|
|
1766
|
+
children: tr(item.key, item.fallback)
|
|
1767
|
+
}, item.action))]
|
|
1768
|
+
})]
|
|
1769
|
+
}),
|
|
1770
|
+
/* @__PURE__ */ jsx(UiStepFields, {
|
|
1771
|
+
step,
|
|
1772
|
+
onStep,
|
|
1773
|
+
context: context.fields,
|
|
1774
|
+
testId
|
|
1775
|
+
}),
|
|
1776
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1777
|
+
className: "flex flex-wrap gap-3",
|
|
1778
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1779
|
+
type: "button",
|
|
1780
|
+
onClick: () => setOpen(key, level >= 2 ? 1 : 2),
|
|
1781
|
+
className: "flex items-center gap-1 text-xs text-primary hover:underline disabled:opacity-50",
|
|
1782
|
+
"aria-expanded": level >= 2,
|
|
1783
|
+
"data-testid": `${testId}-more-toggle`,
|
|
1784
|
+
children: tr("fluidgrids.builder.uiScript.step.moreOptions", "More options ›")
|
|
1785
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1786
|
+
type: "button",
|
|
1787
|
+
onClick: () => setOpen(key, level >= 3 ? 2 : 3),
|
|
1788
|
+
className: "flex items-center gap-1 text-xs text-primary hover:underline disabled:opacity-50",
|
|
1789
|
+
"aria-expanded": level >= 3,
|
|
1790
|
+
"data-testid": `${testId}-technical-toggle`,
|
|
1791
|
+
children: tr("fluidgrids.builder.uiScript.step.technicalDetails", "Show technical details ›")
|
|
1792
|
+
})]
|
|
1793
|
+
}),
|
|
1794
|
+
level >= 2 && /* @__PURE__ */ jsx(UiStepMoreOptions, {
|
|
1795
|
+
step,
|
|
1796
|
+
onStep,
|
|
1797
|
+
elementNames: context.fields.elementNames,
|
|
1798
|
+
testId,
|
|
1799
|
+
readOnly
|
|
1800
|
+
}),
|
|
1801
|
+
level >= 3 && /* @__PURE__ */ jsx(UiStepTechnicalDetails, {
|
|
1802
|
+
step,
|
|
1803
|
+
onStep,
|
|
1804
|
+
testId,
|
|
1805
|
+
readOnly
|
|
1806
|
+
})
|
|
1807
|
+
]
|
|
1808
|
+
}),
|
|
1809
|
+
(STEP_BLOCKS[step.action] ?? []).map((name) => {
|
|
1810
|
+
const label = blockLabel(name);
|
|
1811
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1812
|
+
className: "flex flex-col gap-1 border-l border-border pl-3",
|
|
1813
|
+
"data-testid": `${testId}-block-${name}`,
|
|
1814
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1815
|
+
className: "text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",
|
|
1816
|
+
children: tr(label.key, label.fallback)
|
|
1817
|
+
}), /* @__PURE__ */ jsx(UiStepList, {
|
|
1818
|
+
block: `${path}.${name}`,
|
|
1819
|
+
context
|
|
1820
|
+
})]
|
|
1821
|
+
}, name);
|
|
1822
|
+
})
|
|
1823
|
+
]
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
/** The "Add a step" chooser of one block. */
|
|
1827
|
+
function AddStep({ block, index, context }) {
|
|
1828
|
+
const tr = useTr();
|
|
1829
|
+
const { draft, write, testIdPrefix, readOnly } = context;
|
|
1830
|
+
const testId = `${testIdPrefix}-ui-add-${block || "main"}`;
|
|
1831
|
+
return /* @__PURE__ */ jsxs(ThemedSelect, {
|
|
1832
|
+
value: "",
|
|
1833
|
+
disabled: readOnly,
|
|
1834
|
+
"aria-label": tr("fluidgrids.builder.uiScript.add", "Add step"),
|
|
1835
|
+
onChange: (event) => {
|
|
1836
|
+
const action = event.target.value;
|
|
1837
|
+
if (!action) return;
|
|
1838
|
+
write(insertStep(draft, block, index, newStep(action, draft)), stepPathIn(block, index));
|
|
1839
|
+
},
|
|
1840
|
+
className: cn(uiInputClass, "w-48"),
|
|
1841
|
+
"data-testid": testId,
|
|
1842
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
1843
|
+
value: "",
|
|
1844
|
+
children: tr("fluidgrids.builder.uiScript.add", "Add step")
|
|
1845
|
+
}), UI_STEP_ACTION_TEXTS.map((item) => /* @__PURE__ */ jsx("option", {
|
|
1846
|
+
value: item.action,
|
|
1847
|
+
children: tr(item.key, item.fallback)
|
|
1848
|
+
}, item.action))]
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
/** The steps of one block, then its "Add step" chooser. */
|
|
1852
|
+
function UiStepList({ block, context }) {
|
|
1853
|
+
const tr = useTr();
|
|
1854
|
+
const steps = blockSteps(context.draft, block) ?? [];
|
|
1855
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1856
|
+
className: "flex flex-col gap-1",
|
|
1857
|
+
children: [/* @__PURE__ */ jsx("ol", {
|
|
1858
|
+
className: "flex flex-col gap-1",
|
|
1859
|
+
"aria-label": tr("fluidgrids.builder.uiScript.list", "Steps"),
|
|
1860
|
+
"data-testid": `${context.testIdPrefix}-ui-steps-${block || "main"}`,
|
|
1861
|
+
children: steps.map((step, index) => {
|
|
1862
|
+
const path = stepPathIn(block, index);
|
|
1863
|
+
return /* @__PURE__ */ jsx(UiStepItem, {
|
|
1864
|
+
step,
|
|
1865
|
+
path,
|
|
1866
|
+
index,
|
|
1867
|
+
count: steps.length,
|
|
1868
|
+
context
|
|
1869
|
+
}, stepKey(step, path));
|
|
1870
|
+
})
|
|
1871
|
+
}), /* @__PURE__ */ jsx(AddStep, {
|
|
1872
|
+
block,
|
|
1873
|
+
index: steps.length,
|
|
1874
|
+
context
|
|
1875
|
+
})]
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
// src/builder/components/ndv/ui-script-editor/ui-step-fix-banner.tsx
|
|
1880
|
+
/**
|
|
1881
|
+
* The banner of a step opened from the run view's **Fix this step** (RPA
|
|
1882
|
+
* plan P1-14, spec 19 M6 markers 5 and 6, rule 5): which step failed, the
|
|
1883
|
+
* screenshot taken at the failure, and **Re-run from this step**, offered
|
|
1884
|
+
* only once the fix is saved. The re-run is a TEST run of this node from the
|
|
1885
|
+
* failed step (`uiStepRange.startAt`), started like Run step.
|
|
1886
|
+
*/
|
|
1887
|
+
function UiStepFixBanner({ nodeId, run, runBusy, testIdPrefix }) {
|
|
1888
|
+
const tr = useTr();
|
|
1889
|
+
const fix = useUiStepFixStore((s) => s.fix);
|
|
1890
|
+
const clearFix = useUiStepFixStore((s) => s.clearFix);
|
|
1891
|
+
const workflowKey = useFlowStore((s) => s.workflow.workflowKey || s.workflow.id);
|
|
1892
|
+
const save = useSaveStatusStore(useShallow((s) => ({
|
|
1893
|
+
dirty: s.dirty,
|
|
1894
|
+
saving: s.saving,
|
|
1895
|
+
lastSavedAt: s.lastSavedAt
|
|
1896
|
+
})));
|
|
1897
|
+
if (!(fix !== null && nodeId !== void 0 && fix.nodeId === nodeId && fix.workflowKey === workflowKey) || !fix) return null;
|
|
1898
|
+
let number;
|
|
1899
|
+
try {
|
|
1900
|
+
number = readableStepNumber(fix.stepPath);
|
|
1901
|
+
} catch {
|
|
1902
|
+
number = fix.stepPath;
|
|
1903
|
+
}
|
|
1904
|
+
const saved = fixIsSaved(fix.openedAt, save);
|
|
1905
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1906
|
+
role: "status",
|
|
1907
|
+
className: "flex flex-col gap-2 rounded-md border border-[var(--color-status-error-border)] bg-[var(--color-status-error-bg-subtle)] p-2 text-xs",
|
|
1908
|
+
"data-testid": `${testIdPrefix}-ui-fix`,
|
|
1909
|
+
"data-step-path": fix.stepPath,
|
|
1910
|
+
children: [
|
|
1911
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1912
|
+
className: "flex items-start justify-between gap-2",
|
|
1913
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1914
|
+
className: "text-[var(--color-status-error-text)]",
|
|
1915
|
+
children: tr("fluidgrids.builder.uiScript.fix.title", "Step {{number}} failed in a run. Change the step, save, then re-run from it.", { number })
|
|
1916
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1917
|
+
type: "button",
|
|
1918
|
+
onClick: clearFix,
|
|
1919
|
+
className: uiIconButton,
|
|
1920
|
+
"aria-label": tr("fluidgrids.builder.uiScript.fix.close", "Close"),
|
|
1921
|
+
"data-testid": `${testIdPrefix}-ui-fix-close`,
|
|
1922
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
|
|
1923
|
+
})]
|
|
1924
|
+
}),
|
|
1925
|
+
fix.screenshotFileId && /* @__PURE__ */ jsx(UiStepScreenshot, {
|
|
1926
|
+
fileId: fix.screenshotFileId,
|
|
1927
|
+
size: "large",
|
|
1928
|
+
label: tr("fluidgrids.builder.uiScript.fix.screenshot", "Step {{number}}, at the failure", { number }),
|
|
1929
|
+
testId: `${testIdPrefix}-ui-fix-screenshot`
|
|
1930
|
+
}),
|
|
1931
|
+
run && /* @__PURE__ */ jsxs("div", {
|
|
1932
|
+
className: "flex flex-wrap items-center gap-2",
|
|
1933
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1934
|
+
type: "button",
|
|
1935
|
+
className: "flex items-center gap-1 text-xs text-primary hover:underline disabled:opacity-50",
|
|
1936
|
+
disabled: !saved || runBusy,
|
|
1937
|
+
onClick: () => {
|
|
1938
|
+
run({ startAt: fix.stepPath });
|
|
1939
|
+
clearFix();
|
|
1940
|
+
},
|
|
1941
|
+
"data-testid": `${testIdPrefix}-ui-fix-rerun`,
|
|
1942
|
+
children: tr("fluidgrids.builder.uiScript.fix.rerun", "Re-run from this step")
|
|
1943
|
+
}), !saved && /* @__PURE__ */ jsx("span", {
|
|
1944
|
+
className: "text-muted-foreground",
|
|
1945
|
+
children: tr("fluidgrids.builder.uiScript.fix.saveFirst", "Save the workflow with your fix to re-run from this step.")
|
|
1946
|
+
})]
|
|
1947
|
+
})
|
|
1948
|
+
]
|
|
1949
|
+
});
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
// src/builder/components/ndv/ui-script-editor/held-ui-script-drafts.ts
|
|
1953
|
+
/** The most drafts kept at once; the oldest goes first. */
|
|
1954
|
+
const MAX_HELD_UI_SCRIPT_DRAFTS = 50;
|
|
1955
|
+
const held = /* @__PURE__ */ new Map();
|
|
1956
|
+
function isRecord$1(value) {
|
|
1957
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1958
|
+
}
|
|
1959
|
+
/** The key of a node's held draft: its workflow, the version and its id. */
|
|
1960
|
+
function heldDraftKey(workflow, version, nodeId) {
|
|
1961
|
+
return JSON.stringify([
|
|
1962
|
+
workflow,
|
|
1963
|
+
version,
|
|
1964
|
+
nodeId
|
|
1965
|
+
]);
|
|
1966
|
+
}
|
|
1967
|
+
/** A JSON value with the keys of every object in sorted order. */
|
|
1968
|
+
function sortedKeys(value) {
|
|
1969
|
+
if (Array.isArray(value)) return value.map(sortedKeys);
|
|
1970
|
+
if (!isRecord$1(value)) return value;
|
|
1971
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => [key, sortedKeys(item)]));
|
|
1972
|
+
}
|
|
1973
|
+
/**
|
|
1974
|
+
* A stored script value in the form drafts compare it in: text as it is, an
|
|
1975
|
+
* object as JSON with sorted keys (the service's JSON store does not keep the
|
|
1976
|
+
* order of keys).
|
|
1977
|
+
*/
|
|
1978
|
+
function baseOf(stored) {
|
|
1979
|
+
if (stored === void 0 || stored === null) return "";
|
|
1980
|
+
if (typeof stored === "string") return stored;
|
|
1981
|
+
try {
|
|
1982
|
+
return JSON.stringify(sortedKeys(stored));
|
|
1983
|
+
} catch {
|
|
1984
|
+
return "\0";
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
/** Hold a draft under `key` (`heldDraftKey`), started from `stored`. */
|
|
1988
|
+
function holdUiScriptDraft(key, stored, text, jsonView) {
|
|
1989
|
+
held.delete(key);
|
|
1990
|
+
held.set(key, {
|
|
1991
|
+
base: baseOf(stored),
|
|
1992
|
+
text,
|
|
1993
|
+
jsonView
|
|
1994
|
+
});
|
|
1995
|
+
while (held.size > 50) {
|
|
1996
|
+
const oldest = held.keys().next();
|
|
1997
|
+
if (oldest.done) break;
|
|
1998
|
+
held.delete(oldest.value);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* The draft held under `key`, when it started from the script stored now;
|
|
2003
|
+
* a draft of an older script is dropped.
|
|
2004
|
+
*/
|
|
2005
|
+
function heldUiScriptDraft(key, stored) {
|
|
2006
|
+
const draft = held.get(key);
|
|
2007
|
+
if (!draft) return void 0;
|
|
2008
|
+
if (draft.base === baseOf(stored)) return draft;
|
|
2009
|
+
held.delete(key);
|
|
2010
|
+
}
|
|
2011
|
+
/** Drop the draft held under `key` (it was written, or the script changed). */
|
|
2012
|
+
function releaseUiScriptDraft(key) {
|
|
2013
|
+
held.delete(key);
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
// src/builder/components/ndv/ui-script-editor/use-run-ui-steps.ts
|
|
2017
|
+
/**
|
|
2018
|
+
* "Run step" and "Run from here" of the Use Browser editor (spec 19, M1 rule
|
|
2019
|
+
* 10; contracts section 6): a TEST run of this node only, limited to part of
|
|
2020
|
+
* its UI script with `uiStepRange`. A run executes the saved version, so it
|
|
2021
|
+
* goes through the builder's run guard: unsaved edits are saved first (or the
|
|
2022
|
+
* person is asked), exactly as the node's own Execute step does. The run
|
|
2023
|
+
* itself is started and followed by the node panel (`UiStepRunBoundary`), so
|
|
2024
|
+
* it keeps updating when the editor unmounts.
|
|
2025
|
+
*/
|
|
2026
|
+
function useRunUiSteps(nodeId) {
|
|
2027
|
+
const runner = useUiStepRunner();
|
|
2028
|
+
const pending = useRef(null);
|
|
2029
|
+
const guard = useRunGuard(() => {
|
|
2030
|
+
const range = pending.current;
|
|
2031
|
+
pending.current = null;
|
|
2032
|
+
if (nodeId && range && runner) runner.run(nodeId, range);
|
|
2033
|
+
}, { nodeId });
|
|
2034
|
+
const { requestRun } = guard;
|
|
2035
|
+
const run = useCallback((range) => {
|
|
2036
|
+
pending.current = range;
|
|
2037
|
+
requestRun();
|
|
2038
|
+
}, [requestRun]);
|
|
2039
|
+
return {
|
|
2040
|
+
run: nodeId && runner ? run : void 0,
|
|
2041
|
+
busy: guard.preparing || (runner?.busy ?? false),
|
|
2042
|
+
dialog: guard.dialog
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
// src/builder/components/ndv/ui-script-editor/ui-script-editor.tsx
|
|
2047
|
+
/**
|
|
2048
|
+
* The Use Browser step editor (RPA plan P1-11, spec 19 M1 and M2): the node's
|
|
2049
|
+
* UI script as a list of steps that read as sentences, with flow and call
|
|
2050
|
+
* blocks, clean-up steps, inputs and outputs, a JSON view, and the engine's
|
|
2051
|
+
* problems on save. Warnings never block a save.
|
|
2052
|
+
*
|
|
2053
|
+
* Every edit is written at once (`onChange`, through the flow store, which
|
|
2054
|
+
* keeps the undo history). With `saveOnlyRunnable` (a node's editor) an edit
|
|
2055
|
+
* is written only once the script parses: the workflow service refuses any
|
|
2056
|
+
* other script and the builder then undoes the change (BOFF-17971). Until
|
|
2057
|
+
* then the editor holds the draft (`./held-ui-script-drafts`), says it is not
|
|
2058
|
+
* saved yet, and Run step waits. A value changed from outside (undo, another
|
|
2059
|
+
* panel) is read again and replaces a held draft. The setting keeps its
|
|
2060
|
+
* representation: JSON text stays text, an object stays an object.
|
|
2061
|
+
*
|
|
2062
|
+
* Loaded lazily (see `./index.tsx`), so `@burdenoff/ui-engine` reaches the
|
|
2063
|
+
* browser only when someone opens a Use Browser node.
|
|
2064
|
+
*/
|
|
2065
|
+
function isRecord(value) {
|
|
2066
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2067
|
+
}
|
|
2068
|
+
/** The node's `inputs` setting as a record (it is an object, or its JSON text). */
|
|
2069
|
+
function inputsMapping(value) {
|
|
2070
|
+
if (isRecord(value)) return value;
|
|
2071
|
+
if (typeof value === "string" && value.trim()) try {
|
|
2072
|
+
const parsed = JSON.parse(value);
|
|
2073
|
+
if (isRecord(parsed)) return parsed;
|
|
2074
|
+
} catch {}
|
|
2075
|
+
return {};
|
|
2076
|
+
}
|
|
2077
|
+
/**
|
|
2078
|
+
* The input a dropped workflow field goes to: the name made from the field,
|
|
2079
|
+
* unless an input of that name already reads another value (or the mapping
|
|
2080
|
+
* cannot be read), then the first free `name_2`, `name_3`, …
|
|
2081
|
+
*/
|
|
2082
|
+
function dropInputName(base, declared, mapping, expression) {
|
|
2083
|
+
const free = (name) => !declared.includes(name) || mapping !== null && (mapping[name] === void 0 || mapping[name] === expression);
|
|
2084
|
+
if (free(base)) return base;
|
|
2085
|
+
for (let n = 2;; n++) {
|
|
2086
|
+
const name = `${base}_${n}`;
|
|
2087
|
+
if (free(name)) return name;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
/** The failed step this node's editor opens on, when it opened from Fix this step. */
|
|
2091
|
+
function fixStepPathFor(nodeId) {
|
|
2092
|
+
const fix = useUiStepFixStore.getState().fix;
|
|
2093
|
+
const workflow = useFlowStore.getState().workflow;
|
|
2094
|
+
const workflowKey = workflow.workflowKey || workflow.id;
|
|
2095
|
+
return fix && nodeId !== void 0 && fix.nodeId === nodeId && fix.workflowKey === workflowKey ? fix.stepPath : void 0;
|
|
2096
|
+
}
|
|
2097
|
+
/** The open steps at the start: the failed step's options, when there is one. */
|
|
2098
|
+
function openFixStep(draft, path) {
|
|
2099
|
+
const step = draft && path !== void 0 ? stepAtPath(draft, path) : void 0;
|
|
2100
|
+
return step && path !== void 0 ? /* @__PURE__ */ new Map([[stepKey(step, path), 1]]) : /* @__PURE__ */ new Map();
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Where this node's held draft is kept: the open workflow, its version and the
|
|
2104
|
+
* node (node ids are copied into other versions, for example when an older
|
|
2105
|
+
* version is restored); undefined when nothing is kept. A read-only editor
|
|
2106
|
+
* writes nothing, so it neither holds nor shows a draft.
|
|
2107
|
+
*/
|
|
2108
|
+
function useHoldKey(nodeId, saveOnlyRunnable, readOnly) {
|
|
2109
|
+
const workflow = useFlowStore((state) => state.workflow.workflowKey || state.workflow.id);
|
|
2110
|
+
const version = useFlowStore((state) => state.workflow.version);
|
|
2111
|
+
return saveOnlyRunnable && !readOnly && nodeId ? heldDraftKey(workflow, version, nodeId) : void 0;
|
|
2112
|
+
}
|
|
2113
|
+
/** No script, in the setting's representation: blank text, or nothing. */
|
|
2114
|
+
function noScript(previous) {
|
|
2115
|
+
return typeof previous === "string" ? "" : void 0;
|
|
2116
|
+
}
|
|
2117
|
+
/** The stored script, or the draft held for it when there is one. */
|
|
2118
|
+
function editorStart(value, holdKey) {
|
|
2119
|
+
const held = holdKey === void 0 ? void 0 : heldUiScriptDraft(holdKey, value);
|
|
2120
|
+
if (held) {
|
|
2121
|
+
const draft = readUiScriptSetting(held.text);
|
|
2122
|
+
return {
|
|
2123
|
+
draft,
|
|
2124
|
+
text: held.text,
|
|
2125
|
+
jsonView: held.jsonView || draft === null,
|
|
2126
|
+
held: true
|
|
2127
|
+
};
|
|
2128
|
+
}
|
|
2129
|
+
const draft = readUiScriptSetting(value);
|
|
2130
|
+
return {
|
|
2131
|
+
draft,
|
|
2132
|
+
text: uiScriptText(value),
|
|
2133
|
+
jsonView: draft === null,
|
|
2134
|
+
held: false
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
function DesktopOnly({ testIdPrefix }) {
|
|
2138
|
+
const tr = useTr();
|
|
2139
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2140
|
+
className: "flex items-start gap-2 rounded-md border border-border p-3 text-xs text-muted-foreground",
|
|
2141
|
+
role: "status",
|
|
2142
|
+
"data-testid": `${testIdPrefix}-ui-script-desktop-only`,
|
|
2143
|
+
children: [/* @__PURE__ */ jsx(MonitorSmartphone, { className: "mt-0.5 size-4 shrink-0" }), /* @__PURE__ */ jsx("span", { children: tr("fluidgrids.builder.uiScript.desktopOnly", "Editing UI steps needs a larger screen. You can still view runs and start this workflow.") })]
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
/** The editor with Run step wired to this node's TEST runs. */
|
|
2147
|
+
function UiScriptEditor(props) {
|
|
2148
|
+
const runner = useRunUiSteps(props.nodeId);
|
|
2149
|
+
return /* @__PURE__ */ jsx(UiScriptEditorView, {
|
|
2150
|
+
...props,
|
|
2151
|
+
run: runner.run,
|
|
2152
|
+
runBusy: runner.busy,
|
|
2153
|
+
runDialog: runner.dialog
|
|
2154
|
+
});
|
|
2155
|
+
}
|
|
2156
|
+
/**
|
|
2157
|
+
* The editor itself. `run` starts a TEST run of a step range; without it the
|
|
2158
|
+
* Run step buttons are not offered.
|
|
2159
|
+
*/
|
|
2160
|
+
function UiScriptEditorView({ value, onChange, inputs, onInputsChange, testIdPrefix = "ndv", readOnly, inputsEditable = true, asSequence = false, saveOnlyRunnable = false, nodeId, run, runBusy, runDialog }) {
|
|
2161
|
+
const tr = useTr();
|
|
2162
|
+
const narrow = useIsMobile();
|
|
2163
|
+
const holdKey = useHoldKey(nodeId, saveOnlyRunnable, readOnly === true);
|
|
2164
|
+
const [start] = useState(() => editorStart(value, holdKey));
|
|
2165
|
+
const initial = start.draft;
|
|
2166
|
+
const [draft, setDraft] = useState(initial);
|
|
2167
|
+
const [jsonView, setJsonView] = useState(start.jsonView);
|
|
2168
|
+
const [jsonText, setJsonText] = useState(start.text);
|
|
2169
|
+
const [held, setHeld] = useState(start.held);
|
|
2170
|
+
const [fixPath] = useState(() => fixStepPathFor(nodeId));
|
|
2171
|
+
const [open, setOpenMap] = useState(() => openFixStep(initial, fixPath));
|
|
2172
|
+
const [focusPath, setFocusPath] = useState(fixPath);
|
|
2173
|
+
const rootRef = useRef(null);
|
|
2174
|
+
const [recordOpen, setRecordOpen] = useState(false);
|
|
2175
|
+
const rpaWeb = useRpaWebEnabled();
|
|
2176
|
+
const { workspaceId } = useFluidGridsAnalytics();
|
|
2177
|
+
const canRecordMore = !readOnly && !asSequence && rpaWeb && canUseBridgeHere();
|
|
2178
|
+
const draftRef = useRef(initial);
|
|
2179
|
+
const written = useRef(value);
|
|
2180
|
+
useEffect(() => {
|
|
2181
|
+
if (value === written.current) return;
|
|
2182
|
+
const same = typeof value === typeof written.current && baseOf(value) === baseOf(written.current);
|
|
2183
|
+
written.current = value;
|
|
2184
|
+
if (same) return;
|
|
2185
|
+
if (holdKey !== void 0) releaseUiScriptDraft(holdKey);
|
|
2186
|
+
setHeld(false);
|
|
2187
|
+
const parsed = readUiScriptSetting(value);
|
|
2188
|
+
setJsonText(uiScriptText(value));
|
|
2189
|
+
if (parsed === null) setJsonView(true);
|
|
2190
|
+
else {
|
|
2191
|
+
draftRef.current = parsed;
|
|
2192
|
+
setDraft(parsed);
|
|
2193
|
+
}
|
|
2194
|
+
}, [value, holdKey]);
|
|
2195
|
+
useEffect(() => {
|
|
2196
|
+
if (focusPath === void 0) return;
|
|
2197
|
+
focusRow(rootRef.current, focusPath);
|
|
2198
|
+
setFocusPath(void 0);
|
|
2199
|
+
}, [focusPath, draft]);
|
|
2200
|
+
const mapping = inputsMapping(inputs);
|
|
2201
|
+
/**
|
|
2202
|
+
* Write `next` to the node, or (saveOnlyRunnable, when the service would
|
|
2203
|
+
* refuse it) hold it until it parses. `text` is the draft as the JSON view
|
|
2204
|
+
* shows it, kept with a held draft. True when it was written.
|
|
2205
|
+
*/
|
|
2206
|
+
const save = (next, text, inJsonView) => {
|
|
2207
|
+
if (!saveOnlyRunnable || isSavableUiScript(next)) {
|
|
2208
|
+
written.current = next;
|
|
2209
|
+
if (holdKey !== void 0) releaseUiScriptDraft(holdKey);
|
|
2210
|
+
setHeld(false);
|
|
2211
|
+
onChange(next);
|
|
2212
|
+
return true;
|
|
2213
|
+
}
|
|
2214
|
+
if (holdKey !== void 0) holdUiScriptDraft(holdKey, written.current, text, inJsonView);
|
|
2215
|
+
setHeld(true);
|
|
2216
|
+
return false;
|
|
2217
|
+
};
|
|
2218
|
+
const writeDraft = (update) => {
|
|
2219
|
+
const next = typeof update === "function" ? update(draftRef.current ?? emptyUiScript()) : update;
|
|
2220
|
+
draftRef.current = next;
|
|
2221
|
+
setDraft(next);
|
|
2222
|
+
const serialised = serialiseUiScript(next, value);
|
|
2223
|
+
const text = uiScriptText(serialised);
|
|
2224
|
+
setJsonText(text);
|
|
2225
|
+
const stored = saveOnlyRunnable && isEmptyUiScript(next) ? noScript(value) : serialised;
|
|
2226
|
+
const saved = save(stored, text, false);
|
|
2227
|
+
noteRecordedNodeEdit(nodeId);
|
|
2228
|
+
return saved;
|
|
2229
|
+
};
|
|
2230
|
+
const write = (update, focus) => {
|
|
2231
|
+
writeDraft(update);
|
|
2232
|
+
if (focus !== void 0) setFocusPath(focus);
|
|
2233
|
+
};
|
|
2234
|
+
const onAppend = (result, runNow) => {
|
|
2235
|
+
const appended = appendRecording(draftRef.current ?? emptyUiScript(), result.reviewed);
|
|
2236
|
+
const saved = writeDraft(appended.draft);
|
|
2237
|
+
setFocusPath(appended.firstPath);
|
|
2238
|
+
if (inputsEditable && Object.keys(appended.inputValues).length > 0) onInputsChange({
|
|
2239
|
+
...inputsMapping(inputs),
|
|
2240
|
+
...appended.inputValues
|
|
2241
|
+
});
|
|
2242
|
+
if (nodeId) followRecordedNode(nodeId, result.edits);
|
|
2243
|
+
if (runNow && run && saved) run({});
|
|
2244
|
+
return null;
|
|
2245
|
+
};
|
|
2246
|
+
const walked = useMemo(() => draft ? walkDraft(draft) : [], [draft]);
|
|
2247
|
+
const problems = useMemo(() => draft ? uiScriptProblems(draft) : [], [draft]);
|
|
2248
|
+
const problemPaths = useMemo(() => new Set(problems.map((problem) => problem.path).filter((path) => !!path)), [problems]);
|
|
2249
|
+
if (narrow) return /* @__PURE__ */ jsx(DesktopOnly, { testIdPrefix });
|
|
2250
|
+
const toggleView = () => {
|
|
2251
|
+
if (jsonView) {
|
|
2252
|
+
const parsed = readUiScriptSetting(jsonText);
|
|
2253
|
+
if (parsed === null) return;
|
|
2254
|
+
draftRef.current = parsed;
|
|
2255
|
+
setDraft(parsed);
|
|
2256
|
+
setJsonView(false);
|
|
2257
|
+
if (held && holdKey !== void 0) holdUiScriptDraft(holdKey, written.current, jsonText, false);
|
|
2258
|
+
} else {
|
|
2259
|
+
const text = uiScriptText(draft ? serialiseUiScript(draft, value) : value);
|
|
2260
|
+
setJsonText(text);
|
|
2261
|
+
setJsonView(true);
|
|
2262
|
+
if (held && holdKey !== void 0) holdUiScriptDraft(holdKey, written.current, text, true);
|
|
2263
|
+
}
|
|
2264
|
+
};
|
|
2265
|
+
const onJsonText = (text) => {
|
|
2266
|
+
setJsonText(text);
|
|
2267
|
+
if (typeof value === "string" || value === void 0) {
|
|
2268
|
+
save(text, text, true);
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
if (saveOnlyRunnable && !text.trim()) {
|
|
2272
|
+
const empty = emptyUiScript();
|
|
2273
|
+
draftRef.current = empty;
|
|
2274
|
+
setDraft(empty);
|
|
2275
|
+
save(void 0, text, true);
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
const parsed = readUiScriptSetting(text);
|
|
2279
|
+
if (parsed) {
|
|
2280
|
+
draftRef.current = parsed;
|
|
2281
|
+
setDraft(parsed);
|
|
2282
|
+
save(parsed, text, true);
|
|
2283
|
+
} else if (saveOnlyRunnable) {
|
|
2284
|
+
if (holdKey !== void 0) holdUiScriptDraft(holdKey, written.current, text, true);
|
|
2285
|
+
setHeld(true);
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
const jsonParses = !jsonView || readUiScriptSetting(jsonText) !== null;
|
|
2289
|
+
const onDropField = (path) => {
|
|
2290
|
+
if (!draft) return "";
|
|
2291
|
+
const expression = pathToExpression(path);
|
|
2292
|
+
const declared = namedEntries(draftRef.current ?? draft, "inputs").map((input) => input.name);
|
|
2293
|
+
const name = dropInputName(inputNameFromPath(path), declared, inputsEditable ? mapping : null, expression);
|
|
2294
|
+
if (!declared.includes(name)) write((current) => withEntries(current, "inputs", [...namedEntries(current, "inputs"), {
|
|
2295
|
+
name,
|
|
2296
|
+
type: "any"
|
|
2297
|
+
}]));
|
|
2298
|
+
if (inputsEditable && mapping[name] !== expression) onInputsChange({
|
|
2299
|
+
...mapping,
|
|
2300
|
+
[name]: expression
|
|
2301
|
+
});
|
|
2302
|
+
return { input: name };
|
|
2303
|
+
};
|
|
2304
|
+
const inputNames = draft ? namedEntries(draft, "inputs").map((input) => input.name) : [];
|
|
2305
|
+
const variables = draft ? variableNames(draft, walked) : [];
|
|
2306
|
+
const elements = draft ? draftElements(draft) : {};
|
|
2307
|
+
const elementNames = Object.fromEntries(Object.entries(elements).map(([key, element]) => [key, typeof element.name === "string" ? element.name : key]));
|
|
2308
|
+
const context = draft ? {
|
|
2309
|
+
draft,
|
|
2310
|
+
write,
|
|
2311
|
+
elements,
|
|
2312
|
+
fields: {
|
|
2313
|
+
inputs: inputNames,
|
|
2314
|
+
variables,
|
|
2315
|
+
elementNames,
|
|
2316
|
+
onDropField: readOnly || asSequence ? void 0 : onDropField,
|
|
2317
|
+
readOnly
|
|
2318
|
+
},
|
|
2319
|
+
open,
|
|
2320
|
+
setOpen: (key, level) => setOpenMap((current) => {
|
|
2321
|
+
const next = new Map(current);
|
|
2322
|
+
if (level === 0) next.delete(key);
|
|
2323
|
+
else next.set(key, level);
|
|
2324
|
+
return next;
|
|
2325
|
+
}),
|
|
2326
|
+
run,
|
|
2327
|
+
runBusy: runBusy === true || held,
|
|
2328
|
+
problemPaths,
|
|
2329
|
+
rootRef,
|
|
2330
|
+
testIdPrefix,
|
|
2331
|
+
readOnly
|
|
2332
|
+
} : null;
|
|
2333
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2334
|
+
ref: rootRef,
|
|
2335
|
+
className: "flex flex-col gap-2",
|
|
2336
|
+
"data-testid": `${testIdPrefix}-ui-script`,
|
|
2337
|
+
children: [
|
|
2338
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2339
|
+
className: "flex items-start justify-between gap-2",
|
|
2340
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2341
|
+
className: "text-[11px] leading-snug text-muted-foreground",
|
|
2342
|
+
children: tr("fluidgrids.builder.uiScript.hint", "Steps run in order in the browser. Drag a field from the data panel onto a value to use it. Passwords and keys never go in a step: use Type secret with a connection.")
|
|
2343
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2344
|
+
className: "flex shrink-0 items-center gap-3",
|
|
2345
|
+
children: [canRecordMore && !jsonView && /* @__PURE__ */ jsx("button", {
|
|
2346
|
+
type: "button",
|
|
2347
|
+
onClick: () => setRecordOpen(true),
|
|
2348
|
+
className: "text-[11px] text-primary hover:underline",
|
|
2349
|
+
"data-testid": `${testIdPrefix}-ui-script-record-more`,
|
|
2350
|
+
children: tr("fluidgrids.builder.recording.recordMore", "Record more")
|
|
2351
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
2352
|
+
type: "button",
|
|
2353
|
+
onClick: toggleView,
|
|
2354
|
+
disabled: jsonView && !jsonParses,
|
|
2355
|
+
className: "text-[11px] text-primary hover:underline disabled:opacity-50",
|
|
2356
|
+
"data-testid": `${testIdPrefix}-ui-script-view`,
|
|
2357
|
+
children: jsonView ? tr("fluidgrids.builder.uiScript.showSteps", "Edit as steps") : tr("fluidgrids.builder.uiScript.showJson", "Edit as JSON")
|
|
2358
|
+
})]
|
|
2359
|
+
})]
|
|
2360
|
+
}),
|
|
2361
|
+
!asSequence && /* @__PURE__ */ jsx(UiStepFixBanner, {
|
|
2362
|
+
nodeId,
|
|
2363
|
+
run,
|
|
2364
|
+
runBusy: runBusy === true || held,
|
|
2365
|
+
testIdPrefix
|
|
2366
|
+
}),
|
|
2367
|
+
jsonView || !context ? /* @__PURE__ */ jsx("textarea", {
|
|
2368
|
+
value: jsonText,
|
|
2369
|
+
rows: 14,
|
|
2370
|
+
spellCheck: false,
|
|
2371
|
+
readOnly,
|
|
2372
|
+
"aria-label": tr("fluidgrids.builder.uiScript.jsonLabel", "UI script (JSON)"),
|
|
2373
|
+
onChange: (event) => onJsonText(event.target.value),
|
|
2374
|
+
className: cn(uiInputClass, "w-full font-mono"),
|
|
2375
|
+
"data-testid": `${testIdPrefix}-ui-script-json`
|
|
2376
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2377
|
+
/* @__PURE__ */ jsx(UiStepList, {
|
|
2378
|
+
block: "",
|
|
2379
|
+
context
|
|
2380
|
+
}),
|
|
2381
|
+
/* @__PURE__ */ jsxs("details", {
|
|
2382
|
+
className: "flex flex-col gap-1",
|
|
2383
|
+
open: Array.isArray(context.draft.cleanup) && context.draft.cleanup.length > 0 ? true : void 0,
|
|
2384
|
+
"data-testid": `${testIdPrefix}-ui-cleanup`,
|
|
2385
|
+
children: [/* @__PURE__ */ jsx("summary", {
|
|
2386
|
+
className: cn(uiLinkButton, "cursor-pointer"),
|
|
2387
|
+
children: tr("fluidgrids.builder.uiScript.cleanup", "Clean-up steps (run at the end, also after a failure)")
|
|
2388
|
+
}), /* @__PURE__ */ jsx(UiStepList, {
|
|
2389
|
+
block: CLEANUP_BLOCK,
|
|
2390
|
+
context
|
|
2391
|
+
})]
|
|
2392
|
+
}),
|
|
2393
|
+
/* @__PURE__ */ jsx(UiScriptInputsOutputs, {
|
|
2394
|
+
draft: context.draft,
|
|
2395
|
+
write: (next) => write(next),
|
|
2396
|
+
mapping,
|
|
2397
|
+
onMappingChange: onInputsChange,
|
|
2398
|
+
variables,
|
|
2399
|
+
mappingEditable: inputsEditable && !asSequence,
|
|
2400
|
+
asArguments: asSequence,
|
|
2401
|
+
testIdPrefix,
|
|
2402
|
+
readOnly
|
|
2403
|
+
})
|
|
2404
|
+
] }),
|
|
2405
|
+
held && !readOnly && /* @__PURE__ */ jsx("div", {
|
|
2406
|
+
className: "rounded-md border border-border px-2 py-1 text-[11px] text-muted-foreground",
|
|
2407
|
+
role: "status",
|
|
2408
|
+
"data-testid": `${testIdPrefix}-ui-script-unsaved`,
|
|
2409
|
+
children: tr("fluidgrids.builder.uiScript.notSavedYet", "Not saved yet. The node keeps its last saved steps until every step is filled in, then this script is saved. Run step waits until then.")
|
|
2410
|
+
}),
|
|
2411
|
+
!jsonView && problems.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
2412
|
+
className: "flex flex-col gap-1",
|
|
2413
|
+
role: "status",
|
|
2414
|
+
"data-testid": `${testIdPrefix}-ui-script-problems`,
|
|
2415
|
+
children: [problems.some((problem) => problem.severity !== "error") && /* @__PURE__ */ jsx("span", {
|
|
2416
|
+
className: "text-[11px] font-semibold text-muted-foreground",
|
|
2417
|
+
children: tr("fluidgrids.builder.uiScript.warningsSummary", "{{count}} warning(s). The node can be saved; warnings never block a save.", { count: problems.filter((problem) => problem.severity !== "error").length })
|
|
2418
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
2419
|
+
className: "flex flex-col gap-0.5 text-[11px]",
|
|
2420
|
+
children: problems.map((problem, index) => /* @__PURE__ */ jsxs("li", {
|
|
2421
|
+
className: cn(problem.severity === "error" ? "text-[var(--color-status-error-text)]" : problem.severity === "warning" ? "text-[var(--color-status-warning-text)]" : "text-muted-foreground"),
|
|
2422
|
+
"data-testid": `${testIdPrefix}-ui-script-problem-${problem.severity}`,
|
|
2423
|
+
children: [problem.path !== void 0 && /* @__PURE__ */ jsx("button", {
|
|
2424
|
+
type: "button",
|
|
2425
|
+
onClick: () => setFocusPath(problem.path),
|
|
2426
|
+
className: "mr-1 underline",
|
|
2427
|
+
"data-testid": `${testIdPrefix}-ui-script-problem-step`,
|
|
2428
|
+
children: tr("fluidgrids.builder.uiScript.problemStep", "Step {{number}}", { number: readableStepNumber(problem.path) })
|
|
2429
|
+
}), tr(problem.key, problem.fallback, problem.vars)]
|
|
2430
|
+
}, index))
|
|
2431
|
+
})]
|
|
2432
|
+
}),
|
|
2433
|
+
canRecordMore && recordOpen && /* @__PURE__ */ jsx(RecordMoreDialog, {
|
|
2434
|
+
open: recordOpen,
|
|
2435
|
+
onOpenChange: setRecordOpen,
|
|
2436
|
+
workspaceId,
|
|
2437
|
+
defaultUrl: firstPageOf(draft),
|
|
2438
|
+
onAppend,
|
|
2439
|
+
canRun: run !== void 0,
|
|
2440
|
+
testIdPrefix
|
|
2441
|
+
}),
|
|
2442
|
+
runDialog
|
|
2443
|
+
]
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
export { UiScriptEditor, UiScriptEditor as default, UiScriptEditorView, dropInputName, inputsMapping };
|