@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,3571 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-hDbaFkMy.js";
|
|
3
|
+
import { t as Icon } from "./Icon-BtQ0HXLh.js";
|
|
4
|
+
import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
|
|
5
|
+
import { s as throwIfResultError, t as describeOperationError } from "./errors-ClKb5sEt.js";
|
|
6
|
+
import { y as useSelfHostedWorkersEnabled } from "./feature-flags-B2qetXKd.js";
|
|
7
|
+
import { n as useNavigationV2 } from "./useNavigationV2-C2WeqN7d.js";
|
|
8
|
+
import { c as ResultsPager, f as MORE_TOOLS_PAGE_SIZE, g as serverWindow, n as ListSkeleton, o as PagedBody, r as LoadErrorPanel, t as EmptyPanel, u as formatCount } from "./results-CwK_yDxK.js";
|
|
9
|
+
import { _ as ViewOnlyPill, a as SlotsMeter, c as CompactRow, d as RowIcon, f as RowSummary, g as MoreToolsPage, h as MoreToolsHeader, i as Panel, m as Dot, n as KpiRow, o as ToneAlert, r as KpiTile, s as CompactList, t as KeyValueList, v as WhatIsLink } from "./panels-PfBBAToE.js";
|
|
10
|
+
import { s as useFluidGridsPermission, t as FLUIDGRIDS_PERMISSIONS } from "./constants-DlRnHBfQ.js";
|
|
11
|
+
import { a as NativeSelect, d as useResource, o as RUN_CONTROL_DIALOG_STYLE, s as StatusPill, t as FieldError } from "./shared-DAWGGMSM.js";
|
|
12
|
+
import { a as fetchTaskQueueStats, c as fetchWorkflowWorkers, d as updateTaskQueue, i as deleteWorkerToken, l as rotateWorkerToken, n as createWorkerToken, o as fetchTaskQueues, r as deleteTaskQueue, s as fetchWorkerTokens, t as createTaskQueue, u as setWorkerTokenConnectionAllowlist } from "./api-BKq-nIOZ.js";
|
|
13
|
+
import { KH as WorkflowEnvironment } from "./graphql-types-UTYtujY9.js";
|
|
14
|
+
import { a as useClampedPage, r as readChoice, s as useUrlListState, t as RowMenu } from "./menus-CU3hDGYl.js";
|
|
15
|
+
import { n as fetchTaskQueueAvailability } from "./useCodeWorkflowInsights-w0tz9Ap_.js";
|
|
16
|
+
import { a as windowSlice, i as useLiveRead, r as useVisiblePolling } from "./useRunnerList-Dbi59i1K.js";
|
|
17
|
+
import { n as getFluidGridsClient } from "./client-holder-C0M5Cfwl.js";
|
|
18
|
+
import { t as cn } from "./cn-QqidFIgr.js";
|
|
19
|
+
import { t as TechnicalDetails } from "./TechnicalDetails-B0Oi4aZw.js";
|
|
20
|
+
import { n as Status, t as ReasonLine } from "./status-CessxGpm.js";
|
|
21
|
+
import { n as formatRelativeTime, t as formatExactTime } from "./relative-time-Dxt8ZIIu.js";
|
|
22
|
+
import { t as ConfirmActionDialog } from "./ConfirmActionDialog-DHWTDRbp.js";
|
|
23
|
+
import { t as ChoiceSelect } from "./ChoiceSelect-LkK-uS9J.js";
|
|
24
|
+
import { r as SecretOnceDialog, t as CodeLine } from "./secrets-Re_wSiE3.js";
|
|
25
|
+
import { useCallback, useId, useMemo, useState } from "react";
|
|
26
|
+
import { Link, useLocation, useNavigate, useSearchParams } from "react-router";
|
|
27
|
+
import { gql } from "@apollo/client/core";
|
|
28
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
29
|
+
import { ArrowLeft, Cpu, KeyRound, ListOrdered, Pencil, Plug, Plus, Trash2 } from "lucide-react";
|
|
30
|
+
import { toast } from "sonner";
|
|
31
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Checkbox, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, EmptyState, Input, Label, PageTabs, ResponsiveDialog, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, Textarea } from "@burdenoff/fe-libs/ui";
|
|
32
|
+
import { Button as Button$1 } from "@burdenoff/fe-libs/button";
|
|
33
|
+
|
|
34
|
+
// src/modules/task-queues/utils/task-queues.ts
|
|
35
|
+
/** Lower-case letters, digits and dashes, at most 63, not `managed`. */
|
|
36
|
+
const TASK_QUEUE_NAME = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
37
|
+
function taskQueueNameProblem(name) {
|
|
38
|
+
const value = name.trim();
|
|
39
|
+
if (!value) return "empty";
|
|
40
|
+
if (value === "managed") return "reserved";
|
|
41
|
+
return TASK_QUEUE_NAME.test(value) ? null : "pattern";
|
|
42
|
+
}
|
|
43
|
+
const EMPTY_TASK_QUEUE_FORM = {
|
|
44
|
+
name: "",
|
|
45
|
+
environment: "",
|
|
46
|
+
description: "",
|
|
47
|
+
maxTasksPerSecond: "",
|
|
48
|
+
workerUnavailableTimeoutSeconds: ""
|
|
49
|
+
};
|
|
50
|
+
/** A positive number in range, `undefined` for an empty field, null when invalid. */
|
|
51
|
+
function boundedNumber(text, min, max, integer = false) {
|
|
52
|
+
const value = text.trim();
|
|
53
|
+
if (!value) return void 0;
|
|
54
|
+
const number = Number(value);
|
|
55
|
+
if (!Number.isFinite(number) || number < min || number > max) return null;
|
|
56
|
+
if (integer && !Number.isInteger(number)) return null;
|
|
57
|
+
return number;
|
|
58
|
+
}
|
|
59
|
+
/** The createTaskQueue input from the form (rate 0.01 to 10000, timeout 10 s to 7 days). */
|
|
60
|
+
function taskQueueInputOf(form) {
|
|
61
|
+
if (taskQueueNameProblem(form.name)) return {
|
|
62
|
+
ok: false,
|
|
63
|
+
field: "name"
|
|
64
|
+
};
|
|
65
|
+
const rate = boundedNumber(form.maxTasksPerSecond, .01, 1e4);
|
|
66
|
+
if (rate === null) return {
|
|
67
|
+
ok: false,
|
|
68
|
+
field: "maxTasksPerSecond"
|
|
69
|
+
};
|
|
70
|
+
const timeout = boundedNumber(form.workerUnavailableTimeoutSeconds, 10, 604800, true);
|
|
71
|
+
if (timeout === null) return {
|
|
72
|
+
ok: false,
|
|
73
|
+
field: "workerUnavailableTimeoutSeconds"
|
|
74
|
+
};
|
|
75
|
+
const create = { name: form.name.trim() };
|
|
76
|
+
if (form.environment) create.environment = form.environment;
|
|
77
|
+
if (form.description.trim()) create.description = form.description.trim();
|
|
78
|
+
if (rate !== void 0) create.maxTasksPerSecond = rate;
|
|
79
|
+
if (timeout !== void 0) create.workerUnavailableTimeoutSeconds = timeout;
|
|
80
|
+
return {
|
|
81
|
+
ok: true,
|
|
82
|
+
create
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Connection names: one per line or comma separated, unique, in order. */
|
|
86
|
+
function parseNameList(text) {
|
|
87
|
+
const seen = /* @__PURE__ */ new Set();
|
|
88
|
+
const names = [];
|
|
89
|
+
for (const raw of text.split(/[\n,]+/)) {
|
|
90
|
+
const name = raw.trim();
|
|
91
|
+
if (name && !seen.has(name)) {
|
|
92
|
+
seen.add(name);
|
|
93
|
+
names.push(name);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return names;
|
|
97
|
+
}
|
|
98
|
+
/** "3m ago" style ages for heartbeats. */
|
|
99
|
+
function formatAge(iso, now = Date.now()) {
|
|
100
|
+
if (!iso) return "—";
|
|
101
|
+
const seconds = Math.max(0, Math.round((now - new Date(iso).getTime()) / 1e3));
|
|
102
|
+
if (seconds < 60) return `${seconds}s ago`;
|
|
103
|
+
if (seconds < 3600) return `${Math.round(seconds / 60)}m ago`;
|
|
104
|
+
if (seconds < 86400) return `${Math.round(seconds / 3600)}h ago`;
|
|
105
|
+
return new Date(iso).toLocaleDateString();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The queue a worker token names for one queue row (spec 06 §6, G10): the
|
|
109
|
+
* plain name for an unscoped row (workers may serve every environment), and
|
|
110
|
+
* `name@<env>` for a row scoped to one environment, which binds the token so
|
|
111
|
+
* its workers only take that environment's tasks.
|
|
112
|
+
*/
|
|
113
|
+
function workerQueueOf(queue) {
|
|
114
|
+
return queue.environment ? `${queue.name}@${queue.environment.toLowerCase()}` : queue.name;
|
|
115
|
+
}
|
|
116
|
+
/** The one-line worker start command shown with a new token (no token in it). */
|
|
117
|
+
function workerRunCommand(taskQueues, bridgeUrl) {
|
|
118
|
+
return `FLUIDGRIDS_WORKER_TOKEN=<token> fluidgrids worker run --queue ${taskQueues.length > 0 ? taskQueues.join(",") : "my-queue"}${bridgeUrl ? ` --bridge-url ${bridgeUrl}` : ""}`;
|
|
119
|
+
}
|
|
120
|
+
/** The tabs of the redesigned page: `?tab=` in the address (queues left out). */
|
|
121
|
+
const TASK_QUEUE_TABS = [
|
|
122
|
+
"queues",
|
|
123
|
+
"workers",
|
|
124
|
+
"tokens"
|
|
125
|
+
];
|
|
126
|
+
/** `?queue=`: a self-hosted queue's id, or the managed queue's name (it has no id). */
|
|
127
|
+
function queueParamOf(queue) {
|
|
128
|
+
return queue.id ?? queue.name;
|
|
129
|
+
}
|
|
130
|
+
/** The queue a `?queue=` value names, or undefined. */
|
|
131
|
+
function findQueueByParam(queues, param) {
|
|
132
|
+
return queues.find((queue) => queue.id === param) ?? queues.find((queue) => !queue.id && queue.name === param);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Whether a worker or token entry (`name` or `name@env`) serves a queue row:
|
|
136
|
+
* a plain name serves every environment of the name; `name@env` serves the
|
|
137
|
+
* row scoped to that environment, and that environment's tasks of the
|
|
138
|
+
* unscoped row.
|
|
139
|
+
*/
|
|
140
|
+
function entryServesQueue(entry, queue) {
|
|
141
|
+
const at = entry.indexOf("@");
|
|
142
|
+
if ((at < 0 ? entry : entry.slice(0, at)) !== queue.name) return false;
|
|
143
|
+
if (at < 0 || !queue.environment) return true;
|
|
144
|
+
return entry.slice(at + 1).toLowerCase() === queue.environment.toLowerCase();
|
|
145
|
+
}
|
|
146
|
+
/** The wait-for-a-worker field in minutes, from the queue's seconds ("10", "1.5"). */
|
|
147
|
+
function secondsToMinutesText(seconds) {
|
|
148
|
+
return String(Math.round(seconds / 60 * 100) / 100);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The minutes typed in the form, as the seconds the service takes. Empty
|
|
152
|
+
* stays empty (the service's default); text that is not a number is passed
|
|
153
|
+
* on as is, so the form's check refuses it.
|
|
154
|
+
*/
|
|
155
|
+
function minutesToSecondsText(minutes) {
|
|
156
|
+
const text = minutes.trim();
|
|
157
|
+
if (!text) return "";
|
|
158
|
+
const value = Number(text);
|
|
159
|
+
return Number.isFinite(value) ? String(Math.round(value * 60)) : text;
|
|
160
|
+
}
|
|
161
|
+
const DURATION_UNITS = [
|
|
162
|
+
[86400, "day"],
|
|
163
|
+
[3600, "hour"],
|
|
164
|
+
[60, "minute"]
|
|
165
|
+
];
|
|
166
|
+
/**
|
|
167
|
+
* A duration in the page's language with the largest fitting unit:
|
|
168
|
+
* "45 seconds", "10 minutes", "1.5 hours" (`long`), or "45 sec", "10 min"
|
|
169
|
+
* (`short`), from Intl, so no words need translating.
|
|
170
|
+
*/
|
|
171
|
+
function formatDurationWords(seconds, display = "long", locale) {
|
|
172
|
+
const value = Math.max(0, seconds);
|
|
173
|
+
const [size, unit] = DURATION_UNITS.find(([unitSize]) => value >= unitSize) ?? [1, "second"];
|
|
174
|
+
return new Intl.NumberFormat(locale, {
|
|
175
|
+
style: "unit",
|
|
176
|
+
unit,
|
|
177
|
+
unitDisplay: display,
|
|
178
|
+
maximumFractionDigits: unit === "second" ? 0 : 1
|
|
179
|
+
}).format(value / size);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/modules/task-queues/components/TaskQueueDialogs.tsx
|
|
183
|
+
/**
|
|
184
|
+
* The Task queues page's dialogs (BOFF-9906): create or edit a queue, issue a
|
|
185
|
+
* worker token (shown once, with its connection allow-list) and edit a
|
|
186
|
+
* token's allow-list. Semantic tokens only; layers at 1100.
|
|
187
|
+
*/
|
|
188
|
+
const ENVIRONMENTS = [
|
|
189
|
+
"DEV",
|
|
190
|
+
"STAGING",
|
|
191
|
+
"PROD"
|
|
192
|
+
];
|
|
193
|
+
function TaskQueueDialog({ queue, onClose, onSaved }) {
|
|
194
|
+
const tr = useTr();
|
|
195
|
+
const [form, setForm] = useState(queue ? {
|
|
196
|
+
name: queue.name,
|
|
197
|
+
environment: queue.environment ?? "",
|
|
198
|
+
description: queue.description ?? "",
|
|
199
|
+
maxTasksPerSecond: queue.maxTasksPerSecond === null || queue.maxTasksPerSecond === void 0 ? "" : String(queue.maxTasksPerSecond),
|
|
200
|
+
workerUnavailableTimeoutSeconds: String(queue.workerUnavailableTimeoutSeconds)
|
|
201
|
+
} : EMPTY_TASK_QUEUE_FORM);
|
|
202
|
+
const [busy, setBusy] = useState(false);
|
|
203
|
+
const [error, setError] = useState(null);
|
|
204
|
+
const checked = taskQueueInputOf(form);
|
|
205
|
+
const nameProblem = form.name ? taskQueueNameProblem(form.name) : null;
|
|
206
|
+
const save = async () => {
|
|
207
|
+
if (!checked.ok) return;
|
|
208
|
+
setBusy(true);
|
|
209
|
+
setError(null);
|
|
210
|
+
try {
|
|
211
|
+
if (queue?.id) {
|
|
212
|
+
const rate = boundedNumber(form.maxTasksPerSecond, .01, 1e4);
|
|
213
|
+
await updateTaskQueue(queue.id, {
|
|
214
|
+
description: form.description.trim(),
|
|
215
|
+
...rate === void 0 ? { clearMaxTasksPerSecond: true } : { maxTasksPerSecond: rate },
|
|
216
|
+
...checked.create.workerUnavailableTimeoutSeconds !== void 0 ? { workerUnavailableTimeoutSeconds: checked.create.workerUnavailableTimeoutSeconds } : {}
|
|
217
|
+
});
|
|
218
|
+
} else await createTaskQueue(checked.create);
|
|
219
|
+
onSaved();
|
|
220
|
+
} catch (err) {
|
|
221
|
+
setError(describeOperationError(err));
|
|
222
|
+
} finally {
|
|
223
|
+
setBusy(false);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
227
|
+
open: true,
|
|
228
|
+
onOpenChange: (open) => !open && onClose(),
|
|
229
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
230
|
+
style: RUN_CONTROL_DIALOG_STYLE,
|
|
231
|
+
"data-testid": "task-queue-dialog",
|
|
232
|
+
children: [
|
|
233
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: queue ? tr("fluidgrids.taskQueues.editTitle", "Edit task queue") : tr("fluidgrids.taskQueues.createTitle", "New task queue") }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.taskQueues.dialogDescription", "Workflow and activity tasks on a self-hosted queue run on the workers you start for it.") })] }),
|
|
234
|
+
/* @__PURE__ */ jsxs("div", {
|
|
235
|
+
className: "space-y-3",
|
|
236
|
+
children: [
|
|
237
|
+
/* @__PURE__ */ jsxs("div", {
|
|
238
|
+
className: "space-y-1.5",
|
|
239
|
+
children: [
|
|
240
|
+
/* @__PURE__ */ jsx(Label, {
|
|
241
|
+
htmlFor: "task-queue-name",
|
|
242
|
+
children: tr("fluidgrids.taskQueues.name", "Name")
|
|
243
|
+
}),
|
|
244
|
+
/* @__PURE__ */ jsx(Input, {
|
|
245
|
+
id: "task-queue-name",
|
|
246
|
+
value: form.name,
|
|
247
|
+
disabled: !!queue,
|
|
248
|
+
placeholder: "payments",
|
|
249
|
+
onChange: (event) => setForm({
|
|
250
|
+
...form,
|
|
251
|
+
name: event.target.value
|
|
252
|
+
}),
|
|
253
|
+
"data-testid": "task-queue-name"
|
|
254
|
+
}),
|
|
255
|
+
nameProblem && /* @__PURE__ */ jsx(FieldError, { message: nameProblem === "reserved" ? tr("fluidgrids.taskQueues.nameReserved", "managed is the platform's queue.") : tr("fluidgrids.taskQueues.namePattern", "Lower-case letters, digits and dashes (at most 63).") })
|
|
256
|
+
]
|
|
257
|
+
}),
|
|
258
|
+
/* @__PURE__ */ jsxs("div", {
|
|
259
|
+
className: "space-y-1.5",
|
|
260
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
261
|
+
htmlFor: "task-queue-env",
|
|
262
|
+
children: tr("fluidgrids.taskQueues.environment", "Environment")
|
|
263
|
+
}), /* @__PURE__ */ jsxs(NativeSelect, {
|
|
264
|
+
id: "task-queue-env",
|
|
265
|
+
value: form.environment,
|
|
266
|
+
disabled: !!queue,
|
|
267
|
+
onChange: (value) => setForm({
|
|
268
|
+
...form,
|
|
269
|
+
environment: ENVIRONMENTS.find((item) => item === value) ?? ""
|
|
270
|
+
}),
|
|
271
|
+
testId: "task-queue-env",
|
|
272
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
273
|
+
value: "",
|
|
274
|
+
children: tr("fluidgrids.taskQueues.everyEnvironment", "Every environment")
|
|
275
|
+
}), ENVIRONMENTS.map((env) => /* @__PURE__ */ jsx("option", {
|
|
276
|
+
value: env,
|
|
277
|
+
children: env
|
|
278
|
+
}, env))]
|
|
279
|
+
})]
|
|
280
|
+
}),
|
|
281
|
+
/* @__PURE__ */ jsxs("div", {
|
|
282
|
+
className: "space-y-1.5",
|
|
283
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
284
|
+
htmlFor: "task-queue-description",
|
|
285
|
+
children: tr("fluidgrids.taskQueues.description", "Description (optional)")
|
|
286
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
287
|
+
id: "task-queue-description",
|
|
288
|
+
value: form.description,
|
|
289
|
+
maxLength: 1e3,
|
|
290
|
+
onChange: (event) => setForm({
|
|
291
|
+
...form,
|
|
292
|
+
description: event.target.value
|
|
293
|
+
})
|
|
294
|
+
})]
|
|
295
|
+
}),
|
|
296
|
+
/* @__PURE__ */ jsxs("div", {
|
|
297
|
+
className: "grid gap-3 sm:grid-cols-2",
|
|
298
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
299
|
+
className: "space-y-1.5",
|
|
300
|
+
children: [
|
|
301
|
+
/* @__PURE__ */ jsx(Label, {
|
|
302
|
+
htmlFor: "task-queue-rate",
|
|
303
|
+
children: tr("fluidgrids.taskQueues.rate", "Activity tasks per second (optional)")
|
|
304
|
+
}),
|
|
305
|
+
/* @__PURE__ */ jsx(Input, {
|
|
306
|
+
id: "task-queue-rate",
|
|
307
|
+
inputMode: "decimal",
|
|
308
|
+
value: form.maxTasksPerSecond,
|
|
309
|
+
onChange: (event) => setForm({
|
|
310
|
+
...form,
|
|
311
|
+
maxTasksPerSecond: event.target.value
|
|
312
|
+
}),
|
|
313
|
+
"data-testid": "task-queue-rate"
|
|
314
|
+
}),
|
|
315
|
+
!checked.ok && checked.field === "maxTasksPerSecond" && /* @__PURE__ */ jsx(FieldError, { message: tr("fluidgrids.taskQueues.rateRange", "0.01 to 10000.") })
|
|
316
|
+
]
|
|
317
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
318
|
+
className: "space-y-1.5",
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ jsx(Label, {
|
|
321
|
+
htmlFor: "task-queue-timeout",
|
|
322
|
+
children: tr("fluidgrids.taskQueues.timeout", "Wait for a worker (seconds)")
|
|
323
|
+
}),
|
|
324
|
+
/* @__PURE__ */ jsx(Input, {
|
|
325
|
+
id: "task-queue-timeout",
|
|
326
|
+
inputMode: "numeric",
|
|
327
|
+
value: form.workerUnavailableTimeoutSeconds,
|
|
328
|
+
placeholder: "600",
|
|
329
|
+
onChange: (event) => setForm({
|
|
330
|
+
...form,
|
|
331
|
+
workerUnavailableTimeoutSeconds: event.target.value
|
|
332
|
+
}),
|
|
333
|
+
"data-testid": "task-queue-timeout"
|
|
334
|
+
}),
|
|
335
|
+
!checked.ok && checked.field === "workerUnavailableTimeoutSeconds" && /* @__PURE__ */ jsx(FieldError, { message: tr("fluidgrids.taskQueues.timeoutRange", "10 seconds to 7 days.") })
|
|
336
|
+
]
|
|
337
|
+
})]
|
|
338
|
+
}),
|
|
339
|
+
/* @__PURE__ */ jsx(FieldError, {
|
|
340
|
+
message: error,
|
|
341
|
+
testId: "task-queue-error"
|
|
342
|
+
})
|
|
343
|
+
]
|
|
344
|
+
}),
|
|
345
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
|
|
346
|
+
variant: "outline",
|
|
347
|
+
onClick: onClose,
|
|
348
|
+
disabled: busy,
|
|
349
|
+
children: tr("fluidgrids.runControl.common.cancel", "Cancel")
|
|
350
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
351
|
+
onClick: () => void save(),
|
|
352
|
+
disabled: !checked.ok || busy,
|
|
353
|
+
"data-testid": "task-queue-save",
|
|
354
|
+
children: tr("fluidgrids.runControl.common.save", "Save")
|
|
355
|
+
})] })
|
|
356
|
+
]
|
|
357
|
+
})
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/** The allow-list editor: connection names workers may resolve (H2). */
|
|
361
|
+
function AllowlistEditor({ value, onChange, disabled }) {
|
|
362
|
+
const tr = useTr();
|
|
363
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
364
|
+
className: "space-y-1.5",
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ jsx(Label, {
|
|
367
|
+
htmlFor: "worker-token-allowlist",
|
|
368
|
+
children: tr("fluidgrids.taskQueues.allowlist", "Connections its user activities may use (optional)")
|
|
369
|
+
}),
|
|
370
|
+
/* @__PURE__ */ jsx(Textarea, {
|
|
371
|
+
id: "worker-token-allowlist",
|
|
372
|
+
rows: 3,
|
|
373
|
+
value,
|
|
374
|
+
disabled,
|
|
375
|
+
onChange: (event) => onChange(event.target.value),
|
|
376
|
+
placeholder: "crm-prod\nbilling-api",
|
|
377
|
+
className: "font-mono text-xs",
|
|
378
|
+
"data-testid": "worker-token-allowlist"
|
|
379
|
+
}),
|
|
380
|
+
/* @__PURE__ */ jsx("p", {
|
|
381
|
+
className: "text-xs text-text-secondary",
|
|
382
|
+
children: tr("fluidgrids.taskQueues.allowlistHint", "Empty: no credential is ever released to these workers. Only access tokens are released, never refresh tokens.")
|
|
383
|
+
})
|
|
384
|
+
]
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
function WorkerTokenDialog({ queues, canSetAllowlist, onClose, onCreated }) {
|
|
388
|
+
const tr = useTr();
|
|
389
|
+
const [name, setName] = useState("");
|
|
390
|
+
const [selected, setSelected] = useState(queues[0] ? [queues[0]] : []);
|
|
391
|
+
const selectedQueues = new Set(selected);
|
|
392
|
+
const [allowlist, setAllowlist] = useState("");
|
|
393
|
+
const [busy, setBusy] = useState(false);
|
|
394
|
+
const [error, setError] = useState(null);
|
|
395
|
+
const valid = name.trim().length > 0 && selected.length > 0;
|
|
396
|
+
const submit = async () => {
|
|
397
|
+
if (!valid) return;
|
|
398
|
+
setBusy(true);
|
|
399
|
+
setError(null);
|
|
400
|
+
try {
|
|
401
|
+
onCreated(await createWorkerToken({
|
|
402
|
+
name: name.trim(),
|
|
403
|
+
taskQueues: selected,
|
|
404
|
+
connectionAllowlist: canSetAllowlist ? parseNameList(allowlist) : []
|
|
405
|
+
}));
|
|
406
|
+
} catch (err) {
|
|
407
|
+
setError(describeOperationError(err));
|
|
408
|
+
} finally {
|
|
409
|
+
setBusy(false);
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
413
|
+
open: true,
|
|
414
|
+
onOpenChange: (open) => !open && onClose(),
|
|
415
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
416
|
+
style: RUN_CONTROL_DIALOG_STYLE,
|
|
417
|
+
"data-testid": "worker-token-dialog",
|
|
418
|
+
children: [
|
|
419
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: tr("fluidgrids.taskQueues.tokenTitle", "New worker token") }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.taskQueues.tokenDescription", "Workers authenticate with it and may serve only the queues it names. It is shown once.") })] }),
|
|
420
|
+
/* @__PURE__ */ jsxs("div", {
|
|
421
|
+
className: "space-y-3",
|
|
422
|
+
children: [
|
|
423
|
+
/* @__PURE__ */ jsxs("div", {
|
|
424
|
+
className: "space-y-1.5",
|
|
425
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
426
|
+
htmlFor: "worker-token-name",
|
|
427
|
+
children: tr("fluidgrids.taskQueues.tokenName", "Name")
|
|
428
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
429
|
+
id: "worker-token-name",
|
|
430
|
+
value: name,
|
|
431
|
+
onChange: (event) => setName(event.target.value),
|
|
432
|
+
"data-testid": "worker-token-name"
|
|
433
|
+
})]
|
|
434
|
+
}),
|
|
435
|
+
/* @__PURE__ */ jsxs("fieldset", {
|
|
436
|
+
className: "space-y-1.5",
|
|
437
|
+
children: [
|
|
438
|
+
/* @__PURE__ */ jsx("legend", {
|
|
439
|
+
className: "text-sm font-medium text-text-primary",
|
|
440
|
+
children: tr("fluidgrids.taskQueues.tokenQueues", "Task queues")
|
|
441
|
+
}),
|
|
442
|
+
queues.length === 0 && /* @__PURE__ */ jsx("p", {
|
|
443
|
+
className: "text-sm text-text-secondary",
|
|
444
|
+
children: tr("fluidgrids.taskQueues.noQueues", "Create a self-hosted queue first.")
|
|
445
|
+
}),
|
|
446
|
+
queues.some((queue) => queue.includes("@")) && /* @__PURE__ */ jsx("p", {
|
|
447
|
+
className: "text-xs text-text-secondary",
|
|
448
|
+
"data-testid": "worker-token-environment-hint",
|
|
449
|
+
children: tr("fluidgrids.taskQueues.tokenEnvironmentHint", "A queue shown as name@environment binds the token: its workers only take tasks of runs in that environment. A plain name serves every environment.")
|
|
450
|
+
}),
|
|
451
|
+
queues.map((queue) => /* @__PURE__ */ jsxs("label", {
|
|
452
|
+
className: "flex items-center gap-2 text-sm text-text-primary",
|
|
453
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
454
|
+
type: "checkbox",
|
|
455
|
+
className: "h-4 w-4 rounded",
|
|
456
|
+
checked: selectedQueues.has(queue),
|
|
457
|
+
onChange: (event) => setSelected((current) => event.target.checked ? [...current, queue] : current.filter((item) => item !== queue)),
|
|
458
|
+
"data-testid": `worker-token-queue-${queue}`
|
|
459
|
+
}), /* @__PURE__ */ jsx("code", {
|
|
460
|
+
className: "font-mono text-xs",
|
|
461
|
+
children: queue
|
|
462
|
+
})]
|
|
463
|
+
}, queue))
|
|
464
|
+
]
|
|
465
|
+
}),
|
|
466
|
+
canSetAllowlist && /* @__PURE__ */ jsx(AllowlistEditor, {
|
|
467
|
+
value: allowlist,
|
|
468
|
+
onChange: setAllowlist
|
|
469
|
+
}),
|
|
470
|
+
/* @__PURE__ */ jsx(FieldError, {
|
|
471
|
+
message: error,
|
|
472
|
+
testId: "worker-token-error"
|
|
473
|
+
})
|
|
474
|
+
]
|
|
475
|
+
}),
|
|
476
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
|
|
477
|
+
variant: "outline",
|
|
478
|
+
onClick: onClose,
|
|
479
|
+
disabled: busy,
|
|
480
|
+
children: tr("fluidgrids.runControl.common.cancel", "Cancel")
|
|
481
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
482
|
+
onClick: () => void submit(),
|
|
483
|
+
disabled: !valid || busy,
|
|
484
|
+
"data-testid": "worker-token-submit",
|
|
485
|
+
children: tr("fluidgrids.taskQueues.issue", "Issue token")
|
|
486
|
+
})] })
|
|
487
|
+
]
|
|
488
|
+
})
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
/** Shows a new or rotated token once, with the worker start command. */
|
|
492
|
+
function WorkerTokenSecretDialog({ created, onClose }) {
|
|
493
|
+
const tr = useTr();
|
|
494
|
+
const command = workerRunCommand(created.workerToken.taskQueues, created.bridgeUrl);
|
|
495
|
+
const copy = async (text) => {
|
|
496
|
+
try {
|
|
497
|
+
await navigator.clipboard.writeText(text);
|
|
498
|
+
toast.success(tr("fluidgrids.runControl.common.copied", "Copied"));
|
|
499
|
+
} catch {
|
|
500
|
+
toast.error(tr("fluidgrids.runControl.common.copyFailed", "Could not copy; select the text instead."));
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
504
|
+
open: true,
|
|
505
|
+
onOpenChange: (open) => !open && onClose(),
|
|
506
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
507
|
+
style: RUN_CONTROL_DIALOG_STYLE,
|
|
508
|
+
"data-testid": "worker-token-secret",
|
|
509
|
+
children: [
|
|
510
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: tr("fluidgrids.taskQueues.secretTitle", "Copy the worker token") }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.taskQueues.secretDescription", "It cannot be shown again. Give it to the worker in FLUIDGRIDS_WORKER_TOKEN; never put it in source code.") })] }),
|
|
511
|
+
/* @__PURE__ */ jsxs("div", {
|
|
512
|
+
className: "space-y-3",
|
|
513
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
514
|
+
className: "flex gap-2",
|
|
515
|
+
children: [/* @__PURE__ */ jsx("code", {
|
|
516
|
+
className: "min-w-0 flex-1 break-all rounded-md bg-surface-canvas p-2 font-mono text-xs text-text-primary",
|
|
517
|
+
"data-testid": "worker-token-value",
|
|
518
|
+
children: created.token
|
|
519
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
520
|
+
size: "sm",
|
|
521
|
+
variant: "outline",
|
|
522
|
+
onClick: () => void copy(created.token),
|
|
523
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
524
|
+
icon: "mdi:content-copy",
|
|
525
|
+
width: 14
|
|
526
|
+
})
|
|
527
|
+
})]
|
|
528
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
529
|
+
className: "space-y-1.5",
|
|
530
|
+
children: [/* @__PURE__ */ jsx(Label, { children: tr("fluidgrids.taskQueues.startWorker", "Start a worker") }), /* @__PURE__ */ jsx("code", {
|
|
531
|
+
className: "block break-all rounded-md bg-surface-canvas p-2 font-mono text-xs text-text-primary",
|
|
532
|
+
"data-testid": "worker-run-command",
|
|
533
|
+
children: command
|
|
534
|
+
})]
|
|
535
|
+
})]
|
|
536
|
+
}),
|
|
537
|
+
/* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsx(Button$1, {
|
|
538
|
+
onClick: onClose,
|
|
539
|
+
"data-testid": "worker-token-secret-done",
|
|
540
|
+
children: tr("fluidgrids.runControl.common.done", "Done")
|
|
541
|
+
}) })
|
|
542
|
+
]
|
|
543
|
+
})
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
function AllowlistDialog({ token, onClose, onSaved }) {
|
|
547
|
+
const tr = useTr();
|
|
548
|
+
const [value, setValue] = useState(() => token.connectionAllowlist.join("\n"));
|
|
549
|
+
const [busy, setBusy] = useState(false);
|
|
550
|
+
const [error, setError] = useState(null);
|
|
551
|
+
const save = async () => {
|
|
552
|
+
setBusy(true);
|
|
553
|
+
setError(null);
|
|
554
|
+
try {
|
|
555
|
+
await setWorkerTokenConnectionAllowlist(token.id, parseNameList(value));
|
|
556
|
+
onSaved();
|
|
557
|
+
} catch (err) {
|
|
558
|
+
setError(describeOperationError(err));
|
|
559
|
+
} finally {
|
|
560
|
+
setBusy(false);
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
564
|
+
open: true,
|
|
565
|
+
onOpenChange: (open) => !open && onClose(),
|
|
566
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
567
|
+
style: RUN_CONTROL_DIALOG_STYLE,
|
|
568
|
+
"data-testid": "worker-allowlist-dialog",
|
|
569
|
+
children: [
|
|
570
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: tr("fluidgrids.taskQueues.allowlistTitle", "Connections for {{name}}", { name: token.name }) }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.taskQueues.allowlistDescription", "Workspace admins only. Every release of a credential is audited.") })] }),
|
|
571
|
+
/* @__PURE__ */ jsx(AllowlistEditor, {
|
|
572
|
+
value,
|
|
573
|
+
onChange: setValue
|
|
574
|
+
}),
|
|
575
|
+
/* @__PURE__ */ jsx(FieldError, {
|
|
576
|
+
message: error,
|
|
577
|
+
testId: "worker-allowlist-error"
|
|
578
|
+
}),
|
|
579
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
|
|
580
|
+
variant: "outline",
|
|
581
|
+
onClick: onClose,
|
|
582
|
+
disabled: busy,
|
|
583
|
+
children: tr("fluidgrids.runControl.common.cancel", "Cancel")
|
|
584
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
585
|
+
onClick: () => void save(),
|
|
586
|
+
disabled: busy,
|
|
587
|
+
"data-testid": "worker-allowlist-save",
|
|
588
|
+
children: tr("fluidgrids.runControl.common.save", "Save")
|
|
589
|
+
})] })
|
|
590
|
+
]
|
|
591
|
+
})
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// src/modules/task-queues/pagedApi.ts
|
|
596
|
+
/**
|
|
597
|
+
* The paged reads of the redesigned Task queues page (BOFF-15502) on the
|
|
598
|
+
* service's paging (BOFF-15501): `taskQueues(limit, offset)` with
|
|
599
|
+
* `taskQueueCount`, `workflowWorkers(filter, limit, offset)` with
|
|
600
|
+
* `workflowWorkerCount(filter)`, `workerTokens(limit, offset)` with
|
|
601
|
+
* `workerTokenCount`, and `taskQueueWorkers(name)` for one queue. A window is
|
|
602
|
+
* 1 to 100 rows, and each list's count comes in the same request as its rows.
|
|
603
|
+
*
|
|
604
|
+
* Module-local documents (as `modules/observability/operations.ts` keeps its
|
|
605
|
+
* own), so the classic page's generated operations stay as they are; their
|
|
606
|
+
* fields match the generated fragments and the composed workspace schema
|
|
607
|
+
* (`pagedApi.test.ts`).
|
|
608
|
+
*/
|
|
609
|
+
/** The largest window the service sends. */
|
|
610
|
+
const MAX_WINDOW = 100;
|
|
611
|
+
/**
|
|
612
|
+
* Reading "every" row stops here: the service bounds tokens at 1000 and
|
|
613
|
+
* workers at 500; queues have no stated bound, and no workspace comes near.
|
|
614
|
+
*/
|
|
615
|
+
const READ_ALL_LIMIT = 1e3;
|
|
616
|
+
const QUEUE_FIELDS = gql`
|
|
617
|
+
fragment PagedTaskQueueFields on TaskQueue {
|
|
618
|
+
id
|
|
619
|
+
name
|
|
620
|
+
kind
|
|
621
|
+
environment
|
|
622
|
+
description
|
|
623
|
+
maxTasksPerSecond
|
|
624
|
+
workerUnavailableTimeoutSeconds
|
|
625
|
+
createdAt
|
|
626
|
+
updatedAt
|
|
627
|
+
}
|
|
628
|
+
`;
|
|
629
|
+
const WORKER_FIELDS = gql`
|
|
630
|
+
fragment PagedWorkflowWorkerFields on SandboxWorkflowWorker {
|
|
631
|
+
id
|
|
632
|
+
workerId
|
|
633
|
+
tokenId
|
|
634
|
+
tokenName
|
|
635
|
+
identity
|
|
636
|
+
sdkLanguage
|
|
637
|
+
sdkVersion
|
|
638
|
+
taskQueues
|
|
639
|
+
buildIds
|
|
640
|
+
workflows
|
|
641
|
+
activities
|
|
642
|
+
encodings
|
|
643
|
+
status
|
|
644
|
+
stale
|
|
645
|
+
startedAt
|
|
646
|
+
lastHeartbeatAt
|
|
647
|
+
endedAt
|
|
648
|
+
endReason
|
|
649
|
+
slots {
|
|
650
|
+
workflow {
|
|
651
|
+
used
|
|
652
|
+
total
|
|
653
|
+
}
|
|
654
|
+
activity {
|
|
655
|
+
used
|
|
656
|
+
total
|
|
657
|
+
}
|
|
658
|
+
localActivity {
|
|
659
|
+
used
|
|
660
|
+
total
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
pollers {
|
|
664
|
+
workflow
|
|
665
|
+
activity
|
|
666
|
+
}
|
|
667
|
+
tasksInFlight
|
|
668
|
+
cachedRuns
|
|
669
|
+
host {
|
|
670
|
+
os
|
|
671
|
+
arch
|
|
672
|
+
hostname
|
|
673
|
+
runtime
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
`;
|
|
677
|
+
const TOKEN_FIELDS = gql`
|
|
678
|
+
fragment PagedWorkerTokenFields on SandboxWorkerToken {
|
|
679
|
+
id
|
|
680
|
+
name
|
|
681
|
+
taskQueues
|
|
682
|
+
connectionAllowlist
|
|
683
|
+
tokenPrefix
|
|
684
|
+
activeSessions
|
|
685
|
+
createdBy
|
|
686
|
+
createdAt
|
|
687
|
+
}
|
|
688
|
+
`;
|
|
689
|
+
const TASK_QUEUES_WINDOW = gql`
|
|
690
|
+
${QUEUE_FIELDS}
|
|
691
|
+
query TaskQueuesWindow($limit: Int!, $offset: Int!) {
|
|
692
|
+
taskQueues(limit: $limit, offset: $offset) {
|
|
693
|
+
...PagedTaskQueueFields
|
|
694
|
+
}
|
|
695
|
+
taskQueueCount
|
|
696
|
+
}
|
|
697
|
+
`;
|
|
698
|
+
const TASK_QUEUE_COUNT = gql`
|
|
699
|
+
query TaskQueueCount {
|
|
700
|
+
taskQueueCount
|
|
701
|
+
}
|
|
702
|
+
`;
|
|
703
|
+
const WORKFLOW_WORKERS_WINDOW = gql`
|
|
704
|
+
${WORKER_FIELDS}
|
|
705
|
+
query WorkflowWorkersWindow(
|
|
706
|
+
$filter: SandboxWorkflowWorkersFilter!
|
|
707
|
+
$online: SandboxWorkflowWorkersFilter!
|
|
708
|
+
$limit: Int!
|
|
709
|
+
$offset: Int!
|
|
710
|
+
) {
|
|
711
|
+
workflowWorkers(
|
|
712
|
+
context: {}
|
|
713
|
+
filter: $filter
|
|
714
|
+
limit: $limit
|
|
715
|
+
offset: $offset
|
|
716
|
+
) {
|
|
717
|
+
...PagedWorkflowWorkerFields
|
|
718
|
+
}
|
|
719
|
+
workflowWorkerCount(context: {}, filter: $filter)
|
|
720
|
+
onlineWorkerCount: workflowWorkerCount(context: {}, filter: $online)
|
|
721
|
+
}
|
|
722
|
+
`;
|
|
723
|
+
const WORKFLOW_WORKER_COUNTS = gql`
|
|
724
|
+
query WorkflowWorkerCounts(
|
|
725
|
+
$filter: SandboxWorkflowWorkersFilter!
|
|
726
|
+
$online: SandboxWorkflowWorkersFilter!
|
|
727
|
+
) {
|
|
728
|
+
workflowWorkerCount(context: {}, filter: $filter)
|
|
729
|
+
onlineWorkerCount: workflowWorkerCount(context: {}, filter: $online)
|
|
730
|
+
}
|
|
731
|
+
`;
|
|
732
|
+
const TASK_QUEUE_WORKERS = gql`
|
|
733
|
+
${WORKER_FIELDS}
|
|
734
|
+
query TaskQueueWorkersOf($name: String!) {
|
|
735
|
+
taskQueueWorkers(context: {}, name: $name) {
|
|
736
|
+
...PagedWorkflowWorkerFields
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
`;
|
|
740
|
+
const WORKER_TOKENS_WINDOW = gql`
|
|
741
|
+
${TOKEN_FIELDS}
|
|
742
|
+
query WorkerTokensWindow($limit: Int!, $offset: Int!) {
|
|
743
|
+
workerTokens(context: {}, limit: $limit, offset: $offset) {
|
|
744
|
+
...PagedWorkerTokenFields
|
|
745
|
+
}
|
|
746
|
+
workerTokenCount(context: {})
|
|
747
|
+
}
|
|
748
|
+
`;
|
|
749
|
+
const WORKER_TOKEN_COUNT = gql`
|
|
750
|
+
query WorkerTokenCount {
|
|
751
|
+
workerTokenCount(context: {})
|
|
752
|
+
}
|
|
753
|
+
`;
|
|
754
|
+
/** The workers the page lists: connected now (as the classic page). */
|
|
755
|
+
const LISTED_WORKERS = { includeEnded: false };
|
|
756
|
+
/** The workers that count as online: connected and not stale. */
|
|
757
|
+
const ONLINE_WORKERS = {
|
|
758
|
+
includeEnded: false,
|
|
759
|
+
stale: false
|
|
760
|
+
};
|
|
761
|
+
async function read(query, variables = {}) {
|
|
762
|
+
const result = throwIfResultError(await getFluidGridsClient().query({
|
|
763
|
+
query,
|
|
764
|
+
variables,
|
|
765
|
+
fetchPolicy: "network-only"
|
|
766
|
+
}));
|
|
767
|
+
if (!result.data) throw new Error("The request returned no data");
|
|
768
|
+
return result.data;
|
|
769
|
+
}
|
|
770
|
+
async function fetchQueueWindow(offset, limit) {
|
|
771
|
+
const data = await read(TASK_QUEUES_WINDOW, {
|
|
772
|
+
limit,
|
|
773
|
+
offset
|
|
774
|
+
});
|
|
775
|
+
return {
|
|
776
|
+
items: data.taskQueues,
|
|
777
|
+
total: data.taskQueueCount
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
async function fetchQueueCount() {
|
|
781
|
+
return (await read(TASK_QUEUE_COUNT)).taskQueueCount;
|
|
782
|
+
}
|
|
783
|
+
async function fetchWorkerWindow(offset, limit) {
|
|
784
|
+
const data = await read(WORKFLOW_WORKERS_WINDOW, {
|
|
785
|
+
filter: LISTED_WORKERS,
|
|
786
|
+
online: ONLINE_WORKERS,
|
|
787
|
+
limit,
|
|
788
|
+
offset
|
|
789
|
+
});
|
|
790
|
+
return {
|
|
791
|
+
items: data.workflowWorkers,
|
|
792
|
+
total: data.workflowWorkerCount,
|
|
793
|
+
online: data.onlineWorkerCount
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
async function fetchWorkerCounts() {
|
|
797
|
+
const data = await read(WORKFLOW_WORKER_COUNTS, {
|
|
798
|
+
filter: LISTED_WORKERS,
|
|
799
|
+
online: ONLINE_WORKERS
|
|
800
|
+
});
|
|
801
|
+
return {
|
|
802
|
+
total: data.workflowWorkerCount,
|
|
803
|
+
online: data.onlineWorkerCount
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
/** The workers serving one queue entry: `name` or `name@env`. */
|
|
807
|
+
async function fetchQueueWorkers(name) {
|
|
808
|
+
return (await read(TASK_QUEUE_WORKERS, { name })).taskQueueWorkers;
|
|
809
|
+
}
|
|
810
|
+
async function fetchTokenWindow(offset, limit) {
|
|
811
|
+
const data = await read(WORKER_TOKENS_WINDOW, {
|
|
812
|
+
limit,
|
|
813
|
+
offset
|
|
814
|
+
});
|
|
815
|
+
return {
|
|
816
|
+
items: data.workerTokens,
|
|
817
|
+
total: data.workerTokenCount
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
async function fetchTokenCount() {
|
|
821
|
+
return (await read(WORKER_TOKEN_COUNT)).workerTokenCount;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Every row of a list, 100 at a time (up to `READ_ALL_LIMIT`), each kept once
|
|
825
|
+
* when one shifts into the next window between two reads.
|
|
826
|
+
*/
|
|
827
|
+
async function fetchAllWindows(fetchWindow, keyOf) {
|
|
828
|
+
const first = await fetchWindow(0, 100);
|
|
829
|
+
const bound = Math.min(first.total, READ_ALL_LIMIT);
|
|
830
|
+
const offsets = [];
|
|
831
|
+
for (let offset = 100; offset < bound; offset += 100) offsets.push(offset);
|
|
832
|
+
const rest = await Promise.all(offsets.map((offset) => fetchWindow(offset, 100)));
|
|
833
|
+
const seen = /* @__PURE__ */ new Set();
|
|
834
|
+
const items = [];
|
|
835
|
+
for (const window of [first, ...rest]) for (const item of window.items) {
|
|
836
|
+
const key = keyOf(item);
|
|
837
|
+
if (!seen.has(key)) {
|
|
838
|
+
seen.add(key);
|
|
839
|
+
items.push(item);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return {
|
|
843
|
+
items,
|
|
844
|
+
total: first.total
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
/** A queue row's identity: its id, or the managed queue's name. */
|
|
848
|
+
function queueKey(queue) {
|
|
849
|
+
return queue.id ?? `managed:${queue.name}`;
|
|
850
|
+
}
|
|
851
|
+
function fetchAllQueues() {
|
|
852
|
+
return fetchAllWindows(fetchQueueWindow, queueKey);
|
|
853
|
+
}
|
|
854
|
+
function fetchAllTokens() {
|
|
855
|
+
return fetchAllWindows(fetchTokenWindow, (token) => token.id);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// src/modules/task-queues/hooks/useTaskQueueSources.ts
|
|
859
|
+
/**
|
|
860
|
+
* The sources of the redesigned Task queues page (BOFF-15502), on the
|
|
861
|
+
* service's paging (BOFF-15501). Only what is on screen is read:
|
|
862
|
+
*
|
|
863
|
+
* - each tab's list reads its page (20 rows and the count, in one request)
|
|
864
|
+
* while it is open, and only its count (the tab's badge) while another tab
|
|
865
|
+
* is; nothing while a queue's page is open;
|
|
866
|
+
* - queues and worker tokens are read once and after a change (as today);
|
|
867
|
+
* workers again every 15 s, and the queues' worker availability every 30 s
|
|
868
|
+
* (one row per queue name, for the Workers column and "waiting with no
|
|
869
|
+
* worker"), only ever the window on screen;
|
|
870
|
+
* - a queue's page and the New worker token dialog need every queue (there is
|
|
871
|
+
* no read of one queue), so they read them 100 at a time; the queue page's
|
|
872
|
+
* tokens likewise; its workers come from `taskQueueWorkers(name)`, again
|
|
873
|
+
* every 15 s; its backlog from `taskQueueStats`, every 30 s.
|
|
874
|
+
*/
|
|
875
|
+
/** Workers heartbeat every 30 s; the list is re-read this often (as today). */
|
|
876
|
+
const QUEUE_WORKERS_POLL_MS = 15e3;
|
|
877
|
+
/** Queue availability and one queue's backlog are re-read this often. */
|
|
878
|
+
const QUEUE_STATS_POLL_MS = 3e4;
|
|
879
|
+
/** While the browser tab is hidden, every timed read slows to this. */
|
|
880
|
+
const QUEUE_HIDDEN_POLL_MS = 6e4;
|
|
881
|
+
function usePagedSource(name, mode, page, fetchPage, fetchCount, pollMs = 0) {
|
|
882
|
+
const { offset, limit } = serverWindow(page);
|
|
883
|
+
const key = mode === "off" ? null : mode === "page" ? `${name}:page:${offset}` : `${name}:count`;
|
|
884
|
+
const load = useCallback(async () => {
|
|
885
|
+
if (mode === "page") return {
|
|
886
|
+
kind: "page",
|
|
887
|
+
offset,
|
|
888
|
+
...await fetchPage(offset, limit)
|
|
889
|
+
};
|
|
890
|
+
return {
|
|
891
|
+
kind: "count",
|
|
892
|
+
...await fetchCount()
|
|
893
|
+
};
|
|
894
|
+
}, [
|
|
895
|
+
mode,
|
|
896
|
+
offset,
|
|
897
|
+
limit,
|
|
898
|
+
fetchPage,
|
|
899
|
+
fetchCount
|
|
900
|
+
]);
|
|
901
|
+
const read = useLiveRead(key, load);
|
|
902
|
+
useVisiblePolling(read.refetch, key === null ? 0 : pollMs, QUEUE_HIDDEN_POLL_MS);
|
|
903
|
+
const data = read.data;
|
|
904
|
+
const slice = useMemo(() => data?.kind === "page" ? windowSlice(data.items, data.offset, data.total) : null, [data]);
|
|
905
|
+
return {
|
|
906
|
+
total: data?.total ?? null,
|
|
907
|
+
online: data?.online ?? null,
|
|
908
|
+
slice,
|
|
909
|
+
exact: read.dataKey === key && slice !== null,
|
|
910
|
+
error: read.errorKey === key ? read.error : null,
|
|
911
|
+
refetch: read.refetch
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
const queueCount = async () => ({ total: await fetchQueueCount() });
|
|
915
|
+
const tokenCount = async () => ({ total: await fetchTokenCount() });
|
|
916
|
+
function useQueueSource(mode, page) {
|
|
917
|
+
return usePagedSource("queues", mode, page, fetchQueueWindow, queueCount);
|
|
918
|
+
}
|
|
919
|
+
function useWorkerSource(mode, page) {
|
|
920
|
+
return usePagedSource("workers", mode, page, fetchWorkerWindow, fetchWorkerCounts, QUEUE_WORKERS_POLL_MS);
|
|
921
|
+
}
|
|
922
|
+
function useTokenSource(mode, page) {
|
|
923
|
+
return usePagedSource("tokens", mode, page, fetchTokenWindow, tokenCount);
|
|
924
|
+
}
|
|
925
|
+
/** Whether each queue name has workers right now (the Insights read). */
|
|
926
|
+
function useQueueAvailability(enabled) {
|
|
927
|
+
return useResource("task-queue-availability", enabled, fetchTaskQueueAvailability, {
|
|
928
|
+
live: true,
|
|
929
|
+
intervalMs: QUEUE_STATS_POLL_MS
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
function useAllRows(key, enabled, load) {
|
|
933
|
+
const live = enabled ? key : null;
|
|
934
|
+
const read = useLiveRead(live, load);
|
|
935
|
+
return {
|
|
936
|
+
items: read.dataKey === live && read.data ? read.data.items : null,
|
|
937
|
+
error: read.errorKey === live ? read.error : null,
|
|
938
|
+
refetch: read.refetch
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
/** Every queue (a queue's page, the New worker token dialog), 100 at a time. */
|
|
942
|
+
function useAllQueues(enabled) {
|
|
943
|
+
return useAllRows("all-queues", enabled, fetchAllQueues);
|
|
944
|
+
}
|
|
945
|
+
/** Every worker token (the tokens that serve a queue), 100 at a time. */
|
|
946
|
+
function useAllTokens(enabled) {
|
|
947
|
+
return useAllRows("all-tokens", enabled, fetchAllTokens);
|
|
948
|
+
}
|
|
949
|
+
/** The workers serving one self-hosted queue, re-read every 15 s. */
|
|
950
|
+
function useQueueWorkers(queue) {
|
|
951
|
+
const entry = queue && queue.kind !== "MANAGED" ? workerQueueOf(queue) : null;
|
|
952
|
+
const key = entry === null ? null : `queue-workers:${entry}`;
|
|
953
|
+
const load = useCallback(() => entry === null ? Promise.resolve([]) : fetchQueueWorkers(entry), [entry]);
|
|
954
|
+
const read = useLiveRead(key, load);
|
|
955
|
+
useVisiblePolling(read.refetch, key === null ? 0 : QUEUE_WORKERS_POLL_MS, QUEUE_HIDDEN_POLL_MS);
|
|
956
|
+
return {
|
|
957
|
+
workers: read.dataKey === key ? read.data : null,
|
|
958
|
+
error: read.errorKey === key ? read.error : null
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
/** One queue's backlog, rates and pollers, while its page is open. */
|
|
962
|
+
function useQueueStats(queue) {
|
|
963
|
+
return useResource(queue ? `queue-stats:${queue.name}:${queue.environment ?? ""}` : null, queue !== void 0, () => queue ? fetchTaskQueueStats(queue.name, queue.environment) : Promise.reject(/* @__PURE__ */ new Error("No queue")), {
|
|
964
|
+
live: true,
|
|
965
|
+
intervalMs: QUEUE_STATS_POLL_MS
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// src/modules/task-queues/hooks/useTaskQueueLists.ts
|
|
970
|
+
/** What a tab's source reads: nothing on a queue's page, else page or count. */
|
|
971
|
+
function modeFor(listView, tab, of) {
|
|
972
|
+
if (!listView) return "off";
|
|
973
|
+
return tab === of ? "page" : "count";
|
|
974
|
+
}
|
|
975
|
+
/** The open tab and the sources of the three tabs. */
|
|
976
|
+
function useTaskQueueLists({ perms, params, page, setPage }) {
|
|
977
|
+
const { canReadTokens, permissionsLoading } = perms;
|
|
978
|
+
const tabs = canReadTokens ? TASK_QUEUE_TABS : TASK_QUEUE_TABS.filter((tab) => tab !== "tokens");
|
|
979
|
+
const tab = readChoice(params, "tab", tabs, "queues");
|
|
980
|
+
const queueParam = params.get("queue");
|
|
981
|
+
const listView = queueParam === null;
|
|
982
|
+
const queues = useQueueSource(modeFor(listView, tab, "queues"), page);
|
|
983
|
+
const availability = useQueueAvailability(listView);
|
|
984
|
+
const workers = useWorkerSource(modeFor(listView, tab, "workers"), page);
|
|
985
|
+
const tokens = useTokenSource(canReadTokens ? modeFor(listView, tab, "tokens") : "off", page);
|
|
986
|
+
const active = {
|
|
987
|
+
queues,
|
|
988
|
+
workers,
|
|
989
|
+
tokens
|
|
990
|
+
}[tab];
|
|
991
|
+
useClampedPage(page, active.slice?.total ?? 0, MORE_TOOLS_PAGE_SIZE, active.exact && listView && !permissionsLoading, setPage);
|
|
992
|
+
return {
|
|
993
|
+
tabs,
|
|
994
|
+
tab,
|
|
995
|
+
queueParam,
|
|
996
|
+
listView,
|
|
997
|
+
queues,
|
|
998
|
+
availability,
|
|
999
|
+
workers,
|
|
1000
|
+
tokens
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
/** The every-row reads a queue's page and the token dialog need. */
|
|
1004
|
+
function useTaskQueueLookups(lists, canReadTokens, issuing) {
|
|
1005
|
+
const { listView, queues, availability, tokens } = lists;
|
|
1006
|
+
const allQueues = useAllQueues(!listView || issuing);
|
|
1007
|
+
const allTokens = useAllTokens(!listView && canReadTokens);
|
|
1008
|
+
const selfHostedEntries = allQueues.items ? [...new Set(allQueues.items.filter((queue) => queue.kind === "SELF_HOSTED").map(workerQueueOf))] : null;
|
|
1009
|
+
const { refetch: refetchQueueList } = queues;
|
|
1010
|
+
const { refetch: refetchAvailability } = availability;
|
|
1011
|
+
const { refetch: refetchAllQueues } = allQueues;
|
|
1012
|
+
const refetchQueues = useCallback(() => {
|
|
1013
|
+
refetchQueueList();
|
|
1014
|
+
refetchAvailability();
|
|
1015
|
+
refetchAllQueues();
|
|
1016
|
+
}, [
|
|
1017
|
+
refetchAllQueues,
|
|
1018
|
+
refetchAvailability,
|
|
1019
|
+
refetchQueueList
|
|
1020
|
+
]);
|
|
1021
|
+
const { refetch: refetchTokenList } = tokens;
|
|
1022
|
+
const { refetch: refetchAllTokens } = allTokens;
|
|
1023
|
+
return {
|
|
1024
|
+
allQueues,
|
|
1025
|
+
allTokens,
|
|
1026
|
+
selfHostedEntries,
|
|
1027
|
+
refetchQueues,
|
|
1028
|
+
refetchTokens: useCallback(() => {
|
|
1029
|
+
refetchTokenList();
|
|
1030
|
+
refetchAllTokens();
|
|
1031
|
+
}, [refetchAllTokens, refetchTokenList])
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// src/modules/task-queues/hooks/useTaskQueueDialogState.ts
|
|
1036
|
+
function useTaskQueueDialogState() {
|
|
1037
|
+
const [editing, setEditing] = useState(null);
|
|
1038
|
+
const [deleting, setDeleting] = useState(null);
|
|
1039
|
+
const [queueBusy, setQueueBusy] = useState(false);
|
|
1040
|
+
const [issuing, setIssuing] = useState(null);
|
|
1041
|
+
const [secret, setSecret] = useState(null);
|
|
1042
|
+
const [allowlist, setAllowlist] = useState(null);
|
|
1043
|
+
const [rotating, setRotating] = useState(null);
|
|
1044
|
+
const [deletingToken, setDeletingToken] = useState(null);
|
|
1045
|
+
const [tokenBusy, setTokenBusy] = useState(null);
|
|
1046
|
+
return {
|
|
1047
|
+
editing,
|
|
1048
|
+
setEditing,
|
|
1049
|
+
deleting,
|
|
1050
|
+
setDeleting,
|
|
1051
|
+
queueBusy,
|
|
1052
|
+
setQueueBusy,
|
|
1053
|
+
issuing,
|
|
1054
|
+
setIssuing,
|
|
1055
|
+
secret,
|
|
1056
|
+
setSecret,
|
|
1057
|
+
allowlist,
|
|
1058
|
+
setAllowlist,
|
|
1059
|
+
rotating,
|
|
1060
|
+
setRotating,
|
|
1061
|
+
deletingToken,
|
|
1062
|
+
setDeletingToken,
|
|
1063
|
+
tokenBusy,
|
|
1064
|
+
setTokenBusy
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
/** The row and header actions the lists and a queue's page offer. */
|
|
1068
|
+
function useTaskQueueActions(perms, dialogs) {
|
|
1069
|
+
const { setEditing, setDeleting, setIssuing } = dialogs;
|
|
1070
|
+
return {
|
|
1071
|
+
queueActions: {
|
|
1072
|
+
canCreate: perms.canCreate,
|
|
1073
|
+
canUpdate: perms.canUpdate,
|
|
1074
|
+
canDelete: perms.canDelete,
|
|
1075
|
+
canCreateToken: perms.canCreateToken,
|
|
1076
|
+
onNewQueue: () => setEditing({ queue: null }),
|
|
1077
|
+
onEdit: (queue) => setEditing({ queue }),
|
|
1078
|
+
onDelete: setDeleting,
|
|
1079
|
+
onNewToken: (queue) => setIssuing({ preselect: queue ? workerQueueOf(queue) : void 0 })
|
|
1080
|
+
},
|
|
1081
|
+
tokenActions: {
|
|
1082
|
+
canCreateToken: perms.canCreateToken,
|
|
1083
|
+
canRotateToken: perms.canRotateToken,
|
|
1084
|
+
canDeleteToken: perms.canDeleteToken,
|
|
1085
|
+
canEditAllowlist: perms.canEditAllowlist,
|
|
1086
|
+
busy: dialogs.tokenBusy !== null,
|
|
1087
|
+
onNewToken: () => setIssuing({}),
|
|
1088
|
+
onConnections: dialogs.setAllowlist,
|
|
1089
|
+
onRotate: dialogs.setRotating,
|
|
1090
|
+
onDelete: dialogs.setDeletingToken
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// src/modules/task-queues/hooks/useTaskQueuePermissions.ts
|
|
1096
|
+
function useTaskQueuePermissions() {
|
|
1097
|
+
const createCheck = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.TASK_QUEUE_CREATE);
|
|
1098
|
+
const canCreate = createCheck.allowed;
|
|
1099
|
+
const permissionsLoading = createCheck.isLoading;
|
|
1100
|
+
const canUpdate = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.TASK_QUEUE_UPDATE).allowed;
|
|
1101
|
+
const canDelete = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.TASK_QUEUE_DELETE).allowed;
|
|
1102
|
+
const canReadTokens = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.RUNNER_READ).allowed;
|
|
1103
|
+
const canCreateToken = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.RUNNER_CREATE).allowed;
|
|
1104
|
+
const canRotateToken = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.RUNNER_UPDATE).allowed;
|
|
1105
|
+
const canDeleteToken = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.RUNNER_DELETE).allowed;
|
|
1106
|
+
return {
|
|
1107
|
+
canCreate,
|
|
1108
|
+
canUpdate,
|
|
1109
|
+
canDelete,
|
|
1110
|
+
canReadTokens,
|
|
1111
|
+
canCreateToken,
|
|
1112
|
+
canRotateToken,
|
|
1113
|
+
canDeleteToken,
|
|
1114
|
+
canEditAllowlist: canRotateToken && canCreateToken,
|
|
1115
|
+
permissionsLoading,
|
|
1116
|
+
viewOnly: !permissionsLoading && !canCreate && !canUpdate && !canDelete && !canCreateToken && !canRotateToken && !canDeleteToken
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// src/modules/task-queues/components/QueueParts.tsx
|
|
1121
|
+
/**
|
|
1122
|
+
* Words and small pieces the redesigned Task queues page shares (BOFF-15502):
|
|
1123
|
+
* environments in words (never DEV/STAGING/PROD), a queue's kind, whether
|
|
1124
|
+
* workers serve it, a worker's status, and the "How task queues work" link.
|
|
1125
|
+
*/
|
|
1126
|
+
/** An environment in words; null (an unscoped queue) is every environment. */
|
|
1127
|
+
function environmentLabel(tr, environment) {
|
|
1128
|
+
switch (environment) {
|
|
1129
|
+
case "DEV": return tr("fluidgrids.moreTools.queues.env.dev", "Development");
|
|
1130
|
+
case "STAGING": return tr("fluidgrids.moreTools.queues.env.staging", "Staging");
|
|
1131
|
+
case "PROD": return tr("fluidgrids.moreTools.queues.env.prod", "Production");
|
|
1132
|
+
default: return tr("fluidgrids.moreTools.queues.env.every", "Every environment");
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
/** Managed (neutral) or Self-hosted (info). */
|
|
1136
|
+
function QueueKind({ queue }) {
|
|
1137
|
+
const tr = useTr();
|
|
1138
|
+
return queue.kind === "MANAGED" ? /* @__PURE__ */ jsx(Status, {
|
|
1139
|
+
tone: "neutral",
|
|
1140
|
+
"data-testid": "queue-kind",
|
|
1141
|
+
children: tr("fluidgrids.moreTools.queues.kind.managed", "Managed")
|
|
1142
|
+
}) : /* @__PURE__ */ jsx(Status, {
|
|
1143
|
+
tone: "info",
|
|
1144
|
+
"data-testid": "queue-kind",
|
|
1145
|
+
children: tr("fluidgrids.moreTools.queues.kind.selfHosted", "Self-hosted")
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
/** "5 per second" or "No limit": the queue's activity rate limit. */
|
|
1149
|
+
function rateLimitText(tr, queue) {
|
|
1150
|
+
return queue.maxTasksPerSecond ? tr("fluidgrids.moreTools.queues.rate.perSecond", "{{count}} per second", { count: formatCount(queue.maxTasksPerSecond) }) : tr("fluidgrids.moreTools.queues.rate.none", "No limit");
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Whether workers serve a queue right now, from the availability of its name:
|
|
1154
|
+
* red "No workers" with what waits, yellow "No workers" with nothing waiting,
|
|
1155
|
+
* quiet "N workers online". A name with rows in several environments says
|
|
1156
|
+
* the numbers are for all of them.
|
|
1157
|
+
*/
|
|
1158
|
+
function QueueWorkers({ queue, availability, allEnvironments }) {
|
|
1159
|
+
const tr = useTr();
|
|
1160
|
+
if (queue.kind === "MANAGED") return /* @__PURE__ */ jsx("span", {
|
|
1161
|
+
className: "text-sm text-text-muted",
|
|
1162
|
+
"data-testid": "queue-workers",
|
|
1163
|
+
children: tr("fluidgrids.moreTools.queues.workers.managed", "Served by FluidGrids")
|
|
1164
|
+
});
|
|
1165
|
+
if (!availability) return /* @__PURE__ */ jsx("span", {
|
|
1166
|
+
className: "text-sm text-text-muted",
|
|
1167
|
+
"data-testid": "queue-workers",
|
|
1168
|
+
children: "—"
|
|
1169
|
+
});
|
|
1170
|
+
if (availability.availability === "UNKNOWN") return /* @__PURE__ */ jsx("span", {
|
|
1171
|
+
className: "text-sm text-text-muted",
|
|
1172
|
+
"data-testid": "queue-workers",
|
|
1173
|
+
children: tr("fluidgrids.moreTools.queues.workers.unknown", "Can't tell right now")
|
|
1174
|
+
});
|
|
1175
|
+
const waiting = availability.workflowBacklog + availability.activityBacklog;
|
|
1176
|
+
if (availability.availability === "UNAVAILABLE") {
|
|
1177
|
+
const age = formatDurationWords(availability.oldestBacklogAgeSeconds, "short");
|
|
1178
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1179
|
+
className: "min-w-0",
|
|
1180
|
+
"data-testid": "queue-workers",
|
|
1181
|
+
children: [/* @__PURE__ */ jsx(Status, {
|
|
1182
|
+
tone: "danger",
|
|
1183
|
+
children: tr("fluidgrids.moreTools.queues.workers.none", "No workers")
|
|
1184
|
+
}), /* @__PURE__ */ jsx(ReasonLine, {
|
|
1185
|
+
tone: "danger",
|
|
1186
|
+
children: allEnvironments ? tr("fluidgrids.moreTools.queues.workers.waitingOldestAll", "{{count}} waiting in all environments · oldest {{age}}", {
|
|
1187
|
+
count: formatCount(waiting),
|
|
1188
|
+
age
|
|
1189
|
+
}) : tr("fluidgrids.moreTools.queues.workers.waitingOldest", "{{count}} waiting · oldest {{age}}", {
|
|
1190
|
+
count: formatCount(waiting),
|
|
1191
|
+
age
|
|
1192
|
+
})
|
|
1193
|
+
})]
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
const reason = waiting > 0 ? allEnvironments ? tr("fluidgrids.moreTools.queues.workers.waitingAll", "{{count}} waiting in all environments", { count: formatCount(waiting) }) : tr("fluidgrids.moreTools.queues.workers.waiting", "{{count}} waiting", { count: formatCount(waiting) }) : allEnvironments ? tr("fluidgrids.moreTools.queues.workers.nothingWaitingAll", "Nothing waiting in any environment") : tr("fluidgrids.moreTools.queues.workers.nothingWaiting", "Nothing waiting");
|
|
1197
|
+
if (availability.availability === "IDLE" || availability.pollers === 0) return /* @__PURE__ */ jsxs("span", {
|
|
1198
|
+
className: "min-w-0",
|
|
1199
|
+
"data-testid": "queue-workers",
|
|
1200
|
+
children: [/* @__PURE__ */ jsx(Status, {
|
|
1201
|
+
tone: "warning",
|
|
1202
|
+
children: tr("fluidgrids.moreTools.queues.workers.none", "No workers")
|
|
1203
|
+
}), /* @__PURE__ */ jsx(ReasonLine, {
|
|
1204
|
+
tone: "neutral",
|
|
1205
|
+
children: reason
|
|
1206
|
+
})]
|
|
1207
|
+
});
|
|
1208
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1209
|
+
className: "min-w-0",
|
|
1210
|
+
"data-testid": "queue-workers",
|
|
1211
|
+
children: [/* @__PURE__ */ jsx(Status, {
|
|
1212
|
+
tone: "quiet",
|
|
1213
|
+
children: availability.pollers === 1 ? tr("fluidgrids.moreTools.queues.workers.oneOnline", "1 worker online") : tr("fluidgrids.moreTools.queues.workers.online", "{{count}} workers online", { count: formatCount(availability.pollers) })
|
|
1214
|
+
}), /* @__PURE__ */ jsx(ReasonLine, {
|
|
1215
|
+
tone: "neutral",
|
|
1216
|
+
children: reason
|
|
1217
|
+
})]
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
/** "TypeScript 2026.1030.0": a worker's SDK in words. */
|
|
1221
|
+
function workerSdkText(worker) {
|
|
1222
|
+
return [worker.sdkLanguage.toLowerCase() === "typescript" ? "TypeScript" : worker.sdkLanguage.toLowerCase() === "python" ? "Python" : worker.sdkLanguage, worker.sdkVersion].filter(Boolean).join(" ");
|
|
1223
|
+
}
|
|
1224
|
+
/** Online (quiet), Not responding (yellow) or Disconnected, with the last poll. */
|
|
1225
|
+
function WorkerStatus({ worker, withReason = false }) {
|
|
1226
|
+
const tr = useTr();
|
|
1227
|
+
if (worker.status === "ONLINE") return /* @__PURE__ */ jsx(Status, {
|
|
1228
|
+
tone: "quiet",
|
|
1229
|
+
"data-testid": "worker-status",
|
|
1230
|
+
children: tr("fluidgrids.moreTools.queues.worker.online", "Online")
|
|
1231
|
+
});
|
|
1232
|
+
const lastPoll = tr("fluidgrids.moreTools.queues.worker.lastPoll", "Last poll {{when}}", { when: formatRelativeTime(tr, worker.lastHeartbeatAt) });
|
|
1233
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1234
|
+
className: "min-w-0",
|
|
1235
|
+
children: [worker.status === "STALE" ? /* @__PURE__ */ jsx(Status, {
|
|
1236
|
+
tone: "warning",
|
|
1237
|
+
"data-testid": "worker-status",
|
|
1238
|
+
children: tr("fluidgrids.moreTools.queues.worker.stale", "Not responding")
|
|
1239
|
+
}) : /* @__PURE__ */ jsx(Status, {
|
|
1240
|
+
tone: "neutral",
|
|
1241
|
+
"data-testid": "worker-status",
|
|
1242
|
+
children: tr("fluidgrids.moreTools.queues.worker.offline", "Disconnected")
|
|
1243
|
+
}), withReason && /* @__PURE__ */ jsx(ReasonLine, {
|
|
1244
|
+
tone: "neutral",
|
|
1245
|
+
children: lastPoll
|
|
1246
|
+
})]
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
/** Slots in use across workflow and activity tasks (as the classic page sums them). */
|
|
1250
|
+
function workerSlots(worker) {
|
|
1251
|
+
return {
|
|
1252
|
+
used: worker.slots.workflow.used + worker.slots.activity.used,
|
|
1253
|
+
total: worker.slots.workflow.total + worker.slots.activity.total
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
/** "How task queues work": the page's purpose, one click away. */
|
|
1257
|
+
function QueuesWhatIs() {
|
|
1258
|
+
const tr = useTr();
|
|
1259
|
+
return /* @__PURE__ */ jsx(WhatIsLink, {
|
|
1260
|
+
label: tr("fluidgrids.moreTools.queues.whatIs.label", "How task queues work"),
|
|
1261
|
+
title: tr("fluidgrids.moreTools.queues.whatIs.title", "How task queues work"),
|
|
1262
|
+
children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.moreTools.queues.whatIs.body", "Code workflows and their activities run from task queues. The managed queue is served by FluidGrids. A self-hosted queue is served by workers you start on your own machines with a worker token.") })
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
// src/modules/task-queues/components/queueDetailHelpers.ts
|
|
1267
|
+
/** "Oldest 2 min · 1.5 in/s · 0.5 out/s", or "Nothing waiting · …". */
|
|
1268
|
+
function backlogDetail(tr, kind) {
|
|
1269
|
+
const rates = {
|
|
1270
|
+
in: kind.tasksAddRate.toFixed(1),
|
|
1271
|
+
out: kind.tasksDispatchRate.toFixed(1)
|
|
1272
|
+
};
|
|
1273
|
+
return kind.backlogCount > 0 ? tr("fluidgrids.moreTools.queues.detail.backlogOldest", "Oldest {{age}} · {{in}} in/s · {{out}} out/s", {
|
|
1274
|
+
age: formatDurationWords(kind.approxBacklogAgeSeconds, "short"),
|
|
1275
|
+
...rates
|
|
1276
|
+
}) : tr("fluidgrids.moreTools.queues.detail.backlogNone", "Nothing waiting · {{in}} in/s · {{out}} out/s", rates);
|
|
1277
|
+
}
|
|
1278
|
+
/** The age of the oldest waiting task of either kind, 0 when none waits. */
|
|
1279
|
+
function oldestBacklogSeconds(data) {
|
|
1280
|
+
const workflow = data.workflow.backlogCount > 0 ? data.workflow.approxBacklogAgeSeconds : 0;
|
|
1281
|
+
const activity = data.activity.backlogCount > 0 ? data.activity.approxBacklogAgeSeconds : 0;
|
|
1282
|
+
return Math.max(workflow, activity);
|
|
1283
|
+
}
|
|
1284
|
+
/** What the queue's numbers say: tasks waiting, whether it is stuck. */
|
|
1285
|
+
function queueHealth(queue, data) {
|
|
1286
|
+
const waiting = data ? data.workflow.backlogCount + data.activity.backlogCount : 0;
|
|
1287
|
+
return {
|
|
1288
|
+
waiting,
|
|
1289
|
+
stuck: !(queue.kind === "MANAGED") && !!data && data.pollers === 0 && waiting > 0,
|
|
1290
|
+
oldest: data ? oldestBacklogSeconds(data) : 0
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
/** The tokens that name the queue, once the tokens are read. */
|
|
1294
|
+
function tokensNaming(tokens, queue) {
|
|
1295
|
+
return tokens?.filter((token) => token.taskQueues.some((entry) => entryServesQueue(entry, queue))) ?? null;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// src/modules/task-queues/components/QueueDetailParts.tsx
|
|
1299
|
+
/** A panel's rows while they load, or when they could not be read. */
|
|
1300
|
+
function PanelNote({ error, what, padded = true }) {
|
|
1301
|
+
const tr = useTr();
|
|
1302
|
+
const text = error ? what === "workers" ? tr("fluidgrids.moreTools.queues.error.workers", "Couldn't load the workers") : tr("fluidgrids.moreTools.queues.error.tokens", "Couldn't load the worker tokens") : tr("fluidgrids.moreTools.common.loading", "Loading…");
|
|
1303
|
+
return /* @__PURE__ */ jsx("p", {
|
|
1304
|
+
role: error ? "alert" : "status",
|
|
1305
|
+
className: cn("text-sm", padded && "px-4 py-3", error ? "text-status-error-text" : "text-text-muted"),
|
|
1306
|
+
"data-testid": `queue-${what}-note`,
|
|
1307
|
+
children: text
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
/** The More menu's items: a new token for it, and delete (self-hosted only). */
|
|
1311
|
+
function buildQueueMenu(tr, queue, actions) {
|
|
1312
|
+
const menu = [];
|
|
1313
|
+
if (queue.kind === "MANAGED") return menu;
|
|
1314
|
+
if (actions.canCreateToken) menu.push({
|
|
1315
|
+
id: "new-token",
|
|
1316
|
+
label: tr("fluidgrids.moreTools.queues.menu.newToken", "New worker token for it"),
|
|
1317
|
+
icon: /* @__PURE__ */ jsx(KeyRound, {
|
|
1318
|
+
className: "size-4",
|
|
1319
|
+
"aria-hidden": "true"
|
|
1320
|
+
}),
|
|
1321
|
+
onSelect: () => actions.onNewToken(queue)
|
|
1322
|
+
});
|
|
1323
|
+
if (actions.canDelete) menu.push({
|
|
1324
|
+
id: "delete",
|
|
1325
|
+
label: tr("fluidgrids.moreTools.queues.menu.delete", "Delete…"),
|
|
1326
|
+
icon: /* @__PURE__ */ jsx(Trash2, {
|
|
1327
|
+
className: "size-4",
|
|
1328
|
+
"aria-hidden": "true"
|
|
1329
|
+
}),
|
|
1330
|
+
onSelect: () => actions.onDelete(queue),
|
|
1331
|
+
danger: true,
|
|
1332
|
+
separatorBefore: menu.length > 0
|
|
1333
|
+
});
|
|
1334
|
+
return menu;
|
|
1335
|
+
}
|
|
1336
|
+
function QueueDetailHeader({ queue, back, actions }) {
|
|
1337
|
+
const tr = useTr();
|
|
1338
|
+
const managed = queue.kind === "MANAGED";
|
|
1339
|
+
const menu = buildQueueMenu(tr, queue, actions);
|
|
1340
|
+
return /* @__PURE__ */ jsx(MoreToolsHeader, {
|
|
1341
|
+
back,
|
|
1342
|
+
title: /* @__PURE__ */ jsx("span", {
|
|
1343
|
+
className: "font-mono",
|
|
1344
|
+
children: queue.name
|
|
1345
|
+
}),
|
|
1346
|
+
titleTestId: "queue-detail-title",
|
|
1347
|
+
facts: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1348
|
+
/* @__PURE__ */ jsx(QueueKind, { queue }),
|
|
1349
|
+
/* @__PURE__ */ jsx("span", { children: environmentLabel(tr, queue.environment) }),
|
|
1350
|
+
queue.description && /* @__PURE__ */ jsx("span", { children: queue.description })
|
|
1351
|
+
] }),
|
|
1352
|
+
actions: !managed && (actions.canUpdate || menu.length > 0) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [actions.canUpdate && /* @__PURE__ */ jsxs(Button$1, {
|
|
1353
|
+
variant: "outline",
|
|
1354
|
+
onClick: () => actions.onEdit(queue),
|
|
1355
|
+
"data-testid": "queue-detail-edit",
|
|
1356
|
+
children: [/* @__PURE__ */ jsx(Pencil, {
|
|
1357
|
+
className: "size-4",
|
|
1358
|
+
"aria-hidden": "true"
|
|
1359
|
+
}), tr("fluidgrids.moreTools.queues.menu.edit", "Edit")]
|
|
1360
|
+
}), /* @__PURE__ */ jsx(RowMenu, {
|
|
1361
|
+
label: tr("fluidgrids.moreTools.queues.menu.moreLabel", "More actions for {{name}}", { name: queue.name }),
|
|
1362
|
+
items: menu,
|
|
1363
|
+
testId: "queue-detail-menu",
|
|
1364
|
+
triggerClassName: "size-10 border border-border-default"
|
|
1365
|
+
})] }) : void 0
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
function stuckTitle(tr, waiting) {
|
|
1369
|
+
if (waiting === 1) return tr("fluidgrids.moreTools.queues.detail.stuckOne", "1 task is waiting and no worker serves this queue");
|
|
1370
|
+
return tr("fluidgrids.moreTools.queues.detail.stuck", "{{count}} tasks are waiting and no worker serves this queue", { count: formatCount(waiting) });
|
|
1371
|
+
}
|
|
1372
|
+
/** The alerts above the numbers: tasks waiting with no worker, stats failing. */
|
|
1373
|
+
function QueueAlerts({ queue, health, actions, statsFailed, onRetryStats }) {
|
|
1374
|
+
const tr = useTr();
|
|
1375
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [health.stuck && /* @__PURE__ */ jsx(ToneAlert, {
|
|
1376
|
+
tone: "danger",
|
|
1377
|
+
role: "alert",
|
|
1378
|
+
title: stuckTitle(tr, health.waiting),
|
|
1379
|
+
actions: actions.canCreateToken ? /* @__PURE__ */ jsxs(Button$1, {
|
|
1380
|
+
size: "sm",
|
|
1381
|
+
variant: "outline",
|
|
1382
|
+
onClick: () => actions.onNewToken(queue),
|
|
1383
|
+
"data-testid": "queue-alert-new-token",
|
|
1384
|
+
children: [/* @__PURE__ */ jsx(KeyRound, {
|
|
1385
|
+
className: "size-4",
|
|
1386
|
+
"aria-hidden": "true"
|
|
1387
|
+
}), tr("fluidgrids.moreTools.queues.newToken", "New worker token")]
|
|
1388
|
+
}) : void 0,
|
|
1389
|
+
testId: "queue-alert-stuck",
|
|
1390
|
+
children: tr("fluidgrids.moreTools.queues.detail.stuckText", "The oldest has waited {{age}}. A waiting activity fails after {{wait}} without a worker. Start a worker with a token for {{queue}}.", {
|
|
1391
|
+
age: formatDurationWords(health.oldest),
|
|
1392
|
+
wait: formatDurationWords(queue.workerUnavailableTimeoutSeconds),
|
|
1393
|
+
queue: workerQueueOf(queue)
|
|
1394
|
+
})
|
|
1395
|
+
}), statsFailed && /* @__PURE__ */ jsx(ToneAlert, {
|
|
1396
|
+
tone: "warning",
|
|
1397
|
+
title: tr("fluidgrids.moreTools.queues.detail.statsError", "Couldn't load this queue's numbers"),
|
|
1398
|
+
actions: /* @__PURE__ */ jsx(Button$1, {
|
|
1399
|
+
size: "sm",
|
|
1400
|
+
variant: "outline",
|
|
1401
|
+
onClick: onRetryStats,
|
|
1402
|
+
children: tr("fluidgrids.moreTools.common.tryAgain", "Try again")
|
|
1403
|
+
}),
|
|
1404
|
+
testId: "queue-stats-error"
|
|
1405
|
+
})] });
|
|
1406
|
+
}
|
|
1407
|
+
/** The three number tiles: pollers and the two backlogs. */
|
|
1408
|
+
function QueueStats({ queue, data, stuck }) {
|
|
1409
|
+
const tr = useTr();
|
|
1410
|
+
return /* @__PURE__ */ jsx("section", {
|
|
1411
|
+
"aria-label": tr("fluidgrids.moreTools.queues.detail.numbers", "Numbers of {{name}}", { name: queue.name }),
|
|
1412
|
+
"data-testid": "task-queue-stats",
|
|
1413
|
+
children: /* @__PURE__ */ jsxs(KpiRow, {
|
|
1414
|
+
columns: 3,
|
|
1415
|
+
children: [
|
|
1416
|
+
/* @__PURE__ */ jsx(KpiTile, {
|
|
1417
|
+
label: tr("fluidgrids.moreTools.queues.detail.pollers", "Workers polling"),
|
|
1418
|
+
value: data ? formatCount(data.pollers) : "—",
|
|
1419
|
+
detail: tr("fluidgrids.moreTools.queues.detail.pollersDetail", "In the last 2 minutes"),
|
|
1420
|
+
tone: stuck ? "danger" : void 0,
|
|
1421
|
+
testId: "task-queue-pollers"
|
|
1422
|
+
}),
|
|
1423
|
+
/* @__PURE__ */ jsx(KpiTile, {
|
|
1424
|
+
label: tr("fluidgrids.moreTools.queues.detail.workflowWaiting", "Workflow tasks waiting"),
|
|
1425
|
+
value: data ? formatCount(data.workflow.backlogCount) : "—",
|
|
1426
|
+
detail: data ? backlogDetail(tr, data.workflow) : void 0,
|
|
1427
|
+
testId: "task-queue-backlog-workflow"
|
|
1428
|
+
}),
|
|
1429
|
+
/* @__PURE__ */ jsx(KpiTile, {
|
|
1430
|
+
label: tr("fluidgrids.moreTools.queues.detail.activityWaiting", "Activity tasks waiting"),
|
|
1431
|
+
value: data ? formatCount(data.activity.backlogCount) : "—",
|
|
1432
|
+
detail: data ? backlogDetail(tr, data.activity) : void 0,
|
|
1433
|
+
testId: "task-queue-backlog-activity"
|
|
1434
|
+
})
|
|
1435
|
+
]
|
|
1436
|
+
})
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
function WorkerRows({ serving }) {
|
|
1440
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
1441
|
+
className: "divide-y divide-border-subtle",
|
|
1442
|
+
children: serving.map((worker) => /* @__PURE__ */ jsxs("li", {
|
|
1443
|
+
className: "flex items-center gap-3 px-4 py-2.5",
|
|
1444
|
+
"data-testid": `queue-worker-${worker.id}`,
|
|
1445
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1446
|
+
className: "min-w-0 flex-1",
|
|
1447
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1448
|
+
className: "truncate font-mono text-sm text-text-primary",
|
|
1449
|
+
children: worker.identity
|
|
1450
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1451
|
+
className: "truncate text-xs text-text-muted",
|
|
1452
|
+
children: [workerSdkText(worker), worker.taskQueues.join(", ")].filter(Boolean).join(" · ")
|
|
1453
|
+
})]
|
|
1454
|
+
}), /* @__PURE__ */ jsx(WorkerStatus, {
|
|
1455
|
+
worker,
|
|
1456
|
+
withReason: true
|
|
1457
|
+
})]
|
|
1458
|
+
}, worker.id))
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
function WorkersPanelBody({ managed, workers, error }) {
|
|
1462
|
+
const tr = useTr();
|
|
1463
|
+
if (managed) return /* @__PURE__ */ jsx("p", {
|
|
1464
|
+
className: "px-4 py-3 text-sm text-text-secondary",
|
|
1465
|
+
children: tr("fluidgrids.moreTools.queues.detail.managedWorkers", "Served by FluidGrids. You don't run workers for it.")
|
|
1466
|
+
});
|
|
1467
|
+
if (!workers) return /* @__PURE__ */ jsx(PanelNote, {
|
|
1468
|
+
error,
|
|
1469
|
+
what: "workers"
|
|
1470
|
+
});
|
|
1471
|
+
if (workers.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1472
|
+
className: "px-4",
|
|
1473
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
1474
|
+
kind: "first-use",
|
|
1475
|
+
illustration: "servers",
|
|
1476
|
+
size: "inline",
|
|
1477
|
+
compact: true,
|
|
1478
|
+
icon: null,
|
|
1479
|
+
title: tr("fluidgrids.moreTools.queues.detail.noWorkers", "No worker serves this queue right now.")
|
|
1480
|
+
})
|
|
1481
|
+
});
|
|
1482
|
+
return /* @__PURE__ */ jsx(WorkerRows, { serving: workers });
|
|
1483
|
+
}
|
|
1484
|
+
/** The workers that serve the queue. */
|
|
1485
|
+
function QueueWorkersPanel({ managed, workers, error }) {
|
|
1486
|
+
const tr = useTr();
|
|
1487
|
+
return /* @__PURE__ */ jsx(Panel, {
|
|
1488
|
+
title: tr("fluidgrids.moreTools.queues.detail.workers", "Workers serving it"),
|
|
1489
|
+
count: managed || !workers ? void 0 : workers.length,
|
|
1490
|
+
flush: true,
|
|
1491
|
+
testId: "queue-workers-panel",
|
|
1492
|
+
children: /* @__PURE__ */ jsx(WorkersPanelBody, {
|
|
1493
|
+
managed,
|
|
1494
|
+
workers,
|
|
1495
|
+
error
|
|
1496
|
+
})
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
/** The queue's settings as a key/value list. */
|
|
1500
|
+
function QueueSettingsPanel({ queue }) {
|
|
1501
|
+
const tr = useTr();
|
|
1502
|
+
const managed = queue.kind === "MANAGED";
|
|
1503
|
+
return /* @__PURE__ */ jsx(Panel, {
|
|
1504
|
+
title: tr("fluidgrids.moreTools.queues.detail.settings", "Settings"),
|
|
1505
|
+
testId: "queue-settings",
|
|
1506
|
+
children: /* @__PURE__ */ jsx(KeyValueList, { items: [
|
|
1507
|
+
{
|
|
1508
|
+
term: tr("fluidgrids.moreTools.queues.detail.environment", "Environment"),
|
|
1509
|
+
value: environmentLabel(tr, queue.environment)
|
|
1510
|
+
},
|
|
1511
|
+
{
|
|
1512
|
+
term: tr("fluidgrids.moreTools.queues.detail.rateLimit", "Rate limit"),
|
|
1513
|
+
value: queue.maxTasksPerSecond ? tr("fluidgrids.moreTools.queues.detail.rateValue", "{{count}} activity tasks per second", { count: formatCount(queue.maxTasksPerSecond) }) : tr("fluidgrids.moreTools.queues.rate.none", "No limit")
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
term: tr("fluidgrids.moreTools.queues.detail.wait", "Wait for a worker"),
|
|
1517
|
+
value: tr("fluidgrids.moreTools.queues.detail.waitValue", "{{wait}}, then a waiting activity fails", { wait: formatDurationWords(queue.workerUnavailableTimeoutSeconds) })
|
|
1518
|
+
},
|
|
1519
|
+
...managed ? [] : [{
|
|
1520
|
+
term: tr("fluidgrids.moreTools.queues.detail.workerName", "Name for workers"),
|
|
1521
|
+
value: /* @__PURE__ */ jsx("code", {
|
|
1522
|
+
className: "font-mono text-xs",
|
|
1523
|
+
children: workerQueueOf(queue)
|
|
1524
|
+
})
|
|
1525
|
+
}]
|
|
1526
|
+
] })
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
function TokensPanelBody({ naming, error }) {
|
|
1530
|
+
const tr = useTr();
|
|
1531
|
+
if (!naming) return /* @__PURE__ */ jsx(PanelNote, {
|
|
1532
|
+
error,
|
|
1533
|
+
what: "tokens",
|
|
1534
|
+
padded: false
|
|
1535
|
+
});
|
|
1536
|
+
if (naming.length === 0) return /* @__PURE__ */ jsx(EmptyState, {
|
|
1537
|
+
kind: "first-use",
|
|
1538
|
+
illustration: "security",
|
|
1539
|
+
size: "inline",
|
|
1540
|
+
compact: true,
|
|
1541
|
+
icon: null,
|
|
1542
|
+
title: tr("fluidgrids.moreTools.queues.detail.noTokens", "No token names this queue yet.")
|
|
1543
|
+
});
|
|
1544
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
1545
|
+
className: "space-y-1.5",
|
|
1546
|
+
children: naming.map((token) => /* @__PURE__ */ jsxs("li", {
|
|
1547
|
+
className: "text-sm",
|
|
1548
|
+
children: [
|
|
1549
|
+
/* @__PURE__ */ jsx("span", {
|
|
1550
|
+
className: "font-semibold text-text-primary",
|
|
1551
|
+
children: token.name
|
|
1552
|
+
}),
|
|
1553
|
+
" ",
|
|
1554
|
+
/* @__PURE__ */ jsx("span", {
|
|
1555
|
+
className: "text-text-muted",
|
|
1556
|
+
children: tr("fluidgrids.moreTools.queues.token.startsWith", "Starts with {{prefix}}…", { prefix: token.tokenPrefix })
|
|
1557
|
+
})
|
|
1558
|
+
]
|
|
1559
|
+
}, token.id))
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
/** The tokens that name the queue. */
|
|
1563
|
+
function QueueTokensPanel({ tokens, naming }) {
|
|
1564
|
+
const tr = useTr();
|
|
1565
|
+
return /* @__PURE__ */ jsx(Panel, {
|
|
1566
|
+
title: tr("fluidgrids.moreTools.queues.detail.tokens", "Tokens that serve it"),
|
|
1567
|
+
count: naming?.length,
|
|
1568
|
+
testId: "queue-tokens-panel",
|
|
1569
|
+
children: /* @__PURE__ */ jsx(TokensPanelBody, {
|
|
1570
|
+
naming,
|
|
1571
|
+
error: tokens.error
|
|
1572
|
+
})
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
/** The queue's id, behind the technical-details toggle. */
|
|
1576
|
+
function QueueTechnical({ id }) {
|
|
1577
|
+
const tr = useTr();
|
|
1578
|
+
return /* @__PURE__ */ jsx(TechnicalDetails, {
|
|
1579
|
+
className: "mt-4",
|
|
1580
|
+
"data-testid": "queue-technical",
|
|
1581
|
+
children: /* @__PURE__ */ jsxs("dl", {
|
|
1582
|
+
className: "grid gap-x-4 gap-y-1 text-xs text-text-secondary sm:grid-cols-[auto_1fr]",
|
|
1583
|
+
children: [/* @__PURE__ */ jsx("dt", { children: tr("fluidgrids.moreTools.queues.technical.id", "Queue ID") }), /* @__PURE__ */ jsx("dd", {
|
|
1584
|
+
className: "break-all font-mono text-text-primary",
|
|
1585
|
+
children: id
|
|
1586
|
+
})]
|
|
1587
|
+
})
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
// src/modules/task-queues/components/QueueDetailV2.tsx
|
|
1592
|
+
/**
|
|
1593
|
+
* One queue's page (BOFF-15502, Navigation v2), opened with `?queue=<id>`
|
|
1594
|
+
* (the managed queue by its name): its numbers (the stats card of the classic
|
|
1595
|
+
* page, titled and on its own page), the workers that serve it, its settings
|
|
1596
|
+
* and the tokens that name it.
|
|
1597
|
+
*/
|
|
1598
|
+
function QueueDetailV2({ queue, queues, tokens, backTo, actions }) {
|
|
1599
|
+
const tr = useTr();
|
|
1600
|
+
const back = {
|
|
1601
|
+
to: backTo,
|
|
1602
|
+
label: tr("fluidgrids.moreTools.queues.title", "Task queues")
|
|
1603
|
+
};
|
|
1604
|
+
if (!queue) {
|
|
1605
|
+
if (!queues.items && queues.error) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(MoreToolsHeader, {
|
|
1606
|
+
back,
|
|
1607
|
+
title: back.label
|
|
1608
|
+
}), /* @__PURE__ */ jsx(LoadErrorPanel, {
|
|
1609
|
+
title: tr("fluidgrids.moreTools.queues.error.queues", "Couldn't load task queues"),
|
|
1610
|
+
text: tr("fluidgrids.moreTools.queues.error.text", "The worker service did not answer. Workers already running keep working."),
|
|
1611
|
+
error: queues.error,
|
|
1612
|
+
onRetry: () => void queues.refetch()
|
|
1613
|
+
})] });
|
|
1614
|
+
if (!queues.items) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(MoreToolsHeader, {
|
|
1615
|
+
back,
|
|
1616
|
+
title: back.label
|
|
1617
|
+
}), /* @__PURE__ */ jsx(ListSkeleton, { rows: 3 })] });
|
|
1618
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(MoreToolsHeader, {
|
|
1619
|
+
back,
|
|
1620
|
+
title: tr("fluidgrids.moreTools.queues.missing.title", "Queue not found")
|
|
1621
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1622
|
+
"data-testid": "queue-missing",
|
|
1623
|
+
children: /* @__PURE__ */ jsx(EmptyPanel, {
|
|
1624
|
+
kind: "not-found",
|
|
1625
|
+
icon: /* @__PURE__ */ jsx(ListOrdered, {
|
|
1626
|
+
className: "size-5 text-text-secondary",
|
|
1627
|
+
"aria-hidden": "true"
|
|
1628
|
+
}),
|
|
1629
|
+
title: tr("fluidgrids.moreTools.queues.missing.heading", "This queue no longer exists"),
|
|
1630
|
+
text: tr("fluidgrids.moreTools.queues.missing.text", "It may have been deleted."),
|
|
1631
|
+
children: /* @__PURE__ */ jsx(Button$1, {
|
|
1632
|
+
asChild: true,
|
|
1633
|
+
variant: "outline",
|
|
1634
|
+
children: /* @__PURE__ */ jsxs(Link, {
|
|
1635
|
+
to: backTo,
|
|
1636
|
+
children: [/* @__PURE__ */ jsx(ArrowLeft, {
|
|
1637
|
+
className: "size-4 rtl:rotate-180",
|
|
1638
|
+
"aria-hidden": "true"
|
|
1639
|
+
}), tr("fluidgrids.moreTools.queues.missing.back", "All queues")]
|
|
1640
|
+
})
|
|
1641
|
+
})
|
|
1642
|
+
})
|
|
1643
|
+
})] });
|
|
1644
|
+
}
|
|
1645
|
+
return /* @__PURE__ */ jsx(QueueDetailBody, {
|
|
1646
|
+
queue,
|
|
1647
|
+
tokens,
|
|
1648
|
+
back,
|
|
1649
|
+
actions
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
function QueueDetailBody({ queue, tokens, back, actions }) {
|
|
1653
|
+
const stats = useQueueStats(queue);
|
|
1654
|
+
const served = useQueueWorkers(queue);
|
|
1655
|
+
const managed = queue.kind === "MANAGED";
|
|
1656
|
+
const data = stats.data;
|
|
1657
|
+
const health = queueHealth(queue, data);
|
|
1658
|
+
const naming = tokensNaming(tokens?.items, queue);
|
|
1659
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1660
|
+
"data-testid": "queue-detail",
|
|
1661
|
+
children: [
|
|
1662
|
+
/* @__PURE__ */ jsx(QueueDetailHeader, {
|
|
1663
|
+
queue,
|
|
1664
|
+
back,
|
|
1665
|
+
actions
|
|
1666
|
+
}),
|
|
1667
|
+
/* @__PURE__ */ jsx(QueueAlerts, {
|
|
1668
|
+
queue,
|
|
1669
|
+
health,
|
|
1670
|
+
actions,
|
|
1671
|
+
statsFailed: !!stats.error && !data,
|
|
1672
|
+
onRetryStats: () => void stats.refetch()
|
|
1673
|
+
}),
|
|
1674
|
+
/* @__PURE__ */ jsx(QueueStats, {
|
|
1675
|
+
queue,
|
|
1676
|
+
data,
|
|
1677
|
+
stuck: health.stuck
|
|
1678
|
+
}),
|
|
1679
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1680
|
+
className: "grid items-start gap-4 lg:grid-cols-2",
|
|
1681
|
+
children: [/* @__PURE__ */ jsx(QueueWorkersPanel, {
|
|
1682
|
+
managed,
|
|
1683
|
+
workers: served.workers,
|
|
1684
|
+
error: served.error
|
|
1685
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1686
|
+
className: "grid gap-4",
|
|
1687
|
+
children: [/* @__PURE__ */ jsx(QueueSettingsPanel, { queue }), tokens && !managed && /* @__PURE__ */ jsx(QueueTokensPanel, {
|
|
1688
|
+
tokens,
|
|
1689
|
+
naming
|
|
1690
|
+
})]
|
|
1691
|
+
})]
|
|
1692
|
+
}),
|
|
1693
|
+
queue.id && /* @__PURE__ */ jsx(QueueTechnical, { id: queue.id })
|
|
1694
|
+
]
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
// src/modules/task-queues/components/TaskQueueDialogsV2.tsx
|
|
1699
|
+
/**
|
|
1700
|
+
* The redesigned Task queues dialogs (BOFF-15502, Navigation v2):
|
|
1701
|
+
*
|
|
1702
|
+
* - New or Edit queue: the environment in words in the app's own menu (never
|
|
1703
|
+
* a native select), the name rule as a hint that turns into the error, and
|
|
1704
|
+
* the wait for a worker in minutes;
|
|
1705
|
+
* - New worker token: the queues it may serve as styled checkboxes, and the
|
|
1706
|
+
* connections its activities may use;
|
|
1707
|
+
* - the token, shown once, with the start command; closing before copying it
|
|
1708
|
+
* asks first;
|
|
1709
|
+
* - Connections for a token.
|
|
1710
|
+
*/
|
|
1711
|
+
/** A field's error line, tied to its input by `aria-describedby`. */
|
|
1712
|
+
function FieldMessage({ id, error, hint }) {
|
|
1713
|
+
if (error) return /* @__PURE__ */ jsx("p", {
|
|
1714
|
+
id,
|
|
1715
|
+
className: "text-xs text-status-error-text",
|
|
1716
|
+
role: "alert",
|
|
1717
|
+
children: error
|
|
1718
|
+
});
|
|
1719
|
+
return hint ? /* @__PURE__ */ jsx("p", {
|
|
1720
|
+
id,
|
|
1721
|
+
className: "text-xs text-text-muted",
|
|
1722
|
+
children: hint
|
|
1723
|
+
}) : null;
|
|
1724
|
+
}
|
|
1725
|
+
/** The dialog's own error (the service refused), in plain words. */
|
|
1726
|
+
function FormError({ message, testId }) {
|
|
1727
|
+
if (!message) return null;
|
|
1728
|
+
return /* @__PURE__ */ jsx("p", {
|
|
1729
|
+
role: "alert",
|
|
1730
|
+
className: "rounded-lg border border-status-error-border bg-status-error-bg-subtle px-3 py-2 text-sm text-status-error-text",
|
|
1731
|
+
"data-testid": testId,
|
|
1732
|
+
children: message
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1735
|
+
function environmentOptions(tr) {
|
|
1736
|
+
return [
|
|
1737
|
+
{
|
|
1738
|
+
value: "",
|
|
1739
|
+
label: environmentLabel(tr, null)
|
|
1740
|
+
},
|
|
1741
|
+
{
|
|
1742
|
+
value: "DEV",
|
|
1743
|
+
label: environmentLabel(tr, "DEV")
|
|
1744
|
+
},
|
|
1745
|
+
{
|
|
1746
|
+
value: "STAGING",
|
|
1747
|
+
label: environmentLabel(tr, "STAGING")
|
|
1748
|
+
},
|
|
1749
|
+
{
|
|
1750
|
+
value: "PROD",
|
|
1751
|
+
label: environmentLabel(tr, "PROD")
|
|
1752
|
+
}
|
|
1753
|
+
];
|
|
1754
|
+
}
|
|
1755
|
+
/** The service's default wait for a worker (CreateTaskQueueInput: 600 s). */
|
|
1756
|
+
const DEFAULT_WORKER_WAIT_SECONDS = 600;
|
|
1757
|
+
/** New queue (no `queue`) or Edit queue. */
|
|
1758
|
+
function QueueFormDialogV2({ queue, onClose, onSaved }) {
|
|
1759
|
+
const tr = useTr();
|
|
1760
|
+
const ids = useId();
|
|
1761
|
+
const [form, setForm] = useState(() => queue ? {
|
|
1762
|
+
name: queue.name,
|
|
1763
|
+
environment: queue.environment ?? "",
|
|
1764
|
+
description: queue.description ?? "",
|
|
1765
|
+
rate: queue.maxTasksPerSecond === null || queue.maxTasksPerSecond === void 0 ? "" : String(queue.maxTasksPerSecond),
|
|
1766
|
+
waitMinutes: secondsToMinutesText(queue.workerUnavailableTimeoutSeconds)
|
|
1767
|
+
} : {
|
|
1768
|
+
name: "",
|
|
1769
|
+
environment: "",
|
|
1770
|
+
description: "",
|
|
1771
|
+
rate: "",
|
|
1772
|
+
waitMinutes: ""
|
|
1773
|
+
});
|
|
1774
|
+
const [busy, setBusy] = useState(false);
|
|
1775
|
+
const [error, setError] = useState(null);
|
|
1776
|
+
const waitSeconds = minutesToSecondsText(form.waitMinutes);
|
|
1777
|
+
const checked = taskQueueInputOf({
|
|
1778
|
+
name: form.name,
|
|
1779
|
+
environment: form.environment,
|
|
1780
|
+
description: form.description,
|
|
1781
|
+
maxTasksPerSecond: form.rate,
|
|
1782
|
+
workerUnavailableTimeoutSeconds: waitSeconds
|
|
1783
|
+
});
|
|
1784
|
+
const nameProblem = !queue && form.name ? taskQueueNameProblem(form.name) : null;
|
|
1785
|
+
const rateBad = boundedNumber(form.rate, .01, 1e4) === null;
|
|
1786
|
+
const waitBad = boundedNumber(waitSeconds, 10, 604800, true) === null;
|
|
1787
|
+
const set = (change) => setForm((current) => ({
|
|
1788
|
+
...current,
|
|
1789
|
+
...change
|
|
1790
|
+
}));
|
|
1791
|
+
const save = async () => {
|
|
1792
|
+
if (!checked.ok || busy) return;
|
|
1793
|
+
setBusy(true);
|
|
1794
|
+
setError(null);
|
|
1795
|
+
try {
|
|
1796
|
+
if (queue?.id) {
|
|
1797
|
+
const rate = boundedNumber(form.rate, .01, 1e4);
|
|
1798
|
+
await updateTaskQueue(queue.id, {
|
|
1799
|
+
description: form.description.trim(),
|
|
1800
|
+
...rate === void 0 || rate === null ? { clearMaxTasksPerSecond: true } : { maxTasksPerSecond: rate },
|
|
1801
|
+
workerUnavailableTimeoutSeconds: checked.create.workerUnavailableTimeoutSeconds ?? DEFAULT_WORKER_WAIT_SECONDS
|
|
1802
|
+
});
|
|
1803
|
+
onSaved(false);
|
|
1804
|
+
} else {
|
|
1805
|
+
await createTaskQueue(checked.create);
|
|
1806
|
+
onSaved(true);
|
|
1807
|
+
}
|
|
1808
|
+
} catch (err) {
|
|
1809
|
+
setError(describeOperationError(err));
|
|
1810
|
+
setBusy(false);
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
return /* @__PURE__ */ jsx(ResponsiveDialog, {
|
|
1814
|
+
open: true,
|
|
1815
|
+
onOpenChange: (open) => {
|
|
1816
|
+
if (!open && !busy) onClose();
|
|
1817
|
+
},
|
|
1818
|
+
children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
|
|
1819
|
+
className: "sm:max-w-lg",
|
|
1820
|
+
"data-testid": "task-queue-dialog",
|
|
1821
|
+
children: [
|
|
1822
|
+
/* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: queue ? tr("fluidgrids.moreTools.queues.form.editTitle", "Edit {{name}}", { name: queue.name }) : tr("fluidgrids.moreTools.queues.form.newTitle", "New task queue") }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.moreTools.queues.form.subtitle", "Tasks on a self-hosted queue run on workers you start for it") })] }),
|
|
1823
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1824
|
+
className: "space-y-4",
|
|
1825
|
+
children: [
|
|
1826
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1827
|
+
className: "space-y-1.5",
|
|
1828
|
+
children: [
|
|
1829
|
+
/* @__PURE__ */ jsx(Label, {
|
|
1830
|
+
htmlFor: `${ids}-name`,
|
|
1831
|
+
children: tr("fluidgrids.moreTools.queues.form.name", "Name")
|
|
1832
|
+
}),
|
|
1833
|
+
/* @__PURE__ */ jsx(Input, {
|
|
1834
|
+
id: `${ids}-name`,
|
|
1835
|
+
value: form.name,
|
|
1836
|
+
disabled: !!queue,
|
|
1837
|
+
placeholder: "payments",
|
|
1838
|
+
autoComplete: "off",
|
|
1839
|
+
className: "font-mono",
|
|
1840
|
+
"aria-invalid": nameProblem ? true : void 0,
|
|
1841
|
+
"aria-describedby": `${ids}-name-hint`,
|
|
1842
|
+
onChange: (event) => set({ name: event.target.value }),
|
|
1843
|
+
"data-testid": "task-queue-name"
|
|
1844
|
+
}),
|
|
1845
|
+
/* @__PURE__ */ jsx(FieldMessage, {
|
|
1846
|
+
id: `${ids}-name-hint`,
|
|
1847
|
+
error: nameProblem === "reserved" ? tr("fluidgrids.moreTools.queues.form.nameReserved", "managed is FluidGrids' own queue. Pick another name.") : nameProblem === "pattern" ? tr("fluidgrids.moreTools.queues.form.namePattern", "Use lower-case letters, digits and dashes, up to 63.") : null,
|
|
1848
|
+
hint: tr("fluidgrids.moreTools.queues.form.nameHint", "Lower-case letters, digits and dashes. It can't change later.")
|
|
1849
|
+
})
|
|
1850
|
+
]
|
|
1851
|
+
}),
|
|
1852
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1853
|
+
className: "space-y-1.5",
|
|
1854
|
+
children: [
|
|
1855
|
+
/* @__PURE__ */ jsx(Label, {
|
|
1856
|
+
htmlFor: `${ids}-env`,
|
|
1857
|
+
children: tr("fluidgrids.moreTools.queues.form.environment", "Environment")
|
|
1858
|
+
}),
|
|
1859
|
+
/* @__PURE__ */ jsx(ChoiceSelect, {
|
|
1860
|
+
id: `${ids}-env`,
|
|
1861
|
+
value: form.environment,
|
|
1862
|
+
onValueChange: (environment) => set({ environment }),
|
|
1863
|
+
options: environmentOptions(tr),
|
|
1864
|
+
disabled: !!queue,
|
|
1865
|
+
"aria-describedby": `${ids}-env-hint`,
|
|
1866
|
+
className: "w-full",
|
|
1867
|
+
"data-testid": "task-queue-env"
|
|
1868
|
+
}),
|
|
1869
|
+
/* @__PURE__ */ jsx(FieldMessage, {
|
|
1870
|
+
id: `${ids}-env-hint`,
|
|
1871
|
+
hint: tr("fluidgrids.moreTools.queues.form.environmentHint", "Runs in another environment never take tasks from this queue.")
|
|
1872
|
+
})
|
|
1873
|
+
]
|
|
1874
|
+
}),
|
|
1875
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1876
|
+
className: "space-y-1.5",
|
|
1877
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
1878
|
+
htmlFor: `${ids}-description`,
|
|
1879
|
+
children: tr("fluidgrids.moreTools.queues.form.description", "Description (optional)")
|
|
1880
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
1881
|
+
id: `${ids}-description`,
|
|
1882
|
+
value: form.description,
|
|
1883
|
+
maxLength: 1e3,
|
|
1884
|
+
onChange: (event) => set({ description: event.target.value }),
|
|
1885
|
+
"data-testid": "task-queue-description"
|
|
1886
|
+
})]
|
|
1887
|
+
}),
|
|
1888
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1889
|
+
className: "grid gap-4 sm:grid-cols-2",
|
|
1890
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1891
|
+
className: "space-y-1.5",
|
|
1892
|
+
children: [
|
|
1893
|
+
/* @__PURE__ */ jsx(Label, {
|
|
1894
|
+
htmlFor: `${ids}-rate`,
|
|
1895
|
+
children: tr("fluidgrids.moreTools.queues.form.rate", "Activity tasks per second (optional)")
|
|
1896
|
+
}),
|
|
1897
|
+
/* @__PURE__ */ jsx(Input, {
|
|
1898
|
+
id: `${ids}-rate`,
|
|
1899
|
+
inputMode: "decimal",
|
|
1900
|
+
value: form.rate,
|
|
1901
|
+
placeholder: tr("fluidgrids.moreTools.queues.rate.none", "No limit"),
|
|
1902
|
+
"aria-invalid": rateBad ? true : void 0,
|
|
1903
|
+
"aria-describedby": `${ids}-rate-hint`,
|
|
1904
|
+
onChange: (event) => set({ rate: event.target.value }),
|
|
1905
|
+
"data-testid": "task-queue-rate"
|
|
1906
|
+
}),
|
|
1907
|
+
/* @__PURE__ */ jsx(FieldMessage, {
|
|
1908
|
+
id: `${ids}-rate-hint`,
|
|
1909
|
+
error: rateBad ? tr("fluidgrids.moreTools.queues.form.rateRange", "Use a number from 0.01 to 10,000.") : null
|
|
1910
|
+
})
|
|
1911
|
+
]
|
|
1912
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1913
|
+
className: "space-y-1.5",
|
|
1914
|
+
children: [
|
|
1915
|
+
/* @__PURE__ */ jsx(Label, {
|
|
1916
|
+
htmlFor: `${ids}-wait`,
|
|
1917
|
+
children: tr("fluidgrids.moreTools.queues.form.wait", "Wait for a worker")
|
|
1918
|
+
}),
|
|
1919
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1920
|
+
className: "flex items-center gap-2",
|
|
1921
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
1922
|
+
id: `${ids}-wait`,
|
|
1923
|
+
inputMode: "decimal",
|
|
1924
|
+
value: form.waitMinutes,
|
|
1925
|
+
placeholder: "10",
|
|
1926
|
+
"aria-invalid": waitBad ? true : void 0,
|
|
1927
|
+
"aria-describedby": `${ids}-wait-hint`,
|
|
1928
|
+
onChange: (event) => set({ waitMinutes: event.target.value }),
|
|
1929
|
+
"data-testid": "task-queue-wait"
|
|
1930
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1931
|
+
className: "shrink-0 text-sm text-text-secondary",
|
|
1932
|
+
children: tr("fluidgrids.moreTools.queues.form.minutes", "minutes")
|
|
1933
|
+
})]
|
|
1934
|
+
}),
|
|
1935
|
+
/* @__PURE__ */ jsx(FieldMessage, {
|
|
1936
|
+
id: `${ids}-wait-hint`,
|
|
1937
|
+
error: waitBad ? tr("fluidgrids.moreTools.queues.form.waitRange", "Enter 0.17 to 10,080 minutes (10 seconds to 7 days).") : null,
|
|
1938
|
+
hint: tr("fluidgrids.moreTools.queues.form.waitHint", "Then a waiting activity fails. Empty: 10 minutes.")
|
|
1939
|
+
})
|
|
1940
|
+
]
|
|
1941
|
+
})]
|
|
1942
|
+
}),
|
|
1943
|
+
/* @__PURE__ */ jsx(FormError, {
|
|
1944
|
+
message: error,
|
|
1945
|
+
testId: "task-queue-error"
|
|
1946
|
+
})
|
|
1947
|
+
]
|
|
1948
|
+
}),
|
|
1949
|
+
/* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
|
|
1950
|
+
variant: "outline",
|
|
1951
|
+
onClick: onClose,
|
|
1952
|
+
disabled: busy,
|
|
1953
|
+
children: tr("fluidgrids.moreTools.queues.form.cancel", "Cancel")
|
|
1954
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
1955
|
+
onClick: () => void save(),
|
|
1956
|
+
disabled: !checked.ok || busy,
|
|
1957
|
+
"data-testid": "task-queue-save",
|
|
1958
|
+
children: queue ? tr("fluidgrids.moreTools.queues.form.save", "Save") : tr("fluidgrids.moreTools.queues.form.create", "Create queue")
|
|
1959
|
+
})] })
|
|
1960
|
+
]
|
|
1961
|
+
})
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
/** "payments@staging" → "Staging only"; a plain name → null. */
|
|
1965
|
+
function entryEnvironment(tr, entry) {
|
|
1966
|
+
const at = entry.indexOf("@");
|
|
1967
|
+
if (at < 0) return null;
|
|
1968
|
+
const env = entry.slice(at + 1).toUpperCase();
|
|
1969
|
+
const known = Object.values(WorkflowEnvironment).find((value) => value === env);
|
|
1970
|
+
return tr("fluidgrids.moreTools.queues.tokenForm.envOnly", "{{environment}} only", { environment: known ? environmentLabel(tr, known) : entry.slice(at + 1) });
|
|
1971
|
+
}
|
|
1972
|
+
/** New worker token: its name, the queues it may serve, its connections. */
|
|
1973
|
+
function WorkerTokenDialogV2({ queues, queuesError, onRetryQueues, preselect, canSetAllowlist, onClose, onCreated }) {
|
|
1974
|
+
const tr = useTr();
|
|
1975
|
+
const ids = useId();
|
|
1976
|
+
const [name, setName] = useState("");
|
|
1977
|
+
const [picked, setPicked] = useState(null);
|
|
1978
|
+
const first = queues && preselect && queues.includes(preselect) ? preselect : queues?.[0];
|
|
1979
|
+
const selected = picked ?? (first ? [first] : []);
|
|
1980
|
+
const [allowlist, setAllowlist] = useState("");
|
|
1981
|
+
const [busy, setBusy] = useState(false);
|
|
1982
|
+
const [error, setError] = useState(null);
|
|
1983
|
+
const valid = name.trim().length > 0 && selected.length > 0;
|
|
1984
|
+
const submit = async () => {
|
|
1985
|
+
if (!valid || busy) return;
|
|
1986
|
+
setBusy(true);
|
|
1987
|
+
setError(null);
|
|
1988
|
+
try {
|
|
1989
|
+
onCreated(await createWorkerToken({
|
|
1990
|
+
name: name.trim(),
|
|
1991
|
+
taskQueues: selected,
|
|
1992
|
+
connectionAllowlist: canSetAllowlist ? parseNameList(allowlist) : []
|
|
1993
|
+
}));
|
|
1994
|
+
} catch (err) {
|
|
1995
|
+
setError(describeOperationError(err));
|
|
1996
|
+
setBusy(false);
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
return /* @__PURE__ */ jsx(ResponsiveDialog, {
|
|
2000
|
+
open: true,
|
|
2001
|
+
onOpenChange: (open) => {
|
|
2002
|
+
if (!open && !busy) onClose();
|
|
2003
|
+
},
|
|
2004
|
+
children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
|
|
2005
|
+
className: "sm:max-w-lg",
|
|
2006
|
+
"data-testid": "worker-token-dialog",
|
|
2007
|
+
children: [
|
|
2008
|
+
/* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: tr("fluidgrids.moreTools.queues.tokenForm.title", "New worker token") }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.moreTools.queues.tokenForm.subtitle", "Workers sign in with it and may serve only the queues it names") })] }),
|
|
2009
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2010
|
+
className: "space-y-4",
|
|
2011
|
+
children: [
|
|
2012
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2013
|
+
className: "space-y-1.5",
|
|
2014
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
2015
|
+
htmlFor: `${ids}-name`,
|
|
2016
|
+
children: tr("fluidgrids.moreTools.queues.tokenForm.name", "Name")
|
|
2017
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
2018
|
+
id: `${ids}-name`,
|
|
2019
|
+
value: name,
|
|
2020
|
+
autoComplete: "off",
|
|
2021
|
+
placeholder: tr("fluidgrids.moreTools.queues.tokenForm.namePlaceholder", "warehouse-worker"),
|
|
2022
|
+
onChange: (event) => setName(event.target.value),
|
|
2023
|
+
"data-testid": "worker-token-name"
|
|
2024
|
+
})]
|
|
2025
|
+
}),
|
|
2026
|
+
/* @__PURE__ */ jsxs("fieldset", {
|
|
2027
|
+
className: "space-y-2",
|
|
2028
|
+
children: [
|
|
2029
|
+
/* @__PURE__ */ jsx("legend", {
|
|
2030
|
+
className: "mb-1.5 text-sm font-medium text-text-primary",
|
|
2031
|
+
children: tr("fluidgrids.moreTools.queues.tokenForm.queues", "Queues it may serve")
|
|
2032
|
+
}),
|
|
2033
|
+
!queues && (queuesError ? /* @__PURE__ */ jsxs("p", {
|
|
2034
|
+
role: "alert",
|
|
2035
|
+
className: "flex flex-wrap items-center gap-2 text-sm text-status-error-text",
|
|
2036
|
+
"data-testid": "worker-token-queues-error",
|
|
2037
|
+
children: [tr("fluidgrids.moreTools.queues.error.queues", "Couldn't load task queues"), /* @__PURE__ */ jsx(Button$1, {
|
|
2038
|
+
size: "sm",
|
|
2039
|
+
variant: "outline",
|
|
2040
|
+
onClick: onRetryQueues,
|
|
2041
|
+
children: tr("fluidgrids.moreTools.common.tryAgain", "Try again")
|
|
2042
|
+
})]
|
|
2043
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
2044
|
+
role: "status",
|
|
2045
|
+
className: "text-sm text-text-muted",
|
|
2046
|
+
"data-testid": "worker-token-queues-loading",
|
|
2047
|
+
children: tr("fluidgrids.moreTools.common.loading", "Loading…")
|
|
2048
|
+
})),
|
|
2049
|
+
queues?.length === 0 && /* @__PURE__ */ jsx("p", {
|
|
2050
|
+
className: "text-sm text-text-secondary",
|
|
2051
|
+
children: tr("fluidgrids.moreTools.queues.tokenForm.noQueues", "Create a self-hosted queue first.")
|
|
2052
|
+
}),
|
|
2053
|
+
queues?.some((queue) => queue.includes("@")) && /* @__PURE__ */ jsx("p", {
|
|
2054
|
+
className: "text-xs text-text-muted",
|
|
2055
|
+
"data-testid": "worker-token-environment-hint",
|
|
2056
|
+
children: tr("fluidgrids.moreTools.queues.tokenForm.envHint", "A queue for one environment binds the token: its workers only take tasks of runs in that environment.")
|
|
2057
|
+
}),
|
|
2058
|
+
/* @__PURE__ */ jsx("div", {
|
|
2059
|
+
className: "space-y-1",
|
|
2060
|
+
children: queues?.map((queue, index) => {
|
|
2061
|
+
const env = entryEnvironment(tr, queue);
|
|
2062
|
+
const id = `${ids}-queue-${index}`;
|
|
2063
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2064
|
+
className: "flex min-h-10 items-center gap-2.5 rounded-lg px-1",
|
|
2065
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
2066
|
+
id,
|
|
2067
|
+
checked: selected.includes(queue),
|
|
2068
|
+
onCheckedChange: (next) => setPicked(next === true ? [...selected, queue] : selected.filter((item) => item !== queue)),
|
|
2069
|
+
"data-testid": `worker-token-queue-${queue}`
|
|
2070
|
+
}), /* @__PURE__ */ jsxs(Label, {
|
|
2071
|
+
htmlFor: id,
|
|
2072
|
+
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 font-normal",
|
|
2073
|
+
children: [/* @__PURE__ */ jsx("code", {
|
|
2074
|
+
className: "truncate font-mono text-sm text-text-primary",
|
|
2075
|
+
children: queue.split("@")[0]
|
|
2076
|
+
}), env && /* @__PURE__ */ jsxs("span", {
|
|
2077
|
+
className: "shrink-0 text-xs text-text-muted",
|
|
2078
|
+
children: ["· ", env]
|
|
2079
|
+
})]
|
|
2080
|
+
})]
|
|
2081
|
+
}, queue);
|
|
2082
|
+
})
|
|
2083
|
+
})
|
|
2084
|
+
]
|
|
2085
|
+
}),
|
|
2086
|
+
canSetAllowlist && /* @__PURE__ */ jsx(AllowlistEditor, {
|
|
2087
|
+
value: allowlist,
|
|
2088
|
+
onChange: setAllowlist
|
|
2089
|
+
}),
|
|
2090
|
+
/* @__PURE__ */ jsx(FormError, {
|
|
2091
|
+
message: error,
|
|
2092
|
+
testId: "worker-token-error"
|
|
2093
|
+
})
|
|
2094
|
+
]
|
|
2095
|
+
}),
|
|
2096
|
+
/* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
|
|
2097
|
+
variant: "outline",
|
|
2098
|
+
onClick: onClose,
|
|
2099
|
+
disabled: busy,
|
|
2100
|
+
children: tr("fluidgrids.moreTools.queues.form.cancel", "Cancel")
|
|
2101
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
2102
|
+
onClick: () => void submit(),
|
|
2103
|
+
disabled: !valid || busy,
|
|
2104
|
+
"data-testid": "worker-token-submit",
|
|
2105
|
+
children: tr("fluidgrids.moreTools.queues.tokenForm.create", "Create token")
|
|
2106
|
+
})] })
|
|
2107
|
+
]
|
|
2108
|
+
})
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
/** A new or rotated token, shown once, with the worker start command. */
|
|
2112
|
+
function TokenSecretDialogV2({ created, onClose }) {
|
|
2113
|
+
const tr = useTr();
|
|
2114
|
+
return /* @__PURE__ */ jsx(SecretOnceDialog, {
|
|
2115
|
+
open: true,
|
|
2116
|
+
onClose,
|
|
2117
|
+
title: tr("fluidgrids.moreTools.queues.secret.title", "Copy the worker token"),
|
|
2118
|
+
description: tr("fluidgrids.moreTools.queues.secret.subtitle", "It is shown only once"),
|
|
2119
|
+
secret: created.token,
|
|
2120
|
+
secretWhat: tr("fluidgrids.moreTools.queues.secret.what", "worker token"),
|
|
2121
|
+
warning: tr("fluidgrids.moreTools.queues.secret.warning", "Give it to the worker as FLUIDGRIDS_WORKER_TOKEN. Never put it in source code."),
|
|
2122
|
+
closeCheck: {
|
|
2123
|
+
title: tr("fluidgrids.moreTools.queues.secret.closeTitle", "Close without copying the token?"),
|
|
2124
|
+
body: tr("fluidgrids.moreTools.queues.secret.closeBody", "The token is shown only once. If you close now, you will need to get a new one.")
|
|
2125
|
+
},
|
|
2126
|
+
testId: "worker-token-secret",
|
|
2127
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2128
|
+
className: "space-y-1.5",
|
|
2129
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
2130
|
+
className: "text-sm font-medium text-text-primary",
|
|
2131
|
+
children: tr("fluidgrids.moreTools.queues.secret.start", "Start a worker")
|
|
2132
|
+
}), /* @__PURE__ */ jsx(CodeLine, {
|
|
2133
|
+
value: workerRunCommand(created.workerToken.taskQueues, created.bridgeUrl),
|
|
2134
|
+
what: tr("fluidgrids.moreTools.queues.startCommandWhat", "start command"),
|
|
2135
|
+
testId: "worker-run-command"
|
|
2136
|
+
})]
|
|
2137
|
+
})
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2140
|
+
/** The connections a token's activities may use. */
|
|
2141
|
+
function ConnectionsDialogV2({ token, onClose, onSaved }) {
|
|
2142
|
+
const tr = useTr();
|
|
2143
|
+
const [value, setValue] = useState(() => token.connectionAllowlist.join("\n"));
|
|
2144
|
+
const [busy, setBusy] = useState(false);
|
|
2145
|
+
const [error, setError] = useState(null);
|
|
2146
|
+
const save = async () => {
|
|
2147
|
+
if (busy) return;
|
|
2148
|
+
setBusy(true);
|
|
2149
|
+
setError(null);
|
|
2150
|
+
try {
|
|
2151
|
+
await setWorkerTokenConnectionAllowlist(token.id, parseNameList(value));
|
|
2152
|
+
onSaved();
|
|
2153
|
+
} catch (err) {
|
|
2154
|
+
setError(describeOperationError(err));
|
|
2155
|
+
setBusy(false);
|
|
2156
|
+
}
|
|
2157
|
+
};
|
|
2158
|
+
return /* @__PURE__ */ jsx(ResponsiveDialog, {
|
|
2159
|
+
open: true,
|
|
2160
|
+
onOpenChange: (open) => {
|
|
2161
|
+
if (!open && !busy) onClose();
|
|
2162
|
+
},
|
|
2163
|
+
children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
|
|
2164
|
+
className: "sm:max-w-lg",
|
|
2165
|
+
"data-testid": "worker-allowlist-dialog",
|
|
2166
|
+
children: [
|
|
2167
|
+
/* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: tr("fluidgrids.moreTools.queues.connections.title", "Connections for {{name}}", { name: token.name }) }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.moreTools.queues.connections.subtitle", "Workspace admins only. Every release of a credential is audited.") })] }),
|
|
2168
|
+
/* @__PURE__ */ jsx(AllowlistEditor, {
|
|
2169
|
+
value,
|
|
2170
|
+
onChange: setValue
|
|
2171
|
+
}),
|
|
2172
|
+
/* @__PURE__ */ jsx(FormError, {
|
|
2173
|
+
message: error,
|
|
2174
|
+
testId: "worker-allowlist-error"
|
|
2175
|
+
}),
|
|
2176
|
+
/* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
|
|
2177
|
+
variant: "outline",
|
|
2178
|
+
onClick: onClose,
|
|
2179
|
+
disabled: busy,
|
|
2180
|
+
children: tr("fluidgrids.moreTools.queues.form.cancel", "Cancel")
|
|
2181
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
2182
|
+
onClick: () => void save(),
|
|
2183
|
+
disabled: busy,
|
|
2184
|
+
"data-testid": "worker-allowlist-save",
|
|
2185
|
+
children: tr("fluidgrids.moreTools.queues.form.save", "Save")
|
|
2186
|
+
})] })
|
|
2187
|
+
]
|
|
2188
|
+
})
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
// src/modules/task-queues/components/TaskQueueDialogsHost.tsx
|
|
2193
|
+
function rotateBody(tr, sessions) {
|
|
2194
|
+
if (!sessions) return tr("fluidgrids.moreTools.queues.rotate.bodyIdle", "The old token stops working right away. No worker is using it now.");
|
|
2195
|
+
if (sessions === 1) return tr("fluidgrids.moreTools.queues.rotate.bodyOne", "The old token stops working right away. The worker using it disconnects until it restarts with the new token.");
|
|
2196
|
+
return tr("fluidgrids.moreTools.queues.rotate.body", "The old token stops working right away. {{count}} workers using it disconnect until they restart with the new token.", { count: formatCount(sessions) });
|
|
2197
|
+
}
|
|
2198
|
+
function deleteTokenBody(tr, sessions) {
|
|
2199
|
+
if (!sessions) return tr("fluidgrids.moreTools.queues.deleteToken.bodyIdle", "Workers using it disconnect and can't sign in again. No worker is using it now.");
|
|
2200
|
+
if (sessions === 1) return tr("fluidgrids.moreTools.queues.deleteToken.bodyOne", "Workers using it disconnect and can't sign in again. 1 worker uses it now.");
|
|
2201
|
+
return tr("fluidgrids.moreTools.queues.deleteToken.body", "Workers using it disconnect and can't sign in again. {{count}} workers use it now.", { count: formatCount(sessions) });
|
|
2202
|
+
}
|
|
2203
|
+
function DeleteQueueConfirm({ dialogs, queueParam, refetchQueues }) {
|
|
2204
|
+
const tr = useTr();
|
|
2205
|
+
const [, setSearchParams] = useSearchParams();
|
|
2206
|
+
const { deleting, setDeleting, queueBusy, setQueueBusy } = dialogs;
|
|
2207
|
+
const removeQueue = async () => {
|
|
2208
|
+
const queue = deleting;
|
|
2209
|
+
if (!queue?.id || queueBusy) return;
|
|
2210
|
+
setQueueBusy(true);
|
|
2211
|
+
try {
|
|
2212
|
+
await deleteTaskQueue(queue.id);
|
|
2213
|
+
toast.success(tr("fluidgrids.moreTools.queues.delete.done", "{{name}} was deleted", { name: queue.name }));
|
|
2214
|
+
setDeleting(null);
|
|
2215
|
+
if (queueParam !== null && queueParam === queueParamOf(queue)) setSearchParams((previous) => {
|
|
2216
|
+
const next = new URLSearchParams(previous);
|
|
2217
|
+
next.delete("queue");
|
|
2218
|
+
return next;
|
|
2219
|
+
}, { replace: true });
|
|
2220
|
+
refetchQueues();
|
|
2221
|
+
} catch (err) {
|
|
2222
|
+
toast.error(describeOperationError(err));
|
|
2223
|
+
} finally {
|
|
2224
|
+
setQueueBusy(false);
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
return /* @__PURE__ */ jsx(ConfirmActionDialog, {
|
|
2228
|
+
open: deleting !== null,
|
|
2229
|
+
onOpenChange: (open) => {
|
|
2230
|
+
if (!open && !queueBusy) setDeleting(null);
|
|
2231
|
+
},
|
|
2232
|
+
title: tr("fluidgrids.moreTools.queues.delete.title", "Delete {{name}}?", { name: deleting?.name ?? "" }),
|
|
2233
|
+
description: tr("fluidgrids.moreTools.queues.delete.body", "The service refuses while open runs or activities use the queue. Tokens that name it keep their other queues."),
|
|
2234
|
+
confirmLabel: tr("fluidgrids.moreTools.queues.delete.confirm", "Delete queue"),
|
|
2235
|
+
cancelLabel: tr("fluidgrids.moreTools.queues.delete.keep", "Keep it"),
|
|
2236
|
+
destructive: true,
|
|
2237
|
+
busy: queueBusy,
|
|
2238
|
+
onConfirm: () => void removeQueue(),
|
|
2239
|
+
"data-testid": "confirm-delete-queue"
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
function RotateTokenConfirm({ dialogs, refetchTokens }) {
|
|
2243
|
+
const tr = useTr();
|
|
2244
|
+
const { rotating, setRotating, setSecret, tokenBusy, setTokenBusy } = dialogs;
|
|
2245
|
+
const rotate = async () => {
|
|
2246
|
+
const token = rotating;
|
|
2247
|
+
if (!token || tokenBusy) return;
|
|
2248
|
+
setTokenBusy(token.id);
|
|
2249
|
+
try {
|
|
2250
|
+
setSecret(await rotateWorkerToken(token.id));
|
|
2251
|
+
setRotating(null);
|
|
2252
|
+
refetchTokens();
|
|
2253
|
+
} catch (err) {
|
|
2254
|
+
toast.error(describeOperationError(err));
|
|
2255
|
+
} finally {
|
|
2256
|
+
setTokenBusy(null);
|
|
2257
|
+
}
|
|
2258
|
+
};
|
|
2259
|
+
return /* @__PURE__ */ jsx(ConfirmActionDialog, {
|
|
2260
|
+
open: rotating !== null,
|
|
2261
|
+
onOpenChange: (open) => {
|
|
2262
|
+
if (!open && tokenBusy === null) setRotating(null);
|
|
2263
|
+
},
|
|
2264
|
+
title: tr("fluidgrids.moreTools.queues.rotate.title", "Get a new token for {{name}}?", { name: rotating?.name ?? "" }),
|
|
2265
|
+
description: rotateBody(tr, rotating?.activeSessions),
|
|
2266
|
+
confirmLabel: tr("fluidgrids.moreTools.queues.rotate.confirm", "Get a new token"),
|
|
2267
|
+
cancelLabel: tr("fluidgrids.moreTools.queues.rotate.keep", "Keep the current token"),
|
|
2268
|
+
destructive: true,
|
|
2269
|
+
busy: tokenBusy !== null,
|
|
2270
|
+
onConfirm: () => void rotate(),
|
|
2271
|
+
"data-testid": "confirm-rotate-token"
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2274
|
+
function DeleteTokenConfirm({ dialogs, refetchTokens, refetchWorkers }) {
|
|
2275
|
+
const tr = useTr();
|
|
2276
|
+
const { deletingToken, setDeletingToken, tokenBusy, setTokenBusy } = dialogs;
|
|
2277
|
+
const removeToken = async () => {
|
|
2278
|
+
const token = deletingToken;
|
|
2279
|
+
if (!token || tokenBusy) return;
|
|
2280
|
+
setTokenBusy(token.id);
|
|
2281
|
+
try {
|
|
2282
|
+
await deleteWorkerToken(token.id);
|
|
2283
|
+
toast.success(tr("fluidgrids.moreTools.queues.token.deleted", "{{name}} was deleted", { name: token.name }));
|
|
2284
|
+
setDeletingToken(null);
|
|
2285
|
+
refetchTokens();
|
|
2286
|
+
refetchWorkers();
|
|
2287
|
+
} catch (err) {
|
|
2288
|
+
toast.error(describeOperationError(err));
|
|
2289
|
+
} finally {
|
|
2290
|
+
setTokenBusy(null);
|
|
2291
|
+
}
|
|
2292
|
+
};
|
|
2293
|
+
return /* @__PURE__ */ jsx(ConfirmActionDialog, {
|
|
2294
|
+
open: deletingToken !== null,
|
|
2295
|
+
onOpenChange: (open) => {
|
|
2296
|
+
if (!open && tokenBusy === null) setDeletingToken(null);
|
|
2297
|
+
},
|
|
2298
|
+
title: tr("fluidgrids.moreTools.queues.deleteToken.title", "Delete {{name}}?", { name: deletingToken?.name ?? "" }),
|
|
2299
|
+
description: deleteTokenBody(tr, deletingToken?.activeSessions),
|
|
2300
|
+
confirmLabel: tr("fluidgrids.moreTools.queues.deleteToken.confirm", "Delete token"),
|
|
2301
|
+
cancelLabel: tr("fluidgrids.moreTools.queues.deleteToken.keep", "Keep it"),
|
|
2302
|
+
destructive: true,
|
|
2303
|
+
busy: tokenBusy !== null,
|
|
2304
|
+
onConfirm: () => void removeToken(),
|
|
2305
|
+
"data-testid": "confirm-delete-token"
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
function QueueFormHost({ dialogs, refetchQueues }) {
|
|
2309
|
+
const tr = useTr();
|
|
2310
|
+
const { editing, setEditing } = dialogs;
|
|
2311
|
+
if (!editing) return null;
|
|
2312
|
+
return /* @__PURE__ */ jsx(QueueFormDialogV2, {
|
|
2313
|
+
queue: editing.queue,
|
|
2314
|
+
onClose: () => setEditing(null),
|
|
2315
|
+
onSaved: (created) => {
|
|
2316
|
+
setEditing(null);
|
|
2317
|
+
toast.success(created ? tr("fluidgrids.moreTools.queues.form.created", "Queue created") : tr("fluidgrids.moreTools.queues.form.saved", "Queue saved"));
|
|
2318
|
+
refetchQueues();
|
|
2319
|
+
}
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
/** Every dialog of the task queues page, each opened by `dialogs`. */
|
|
2323
|
+
function TaskQueueDialogsHost({ dialogs, lookups, canCreateToken, queueParam, refetchWorkers }) {
|
|
2324
|
+
const { allQueues, selfHostedEntries, refetchQueues, refetchTokens } = lookups;
|
|
2325
|
+
const { issuing, setIssuing, secret, setSecret, allowlist, setAllowlist } = dialogs;
|
|
2326
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2327
|
+
/* @__PURE__ */ jsx(QueueFormHost, {
|
|
2328
|
+
dialogs,
|
|
2329
|
+
refetchQueues
|
|
2330
|
+
}),
|
|
2331
|
+
issuing && /* @__PURE__ */ jsx(WorkerTokenDialogV2, {
|
|
2332
|
+
queues: selfHostedEntries,
|
|
2333
|
+
queuesError: allQueues.error,
|
|
2334
|
+
onRetryQueues: () => void allQueues.refetch(),
|
|
2335
|
+
preselect: issuing.preselect,
|
|
2336
|
+
canSetAllowlist: canCreateToken,
|
|
2337
|
+
onClose: () => setIssuing(null),
|
|
2338
|
+
onCreated: (created) => {
|
|
2339
|
+
setIssuing(null);
|
|
2340
|
+
setSecret(created);
|
|
2341
|
+
refetchTokens();
|
|
2342
|
+
}
|
|
2343
|
+
}),
|
|
2344
|
+
secret && /* @__PURE__ */ jsx(TokenSecretDialogV2, {
|
|
2345
|
+
created: secret,
|
|
2346
|
+
onClose: () => setSecret(null)
|
|
2347
|
+
}),
|
|
2348
|
+
allowlist && /* @__PURE__ */ jsx(ConnectionsDialogV2, {
|
|
2349
|
+
token: allowlist,
|
|
2350
|
+
onClose: () => setAllowlist(null),
|
|
2351
|
+
onSaved: () => {
|
|
2352
|
+
setAllowlist(null);
|
|
2353
|
+
refetchTokens();
|
|
2354
|
+
}
|
|
2355
|
+
}),
|
|
2356
|
+
/* @__PURE__ */ jsx(DeleteQueueConfirm, {
|
|
2357
|
+
dialogs,
|
|
2358
|
+
queueParam,
|
|
2359
|
+
refetchQueues
|
|
2360
|
+
}),
|
|
2361
|
+
/* @__PURE__ */ jsx(RotateTokenConfirm, {
|
|
2362
|
+
dialogs,
|
|
2363
|
+
refetchTokens
|
|
2364
|
+
}),
|
|
2365
|
+
/* @__PURE__ */ jsx(DeleteTokenConfirm, {
|
|
2366
|
+
dialogs,
|
|
2367
|
+
refetchTokens,
|
|
2368
|
+
refetchWorkers
|
|
2369
|
+
})
|
|
2370
|
+
] });
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
// src/modules/task-queues/components/QueueListsV2.tsx
|
|
2374
|
+
const QUEUE_COLUMNS = "sm:grid-cols-[2rem_minmax(0,1fr)_minmax(0,9rem)_minmax(0,11rem)_2rem]";
|
|
2375
|
+
const WORKER_COLUMNS = "sm:grid-cols-[2rem_minmax(0,1fr)_9rem_8rem_6rem]";
|
|
2376
|
+
const TOKEN_COLUMNS = "sm:grid-cols-[2rem_minmax(0,1fr)_8rem_9rem_5.5rem_9.5rem]";
|
|
2377
|
+
/**
|
|
2378
|
+
* A tab's page: Try again when it could not be read, placeholders while the
|
|
2379
|
+
* first page loads (or a page past the end until the address is corrected),
|
|
2380
|
+
* the previous page dimmed while the next loads, and a warning when a
|
|
2381
|
+
* refresh failed.
|
|
2382
|
+
*/
|
|
2383
|
+
function SourceState({ source, errorTitle, onRetry, children }) {
|
|
2384
|
+
const tr = useTr();
|
|
2385
|
+
const { slice, exact, error } = source;
|
|
2386
|
+
if (error && !exact) return /* @__PURE__ */ jsx(LoadErrorPanel, {
|
|
2387
|
+
title: errorTitle,
|
|
2388
|
+
text: tr("fluidgrids.moreTools.queues.error.text", "The worker service did not answer. Workers already running keep working."),
|
|
2389
|
+
error,
|
|
2390
|
+
onRetry
|
|
2391
|
+
});
|
|
2392
|
+
if (!slice || exact && slice.total > 0 && slice.items.length === 0) return /* @__PURE__ */ jsx(ListSkeleton, { rows: 5 });
|
|
2393
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [error !== null && error !== void 0 && /* @__PURE__ */ jsx(ToneAlert, {
|
|
2394
|
+
tone: "warning",
|
|
2395
|
+
title: tr("fluidgrids.moreTools.queues.error.stale", "Couldn't refresh this list. What you see may be out of date."),
|
|
2396
|
+
actions: /* @__PURE__ */ jsx(Button$1, {
|
|
2397
|
+
size: "sm",
|
|
2398
|
+
variant: "outline",
|
|
2399
|
+
onClick: onRetry,
|
|
2400
|
+
children: tr("fluidgrids.moreTools.common.tryAgain", "Try again")
|
|
2401
|
+
}),
|
|
2402
|
+
testId: "queues-stale"
|
|
2403
|
+
}), /* @__PURE__ */ jsx(PagedBody, {
|
|
2404
|
+
pageLoading: !exact,
|
|
2405
|
+
page: slice.page,
|
|
2406
|
+
busy: !exact,
|
|
2407
|
+
children: children(slice)
|
|
2408
|
+
})] });
|
|
2409
|
+
}
|
|
2410
|
+
function QueuesTab({ source, availability, queueLink, actions, onPage, onRetry }) {
|
|
2411
|
+
const tr = useTr();
|
|
2412
|
+
const byName = new Map(availability?.map((entry) => [entry.name, entry]));
|
|
2413
|
+
const noSelfHosted = source.total !== null && source.total <= 1;
|
|
2414
|
+
return /* @__PURE__ */ jsx(SourceState, {
|
|
2415
|
+
source,
|
|
2416
|
+
errorTitle: tr("fluidgrids.moreTools.queues.error.queues", "Couldn't load task queues"),
|
|
2417
|
+
onRetry,
|
|
2418
|
+
children: (slice) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2419
|
+
/* @__PURE__ */ jsx(CompactList, {
|
|
2420
|
+
label: tr("fluidgrids.moreTools.queues.tabs.queues", "Queues"),
|
|
2421
|
+
columns: QUEUE_COLUMNS,
|
|
2422
|
+
headings: [
|
|
2423
|
+
"",
|
|
2424
|
+
tr("fluidgrids.moreTools.queues.columns.queue", "Queue"),
|
|
2425
|
+
tr("fluidgrids.moreTools.queues.columns.kind", "Kind"),
|
|
2426
|
+
tr("fluidgrids.moreTools.queues.columns.workers", "Workers"),
|
|
2427
|
+
""
|
|
2428
|
+
],
|
|
2429
|
+
testId: "queue-list",
|
|
2430
|
+
children: slice.items.map((queue) => {
|
|
2431
|
+
const entry = byName.get(queue.name);
|
|
2432
|
+
return /* @__PURE__ */ jsx(QueueRow, {
|
|
2433
|
+
queue,
|
|
2434
|
+
link: queueLink(queue),
|
|
2435
|
+
availability: entry,
|
|
2436
|
+
allEnvironments: (entry?.environments.length ?? 0) > 0,
|
|
2437
|
+
actions
|
|
2438
|
+
}, `${queue.name}:${queue.environment ?? ""}`);
|
|
2439
|
+
})
|
|
2440
|
+
}),
|
|
2441
|
+
/* @__PURE__ */ jsx(ResultsPager, {
|
|
2442
|
+
page: slice.page,
|
|
2443
|
+
total: slice.total,
|
|
2444
|
+
onPage
|
|
2445
|
+
}),
|
|
2446
|
+
noSelfHosted && /* @__PURE__ */ jsx("div", {
|
|
2447
|
+
className: "mt-4",
|
|
2448
|
+
"data-testid": "queues-empty",
|
|
2449
|
+
children: /* @__PURE__ */ jsx(EmptyPanel, {
|
|
2450
|
+
illustration: "tasks",
|
|
2451
|
+
size: "panel",
|
|
2452
|
+
icon: /* @__PURE__ */ jsx(ListOrdered, {
|
|
2453
|
+
className: "size-5 text-text-secondary",
|
|
2454
|
+
"aria-hidden": "true"
|
|
2455
|
+
}),
|
|
2456
|
+
title: tr("fluidgrids.moreTools.queues.empty.title", "No self-hosted queues yet"),
|
|
2457
|
+
text: tr("fluidgrids.moreTools.queues.empty.text", "Create a queue, start a worker on your machine with a worker token, and code workflows can run their activities there."),
|
|
2458
|
+
children: actions.canCreate && /* @__PURE__ */ jsxs(Button$1, {
|
|
2459
|
+
onClick: actions.onNewQueue,
|
|
2460
|
+
"data-testid": "queues-empty-new",
|
|
2461
|
+
children: [/* @__PURE__ */ jsx(Plus, {
|
|
2462
|
+
className: "size-4",
|
|
2463
|
+
"aria-hidden": "true"
|
|
2464
|
+
}), tr("fluidgrids.moreTools.queues.newQueue", "New queue")]
|
|
2465
|
+
})
|
|
2466
|
+
})
|
|
2467
|
+
})
|
|
2468
|
+
] })
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
function QueueRow({ queue, link, availability, allEnvironments, actions }) {
|
|
2472
|
+
const tr = useTr();
|
|
2473
|
+
const navigate = useNavigate();
|
|
2474
|
+
const managed = queue.kind === "MANAGED";
|
|
2475
|
+
const environment = environmentLabel(tr, queue.environment);
|
|
2476
|
+
const waitingWithoutWorkers = !managed && availability?.availability === "UNAVAILABLE";
|
|
2477
|
+
const items = [];
|
|
2478
|
+
if (!managed && queue.id) {
|
|
2479
|
+
items.push({
|
|
2480
|
+
id: "open",
|
|
2481
|
+
label: tr("fluidgrids.moreTools.queues.menu.open", "Open"),
|
|
2482
|
+
icon: /* @__PURE__ */ jsx(ListOrdered, {
|
|
2483
|
+
className: "size-4",
|
|
2484
|
+
"aria-hidden": "true"
|
|
2485
|
+
}),
|
|
2486
|
+
onSelect: () => void navigate(link)
|
|
2487
|
+
});
|
|
2488
|
+
if (actions.canUpdate) items.push({
|
|
2489
|
+
id: "edit",
|
|
2490
|
+
label: tr("fluidgrids.moreTools.queues.menu.edit", "Edit"),
|
|
2491
|
+
icon: /* @__PURE__ */ jsx(Pencil, {
|
|
2492
|
+
className: "size-4",
|
|
2493
|
+
"aria-hidden": "true"
|
|
2494
|
+
}),
|
|
2495
|
+
onSelect: () => actions.onEdit(queue)
|
|
2496
|
+
});
|
|
2497
|
+
if (actions.canCreateToken) items.push({
|
|
2498
|
+
id: "new-token",
|
|
2499
|
+
label: tr("fluidgrids.moreTools.queues.menu.newToken", "New worker token for it"),
|
|
2500
|
+
icon: /* @__PURE__ */ jsx(KeyRound, {
|
|
2501
|
+
className: "size-4",
|
|
2502
|
+
"aria-hidden": "true"
|
|
2503
|
+
}),
|
|
2504
|
+
onSelect: () => actions.onNewToken(queue)
|
|
2505
|
+
});
|
|
2506
|
+
if (actions.canDelete) items.push({
|
|
2507
|
+
id: "delete",
|
|
2508
|
+
label: tr("fluidgrids.moreTools.queues.menu.delete", "Delete…"),
|
|
2509
|
+
icon: /* @__PURE__ */ jsx(Trash2, {
|
|
2510
|
+
className: "size-4",
|
|
2511
|
+
"aria-hidden": "true"
|
|
2512
|
+
}),
|
|
2513
|
+
onSelect: () => actions.onDelete(queue),
|
|
2514
|
+
danger: true,
|
|
2515
|
+
separatorBefore: true
|
|
2516
|
+
});
|
|
2517
|
+
}
|
|
2518
|
+
return /* @__PURE__ */ jsxs(CompactRow, {
|
|
2519
|
+
columns: QUEUE_COLUMNS,
|
|
2520
|
+
attention: waitingWithoutWorkers ? "danger" : void 0,
|
|
2521
|
+
testId: `task-queue-${queue.name}`,
|
|
2522
|
+
children: [
|
|
2523
|
+
/* @__PURE__ */ jsx(RowIcon, { children: /* @__PURE__ */ jsx(ListOrdered, {
|
|
2524
|
+
className: "size-4",
|
|
2525
|
+
"aria-hidden": "true"
|
|
2526
|
+
}) }),
|
|
2527
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2528
|
+
className: "min-w-0",
|
|
2529
|
+
children: [
|
|
2530
|
+
/* @__PURE__ */ jsx(Link, {
|
|
2531
|
+
to: link,
|
|
2532
|
+
className: "block truncate font-mono text-sm font-medium text-text-primary hover:underline",
|
|
2533
|
+
"data-testid": "queue-row-name",
|
|
2534
|
+
children: queue.name
|
|
2535
|
+
}),
|
|
2536
|
+
/* @__PURE__ */ jsxs("p", {
|
|
2537
|
+
className: "flex min-w-0 gap-1.5 text-xs text-text-muted",
|
|
2538
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2539
|
+
className: "truncate",
|
|
2540
|
+
children: queue.description || tr("fluidgrids.moreTools.queues.row.noDescription", "No description")
|
|
2541
|
+
}), queue.maxTasksPerSecond ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
2542
|
+
"aria-hidden": "true",
|
|
2543
|
+
children: "·"
|
|
2544
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2545
|
+
className: "shrink-0",
|
|
2546
|
+
children: rateLimitText(tr, queue)
|
|
2547
|
+
})] }) : null]
|
|
2548
|
+
}),
|
|
2549
|
+
/* @__PURE__ */ jsxs(RowSummary, { children: [
|
|
2550
|
+
/* @__PURE__ */ jsx("span", { children: managed ? tr("fluidgrids.moreTools.queues.kind.managed", "Managed") : tr("fluidgrids.moreTools.queues.kind.selfHosted", "Self-hosted") }),
|
|
2551
|
+
/* @__PURE__ */ jsx("span", {
|
|
2552
|
+
"aria-hidden": "true",
|
|
2553
|
+
children: "·"
|
|
2554
|
+
}),
|
|
2555
|
+
/* @__PURE__ */ jsx("span", { children: environment })
|
|
2556
|
+
] }),
|
|
2557
|
+
/* @__PURE__ */ jsx("div", {
|
|
2558
|
+
className: "mt-1 sm:hidden",
|
|
2559
|
+
children: /* @__PURE__ */ jsx(QueueWorkers, {
|
|
2560
|
+
queue,
|
|
2561
|
+
availability,
|
|
2562
|
+
allEnvironments
|
|
2563
|
+
})
|
|
2564
|
+
})
|
|
2565
|
+
]
|
|
2566
|
+
}),
|
|
2567
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2568
|
+
className: "min-w-0 max-sm:hidden",
|
|
2569
|
+
children: [/* @__PURE__ */ jsx(QueueKind, { queue }), /* @__PURE__ */ jsx("span", {
|
|
2570
|
+
className: "mt-0.5 block truncate text-xs text-text-muted",
|
|
2571
|
+
children: environment
|
|
2572
|
+
})]
|
|
2573
|
+
}),
|
|
2574
|
+
/* @__PURE__ */ jsx("div", {
|
|
2575
|
+
className: "min-w-0 max-sm:hidden",
|
|
2576
|
+
children: /* @__PURE__ */ jsx(QueueWorkers, {
|
|
2577
|
+
queue,
|
|
2578
|
+
availability,
|
|
2579
|
+
allEnvironments
|
|
2580
|
+
})
|
|
2581
|
+
}),
|
|
2582
|
+
/* @__PURE__ */ jsx("div", {
|
|
2583
|
+
className: "flex justify-end",
|
|
2584
|
+
children: /* @__PURE__ */ jsx(RowMenu, {
|
|
2585
|
+
label: tr("fluidgrids.moreTools.queues.menu.label", "Actions for {{name}}", { name: queue.name }),
|
|
2586
|
+
items,
|
|
2587
|
+
testId: `task-queue-menu-${queue.name}`
|
|
2588
|
+
})
|
|
2589
|
+
})
|
|
2590
|
+
]
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
function WorkersTab({ source, canCreateToken, onNewToken, onPage }) {
|
|
2594
|
+
const tr = useTr();
|
|
2595
|
+
return /* @__PURE__ */ jsx(SourceState, {
|
|
2596
|
+
source,
|
|
2597
|
+
errorTitle: tr("fluidgrids.moreTools.queues.error.workers", "Couldn't load the workers"),
|
|
2598
|
+
onRetry: () => void source.refetch(),
|
|
2599
|
+
children: (slice) => slice.total === 0 ? /* @__PURE__ */ jsx("div", {
|
|
2600
|
+
"data-testid": "workers-empty",
|
|
2601
|
+
children: /* @__PURE__ */ jsx(EmptyPanel, {
|
|
2602
|
+
illustration: "servers",
|
|
2603
|
+
icon: /* @__PURE__ */ jsx(Cpu, {
|
|
2604
|
+
className: "size-5 text-text-secondary",
|
|
2605
|
+
"aria-hidden": "true"
|
|
2606
|
+
}),
|
|
2607
|
+
title: tr("fluidgrids.moreTools.queues.workersEmpty.title", "No worker is connected"),
|
|
2608
|
+
text: tr("fluidgrids.moreTools.queues.workersEmpty.text", "Start one on your machine with a worker token. It shows here once it connects."),
|
|
2609
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2610
|
+
className: "flex w-full max-w-lg flex-col items-center gap-3",
|
|
2611
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2612
|
+
className: "w-full text-start",
|
|
2613
|
+
children: /* @__PURE__ */ jsx(CodeLine, {
|
|
2614
|
+
value: workerRunCommand([]),
|
|
2615
|
+
what: tr("fluidgrids.moreTools.queues.startCommandWhat", "start command")
|
|
2616
|
+
})
|
|
2617
|
+
}), canCreateToken && /* @__PURE__ */ jsxs(Button$1, {
|
|
2618
|
+
variant: "outline",
|
|
2619
|
+
onClick: onNewToken,
|
|
2620
|
+
children: [/* @__PURE__ */ jsx(KeyRound, {
|
|
2621
|
+
className: "size-4",
|
|
2622
|
+
"aria-hidden": "true"
|
|
2623
|
+
}), tr("fluidgrids.moreTools.queues.newToken", "New worker token")]
|
|
2624
|
+
})]
|
|
2625
|
+
})
|
|
2626
|
+
})
|
|
2627
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CompactList, {
|
|
2628
|
+
label: tr("fluidgrids.moreTools.queues.tabs.workers", "Workers"),
|
|
2629
|
+
columns: WORKER_COLUMNS,
|
|
2630
|
+
headings: [
|
|
2631
|
+
"",
|
|
2632
|
+
tr("fluidgrids.moreTools.queues.columns.worker", "Worker"),
|
|
2633
|
+
tr("fluidgrids.moreTools.queues.columns.status", "Status"),
|
|
2634
|
+
tr("fluidgrids.moreTools.queues.columns.slots", "Slots in use"),
|
|
2635
|
+
tr("fluidgrids.moreTools.queues.columns.lastPoll", "Last poll")
|
|
2636
|
+
],
|
|
2637
|
+
testId: "worker-list",
|
|
2638
|
+
children: slice.items.map((worker) => /* @__PURE__ */ jsx(WorkerRow, { worker }, worker.id))
|
|
2639
|
+
}), /* @__PURE__ */ jsx(ResultsPager, {
|
|
2640
|
+
page: slice.page,
|
|
2641
|
+
total: slice.total,
|
|
2642
|
+
onPage
|
|
2643
|
+
})] })
|
|
2644
|
+
});
|
|
2645
|
+
}
|
|
2646
|
+
/** "3 of 8 slots in use". */
|
|
2647
|
+
function slotsText(tr, worker) {
|
|
2648
|
+
const { used, total } = workerSlots(worker);
|
|
2649
|
+
return tr("fluidgrids.moreTools.queues.worker.slots", "{{used}} of {{total}} slots in use", {
|
|
2650
|
+
used: formatCount(used),
|
|
2651
|
+
total: formatCount(total)
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2654
|
+
function WorkerRow({ worker }) {
|
|
2655
|
+
const tr = useTr();
|
|
2656
|
+
const { used, total } = workerSlots(worker);
|
|
2657
|
+
return /* @__PURE__ */ jsxs(CompactRow, {
|
|
2658
|
+
columns: WORKER_COLUMNS,
|
|
2659
|
+
testId: `worker-${worker.id}`,
|
|
2660
|
+
children: [
|
|
2661
|
+
/* @__PURE__ */ jsx(RowIcon, { children: /* @__PURE__ */ jsx(Cpu, {
|
|
2662
|
+
className: "size-4",
|
|
2663
|
+
"aria-hidden": "true"
|
|
2664
|
+
}) }),
|
|
2665
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2666
|
+
className: "min-w-0",
|
|
2667
|
+
children: [
|
|
2668
|
+
/* @__PURE__ */ jsx("p", {
|
|
2669
|
+
className: "truncate font-mono text-sm font-medium text-text-primary",
|
|
2670
|
+
children: worker.identity
|
|
2671
|
+
}),
|
|
2672
|
+
/* @__PURE__ */ jsx("p", {
|
|
2673
|
+
className: "truncate text-xs text-text-muted",
|
|
2674
|
+
children: [workerSdkText(worker), worker.taskQueues.join(", ")].filter(Boolean).join(" · ")
|
|
2675
|
+
}),
|
|
2676
|
+
/* @__PURE__ */ jsxs(RowSummary, { children: [/* @__PURE__ */ jsx(WorkerStatus, { worker }), /* @__PURE__ */ jsx("span", { children: slotsText(tr, worker) })] })
|
|
2677
|
+
]
|
|
2678
|
+
}),
|
|
2679
|
+
/* @__PURE__ */ jsx("div", {
|
|
2680
|
+
className: "min-w-0 max-sm:hidden",
|
|
2681
|
+
children: /* @__PURE__ */ jsx(WorkerStatus, {
|
|
2682
|
+
worker,
|
|
2683
|
+
withReason: true
|
|
2684
|
+
})
|
|
2685
|
+
}),
|
|
2686
|
+
/* @__PURE__ */ jsx("div", {
|
|
2687
|
+
className: "max-sm:hidden",
|
|
2688
|
+
children: /* @__PURE__ */ jsx(SlotsMeter, {
|
|
2689
|
+
used,
|
|
2690
|
+
total,
|
|
2691
|
+
label: slotsText(tr, worker)
|
|
2692
|
+
})
|
|
2693
|
+
}),
|
|
2694
|
+
/* @__PURE__ */ jsx("div", {
|
|
2695
|
+
className: "text-sm tabular-nums text-text-secondary max-sm:hidden",
|
|
2696
|
+
children: worker.status === "ONLINE" ? tr("fluidgrids.moreTools.queues.worker.pollingNow", "Polling now") : /* @__PURE__ */ jsx("span", {
|
|
2697
|
+
title: formatExactTime(worker.lastHeartbeatAt),
|
|
2698
|
+
children: formatRelativeTime(tr, worker.lastHeartbeatAt)
|
|
2699
|
+
})
|
|
2700
|
+
})
|
|
2701
|
+
]
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
function TokensTab({ source, actions, onPage }) {
|
|
2705
|
+
const tr = useTr();
|
|
2706
|
+
return /* @__PURE__ */ jsx(SourceState, {
|
|
2707
|
+
source,
|
|
2708
|
+
errorTitle: tr("fluidgrids.moreTools.queues.error.tokens", "Couldn't load the worker tokens"),
|
|
2709
|
+
onRetry: () => void source.refetch(),
|
|
2710
|
+
children: (slice) => slice.total === 0 ? /* @__PURE__ */ jsx("div", {
|
|
2711
|
+
"data-testid": "tokens-empty",
|
|
2712
|
+
children: /* @__PURE__ */ jsx(EmptyPanel, {
|
|
2713
|
+
illustration: "security",
|
|
2714
|
+
icon: /* @__PURE__ */ jsx(KeyRound, {
|
|
2715
|
+
className: "size-5 text-text-secondary",
|
|
2716
|
+
"aria-hidden": "true"
|
|
2717
|
+
}),
|
|
2718
|
+
title: tr("fluidgrids.moreTools.queues.tokensEmpty.title", "No worker tokens"),
|
|
2719
|
+
text: tr("fluidgrids.moreTools.queues.tokensEmpty.text", "Workers sign in with a token that names the queues they may serve."),
|
|
2720
|
+
children: actions.canCreateToken && /* @__PURE__ */ jsxs(Button$1, {
|
|
2721
|
+
variant: "outline",
|
|
2722
|
+
onClick: actions.onNewToken,
|
|
2723
|
+
children: [/* @__PURE__ */ jsx(Plus, {
|
|
2724
|
+
className: "size-4",
|
|
2725
|
+
"aria-hidden": "true"
|
|
2726
|
+
}), tr("fluidgrids.moreTools.queues.newToken", "New worker token")]
|
|
2727
|
+
})
|
|
2728
|
+
})
|
|
2729
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CompactList, {
|
|
2730
|
+
label: tr("fluidgrids.moreTools.queues.tabs.tokens", "Worker tokens"),
|
|
2731
|
+
columns: TOKEN_COLUMNS,
|
|
2732
|
+
headings: [
|
|
2733
|
+
"",
|
|
2734
|
+
tr("fluidgrids.moreTools.queues.columns.token", "Token"),
|
|
2735
|
+
tr("fluidgrids.moreTools.queues.columns.connections", "Connections"),
|
|
2736
|
+
tr("fluidgrids.moreTools.queues.columns.inUse", "In use"),
|
|
2737
|
+
tr("fluidgrids.moreTools.queues.columns.created", "Created"),
|
|
2738
|
+
""
|
|
2739
|
+
],
|
|
2740
|
+
testId: "token-list",
|
|
2741
|
+
children: slice.items.map((token) => /* @__PURE__ */ jsx(TokenRow, {
|
|
2742
|
+
token,
|
|
2743
|
+
actions
|
|
2744
|
+
}, token.id))
|
|
2745
|
+
}), /* @__PURE__ */ jsx(ResultsPager, {
|
|
2746
|
+
page: slice.page,
|
|
2747
|
+
total: slice.total,
|
|
2748
|
+
onPage
|
|
2749
|
+
})] })
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
/** "2 connections", "1 connection" or "No connections". */
|
|
2753
|
+
function connectionsText(tr, token) {
|
|
2754
|
+
const count = token.connectionAllowlist.length;
|
|
2755
|
+
if (count === 0) return tr("fluidgrids.moreTools.queues.token.noConnections", "No connections");
|
|
2756
|
+
return count === 1 ? tr("fluidgrids.moreTools.queues.token.oneConnection", "1 connection") : tr("fluidgrids.moreTools.queues.token.connections", "{{count}} connections", { count: formatCount(count) });
|
|
2757
|
+
}
|
|
2758
|
+
/** "2 workers using it", "1 worker using it" or "Not in use". */
|
|
2759
|
+
function inUseText(tr, token) {
|
|
2760
|
+
if (token.activeSessions === 0) return tr("fluidgrids.moreTools.queues.token.notInUse", "Not in use");
|
|
2761
|
+
return token.activeSessions === 1 ? tr("fluidgrids.moreTools.queues.token.oneInUse", "1 worker using it") : tr("fluidgrids.moreTools.queues.token.inUse", "{{count}} workers using it", { count: formatCount(token.activeSessions) });
|
|
2762
|
+
}
|
|
2763
|
+
function TokenRow({ token, actions }) {
|
|
2764
|
+
const tr = useTr();
|
|
2765
|
+
const items = [];
|
|
2766
|
+
if (actions.canEditAllowlist) items.push({
|
|
2767
|
+
id: "connections",
|
|
2768
|
+
label: tr("fluidgrids.moreTools.queues.token.connectionsAction", "Connections"),
|
|
2769
|
+
icon: /* @__PURE__ */ jsx(Plug, {
|
|
2770
|
+
className: "size-4",
|
|
2771
|
+
"aria-hidden": "true"
|
|
2772
|
+
}),
|
|
2773
|
+
onSelect: () => actions.onConnections(token)
|
|
2774
|
+
});
|
|
2775
|
+
if (actions.canRotateToken) items.push({
|
|
2776
|
+
id: "rotate",
|
|
2777
|
+
label: tr("fluidgrids.moreTools.queues.token.rotate", "Get a new token…"),
|
|
2778
|
+
icon: /* @__PURE__ */ jsx(KeyRound, {
|
|
2779
|
+
className: "size-4",
|
|
2780
|
+
"aria-hidden": "true"
|
|
2781
|
+
}),
|
|
2782
|
+
onSelect: () => actions.onRotate(token),
|
|
2783
|
+
disabled: actions.busy
|
|
2784
|
+
});
|
|
2785
|
+
if (actions.canDeleteToken) items.push({
|
|
2786
|
+
id: "delete",
|
|
2787
|
+
label: tr("fluidgrids.moreTools.queues.token.delete", "Delete…"),
|
|
2788
|
+
icon: /* @__PURE__ */ jsx(Trash2, {
|
|
2789
|
+
className: "size-4",
|
|
2790
|
+
"aria-hidden": "true"
|
|
2791
|
+
}),
|
|
2792
|
+
onSelect: () => actions.onDelete(token),
|
|
2793
|
+
danger: true,
|
|
2794
|
+
separatorBefore: items.length > 0,
|
|
2795
|
+
disabled: actions.busy
|
|
2796
|
+
});
|
|
2797
|
+
const inUse = inUseText(tr, token);
|
|
2798
|
+
return /* @__PURE__ */ jsxs(CompactRow, {
|
|
2799
|
+
columns: TOKEN_COLUMNS,
|
|
2800
|
+
testId: `worker-token-${token.id}`,
|
|
2801
|
+
children: [
|
|
2802
|
+
/* @__PURE__ */ jsx(RowIcon, { children: /* @__PURE__ */ jsx(KeyRound, {
|
|
2803
|
+
className: "size-4",
|
|
2804
|
+
"aria-hidden": "true"
|
|
2805
|
+
}) }),
|
|
2806
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2807
|
+
className: "min-w-0",
|
|
2808
|
+
children: [
|
|
2809
|
+
/* @__PURE__ */ jsx("p", {
|
|
2810
|
+
className: "truncate text-sm font-semibold text-text-primary",
|
|
2811
|
+
children: token.name
|
|
2812
|
+
}),
|
|
2813
|
+
/* @__PURE__ */ jsxs("p", {
|
|
2814
|
+
className: "flex min-w-0 gap-1.5 text-xs text-text-muted",
|
|
2815
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2816
|
+
className: "shrink-0",
|
|
2817
|
+
children: tr("fluidgrids.moreTools.queues.token.startsWith", "Starts with {{prefix}}…", { prefix: token.tokenPrefix })
|
|
2818
|
+
}), token.taskQueues.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
2819
|
+
"aria-hidden": "true",
|
|
2820
|
+
children: "·"
|
|
2821
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2822
|
+
className: "truncate font-mono",
|
|
2823
|
+
children: token.taskQueues.join(", ")
|
|
2824
|
+
})] })]
|
|
2825
|
+
}),
|
|
2826
|
+
/* @__PURE__ */ jsxs(RowSummary, { children: [
|
|
2827
|
+
/* @__PURE__ */ jsx("span", { children: inUse }),
|
|
2828
|
+
/* @__PURE__ */ jsx("span", {
|
|
2829
|
+
"aria-hidden": "true",
|
|
2830
|
+
children: "·"
|
|
2831
|
+
}),
|
|
2832
|
+
/* @__PURE__ */ jsx("span", { children: connectionsText(tr, token) })
|
|
2833
|
+
] })
|
|
2834
|
+
]
|
|
2835
|
+
}),
|
|
2836
|
+
/* @__PURE__ */ jsx("div", {
|
|
2837
|
+
className: token.connectionAllowlist.length === 0 ? "truncate text-sm text-text-muted max-sm:hidden" : "truncate text-sm text-text-secondary max-sm:hidden",
|
|
2838
|
+
children: connectionsText(tr, token)
|
|
2839
|
+
}),
|
|
2840
|
+
/* @__PURE__ */ jsx("div", {
|
|
2841
|
+
className: "min-w-0 max-sm:hidden",
|
|
2842
|
+
children: token.activeSessions > 0 ? /* @__PURE__ */ jsx(Status, {
|
|
2843
|
+
tone: "quiet",
|
|
2844
|
+
children: inUse
|
|
2845
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
2846
|
+
className: "text-sm text-text-muted",
|
|
2847
|
+
children: inUse
|
|
2848
|
+
})
|
|
2849
|
+
}),
|
|
2850
|
+
/* @__PURE__ */ jsx("div", {
|
|
2851
|
+
className: "text-sm tabular-nums text-text-secondary max-sm:hidden",
|
|
2852
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2853
|
+
title: formatExactTime(token.createdAt),
|
|
2854
|
+
children: formatRelativeTime(tr, token.createdAt)
|
|
2855
|
+
})
|
|
2856
|
+
}),
|
|
2857
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2858
|
+
className: "flex items-center justify-end gap-2",
|
|
2859
|
+
children: [actions.canEditAllowlist && /* @__PURE__ */ jsx(Button$1, {
|
|
2860
|
+
size: "sm",
|
|
2861
|
+
variant: "outline",
|
|
2862
|
+
className: "max-lg:hidden",
|
|
2863
|
+
onClick: () => actions.onConnections(token),
|
|
2864
|
+
"data-testid": `worker-token-allowlist-${token.id}`,
|
|
2865
|
+
children: tr("fluidgrids.moreTools.queues.token.connectionsAction", "Connections")
|
|
2866
|
+
}), /* @__PURE__ */ jsx(RowMenu, {
|
|
2867
|
+
label: tr("fluidgrids.moreTools.queues.token.menuLabel", "Actions for {{name}}", { name: token.name }),
|
|
2868
|
+
items,
|
|
2869
|
+
testId: `worker-token-menu-${token.id}`
|
|
2870
|
+
})]
|
|
2871
|
+
})
|
|
2872
|
+
]
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
// src/modules/task-queues/components/TaskQueuesFacts.tsx
|
|
2877
|
+
function queuesLabel(tr, total) {
|
|
2878
|
+
if (total === 1) return tr("fluidgrids.moreTools.queues.facts.one", "1 queue");
|
|
2879
|
+
return tr("fluidgrids.moreTools.queues.facts.count", "{{count}} queues", { count: formatCount(total) });
|
|
2880
|
+
}
|
|
2881
|
+
function onlineLabel(tr, online) {
|
|
2882
|
+
if (online === 1) return tr("fluidgrids.moreTools.queues.facts.oneOnline", "1 worker online");
|
|
2883
|
+
return tr("fluidgrids.moreTools.queues.facts.online", "{{count}} workers online", { count: formatCount(online) });
|
|
2884
|
+
}
|
|
2885
|
+
function waitingLabel(tr, waiting) {
|
|
2886
|
+
if (waiting === 1) return tr("fluidgrids.moreTools.queues.facts.oneWaiting", "1 queue waiting with no worker");
|
|
2887
|
+
return tr("fluidgrids.moreTools.queues.facts.waiting", "{{count}} queues waiting with no worker", { count: formatCount(waiting) });
|
|
2888
|
+
}
|
|
2889
|
+
/** The header's fact line: counts, the explainer and the view-only pill. */
|
|
2890
|
+
function TaskQueuesFacts({ tr, total, onlineWorkers, waitingWithoutWorkers, viewOnly }) {
|
|
2891
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2892
|
+
total !== null && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
2893
|
+
className: "tabular-nums",
|
|
2894
|
+
"data-testid": "queues-facts-count",
|
|
2895
|
+
children: queuesLabel(tr, total)
|
|
2896
|
+
}), /* @__PURE__ */ jsx(Dot, {})] }),
|
|
2897
|
+
onlineWorkers !== null && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
2898
|
+
className: "tabular-nums",
|
|
2899
|
+
"data-testid": "queues-facts-online",
|
|
2900
|
+
children: onlineLabel(tr, onlineWorkers)
|
|
2901
|
+
}), /* @__PURE__ */ jsx(Dot, {})] }),
|
|
2902
|
+
waitingWithoutWorkers > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
2903
|
+
className: "font-medium text-status-error-text",
|
|
2904
|
+
"data-testid": "queues-facts-waiting",
|
|
2905
|
+
children: waitingLabel(tr, waitingWithoutWorkers)
|
|
2906
|
+
}), /* @__PURE__ */ jsx(Dot, {})] }),
|
|
2907
|
+
/* @__PURE__ */ jsx(QueuesWhatIs, {}),
|
|
2908
|
+
viewOnly && /* @__PURE__ */ jsx(ViewOnlyPill, {})
|
|
2909
|
+
] });
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
// src/modules/task-queues/components/taskQueuesPageTabs.ts
|
|
2913
|
+
/** A tab's badge: its count, once known. */
|
|
2914
|
+
function badgeOf(source) {
|
|
2915
|
+
return source.total === null ? void 0 : formatCount(source.total);
|
|
2916
|
+
}
|
|
2917
|
+
/** The tabs' labels, in one place. */
|
|
2918
|
+
function tabLabel(tr, id) {
|
|
2919
|
+
if (id === "queues") return tr("fluidgrids.moreTools.queues.tabs.queues", "Queues");
|
|
2920
|
+
if (id === "workers") return tr("fluidgrids.moreTools.queues.tabs.workers", "Workers");
|
|
2921
|
+
return tr("fluidgrids.moreTools.queues.tabs.tokens", "Worker tokens");
|
|
2922
|
+
}
|
|
2923
|
+
function buildPageTabs(tr, tabs, pathname, sources) {
|
|
2924
|
+
return tabs.map((id) => ({
|
|
2925
|
+
id,
|
|
2926
|
+
href: id === "queues" ? pathname : `?tab=${id}`,
|
|
2927
|
+
label: tabLabel(tr, id),
|
|
2928
|
+
badge: badgeOf(sources[id])
|
|
2929
|
+
}));
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
// src/modules/task-queues/components/TaskQueuesListView.tsx
|
|
2933
|
+
function HeaderActions({ tr, perms, onNewToken, onNewQueue }) {
|
|
2934
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [perms.canCreateToken && /* @__PURE__ */ jsxs(Button$1, {
|
|
2935
|
+
variant: "outline",
|
|
2936
|
+
onClick: onNewToken,
|
|
2937
|
+
"data-testid": "worker-token-create",
|
|
2938
|
+
children: [/* @__PURE__ */ jsx(KeyRound, {
|
|
2939
|
+
className: "size-4",
|
|
2940
|
+
"aria-hidden": "true"
|
|
2941
|
+
}), tr("fluidgrids.moreTools.queues.newToken", "New worker token")]
|
|
2942
|
+
}), perms.canCreate && /* @__PURE__ */ jsxs(Button$1, {
|
|
2943
|
+
onClick: onNewQueue,
|
|
2944
|
+
"data-testid": "task-queue-create",
|
|
2945
|
+
children: [/* @__PURE__ */ jsx(Plus, {
|
|
2946
|
+
className: "size-4",
|
|
2947
|
+
"aria-hidden": "true"
|
|
2948
|
+
}), tr("fluidgrids.moreTools.queues.newQueue", "New queue")]
|
|
2949
|
+
})] });
|
|
2950
|
+
}
|
|
2951
|
+
/** The three-tab list view: header, tab bar and the open tab. */
|
|
2952
|
+
function TaskQueuesListView({ lists, perms, pathname, queueLink, queueActions, tokenActions, onNewToken, onNewQueue, onPage, onRetry }) {
|
|
2953
|
+
const tr = useTr();
|
|
2954
|
+
const { tab, tabs, queues, workers, tokens, availability } = lists;
|
|
2955
|
+
const waitingWithoutWorkers = (availability.data ?? []).filter((entry) => entry.availability === "UNAVAILABLE").length;
|
|
2956
|
+
const pageTabs = buildPageTabs(tr, tabs, pathname, {
|
|
2957
|
+
queues,
|
|
2958
|
+
workers,
|
|
2959
|
+
tokens
|
|
2960
|
+
});
|
|
2961
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2962
|
+
/* @__PURE__ */ jsx(MoreToolsHeader, {
|
|
2963
|
+
title: tr("fluidgrids.moreTools.queues.title", "Task queues"),
|
|
2964
|
+
titleTestId: "task-queues-title",
|
|
2965
|
+
facts: /* @__PURE__ */ jsx(TaskQueuesFacts, {
|
|
2966
|
+
tr,
|
|
2967
|
+
total: queues.total,
|
|
2968
|
+
onlineWorkers: workers.online,
|
|
2969
|
+
waitingWithoutWorkers,
|
|
2970
|
+
viewOnly: perms.viewOnly
|
|
2971
|
+
}),
|
|
2972
|
+
actions: perms.canCreateToken || perms.canCreate ? /* @__PURE__ */ jsx(HeaderActions, {
|
|
2973
|
+
tr,
|
|
2974
|
+
perms,
|
|
2975
|
+
onNewToken,
|
|
2976
|
+
onNewQueue
|
|
2977
|
+
}) : void 0
|
|
2978
|
+
}),
|
|
2979
|
+
/* @__PURE__ */ jsx(PageTabs, {
|
|
2980
|
+
tabs: pageTabs,
|
|
2981
|
+
activeId: tab,
|
|
2982
|
+
ariaLabel: tr("fluidgrids.moreTools.queues.tabs.label", "Task queue sections"),
|
|
2983
|
+
className: "mb-4"
|
|
2984
|
+
}),
|
|
2985
|
+
/* @__PURE__ */ jsx(ActiveTab, {
|
|
2986
|
+
tab,
|
|
2987
|
+
lists,
|
|
2988
|
+
canCreateToken: perms.canCreateToken,
|
|
2989
|
+
queueLink,
|
|
2990
|
+
queueActions,
|
|
2991
|
+
tokenActions,
|
|
2992
|
+
onNewToken,
|
|
2993
|
+
onPage,
|
|
2994
|
+
onRetry
|
|
2995
|
+
})
|
|
2996
|
+
] });
|
|
2997
|
+
}
|
|
2998
|
+
function ActiveTab({ tab, lists, canCreateToken, queueLink, queueActions, tokenActions, onNewToken, onPage, onRetry }) {
|
|
2999
|
+
if (tab === "workers") return /* @__PURE__ */ jsx(WorkersTab, {
|
|
3000
|
+
source: lists.workers,
|
|
3001
|
+
canCreateToken,
|
|
3002
|
+
onNewToken,
|
|
3003
|
+
onPage
|
|
3004
|
+
});
|
|
3005
|
+
if (tab === "tokens") return /* @__PURE__ */ jsx(TokensTab, {
|
|
3006
|
+
source: lists.tokens,
|
|
3007
|
+
actions: tokenActions,
|
|
3008
|
+
onPage
|
|
3009
|
+
});
|
|
3010
|
+
return /* @__PURE__ */ jsx(QueuesTab, {
|
|
3011
|
+
source: lists.queues,
|
|
3012
|
+
availability: lists.availability.data,
|
|
3013
|
+
queueLink,
|
|
3014
|
+
actions: queueActions,
|
|
3015
|
+
onPage,
|
|
3016
|
+
onRetry
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
// src/modules/task-queues/pages/TaskQueuesPageV2.tsx
|
|
3021
|
+
/**
|
|
3022
|
+
* Task queues, redesigned (BOFF-15502, Navigation v2 only): tabs with counts
|
|
3023
|
+
* (Queues, Workers, Worker tokens; `?tab=` in the address) and one queue's
|
|
3024
|
+
* page on the same route (`?queue=<id>`), so Back, Forward and shared links
|
|
3025
|
+
* work. Each tab pages with the Templates pager (`?page=`).
|
|
3026
|
+
*
|
|
3027
|
+
* Deleting a queue, getting a new token and deleting a token ask first; a new
|
|
3028
|
+
* token is shown once, and closing it before it was copied asks first too.
|
|
3029
|
+
*/
|
|
3030
|
+
/** `params` with `name` set to `value` (or removed), as "?…" or "". */
|
|
3031
|
+
function searchWith(params, name, value) {
|
|
3032
|
+
const next = new URLSearchParams(params);
|
|
3033
|
+
if (value === null) next.delete(name);
|
|
3034
|
+
else next.set(name, value);
|
|
3035
|
+
const text = next.toString();
|
|
3036
|
+
return text ? `?${text}` : "";
|
|
3037
|
+
}
|
|
3038
|
+
function TaskQueuesPageV2() {
|
|
3039
|
+
const { pathname } = useLocation();
|
|
3040
|
+
const { params, page, setPage } = useUrlListState();
|
|
3041
|
+
const perms = useTaskQueuePermissions();
|
|
3042
|
+
const lists = useTaskQueueLists({
|
|
3043
|
+
perms,
|
|
3044
|
+
params,
|
|
3045
|
+
page,
|
|
3046
|
+
setPage
|
|
3047
|
+
});
|
|
3048
|
+
const dialogs = useTaskQueueDialogState();
|
|
3049
|
+
const lookups = useTaskQueueLookups(lists, perms.canReadTokens, dialogs.issuing !== null);
|
|
3050
|
+
const { queueActions, tokenActions } = useTaskQueueActions(perms, dialogs);
|
|
3051
|
+
const { queueParam } = lists;
|
|
3052
|
+
const { allQueues, allTokens } = lookups;
|
|
3053
|
+
const backTo = searchWith(params, "queue", null) || pathname;
|
|
3054
|
+
const queueLink = useCallback((queue) => ({ search: searchWith(params, "queue", queueParamOf(queue)) }), [params]);
|
|
3055
|
+
return /* @__PURE__ */ jsxs(MoreToolsPage, {
|
|
3056
|
+
testId: "task-queues-page",
|
|
3057
|
+
children: [queueParam !== null ? /* @__PURE__ */ jsx(QueueDetailV2, {
|
|
3058
|
+
queue: allQueues.items ? findQueueByParam(allQueues.items, queueParam) : void 0,
|
|
3059
|
+
queues: allQueues,
|
|
3060
|
+
tokens: perms.canReadTokens ? allTokens : null,
|
|
3061
|
+
backTo,
|
|
3062
|
+
actions: queueActions
|
|
3063
|
+
}) : /* @__PURE__ */ jsx(TaskQueuesListView, {
|
|
3064
|
+
lists,
|
|
3065
|
+
perms,
|
|
3066
|
+
pathname,
|
|
3067
|
+
queueLink,
|
|
3068
|
+
queueActions,
|
|
3069
|
+
tokenActions,
|
|
3070
|
+
onNewToken: () => dialogs.setIssuing({}),
|
|
3071
|
+
onNewQueue: () => dialogs.setEditing({ queue: null }),
|
|
3072
|
+
onPage: setPage,
|
|
3073
|
+
onRetry: lookups.refetchQueues
|
|
3074
|
+
}), /* @__PURE__ */ jsx(TaskQueueDialogsHost, {
|
|
3075
|
+
dialogs,
|
|
3076
|
+
lookups,
|
|
3077
|
+
canCreateToken: perms.canCreateToken,
|
|
3078
|
+
queueParam,
|
|
3079
|
+
refetchWorkers: lists.workers.refetch
|
|
3080
|
+
})]
|
|
3081
|
+
});
|
|
3082
|
+
}
|
|
3083
|
+
|
|
3084
|
+
// src/modules/task-queues/pages/TaskQueuesPage.tsx
|
|
3085
|
+
/**
|
|
3086
|
+
* Task queues (BOFF-9906, spec code-first 04 §8, 08 §3 and 11 §2.31): the
|
|
3087
|
+
* workspace's queues (managed first, then the self-hosted ones it created)
|
|
3088
|
+
* with each queue's backlog, the self-hosted workers connected now, and the
|
|
3089
|
+
* worker tokens they authenticate with. The whole page needs
|
|
3090
|
+
* fluidgrids.self-hosted-workers; with it off the page says so and sends
|
|
3091
|
+
* nothing.
|
|
3092
|
+
*
|
|
3093
|
+
* Under FluidGrids' Navigation v2 the page is the redesign (BOFF-15502,
|
|
3094
|
+
* `TaskQueuesPageV2`); every other app keeps the classic page below.
|
|
3095
|
+
*/
|
|
3096
|
+
var TaskQueuesPage_exports = /* @__PURE__ */ __exportAll({
|
|
3097
|
+
TaskQueueStatsCard: () => TaskQueueStatsCard,
|
|
3098
|
+
TaskQueuesContent: () => TaskQueuesContent,
|
|
3099
|
+
TaskQueuesPage: () => TaskQueuesPage,
|
|
3100
|
+
WORKERS_POLL_MS: () => WORKERS_POLL_MS
|
|
3101
|
+
});
|
|
3102
|
+
/** Workers heartbeat every 30 s; the list is re-read this often. */
|
|
3103
|
+
const WORKERS_POLL_MS = 15e3;
|
|
3104
|
+
function TaskQueuesPage() {
|
|
3105
|
+
const tr = useTr();
|
|
3106
|
+
const v2 = useNavigationV2();
|
|
3107
|
+
const enabled = useSelfHostedWorkersEnabled();
|
|
3108
|
+
if (v2) return enabled ? /* @__PURE__ */ jsx(TaskQueuesPageV2, {}) : /* @__PURE__ */ jsx(TaskQueuesOffV2, {});
|
|
3109
|
+
if (!enabled) return /* @__PURE__ */ jsxs("div", {
|
|
3110
|
+
className: "p-4 sm:p-6",
|
|
3111
|
+
"data-testid": "task-queues-disabled",
|
|
3112
|
+
children: [/* @__PURE__ */ jsx("h1", {
|
|
3113
|
+
className: "text-2xl font-bold text-text-primary",
|
|
3114
|
+
children: tr("fluidgrids.taskQueues.title", "Task queues")
|
|
3115
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
3116
|
+
className: "mt-2 text-text-secondary",
|
|
3117
|
+
children: tr("fluidgrids.taskQueues.disabled", "Self-hosted workers are not enabled for this workspace.")
|
|
3118
|
+
})]
|
|
3119
|
+
});
|
|
3120
|
+
return /* @__PURE__ */ jsx(TaskQueuesContent, {});
|
|
3121
|
+
}
|
|
3122
|
+
/**
|
|
3123
|
+
* Navigation v2 with self-hosted workers off for the workspace: what the page
|
|
3124
|
+
* is for and where an admin turns it on. Nothing is read.
|
|
3125
|
+
*/
|
|
3126
|
+
function TaskQueuesOffV2() {
|
|
3127
|
+
const tr = useTr();
|
|
3128
|
+
return /* @__PURE__ */ jsxs(MoreToolsPage, {
|
|
3129
|
+
testId: "task-queues-disabled",
|
|
3130
|
+
children: [/* @__PURE__ */ jsx(MoreToolsHeader, { title: tr("fluidgrids.moreTools.queues.title", "Task queues") }), /* @__PURE__ */ jsx(EmptyPanel, {
|
|
3131
|
+
illustration: "servers",
|
|
3132
|
+
icon: /* @__PURE__ */ jsx(ListOrdered, {
|
|
3133
|
+
className: "size-5 text-text-secondary",
|
|
3134
|
+
"aria-hidden": "true"
|
|
3135
|
+
}),
|
|
3136
|
+
title: tr("fluidgrids.moreTools.queues.off.title", "Self-hosted workers are off for this workspace"),
|
|
3137
|
+
text: tr("fluidgrids.moreTools.queues.off.text", "Task queues let code workflows and activities run on workers you host. A workspace admin can turn them on in Feature Previews.")
|
|
3138
|
+
})]
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3141
|
+
/** The page body; exported for hosts that gate the flag themselves, and for tests. */
|
|
3142
|
+
function TaskQueuesContent() {
|
|
3143
|
+
const tr = useTr();
|
|
3144
|
+
const { allowed: canCreate } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.TASK_QUEUE_CREATE);
|
|
3145
|
+
const { allowed: canUpdate } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.TASK_QUEUE_UPDATE);
|
|
3146
|
+
const { allowed: canDelete } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.TASK_QUEUE_DELETE);
|
|
3147
|
+
const { allowed: canReadTokens } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.RUNNER_READ);
|
|
3148
|
+
const { allowed: canCreateToken } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.RUNNER_CREATE);
|
|
3149
|
+
const { allowed: canRotateToken } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.RUNNER_UPDATE);
|
|
3150
|
+
const { allowed: canDeleteToken } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.RUNNER_DELETE);
|
|
3151
|
+
const canEditAllowlist = canRotateToken && canCreateToken;
|
|
3152
|
+
const queues = useResource("task-queues", true, fetchTaskQueues);
|
|
3153
|
+
const workers = useResource("workflow-workers", true, () => fetchWorkflowWorkers({ includeEnded: false }), {
|
|
3154
|
+
live: true,
|
|
3155
|
+
intervalMs: WORKERS_POLL_MS
|
|
3156
|
+
});
|
|
3157
|
+
const tokens = useResource("worker-tokens", canReadTokens, fetchWorkerTokens);
|
|
3158
|
+
const [selected, setSelected] = useState(null);
|
|
3159
|
+
const [editing, setEditing] = useState(null);
|
|
3160
|
+
const [deleting, setDeleting] = useState(null);
|
|
3161
|
+
const [issuing, setIssuing] = useState(false);
|
|
3162
|
+
const [secret, setSecret] = useState(null);
|
|
3163
|
+
const [allowlist, setAllowlist] = useState(null);
|
|
3164
|
+
const selfHosted = [...new Set((queues.data ?? []).filter((queue) => queue.kind === "SELF_HOSTED").map(workerQueueOf))];
|
|
3165
|
+
const removeQueue = async () => {
|
|
3166
|
+
if (!deleting?.id) return;
|
|
3167
|
+
try {
|
|
3168
|
+
await deleteTaskQueue(deleting.id);
|
|
3169
|
+
toast.success(tr("fluidgrids.taskQueues.deleted", "Task queue deleted"));
|
|
3170
|
+
if (selected?.id === deleting.id) setSelected(null);
|
|
3171
|
+
await queues.refetch();
|
|
3172
|
+
} catch (err) {
|
|
3173
|
+
toast.error(describeOperationError(err));
|
|
3174
|
+
} finally {
|
|
3175
|
+
setDeleting(null);
|
|
3176
|
+
}
|
|
3177
|
+
};
|
|
3178
|
+
const [tokenBusy, setTokenBusy] = useState(null);
|
|
3179
|
+
const rotate = async (token) => {
|
|
3180
|
+
if (tokenBusy) return;
|
|
3181
|
+
setTokenBusy(token.id);
|
|
3182
|
+
try {
|
|
3183
|
+
setSecret(await rotateWorkerToken(token.id));
|
|
3184
|
+
await tokens.refetch();
|
|
3185
|
+
} catch (err) {
|
|
3186
|
+
toast.error(describeOperationError(err));
|
|
3187
|
+
} finally {
|
|
3188
|
+
setTokenBusy(null);
|
|
3189
|
+
}
|
|
3190
|
+
};
|
|
3191
|
+
const removeToken = async (token) => {
|
|
3192
|
+
if (tokenBusy) return;
|
|
3193
|
+
setTokenBusy(token.id);
|
|
3194
|
+
try {
|
|
3195
|
+
await deleteWorkerToken(token.id);
|
|
3196
|
+
await Promise.all([tokens.refetch(), workers.refetch()]);
|
|
3197
|
+
} catch (err) {
|
|
3198
|
+
toast.error(describeOperationError(err));
|
|
3199
|
+
} finally {
|
|
3200
|
+
setTokenBusy(null);
|
|
3201
|
+
}
|
|
3202
|
+
};
|
|
3203
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3204
|
+
className: "min-h-screen space-y-6 bg-surface-canvas p-4 sm:p-6",
|
|
3205
|
+
"data-testid": "task-queues-page",
|
|
3206
|
+
children: [
|
|
3207
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3208
|
+
className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",
|
|
3209
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h1", {
|
|
3210
|
+
className: "text-2xl font-bold text-text-primary sm:text-3xl",
|
|
3211
|
+
children: tr("fluidgrids.taskQueues.title", "Task queues")
|
|
3212
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
3213
|
+
className: "mt-1 text-text-secondary",
|
|
3214
|
+
children: tr("fluidgrids.taskQueues.subtitle", "Run durable functions and activities on workers you host.")
|
|
3215
|
+
})] }), canCreate && /* @__PURE__ */ jsxs(Button$1, {
|
|
3216
|
+
onClick: () => setEditing({ queue: null }),
|
|
3217
|
+
"data-testid": "task-queue-create",
|
|
3218
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
3219
|
+
icon: "mdi:plus",
|
|
3220
|
+
className: "mr-1",
|
|
3221
|
+
width: 16
|
|
3222
|
+
}), tr("fluidgrids.taskQueues.create", "New queue")]
|
|
3223
|
+
})]
|
|
3224
|
+
}),
|
|
3225
|
+
/* @__PURE__ */ jsxs("section", {
|
|
3226
|
+
className: "rounded-lg border border-border-default bg-surface",
|
|
3227
|
+
"data-testid": "task-queues-table",
|
|
3228
|
+
children: [/* @__PURE__ */ jsx(FieldError, { message: queues.error }), /* @__PURE__ */ jsxs("table", {
|
|
3229
|
+
className: "w-full text-sm",
|
|
3230
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
3231
|
+
className: "border-b border-border-default text-left text-xs uppercase text-text-secondary",
|
|
3232
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
3233
|
+
/* @__PURE__ */ jsx("th", {
|
|
3234
|
+
className: "px-4 py-2",
|
|
3235
|
+
children: tr("fluidgrids.taskQueues.name", "Name")
|
|
3236
|
+
}),
|
|
3237
|
+
/* @__PURE__ */ jsx("th", {
|
|
3238
|
+
className: "px-4 py-2",
|
|
3239
|
+
children: tr("fluidgrids.taskQueues.kind", "Kind")
|
|
3240
|
+
}),
|
|
3241
|
+
/* @__PURE__ */ jsx("th", {
|
|
3242
|
+
className: "hidden px-4 py-2 sm:table-cell",
|
|
3243
|
+
children: tr("fluidgrids.taskQueues.environment", "Environment")
|
|
3244
|
+
}),
|
|
3245
|
+
/* @__PURE__ */ jsx("th", {
|
|
3246
|
+
className: "hidden px-4 py-2 md:table-cell",
|
|
3247
|
+
children: tr("fluidgrids.taskQueues.limit", "Rate limit")
|
|
3248
|
+
}),
|
|
3249
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-2" })
|
|
3250
|
+
] })
|
|
3251
|
+
}), /* @__PURE__ */ jsx("tbody", {
|
|
3252
|
+
className: "divide-y divide-border-default",
|
|
3253
|
+
children: (queues.data ?? []).map((queue) => /* @__PURE__ */ jsxs("tr", {
|
|
3254
|
+
className: selected?.name === queue.name && selected.environment === queue.environment ? "bg-action-primary-bg/10" : "",
|
|
3255
|
+
"data-testid": `task-queue-${queue.name}`,
|
|
3256
|
+
children: [
|
|
3257
|
+
/* @__PURE__ */ jsxs("td", {
|
|
3258
|
+
className: "px-4 py-2",
|
|
3259
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
3260
|
+
type: "button",
|
|
3261
|
+
className: "font-mono text-text-primary hover:underline",
|
|
3262
|
+
onClick: () => setSelected(queue),
|
|
3263
|
+
children: queue.name
|
|
3264
|
+
}), queue.description && /* @__PURE__ */ jsx("p", {
|
|
3265
|
+
className: "text-xs text-text-secondary",
|
|
3266
|
+
children: queue.description
|
|
3267
|
+
})]
|
|
3268
|
+
}),
|
|
3269
|
+
/* @__PURE__ */ jsx("td", {
|
|
3270
|
+
className: "px-4 py-2",
|
|
3271
|
+
children: /* @__PURE__ */ jsx(StatusPill, {
|
|
3272
|
+
tone: queue.kind === "MANAGED" ? "neutral" : "info",
|
|
3273
|
+
children: queue.kind === "MANAGED" ? tr("fluidgrids.taskQueues.managed", "Managed") : tr("fluidgrids.taskQueues.selfHosted", "Self-hosted")
|
|
3274
|
+
})
|
|
3275
|
+
}),
|
|
3276
|
+
/* @__PURE__ */ jsx("td", {
|
|
3277
|
+
className: "hidden px-4 py-2 text-text-secondary sm:table-cell",
|
|
3278
|
+
children: queue.environment ?? tr("fluidgrids.taskQueues.every", "Every")
|
|
3279
|
+
}),
|
|
3280
|
+
/* @__PURE__ */ jsx("td", {
|
|
3281
|
+
className: "hidden px-4 py-2 text-text-secondary md:table-cell",
|
|
3282
|
+
children: queue.maxTasksPerSecond ? `${queue.maxTasksPerSecond}/s` : "—"
|
|
3283
|
+
}),
|
|
3284
|
+
/* @__PURE__ */ jsxs("td", {
|
|
3285
|
+
className: "px-4 py-2 text-right",
|
|
3286
|
+
children: [queue.id && canUpdate && /* @__PURE__ */ jsx(Button$1, {
|
|
3287
|
+
size: "sm",
|
|
3288
|
+
variant: "ghost",
|
|
3289
|
+
onClick: () => setEditing({ queue }),
|
|
3290
|
+
"aria-label": tr("fluidgrids.taskQueues.edit", "Edit"),
|
|
3291
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3292
|
+
icon: "mdi:pencil",
|
|
3293
|
+
width: 14
|
|
3294
|
+
})
|
|
3295
|
+
}), queue.id && canDelete && /* @__PURE__ */ jsx(Button$1, {
|
|
3296
|
+
size: "sm",
|
|
3297
|
+
variant: "ghost",
|
|
3298
|
+
className: "text-[var(--color-status-error-text)]",
|
|
3299
|
+
onClick: () => setDeleting(queue),
|
|
3300
|
+
"aria-label": tr("fluidgrids.taskQueues.delete", "Delete"),
|
|
3301
|
+
"data-testid": `task-queue-delete-${queue.name}`,
|
|
3302
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3303
|
+
icon: "mdi:delete-outline",
|
|
3304
|
+
width: 14
|
|
3305
|
+
})
|
|
3306
|
+
})]
|
|
3307
|
+
})
|
|
3308
|
+
]
|
|
3309
|
+
}, `${queue.name}:${queue.environment ?? ""}`))
|
|
3310
|
+
})]
|
|
3311
|
+
})]
|
|
3312
|
+
}),
|
|
3313
|
+
selected && /* @__PURE__ */ jsx(TaskQueueStatsCard, { queue: selected }),
|
|
3314
|
+
/* @__PURE__ */ jsxs("section", {
|
|
3315
|
+
className: "rounded-lg border border-border-default bg-surface",
|
|
3316
|
+
"data-testid": "workers-table",
|
|
3317
|
+
children: [
|
|
3318
|
+
/* @__PURE__ */ jsxs("header", {
|
|
3319
|
+
className: "flex items-center gap-2 border-b border-border-default px-4 py-3",
|
|
3320
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
3321
|
+
icon: "mdi:server-network",
|
|
3322
|
+
width: 18,
|
|
3323
|
+
className: "text-text-secondary"
|
|
3324
|
+
}), /* @__PURE__ */ jsx("h2", {
|
|
3325
|
+
className: "text-sm font-semibold text-text-primary",
|
|
3326
|
+
children: tr("fluidgrids.taskQueues.workers", "Workers")
|
|
3327
|
+
})]
|
|
3328
|
+
}),
|
|
3329
|
+
/* @__PURE__ */ jsx(FieldError, { message: workers.error }),
|
|
3330
|
+
workers.data && workers.data.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
3331
|
+
className: "px-4",
|
|
3332
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
3333
|
+
kind: "first-use",
|
|
3334
|
+
illustration: "servers",
|
|
3335
|
+
size: "inline",
|
|
3336
|
+
compact: true,
|
|
3337
|
+
icon: null,
|
|
3338
|
+
title: tr("fluidgrids.taskQueues.noWorkers", "No worker is connected.")
|
|
3339
|
+
})
|
|
3340
|
+
}),
|
|
3341
|
+
/* @__PURE__ */ jsx("ul", {
|
|
3342
|
+
className: "divide-y divide-border-default",
|
|
3343
|
+
children: (workers.data ?? []).map((worker) => /* @__PURE__ */ jsxs("li", {
|
|
3344
|
+
className: "flex flex-wrap items-center gap-3 px-4 py-2 text-sm",
|
|
3345
|
+
"data-testid": `worker-${worker.id}`,
|
|
3346
|
+
children: [
|
|
3347
|
+
/* @__PURE__ */ jsx(StatusPill, {
|
|
3348
|
+
tone: worker.status === "ONLINE" ? "success" : worker.status === "STALE" ? "warning" : "neutral",
|
|
3349
|
+
children: worker.status
|
|
3350
|
+
}),
|
|
3351
|
+
/* @__PURE__ */ jsx("span", {
|
|
3352
|
+
className: "font-mono text-xs text-text-primary",
|
|
3353
|
+
children: worker.identity
|
|
3354
|
+
}),
|
|
3355
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3356
|
+
className: "text-xs text-text-secondary",
|
|
3357
|
+
children: [
|
|
3358
|
+
worker.sdkLanguage,
|
|
3359
|
+
" ",
|
|
3360
|
+
worker.sdkVersion
|
|
3361
|
+
]
|
|
3362
|
+
}),
|
|
3363
|
+
/* @__PURE__ */ jsx("span", {
|
|
3364
|
+
className: "text-xs text-text-secondary",
|
|
3365
|
+
children: worker.taskQueues.join(", ")
|
|
3366
|
+
}),
|
|
3367
|
+
/* @__PURE__ */ jsx("span", {
|
|
3368
|
+
className: "text-xs text-text-secondary",
|
|
3369
|
+
children: tr("fluidgrids.taskQueues.slots", "slots {{used}}/{{total}}", {
|
|
3370
|
+
used: worker.slots.workflow.used + worker.slots.activity.used,
|
|
3371
|
+
total: worker.slots.workflow.total + worker.slots.activity.total
|
|
3372
|
+
})
|
|
3373
|
+
}),
|
|
3374
|
+
/* @__PURE__ */ jsx("span", {
|
|
3375
|
+
className: "ml-auto text-xs text-text-secondary",
|
|
3376
|
+
children: formatAge(worker.lastHeartbeatAt)
|
|
3377
|
+
})
|
|
3378
|
+
]
|
|
3379
|
+
}, worker.id))
|
|
3380
|
+
})
|
|
3381
|
+
]
|
|
3382
|
+
}),
|
|
3383
|
+
canReadTokens && /* @__PURE__ */ jsxs("section", {
|
|
3384
|
+
className: "rounded-lg border border-border-default bg-surface",
|
|
3385
|
+
"data-testid": "worker-tokens",
|
|
3386
|
+
children: [
|
|
3387
|
+
/* @__PURE__ */ jsxs("header", {
|
|
3388
|
+
className: "flex items-center gap-2 border-b border-border-default px-4 py-3",
|
|
3389
|
+
children: [
|
|
3390
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
3391
|
+
icon: "mdi:key-variant",
|
|
3392
|
+
width: 18,
|
|
3393
|
+
className: "text-text-secondary"
|
|
3394
|
+
}),
|
|
3395
|
+
/* @__PURE__ */ jsx("h2", {
|
|
3396
|
+
className: "text-sm font-semibold text-text-primary",
|
|
3397
|
+
children: tr("fluidgrids.taskQueues.tokens", "Worker tokens")
|
|
3398
|
+
}),
|
|
3399
|
+
canCreateToken && /* @__PURE__ */ jsxs(Button$1, {
|
|
3400
|
+
size: "sm",
|
|
3401
|
+
variant: "outline",
|
|
3402
|
+
className: "ml-auto",
|
|
3403
|
+
onClick: () => setIssuing(true),
|
|
3404
|
+
"data-testid": "worker-token-create",
|
|
3405
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
3406
|
+
icon: "mdi:plus",
|
|
3407
|
+
className: "mr-1",
|
|
3408
|
+
width: 14
|
|
3409
|
+
}), tr("fluidgrids.taskQueues.issueToken", "New token")]
|
|
3410
|
+
})
|
|
3411
|
+
]
|
|
3412
|
+
}),
|
|
3413
|
+
/* @__PURE__ */ jsx(FieldError, { message: tokens.error }),
|
|
3414
|
+
/* @__PURE__ */ jsxs("ul", {
|
|
3415
|
+
className: "divide-y divide-border-default",
|
|
3416
|
+
children: [(tokens.data ?? []).map((token) => /* @__PURE__ */ jsxs("li", {
|
|
3417
|
+
className: "flex flex-wrap items-center gap-3 px-4 py-2 text-sm",
|
|
3418
|
+
"data-testid": `worker-token-${token.id}`,
|
|
3419
|
+
children: [
|
|
3420
|
+
/* @__PURE__ */ jsx("span", {
|
|
3421
|
+
className: "font-medium text-text-primary",
|
|
3422
|
+
children: token.name
|
|
3423
|
+
}),
|
|
3424
|
+
/* @__PURE__ */ jsxs("code", {
|
|
3425
|
+
className: "font-mono text-xs text-text-secondary",
|
|
3426
|
+
children: [token.tokenPrefix, "…"]
|
|
3427
|
+
}),
|
|
3428
|
+
/* @__PURE__ */ jsx("span", {
|
|
3429
|
+
className: "text-xs text-text-secondary",
|
|
3430
|
+
children: token.taskQueues.join(", ")
|
|
3431
|
+
}),
|
|
3432
|
+
/* @__PURE__ */ jsx("span", {
|
|
3433
|
+
className: "text-xs text-text-secondary",
|
|
3434
|
+
children: token.connectionAllowlist.length > 0 ? tr("fluidgrids.taskQueues.connections", "{{count}} connections", { count: token.connectionAllowlist.length }) : tr("fluidgrids.taskQueues.noConnections", "no connections")
|
|
3435
|
+
}),
|
|
3436
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3437
|
+
className: "ml-auto flex gap-1",
|
|
3438
|
+
children: [
|
|
3439
|
+
canEditAllowlist && /* @__PURE__ */ jsx(Button$1, {
|
|
3440
|
+
size: "sm",
|
|
3441
|
+
variant: "ghost",
|
|
3442
|
+
onClick: () => setAllowlist(token),
|
|
3443
|
+
"data-testid": `worker-token-allowlist-${token.id}`,
|
|
3444
|
+
children: tr("fluidgrids.taskQueues.editConnections", "Connections")
|
|
3445
|
+
}),
|
|
3446
|
+
canRotateToken && /* @__PURE__ */ jsx(Button$1, {
|
|
3447
|
+
size: "sm",
|
|
3448
|
+
variant: "ghost",
|
|
3449
|
+
onClick: () => void rotate(token),
|
|
3450
|
+
disabled: tokenBusy !== null,
|
|
3451
|
+
"data-testid": `worker-token-rotate-${token.id}`,
|
|
3452
|
+
children: tr("fluidgrids.taskQueues.rotate", "Rotate")
|
|
3453
|
+
}),
|
|
3454
|
+
canDeleteToken && /* @__PURE__ */ jsx(Button$1, {
|
|
3455
|
+
size: "sm",
|
|
3456
|
+
variant: "ghost",
|
|
3457
|
+
className: "text-[var(--color-status-error-text)]",
|
|
3458
|
+
onClick: () => void removeToken(token),
|
|
3459
|
+
disabled: tokenBusy !== null,
|
|
3460
|
+
"data-testid": `worker-token-delete-${token.id}`,
|
|
3461
|
+
children: tr("fluidgrids.taskQueues.delete", "Delete")
|
|
3462
|
+
})
|
|
3463
|
+
]
|
|
3464
|
+
})
|
|
3465
|
+
]
|
|
3466
|
+
}, token.id)), tokens.data && tokens.data.length === 0 && /* @__PURE__ */ jsx("li", {
|
|
3467
|
+
className: "px-4",
|
|
3468
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
3469
|
+
kind: "first-use",
|
|
3470
|
+
illustration: "security",
|
|
3471
|
+
size: "inline",
|
|
3472
|
+
compact: true,
|
|
3473
|
+
icon: null,
|
|
3474
|
+
title: tr("fluidgrids.taskQueues.noTokens", "No worker tokens.")
|
|
3475
|
+
})
|
|
3476
|
+
})]
|
|
3477
|
+
})
|
|
3478
|
+
]
|
|
3479
|
+
}),
|
|
3480
|
+
editing && /* @__PURE__ */ jsx(TaskQueueDialog, {
|
|
3481
|
+
queue: editing.queue,
|
|
3482
|
+
onClose: () => setEditing(null),
|
|
3483
|
+
onSaved: () => {
|
|
3484
|
+
setEditing(null);
|
|
3485
|
+
queues.refetch();
|
|
3486
|
+
}
|
|
3487
|
+
}),
|
|
3488
|
+
issuing && /* @__PURE__ */ jsx(WorkerTokenDialog, {
|
|
3489
|
+
queues: selfHosted,
|
|
3490
|
+
canSetAllowlist: canCreateToken,
|
|
3491
|
+
onClose: () => setIssuing(false),
|
|
3492
|
+
onCreated: (created) => {
|
|
3493
|
+
setIssuing(false);
|
|
3494
|
+
setSecret(created);
|
|
3495
|
+
tokens.refetch();
|
|
3496
|
+
}
|
|
3497
|
+
}),
|
|
3498
|
+
secret && /* @__PURE__ */ jsx(WorkerTokenSecretDialog, {
|
|
3499
|
+
created: secret,
|
|
3500
|
+
onClose: () => setSecret(null)
|
|
3501
|
+
}),
|
|
3502
|
+
allowlist && /* @__PURE__ */ jsx(AllowlistDialog, {
|
|
3503
|
+
token: allowlist,
|
|
3504
|
+
onClose: () => setAllowlist(null),
|
|
3505
|
+
onSaved: () => {
|
|
3506
|
+
setAllowlist(null);
|
|
3507
|
+
tokens.refetch();
|
|
3508
|
+
}
|
|
3509
|
+
}),
|
|
3510
|
+
/* @__PURE__ */ jsx(AlertDialog, {
|
|
3511
|
+
open: deleting !== null,
|
|
3512
|
+
onOpenChange: (open) => !open && setDeleting(null),
|
|
3513
|
+
children: /* @__PURE__ */ jsxs(AlertDialogContent, {
|
|
3514
|
+
style: RUN_CONTROL_DIALOG_STYLE,
|
|
3515
|
+
children: [/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: tr("fluidgrids.taskQueues.deleteTitle", "Delete {{name}}?", { name: deleting?.name ?? "" }) }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: tr("fluidgrids.taskQueues.deleteDescription", "The service refuses while open runs or activities use the queue.") })] }), /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, { children: tr("fluidgrids.runControl.common.cancel", "Cancel") }), /* @__PURE__ */ jsx(AlertDialogAction, {
|
|
3516
|
+
onClick: () => void removeQueue(),
|
|
3517
|
+
"data-testid": "task-queue-delete-confirm",
|
|
3518
|
+
children: tr("fluidgrids.taskQueues.delete", "Delete")
|
|
3519
|
+
})] })]
|
|
3520
|
+
})
|
|
3521
|
+
})
|
|
3522
|
+
]
|
|
3523
|
+
});
|
|
3524
|
+
}
|
|
3525
|
+
function TaskQueueStatsCard({ queue }) {
|
|
3526
|
+
const tr = useTr();
|
|
3527
|
+
const stats = useResource(`queue-stats:${queue.name}:${queue.environment ?? ""}`, true, () => fetchTaskQueueStats(queue.name, queue.environment), {
|
|
3528
|
+
live: true,
|
|
3529
|
+
intervalMs: 3e4
|
|
3530
|
+
});
|
|
3531
|
+
const data = stats.data;
|
|
3532
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
3533
|
+
className: "grid gap-4 rounded-lg border border-border-default bg-surface p-4 sm:grid-cols-3",
|
|
3534
|
+
"data-testid": "task-queue-stats",
|
|
3535
|
+
children: [
|
|
3536
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
3537
|
+
className: "text-xs uppercase text-text-secondary",
|
|
3538
|
+
children: tr("fluidgrids.taskQueues.pollers", "Pollers")
|
|
3539
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
3540
|
+
className: "text-2xl font-bold text-text-primary",
|
|
3541
|
+
"data-testid": "task-queue-pollers",
|
|
3542
|
+
children: data?.pollers ?? "—"
|
|
3543
|
+
})] }),
|
|
3544
|
+
["workflow", "activity"].map((kind) => /* @__PURE__ */ jsxs("div", { children: [
|
|
3545
|
+
/* @__PURE__ */ jsx("p", {
|
|
3546
|
+
className: "text-xs uppercase text-text-secondary",
|
|
3547
|
+
children: kind === "workflow" ? tr("fluidgrids.taskQueues.workflowBacklog", "Workflow backlog") : tr("fluidgrids.taskQueues.activityBacklog", "Activity backlog")
|
|
3548
|
+
}),
|
|
3549
|
+
/* @__PURE__ */ jsx("p", {
|
|
3550
|
+
className: "text-2xl font-bold text-text-primary",
|
|
3551
|
+
"data-testid": `task-queue-backlog-${kind}`,
|
|
3552
|
+
children: data ? data[kind].backlogCount : "—"
|
|
3553
|
+
}),
|
|
3554
|
+
data && /* @__PURE__ */ jsx("p", {
|
|
3555
|
+
className: "text-xs text-text-secondary",
|
|
3556
|
+
children: tr("fluidgrids.taskQueues.rates", "oldest {{age}}s · {{add}}/s in · {{out}}/s out", {
|
|
3557
|
+
age: Math.round(data[kind].approxBacklogAgeSeconds),
|
|
3558
|
+
add: data[kind].tasksAddRate.toFixed(1),
|
|
3559
|
+
out: data[kind].tasksDispatchRate.toFixed(1)
|
|
3560
|
+
})
|
|
3561
|
+
})
|
|
3562
|
+
] }, kind)),
|
|
3563
|
+
/* @__PURE__ */ jsx("div", {
|
|
3564
|
+
className: "sm:col-span-3",
|
|
3565
|
+
children: /* @__PURE__ */ jsx(FieldError, { message: stats.error })
|
|
3566
|
+
})
|
|
3567
|
+
]
|
|
3568
|
+
});
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
export { taskQueueNameProblem as a, taskQueueInputOf as i, TaskQueuesPage as n, TaskQueuesPage_exports as r, TaskQueueStatsCard as t };
|