@processfocus/runtime-local 0.1.0-next.2 → 0.1.0-next.3

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.
Files changed (326) hide show
  1. package/README.md +48 -253
  2. package/dist/authentication-server.mjs +52 -84
  3. package/dist/{chunk-yhzbn4vx.js → chunk-04r0t2mb.js} +34324 -49067
  4. package/dist/chunk-727y6qkb.js +156 -0
  5. package/dist/chunk-bg5r4wpv.js +4755 -0
  6. package/dist/chunk-cbd36jq1.js +512 -0
  7. package/dist/chunk-d4ctj079.js +241 -0
  8. package/dist/{chunk-352j1ayk.js → chunk-r5s2v669.js} +51753 -36263
  9. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +12 -12
  10. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +31 -21
  11. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +3 -0
  12. package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +1 -12
  13. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +1 -1
  14. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
  15. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -0
  16. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
  17. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +3 -1
  18. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
  19. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
  20. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
  21. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
  22. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
  23. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
  24. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
  25. package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
  26. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
  27. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -0
  28. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
  29. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +145 -19
  30. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +10 -2
  31. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +29 -13
  32. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
  33. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
  34. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
  35. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
  36. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
  37. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
  38. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
  39. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
  40. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
  41. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
  42. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
  43. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
  44. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
  45. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
  46. package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
  47. package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
  48. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
  49. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
  50. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
  51. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
  52. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
  53. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
  54. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
  55. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
  56. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
  57. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
  58. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
  59. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
  60. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
  61. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
  62. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
  63. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
  64. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
  65. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
  66. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
  67. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
  68. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
  69. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
  70. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
  71. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
  72. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
  73. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
  74. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
  75. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
  76. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
  77. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
  78. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
  79. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
  80. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
  81. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
  82. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
  83. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
  84. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
  85. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
  86. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
  87. package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
  88. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
  89. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
  90. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
  91. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +2 -4
  92. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
  93. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
  94. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
  95. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
  96. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
  97. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
  98. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
  99. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
  100. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
  101. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
  102. package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
  103. package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
  104. package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
  105. package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
  106. package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
  107. package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
  108. package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
  109. package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
  110. package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
  111. package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
  112. package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
  113. package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
  114. package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
  115. package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +11 -4
  116. package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
  117. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
  118. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
  119. package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
  120. package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
  121. package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
  122. package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +47 -0
  123. package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
  124. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
  125. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
  126. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
  127. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
  128. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
  129. package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
  130. package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
  131. package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
  132. package/dist/dashboard-source/apps/frontend/components/Header.tsx +4 -8
  133. package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
  134. package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
  135. package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
  136. package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
  137. package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
  138. package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
  139. package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
  140. package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
  141. package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
  142. package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
  143. package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
  144. package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
  145. package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
  146. package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
  147. package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
  148. package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
  149. package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
  150. package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
  151. package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
  152. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
  153. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
  154. package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
  155. package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
  156. package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
  157. package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
  158. package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
  159. package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
  160. package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
  161. package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
  162. package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
  163. package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
  164. package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
  165. package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
  166. package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
  167. package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
  168. package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +112 -21
  169. package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
  170. package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
  171. package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
  172. package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
  173. package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
  174. package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
  175. package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
  176. package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
  177. package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
  178. package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
  179. package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
  180. package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
  181. package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
  182. package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
  183. package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
  184. package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
  185. package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
  186. package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
  187. package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
  188. package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
  189. package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
  190. package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
  191. package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +169 -30
  192. package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
  193. package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
  194. package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
  195. package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +34 -29
  196. package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
  197. package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
  198. package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
  199. package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
  200. package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
  201. package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
  202. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
  203. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
  204. package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
  205. package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
  206. package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
  207. package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
  208. package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +900 -0
  209. package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +42 -0
  210. package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
  211. package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
  212. package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
  213. package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
  214. package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +193 -0
  215. package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +237 -0
  216. package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
  217. package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
  218. package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
  219. package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
  220. package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
  221. package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
  222. package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
  223. package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
  224. package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
  225. package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
  226. package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
  227. package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
  228. package/dist/dashboard-source/apps/frontend/package.json +48 -47
  229. package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
  230. package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
  231. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
  232. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
  233. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
  234. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
  235. package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
  236. package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
  237. package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
  238. package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
  239. package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
  240. package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
  241. package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
  242. package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
  243. package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
  244. package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
  245. package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
  246. package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
  247. package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
  248. package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
  249. package/dist/dashboard-source/modules/form/src/index.ts +1 -10
  250. package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
  251. package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
  252. package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
  253. package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
  254. package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
  255. package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
  256. package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
  257. package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
  258. package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
  259. package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
  260. package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
  261. package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
  262. package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
  263. package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
  264. package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
  265. package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
  266. package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
  267. package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
  268. package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
  269. package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
  270. package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
  271. package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
  272. package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
  273. package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
  274. package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
  275. package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
  276. package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
  277. package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
  278. package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
  279. package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
  280. package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
  281. package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
  282. package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
  283. package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
  284. package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
  285. package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
  286. package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
  287. package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
  288. package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
  289. package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
  290. package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
  291. package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
  292. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
  293. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
  294. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +272 -0
  295. package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
  296. package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
  297. package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
  298. package/dist/dashboard-source.json +48 -47
  299. package/dist/graphql-server.mjs +245 -200
  300. package/dist/job-worker-supervisor.mjs +262 -0
  301. package/dist/job-worker.mjs +234 -133
  302. package/dist/main.mjs +23 -4
  303. package/dist/prepare-dashboard.mjs +8 -8
  304. package/dist/resources/cedar/policies.cedar +80 -38
  305. package/dist/resources/cedar/schema.cedarschema +39 -21
  306. package/dist/resources/graphql-schema/rxdb.graphql +2 -0
  307. package/dist/resources/graphql-schema/system.graphql +190 -51
  308. package/package.json +64 -62
  309. package/dist/chunk-6ntmymmx.js +0 -85
  310. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
  311. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
  312. package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
  313. package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
  314. package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
  315. package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
  316. package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
  317. package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
  318. package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
  319. package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
  320. package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
  321. package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
  322. package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
  323. package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
  324. package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
  325. package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
  326. package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
@@ -1,1591 +1,6 @@
1
- "use client"
1
+ import ExecutionsPage from "./executions-client.tsx"
2
2
 
3
- import type { Collection } from "@tanstack/db"
4
- import { useLiveQuery } from "@tanstack/react-db"
5
- import { ChevronLeft } from "lucide-react"
6
- import Image from "next/image"
7
- import Link from "next/link"
8
- import { useRouter, useSearchParams } from "next/navigation"
9
- import { Suspense, use, useMemo, useRef, useState } from "react"
10
- import { ExecutionCardMenu } from "./execution-card-menu.tsx"
11
- import { useMocks } from "@/components/mocks-provider"
12
- import { ProcessWorkflowLink } from "@/components/process-workflow-link"
13
- import { TabPill } from "@/components/ui/tab-pill"
14
- import { WithoutWaitingBadge } from "@/components/without-waiting-badge"
15
- import { useIsMobile } from "@/hooks/use-mobile"
16
- import {
17
- type ExecutionDocType,
18
- useExecutionCollection,
19
- } from "@/lib/collections/execution-collection-provider"
20
- import { type Execution, executions as mockExecutions } from "@/lib/mock-data"
21
- import { cn } from "@/lib/utils"
3
+ // The authenticated layout can omit this page while checking the session.
4
+ export const instant = false
22
5
 
23
- type ExecutionStatus =
24
- | "Running"
25
- | "Completed"
26
- | "Failed"
27
- | "Abandoned"
28
- | "Not started"
29
- type ExecutionTabKey =
30
- | "in-progress"
31
- | "completed"
32
- | "failed"
33
- | "not-started"
34
- | "all"
35
- type MockExecutionView = "timeline" | "kanban"
36
- type MockExecutionTabKey = "in-progress" | "completed" | "failed" | "all"
37
-
38
- const executionStatusTheme: Record<ExecutionStatus, string> = {
39
- "Not started":
40
- "bg-amber-100 text-amber-800 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-300 dark:border-amber-500/30",
41
- Running:
42
- "bg-sky-100 text-sky-700 border border-sky-200 dark:bg-sky-500/10 dark:text-sky-300 dark:border-sky-500/30",
43
- Completed:
44
- "bg-emerald-100 text-emerald-700 border border-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-300 dark:border-emerald-500/30",
45
- Failed:
46
- "bg-rose-100 text-rose-700 border border-rose-200 dark:bg-rose-500/10 dark:text-rose-300 dark:border-rose-500/30",
47
- Abandoned:
48
- "bg-slate-100 text-slate-600 border border-slate-200 dark:bg-slate-500/10 dark:text-slate-400 dark:border-slate-500/30",
49
- }
50
-
51
- const mockExecutionStatusTheme = {
52
- Running:
53
- "bg-sky-100 text-sky-700 border border-sky-200 dark:bg-sky-500/10 dark:text-sky-300 dark:border-sky-500/30",
54
- Paused:
55
- "bg-amber-100 text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-300 dark:border-amber-500/30",
56
- Completed:
57
- "bg-emerald-100 text-emerald-700 border border-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-300 dark:border-emerald-500/30",
58
- Failed:
59
- "bg-rose-100 text-rose-700 border border-rose-200 dark:bg-rose-500/10 dark:text-rose-300 dark:border-rose-500/30",
60
- }
61
-
62
- const mockExecutionTabFilters: Record<
63
- MockExecutionTabKey,
64
- Execution["status"][]
65
- > = {
66
- "in-progress": ["Running", "Paused"],
67
- completed: ["Completed"],
68
- failed: ["Failed"],
69
- all: ["Running", "Paused", "Completed", "Failed"],
70
- }
71
-
72
- const executionTabKeys = [
73
- "not-started",
74
- "in-progress",
75
- "completed",
76
- "failed",
77
- "all",
78
- ] as const satisfies readonly ExecutionTabKey[]
79
-
80
- function parseExecutionTabKey(value: string | null): ExecutionTabKey | null {
81
- return executionTabKeys.find((key) => key === value) ?? null
82
- }
83
-
84
- /**
85
- * Format timestamp to relative time string
86
- * Accepts either epoch ms (number) or ISO date string
87
- */
88
- function formatRelativeTime(timestamp: number | string): string {
89
- const time =
90
- typeof timestamp === "string" ? new Date(timestamp).getTime() : timestamp
91
-
92
- if (!Number.isFinite(time) || time <= 0) {
93
- return "Unknown"
94
- }
95
-
96
- const now = Date.now()
97
- const diff = now - time
98
-
99
- if (diff < 0) {
100
- return "Just now"
101
- }
102
-
103
- const seconds = Math.floor(diff / 1000)
104
- const minutes = Math.floor(seconds / 60)
105
- const hours = Math.floor(minutes / 60)
106
- const days = Math.floor(hours / 24)
107
-
108
- if (days > 0) return `${days} day${days > 1 ? "s" : ""} ago`
109
- if (hours > 0) return `${hours} hour${hours > 1 ? "s" : ""} ago`
110
- if (minutes > 0) return `${minutes} minute${minutes > 1 ? "s" : ""} ago`
111
- return "Just now"
112
- }
113
-
114
- function ExecutionsSkeleton() {
115
- return (
116
- <div className="flex-1 overflow-y-auto">
117
- <section className="space-y-6">
118
- <div className="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-900/60">
119
- <div className="flex items-center justify-center py-12">
120
- <div className="text-center">
121
- <output
122
- className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-blue-600 border-r-transparent motion-reduce:animate-[spin_1.5s_linear_infinite]"
123
- aria-label="Loading executions"
124
- />
125
- <p className="mt-4 text-sm text-slate-500 dark:text-slate-400">
126
- Loading executions...
127
- </p>
128
- </div>
129
- </div>
130
- </div>
131
- </section>
132
- </div>
133
- )
134
- }
135
-
136
- // =============================================================================
137
- // LIVE IMPLEMENTATION (using RxDB data)
138
- // =============================================================================
139
-
140
- function ExecutionsPageInner({
141
- collectionPromise,
142
- initialSelectedExecutionId = null,
143
- onMobileBack,
144
- }: {
145
- collectionPromise: Promise<Collection<ExecutionDocType, string>>
146
- initialSelectedExecutionId?: string | null
147
- onMobileBack?: () => void
148
- }) {
149
- "use memo"
150
-
151
- const executionCollection = use(collectionPromise)
152
- const router = useRouter()
153
- const searchParams = useSearchParams()
154
- const isMobile = useIsMobile()
155
- const defaultTab = initialSelectedExecutionId ? "all" : "in-progress"
156
- const tab = parseExecutionTabKey(searchParams.get("filter")) ?? defaultTab
157
- const currentQueryString = searchParams.toString()
158
- const currentQuerySuffix = currentQueryString ? `?${currentQueryString}` : ""
159
- const [selectedExecutionId, setSelectedExecutionId] = useState<string | null>(
160
- null,
161
- )
162
-
163
- // Live query for all executions, ordered by most recent first
164
- const executionsQuery = useLiveQuery((q) =>
165
- q
166
- .from({ execution: executionCollection })
167
- .select(({ execution }) => ({
168
- id: execution.id,
169
- updatedAt: execution.updatedAt,
170
- processStateId: execution.processStateId,
171
- processName: execution.processName,
172
- withoutWaiting: execution.withoutWaiting ?? false,
173
- processPath: execution.processPath,
174
- canAbandonExecution: execution.canAbandonExecution ?? false,
175
- canRestartExecution: execution.canRestartExecution ?? false,
176
- status: execution.status,
177
- failureReason: execution.failureReason,
178
- notStartedReason: execution.notStartedReason,
179
- abandonedReason: execution.abandonedReason,
180
- startedAt: execution.startedAt,
181
- finishedAt: execution.finishedAt,
182
- completedSteps: execution.completedSteps,
183
- totalSteps: execution.totalSteps,
184
- durationMs: execution.durationMs,
185
- estimatedCompletionAt: execution.estimatedCompletionAt,
186
- slaTargetAt: execution.slaTargetAt,
187
- steps: execution.steps,
188
- }))
189
- .orderBy(({ execution }) => execution.startedAt, "desc"),
190
- )
191
-
192
- const executions = executionsQuery.data ?? []
193
-
194
- const routeSelectedExecution = initialSelectedExecutionId
195
- ? executions.find(
196
- (execution) => execution.id === initialSelectedExecutionId,
197
- )
198
- : null
199
-
200
- // Count by status
201
- const runningCount = executions.filter((e) => e.status === "Running").length
202
- const completedCount = executions.filter(
203
- (e) => e.status === "Completed",
204
- ).length
205
- const failedCount = executions.filter(
206
- (e) => e.status === "Failed" || e.status === "Abandoned",
207
- ).length
208
-
209
- // Filter based on tab
210
- const filtered = (() => {
211
- switch (tab) {
212
- case "not-started":
213
- return executions.filter((e) => e.status === "Not started")
214
- case "in-progress":
215
- return executions.filter((e) => e.status === "Running")
216
- case "completed":
217
- return executions.filter((e) => e.status === "Completed")
218
- case "failed":
219
- return executions.filter(
220
- (e) => e.status === "Failed" || e.status === "Abandoned",
221
- )
222
- default:
223
- return executions
224
- }
225
- })()
226
-
227
- // Selected execution
228
- const selectedExecution = (() => {
229
- if (filtered.length === 0) return null
230
-
231
- if (selectedExecutionId) {
232
- const found = filtered.find((e) => e.id === selectedExecutionId)
233
- if (found) return found
234
- }
235
-
236
- if (initialSelectedExecutionId) {
237
- if (!routeSelectedExecution) return null
238
-
239
- const routeSelection = filtered.find(
240
- (execution) => execution.id === initialSelectedExecutionId,
241
- )
242
-
243
- if (routeSelection) return routeSelection
244
- return isMobile ? routeSelectedExecution : (filtered[0] ?? null)
245
- }
246
-
247
- return filtered[0] ?? null
248
- })()
249
-
250
- const handleSelectExecution = (executionId: string) => {
251
- setSelectedExecutionId(executionId)
252
-
253
- const executionPath = `/executions/${encodeURIComponent(executionId)}${currentQuerySuffix}`
254
-
255
- if (isMobile) {
256
- router.push(executionPath, { scroll: false })
257
- return
258
- }
259
-
260
- router.replace(executionPath, { scroll: false })
261
- }
262
-
263
- const handleSelectTab = (nextTab: ExecutionTabKey) => {
264
- const nextSearchParams = new URLSearchParams(searchParams)
265
-
266
- if (nextTab === defaultTab) {
267
- nextSearchParams.delete("filter")
268
- } else {
269
- nextSearchParams.set("filter", nextTab)
270
- }
271
-
272
- const nextQueryString = nextSearchParams.toString()
273
- router.replace(
274
- nextQueryString ? `/executions?${nextQueryString}` : "/executions",
275
- { scroll: false },
276
- )
277
- }
278
-
279
- const handleCloseMobileDetail = () => {
280
- if (onMobileBack) {
281
- onMobileBack()
282
- return
283
- }
284
-
285
- router.push(`/executions${currentQuerySuffix}`, { scroll: false })
286
- }
287
-
288
- const isMobileDetailRoute = isMobile && initialSelectedExecutionId !== null
289
- const isRouteExecutionMissing =
290
- initialSelectedExecutionId !== null && routeSelectedExecution === null
291
-
292
- if (!executionsQuery.isReady) {
293
- return <ExecutionsSkeleton />
294
- }
295
-
296
- return (
297
- <section className="space-y-6">
298
- {!isMobileDetailRoute && (
299
- <div className="flex flex-wrap items-center justify-between gap-4 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900/60">
300
- <div className="flex flex-wrap items-center gap-2">
301
- <TabPill
302
- label="In Progress"
303
- count={runningCount}
304
- active={tab === "in-progress"}
305
- onClick={() => handleSelectTab("in-progress")}
306
- />
307
- <TabPill
308
- label="Completed"
309
- count={completedCount}
310
- active={tab === "completed"}
311
- onClick={() => handleSelectTab("completed")}
312
- />
313
- <TabPill
314
- label="Failed"
315
- count={failedCount}
316
- active={tab === "failed"}
317
- onClick={() => handleSelectTab("failed")}
318
- />
319
- <TabPill
320
- label="All"
321
- count={executions.length}
322
- active={tab === "all"}
323
- onClick={() => handleSelectTab("all")}
324
- />
325
- <TabPill
326
- label="Not started"
327
- count={
328
- executions.filter((e) => e.status === "Not started").length
329
- }
330
- active={tab === "not-started"}
331
- onClick={() => handleSelectTab("not-started")}
332
- />
333
- </div>
334
- </div>
335
- )}
336
-
337
- {isMobileDetailRoute ? (
338
- selectedExecution ? (
339
- <MobileExecutionDetail
340
- execution={selectedExecution}
341
- onBack={handleCloseMobileDetail}
342
- />
343
- ) : (
344
- <EmptyState
345
- title="Execution not found"
346
- description="This execution is no longer available or you no longer have access to it."
347
- />
348
- )
349
- ) : filtered.length === 0 ? (
350
- <EmptyState
351
- title="No executions in this view"
352
- description="Adjust filters or start a process from the catalog to see live executions."
353
- />
354
- ) : isMobile ? (
355
- <div className="space-y-3">
356
- {filtered.map((exec) => (
357
- <ExecutionListCard
358
- key={exec.id}
359
- execution={exec}
360
- isSelected={false}
361
- onSelect={() => handleSelectExecution(exec.id)}
362
- />
363
- ))}
364
- </div>
365
- ) : (
366
- <div className="mt-4 grid gap-6 lg:grid-cols-[380px_1fr]">
367
- <div className="space-y-3">
368
- {filtered.map((exec) => (
369
- <ExecutionListCard
370
- key={exec.id}
371
- execution={exec}
372
- isSelected={exec.id === selectedExecution?.id}
373
- onSelect={() => handleSelectExecution(exec.id)}
374
- />
375
- ))}
376
- </div>
377
- {selectedExecution ? (
378
- <LiveExecutionDetail execution={selectedExecution} />
379
- ) : isRouteExecutionMissing ? (
380
- <EmptyState
381
- title="Execution not found"
382
- description="This execution is no longer available or you no longer have access to it."
383
- />
384
- ) : null}
385
- </div>
386
- )}
387
- </section>
388
- )
389
- }
390
-
391
- function ExecutionListCard({
392
- execution,
393
- isSelected,
394
- onSelect,
395
- }: {
396
- execution: ExecutionData
397
- isSelected: boolean
398
- onSelect: () => void
399
- }) {
400
- "use memo"
401
-
402
- const waitingStep = execution.steps.find(
403
- (step) =>
404
- step.status === "Correction Required" || step.status === "Waiting",
405
- )
406
-
407
- return (
408
- // biome-ignore lint/a11y/useSemanticElements: div needed to allow nested button in ExecutionCardMenu
409
- <div
410
- role="button"
411
- tabIndex={0}
412
- onClick={onSelect}
413
- onKeyDown={(event) => {
414
- if (event.key === "Enter" || event.key === " ") {
415
- event.preventDefault()
416
- onSelect()
417
- }
418
- }}
419
- className={cn(
420
- "flex w-full cursor-pointer flex-col gap-3 rounded-2xl border bg-white p-4 text-left shadow-sm transition hover:-translate-y-0.5 hover:shadow-md dark:border-slate-800 dark:bg-slate-900/70",
421
- isSelected
422
- ? "border-blue-500 dark:border-blue-400 dark:bg-blue-500/10"
423
- : "border-slate-200",
424
- )}
425
- >
426
- <div className="flex items-center justify-between">
427
- <h4 className="text-lg font-semibold text-slate-900 dark:text-slate-100">
428
- {execution.processName}
429
- {execution.withoutWaiting && <WithoutWaitingBadge />}
430
- </h4>
431
- <div className="flex items-center gap-2">
432
- <ExecutionCardMenu
433
- executionId={execution.id}
434
- status={execution.status}
435
- processPath={execution.processPath}
436
- canAbandonExecution={execution.canAbandonExecution}
437
- canRestartExecution={execution.canRestartExecution}
438
- />
439
- <span
440
- className={cn(
441
- "inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold",
442
- executionStatusTheme[execution.status as ExecutionStatus] ||
443
- executionStatusTheme.Running,
444
- )}
445
- >
446
- {execution.status}
447
- </span>
448
- </div>
449
- </div>
450
- <p className="text-sm text-slate-500 dark:text-slate-400">
451
- {execution.status === "Completed"
452
- ? "Finished"
453
- : `Step ${execution.completedSteps} of ${execution.totalSteps}`}
454
- </p>
455
- <div className="flex items-center justify-between text-xs text-slate-500 dark:text-slate-400">
456
- <span>Started {formatRelativeTime(execution.startedAt)}</span>
457
- <span>
458
- {execution.status === "Completed" && execution.finishedAt
459
- ? `Completed ${formatRelativeTime(execution.finishedAt)}`
460
- : `Last activity ${formatRelativeTime(execution.updatedAt)}`}
461
- </span>
462
- </div>
463
- {waitingStep && (
464
- <div className="flex items-center gap-2">
465
- <span
466
- className={cn(
467
- "rounded-full px-2 py-0.5 text-xs font-semibold",
468
- waitingStep.status === "Correction Required"
469
- ? "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-200"
470
- : "bg-slate-200 text-slate-600 dark:bg-slate-800 dark:text-slate-300",
471
- )}
472
- >
473
- {waitingStep.status === "Correction Required"
474
- ? `Correction required: ${waitingStep.name}`
475
- : waitingStep.name}
476
- </span>
477
- </div>
478
- )}
479
- <StepParticipants steps={execution.steps} />
480
- </div>
481
- )
482
- }
483
-
484
- interface ExecutionStep {
485
- readonly id: string
486
- readonly name: string
487
- readonly path: string
488
- readonly status:
489
- | "Completed"
490
- | "Waiting"
491
- | "Potential"
492
- | "Failed"
493
- | "Correction Required"
494
- | "Not started"
495
- readonly failureReason?: string | undefined
496
- readonly notStartedReason?: string | undefined
497
- readonly role?:
498
- | {
499
- readonly id: string
500
- readonly name: string
501
- }
502
- | undefined
503
- readonly submittedViaEmbeddedForm?: boolean | undefined
504
- readonly externalSubmitterEmail?: string | undefined
505
- readonly assignedProviderUserEmail?: string | undefined
506
- readonly providerUser?:
507
- | {
508
- readonly id: string
509
- readonly firstName: string
510
- readonly lastName: string
511
- readonly picture: string
512
- readonly orgUnit: string
513
- }
514
- | undefined
515
- readonly startedAt?: string | undefined // ISO date string
516
- readonly completedAt?: string | undefined // ISO date string
517
- }
518
-
519
- interface ExecutionData {
520
- withoutWaiting: boolean
521
- id: string
522
- updatedAt: number
523
- processStateId: string
524
- processName: string
525
- processPath: string
526
- canAbandonExecution: boolean
527
- canRestartExecution: boolean
528
- status: ExecutionStatus
529
- failureReason?: string | undefined
530
- notStartedReason?: string | undefined
531
- abandonedReason?: string | undefined
532
- startedAt: string // ISO date string
533
- finishedAt: string | undefined // ISO date string
534
- completedSteps: number
535
- totalSteps: number
536
- durationMs: number | undefined
537
- estimatedCompletionAt: string | undefined // ISO date string
538
- slaTargetAt: string | undefined // ISO date string
539
- steps: readonly ExecutionStep[]
540
- }
541
-
542
- const SWIPE_CLOSE_MIN_PX = 72
543
- const SWIPE_CLOSE_HORIZONTAL_RATIO = 1.25
544
-
545
- /**
546
- * Format ISO date string to readable date/time
547
- */
548
- function formatDateTime(isoString: string | undefined): string {
549
- if (!isoString) return "N/A"
550
- const date = new Date(isoString)
551
- return date.toLocaleString(undefined, {
552
- month: "short",
553
- day: "numeric",
554
- hour: "2-digit",
555
- minute: "2-digit",
556
- })
557
- }
558
-
559
- /**
560
- * Extract unique participants from execution steps
561
- */
562
- function getParticipants(steps: readonly ExecutionStep[]) {
563
- const completedWithProviderUser = steps.filter(
564
- (
565
- s,
566
- ): s is typeof s & {
567
- providerUser: NonNullable<typeof s.providerUser>
568
- } => s.status === "Completed" && s.providerUser != null,
569
- )
570
- const waitingWithRole = steps.filter(
571
- (s): s is typeof s & { role: NonNullable<typeof s.role> } =>
572
- (s.status === "Waiting" || s.status === "Correction Required") &&
573
- s.role != null,
574
- )
575
-
576
- // Dedupe provider users by id
577
- const seenProviderUsers = new Set<string>()
578
- const uniqueProviderUsers = completedWithProviderUser.filter((step) => {
579
- const key = step.providerUser.id
580
- if (seenProviderUsers.has(key)) return false
581
- seenProviderUsers.add(key)
582
- return true
583
- })
584
-
585
- return { providerUsers: uniqueProviderUsers, waitingRoles: waitingWithRole }
586
- }
587
-
588
- function LiveExecutionDetail({ execution }: { execution: ExecutionData }) {
589
- "use memo"
590
-
591
- // Find current waiting step for display
592
- const currentWaitingStep = execution.steps.find(
593
- (s) => s.status === "Waiting" || s.status === "Correction Required",
594
- )
595
- const failedStep = execution.steps.find((s) => s.status === "Failed")
596
- const { providerUsers, waitingRoles } = getParticipants(execution.steps)
597
-
598
- return (
599
- <div className="flex flex-col gap-4 rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-900/70">
600
- <div className="flex flex-wrap items-start justify-between gap-3">
601
- <div>
602
- <h3 className="text-2xl font-semibold text-slate-900 dark:text-slate-100">
603
- {execution.processName}
604
- {execution.withoutWaiting && <WithoutWaitingBadge />}
605
- </h3>
606
- <p className="text-sm text-slate-500 dark:text-slate-400">
607
- Started {formatRelativeTime(execution.startedAt)}.
608
- {currentWaitingStep?.status === "Correction Required"
609
- ? ` Correction required on ${currentWaitingStep.name}.`
610
- : currentWaitingStep?.providerUser
611
- ? ` Current assignee: ${currentWaitingStep.providerUser.firstName} ${currentWaitingStep.providerUser.lastName}`
612
- : ""}
613
- </p>
614
- </div>
615
- <div className="flex items-center gap-2">
616
- <span
617
- className={cn(
618
- "inline-flex items-center rounded-full px-3 py-1 text-sm font-semibold",
619
- executionStatusTheme[execution.status as ExecutionStatus] ||
620
- executionStatusTheme.Running,
621
- )}
622
- >
623
- {execution.status}
624
- </span>
625
- <ProcessWorkflowLink
626
- processName={execution.processName}
627
- processPath={execution.processPath}
628
- />
629
- </div>
630
- </div>
631
-
632
- {/* Progress */}
633
- {execution.status === "Not started" && (
634
- <div className="rounded-2xl border border-amber-200 bg-amber-50 p-4 text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/20 dark:text-amber-200">
635
- <h4 className="text-sm font-semibold">Not started</h4>
636
- <p className="mt-2 text-sm">{execution.notStartedReason}</p>
637
- </div>
638
- )}
639
- {execution.status === "Failed" &&
640
- (execution.failureReason || failedStep) && (
641
- <div className="rounded-2xl border border-rose-200 bg-rose-50 p-4 text-rose-800 dark:border-rose-900/40 dark:bg-rose-950/20 dark:text-rose-200">
642
- <h4 className="text-sm font-semibold tracking-wide uppercase">
643
- Failure
644
- </h4>
645
- <p className="mt-2 text-sm leading-relaxed">
646
- {execution.failureReason ??
647
- failedStep?.failureReason ??
648
- "A system step failed."}
649
- </p>
650
- </div>
651
- )}
652
-
653
- {execution.status === "Abandoned" && (
654
- <div className="rounded-2xl border border-slate-300 bg-slate-100 p-4 text-slate-700 dark:border-slate-600 dark:bg-slate-800/40 dark:text-slate-300">
655
- <h4 className="text-sm font-semibold tracking-wide uppercase">
656
- Abandoned
657
- </h4>
658
- <p className="mt-2 text-sm leading-relaxed">
659
- {execution.abandonedReason || "This execution was abandoned."}
660
- </p>
661
- </div>
662
- )}
663
-
664
- <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-900/60">
665
- <h4 className="text-sm font-semibold tracking-wide text-slate-500 uppercase dark:text-slate-400">
666
- Progress
667
- </h4>
668
- <div className="mt-4 space-y-3">
669
- <div className="flex items-center justify-between text-sm">
670
- <span className="text-slate-600 dark:text-slate-300">
671
- Steps completed
672
- </span>
673
- <span className="font-semibold text-slate-900 dark:text-slate-100">
674
- {execution.completedSteps} / {execution.totalSteps}
675
- </span>
676
- </div>
677
- <div className="h-2 w-full rounded-full bg-slate-200 dark:bg-slate-700">
678
- <div
679
- className="h-2 rounded-full bg-blue-500"
680
- style={{
681
- width: `${execution.totalSteps > 0 ? (execution.completedSteps / execution.totalSteps) * 100 : 0}%`,
682
- }}
683
- />
684
- </div>
685
- </div>
686
- </div>
687
-
688
- {/* Timeline */}
689
- {execution.steps.length > 0 && (
690
- <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-900/60">
691
- <h4 className="text-sm font-semibold tracking-wide text-slate-500 uppercase dark:text-slate-400">
692
- Timeline
693
- </h4>
694
- <ul className="mt-4 space-y-4">
695
- {execution.steps.map((step) => {
696
- const isEmbeddedSubmission =
697
- step.submittedViaEmbeddedForm === true
698
- const hasExternalSubmitterEmail =
699
- step.externalSubmitterEmail != null &&
700
- step.externalSubmitterEmail.length > 0
701
- const showExternalSubmissionInfo =
702
- step.status !== "Correction Required" &&
703
- (isEmbeddedSubmission || hasExternalSubmitterEmail)
704
-
705
- return (
706
- <li key={step.id} className="relative pl-8">
707
- <span
708
- className={cn(
709
- "absolute left-0 top-1.5 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold",
710
- step.status === "Completed"
711
- ? "border-emerald-500 bg-emerald-500 text-white"
712
- : step.status === "Failed"
713
- ? "border-rose-500 bg-rose-500 text-white"
714
- : step.status === "Correction Required"
715
- ? "border-amber-500 bg-amber-500 text-white"
716
- : step.status === "Waiting"
717
- ? "border-blue-500 bg-blue-500 text-white"
718
- : "border-slate-300 bg-white text-slate-400 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-500",
719
- )}
720
- >
721
- {step.status === "Completed"
722
- ? "\u2713"
723
- : step.status === "Failed"
724
- ? "!"
725
- : step.status === "Correction Required"
726
- ? "?"
727
- : step.status === "Waiting"
728
- ? "\u2022"
729
- : ""}
730
- </span>
731
- <div className="flex flex-wrap items-center gap-2">
732
- <p className="text-sm font-semibold text-slate-900 dark:text-slate-100">
733
- {step.name}
734
- </p>
735
- {/* External submissions can have internal roles but external submitters. */}
736
- {showExternalSubmissionInfo ? (
737
- <span className="rounded-full bg-cyan-500/10 px-2 py-0.5 text-[11px] font-semibold text-cyan-700 dark:text-cyan-300">
738
- External Participant
739
- </span>
740
- ) : step.assignedProviderUserEmail ? (
741
- <span className="rounded-full bg-blue-500/10 px-2 py-0.5 text-[11px] font-semibold text-blue-700 dark:text-blue-300">
742
- {step.assignedProviderUserEmail}
743
- </span>
744
- ) : step.role ? (
745
- <span className="rounded-full bg-slate-200 px-2 py-0.5 text-[11px] font-semibold text-slate-600 dark:bg-slate-800/60 dark:text-slate-300">
746
- {step.role.name}
747
- </span>
748
- ) : null}
749
- </div>
750
- {showExternalSubmissionInfo && hasExternalSubmitterEmail ? (
751
- <p className="mt-1 text-[11px] text-slate-500 dark:text-slate-400">
752
- {step.status === "Waiting"
753
- ? "Waiting for"
754
- : isEmbeddedSubmission
755
- ? "Submitted via embedded form by"
756
- : "Submitted by"}{" "}
757
- {step.externalSubmitterEmail}
758
- </p>
759
- ) : isEmbeddedSubmission &&
760
- step.status !== "Waiting" &&
761
- step.status !== "Correction Required" ? (
762
- <p className="mt-1 text-[11px] text-slate-500 dark:text-slate-400">
763
- Submitted via embedded form (no email recorded)
764
- </p>
765
- ) : !showExternalSubmissionInfo && step.providerUser ? (
766
- <p className="mt-1 text-[11px] text-slate-500 dark:text-slate-400">
767
- {step.status === "Completed"
768
- ? "Completed by"
769
- : step.status === "Failed"
770
- ? "Failed at"
771
- : step.status === "Correction Required"
772
- ? "Correction assigned to"
773
- : "Assigned to"}{" "}
774
- {step.providerUser.firstName} {step.providerUser.lastName}
775
- </p>
776
- ) : step.status === "Correction Required" && step.role ? (
777
- <p className="mt-1 text-[11px] text-slate-500 dark:text-slate-400">
778
- Correction assigned to {step.role.name}
779
- </p>
780
- ) : null}
781
- {step.status === "Failed" && step.failureReason && (
782
- <p className="mt-1 text-xs text-rose-700 dark:text-rose-300">
783
- {step.failureReason}
784
- </p>
785
- )}
786
- {step.status === "Not started" && (
787
- <p className="mt-1 text-xs text-amber-700 dark:text-amber-300">
788
- Not started: {step.notStartedReason}
789
- </p>
790
- )}
791
- {step.status === "Correction Required" &&
792
- step.failureReason && (
793
- <p className="mt-1 text-xs text-amber-700 dark:text-amber-300">
794
- {step.failureReason}
795
- </p>
796
- )}
797
- <div className="mt-1 flex flex-wrap items-center gap-3 text-xs text-slate-500 dark:text-slate-400">
798
- {step.startedAt && step.status !== "Not started" && (
799
- <span>Started {formatRelativeTime(step.startedAt)}</span>
800
- )}
801
- {step.completedAt && (
802
- <span>
803
- {step.status === "Not started"
804
- ? `Not started ${formatRelativeTime(step.completedAt)}`
805
- : step.status === "Failed"
806
- ? `Failed ${formatRelativeTime(step.completedAt)}`
807
- : `Completed ${formatRelativeTime(step.completedAt)}`}
808
- </span>
809
- )}
810
- </div>
811
- </li>
812
- )
813
- })}
814
- </ul>
815
- </div>
816
- )}
817
-
818
- {/* Participants and State Snapshot cards */}
819
- <div className="grid gap-4 md:grid-cols-2">
820
- {/* Participants */}
821
- <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-900/60">
822
- <h4 className="text-sm font-semibold tracking-wide text-slate-500 uppercase dark:text-slate-400">
823
- Participants
824
- </h4>
825
- <div className="mt-3 space-y-2">
826
- {providerUsers.map((step) => (
827
- <div
828
- key={step.id}
829
- className="flex items-center justify-between rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300"
830
- >
831
- <span>
832
- {step.providerUser.firstName} {step.providerUser.lastName}
833
- </span>
834
- <span className="text-xs text-slate-500 dark:text-slate-400">
835
- {step.providerUser.orgUnit}
836
- </span>
837
- </div>
838
- ))}
839
- {waitingRoles.map((step) => (
840
- <div
841
- key={step.id}
842
- className="flex items-center justify-between rounded-xl border border-dashed border-slate-300 bg-white px-3 py-2 text-sm text-slate-500 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-400"
843
- >
844
- <span className="italic">
845
- Waiting for{" "}
846
- {step.externalSubmitterEmail ??
847
- step.assignedProviderUserEmail ??
848
- step.role.name}
849
- </span>
850
- </div>
851
- ))}
852
- {providerUsers.length === 0 && waitingRoles.length === 0 && (
853
- <p className="text-sm text-slate-500 dark:text-slate-400">
854
- No participants yet
855
- </p>
856
- )}
857
- </div>
858
- </div>
859
-
860
- {/* State Snapshot */}
861
- <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-900/60">
862
- <h4 className="text-sm font-semibold tracking-wide text-slate-500 uppercase dark:text-slate-400">
863
- State snapshot
864
- </h4>
865
- <dl className="mt-3 grid grid-cols-2 gap-3 text-sm text-slate-600 dark:text-slate-300">
866
- <div>
867
- <dt className="text-xs tracking-wide text-slate-400 uppercase dark:text-slate-500">
868
- {execution.status === "Abandoned"
869
- ? "Abandoned"
870
- : execution.status === "Not started"
871
- ? "Not started"
872
- : execution.finishedAt
873
- ? "Completed"
874
- : "Estimated completion"}
875
- </dt>
876
- <dd>
877
- {execution.finishedAt
878
- ? formatDateTime(execution.finishedAt)
879
- : execution.estimatedCompletionAt
880
- ? formatDateTime(execution.estimatedCompletionAt)
881
- : "N/A"}
882
- </dd>
883
- </div>
884
- <div>
885
- <dt className="text-xs tracking-wide text-slate-400 uppercase dark:text-slate-500">
886
- SLA target
887
- </dt>
888
- <dd>
889
- {execution.slaTargetAt
890
- ? formatDateTime(execution.slaTargetAt)
891
- : "Not set"}
892
- </dd>
893
- </div>
894
- </dl>
895
- </div>
896
- </div>
897
- </div>
898
- )
899
- }
900
-
901
- function MobileExecutionDetail({
902
- execution,
903
- onBack,
904
- }: {
905
- execution: ExecutionData
906
- onBack: () => void
907
- }) {
908
- "use memo"
909
-
910
- const touchStartX = useRef<number | null>(null)
911
- const touchStartY = useRef<number | null>(null)
912
- const touchCurrentX = useRef<number | null>(null)
913
- const touchCurrentY = useRef<number | null>(null)
914
-
915
- const resetSwipe = () => {
916
- touchStartX.current = null
917
- touchStartY.current = null
918
- touchCurrentX.current = null
919
- touchCurrentY.current = null
920
- }
921
-
922
- return (
923
- <div
924
- className="space-y-4"
925
- onTouchStart={(event) => {
926
- const touch = event.touches[0]
927
- if (!touch) return
928
-
929
- touchStartX.current = touch.clientX
930
- touchStartY.current = touch.clientY
931
- touchCurrentX.current = touch.clientX
932
- touchCurrentY.current = touch.clientY
933
- }}
934
- onTouchMove={(event) => {
935
- const touch = event.touches[0]
936
- if (!touch) return
937
-
938
- touchCurrentX.current = touch.clientX
939
- touchCurrentY.current = touch.clientY
940
- }}
941
- onTouchEnd={() => {
942
- if (
943
- touchStartX.current === null ||
944
- touchStartY.current === null ||
945
- touchCurrentX.current === null ||
946
- touchCurrentY.current === null
947
- ) {
948
- resetSwipe()
949
- return
950
- }
951
-
952
- const deltaX = touchCurrentX.current - touchStartX.current
953
- const deltaY = Math.abs(touchCurrentY.current - touchStartY.current)
954
-
955
- resetSwipe()
956
-
957
- if (
958
- deltaX > SWIPE_CLOSE_MIN_PX &&
959
- deltaX > deltaY * SWIPE_CLOSE_HORIZONTAL_RATIO
960
- ) {
961
- onBack()
962
- }
963
- }}
964
- onTouchCancel={resetSwipe}
965
- >
966
- <div className="flex items-center gap-3 rounded-2xl border border-slate-200 bg-white px-3 py-2.5 shadow-sm dark:border-slate-800 dark:bg-slate-900/70">
967
- <button
968
- type="button"
969
- onClick={onBack}
970
- className="inline-flex items-center gap-1 rounded-full px-2 py-1 text-sm font-medium text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-slate-50"
971
- >
972
- <ChevronLeft className="h-4 w-4" />
973
- Back
974
- </button>
975
- <div className="min-w-0">
976
- <p className="text-[11px] font-semibold tracking-[0.18em] text-slate-400 uppercase dark:text-slate-500">
977
- Execution detail
978
- </p>
979
- <p className="truncate text-sm font-semibold text-slate-900 dark:text-slate-100">
980
- {execution.processName}
981
- {execution.withoutWaiting && <WithoutWaitingBadge />}
982
- </p>
983
- </div>
984
- </div>
985
-
986
- <div className="animate-in slide-in-from-right-4 duration-200">
987
- <LiveExecutionDetail execution={execution} />
988
- </div>
989
- </div>
990
- )
991
- }
992
-
993
- // =============================================================================
994
- // MOCK IMPLEMENTATION (for reference)
995
- // =============================================================================
996
-
997
- function MockExecutionsSection() {
998
- const [tab, setTab] = useState<MockExecutionTabKey>("in-progress")
999
- const [view, setView] = useState<MockExecutionView>("timeline")
1000
- const [selectedExecutionId, setSelectedExecutionId] = useState<string | null>(
1001
- mockExecutions[0]?.id ?? null,
1002
- )
1003
-
1004
- const filtered = useMemo(() => {
1005
- const statuses = mockExecutionTabFilters[tab]
1006
- return mockExecutions.filter((exec) => statuses.includes(exec.status))
1007
- }, [tab])
1008
-
1009
- const selectedExecution = useMemo(() => {
1010
- if (filtered.length === 0) return null
1011
- const selected = filtered.find((exec) => exec.id === selectedExecutionId)
1012
- return selected ?? filtered[0] ?? null
1013
- }, [filtered, selectedExecutionId])
1014
-
1015
- return (
1016
- <section className="space-y-6">
1017
- <div className="rounded-2xl border-2 border-amber-500 bg-amber-50 p-2 dark:border-amber-400 dark:bg-amber-900/20">
1018
- <h2 className="mb-4 text-lg font-bold text-amber-700 dark:text-amber-300">
1019
- MOCK DATA (for reference)
1020
- </h2>
1021
- <div className="flex flex-wrap items-center justify-between gap-4 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900/60">
1022
- <div className="flex flex-wrap items-center gap-2">
1023
- <TabPill
1024
- label="In Progress"
1025
- count={
1026
- mockExecutions.filter(
1027
- (exec) =>
1028
- exec.status === "Running" || exec.status === "Paused",
1029
- ).length
1030
- }
1031
- active={tab === "in-progress"}
1032
- onClick={() => setTab("in-progress")}
1033
- />
1034
- <TabPill
1035
- label="Completed"
1036
- count={
1037
- mockExecutions.filter((exec) => exec.status === "Completed")
1038
- .length
1039
- }
1040
- active={tab === "completed"}
1041
- onClick={() => setTab("completed")}
1042
- />
1043
- <TabPill
1044
- label="Failed / Cancelled"
1045
- count={
1046
- mockExecutions.filter((exec) => exec.status === "Failed").length
1047
- }
1048
- active={tab === "failed"}
1049
- onClick={() => setTab("failed")}
1050
- />
1051
- <TabPill
1052
- label="All"
1053
- count={mockExecutions.length}
1054
- active={tab === "all"}
1055
- onClick={() => setTab("all")}
1056
- />
1057
- </div>
1058
- <div className="flex items-center gap-2">
1059
- <button
1060
- type="button"
1061
- onClick={() => setView("timeline")}
1062
- className={cn(
1063
- "rounded-full border px-3 py-1.5 text-sm font-medium",
1064
- view === "timeline"
1065
- ? "border-blue-500 text-blue-600 dark:text-blue-300"
1066
- : "border-slate-200 text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200",
1067
- )}
1068
- >
1069
- Timeline
1070
- </button>
1071
- <button
1072
- type="button"
1073
- onClick={() => setView("kanban")}
1074
- className={cn(
1075
- "rounded-full border px-3 py-1.5 text-sm font-medium",
1076
- view === "kanban"
1077
- ? "border-blue-500 text-blue-600 dark:text-blue-300"
1078
- : "border-slate-200 text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200",
1079
- )}
1080
- >
1081
- Kanban
1082
- </button>
1083
- <button
1084
- type="button"
1085
- className="rounded-full border border-slate-200 px-3 py-1.5 text-sm text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200"
1086
- >
1087
- Export CSV
1088
- </button>
1089
- </div>
1090
- </div>
1091
-
1092
- {filtered.length === 0 ? (
1093
- <EmptyState
1094
- title="No executions in this view"
1095
- description="Adjust filters or start a process from the catalog to see live executions."
1096
- />
1097
- ) : view === "kanban" ? (
1098
- <div className="mt-4">
1099
- <MockExecutionKanban executions={filtered} />
1100
- </div>
1101
- ) : (
1102
- <div className="mt-4 grid gap-6 lg:grid-cols-[380px_1fr]">
1103
- <div className="space-y-3">
1104
- {filtered.map((exec) => (
1105
- <button
1106
- key={exec.id}
1107
- type="button"
1108
- onClick={() => setSelectedExecutionId(exec.id)}
1109
- className={cn(
1110
- "flex w-full flex-col gap-3 rounded-2xl border bg-white p-4 text-left shadow-sm transition hover:-translate-y-0.5 hover:shadow-md dark:border-slate-800 dark:bg-slate-900/70",
1111
- exec.id === selectedExecution?.id
1112
- ? "border-blue-500 dark:border-blue-400 dark:bg-blue-500/10"
1113
- : "border-slate-200",
1114
- )}
1115
- >
1116
- <div className="flex items-center justify-between">
1117
- <h4 className="text-lg font-semibold text-slate-900 dark:text-slate-100">
1118
- {exec.processName} {exec.executionId}
1119
- </h4>
1120
- <span
1121
- className={cn(
1122
- "inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold",
1123
- mockExecutionStatusTheme[exec.status],
1124
- )}
1125
- >
1126
- {exec.status}
1127
- </span>
1128
- </div>
1129
- <p className="text-sm text-slate-500 dark:text-slate-400">
1130
- {exec.progress}
1131
- </p>
1132
- <div className="flex items-center justify-between text-xs text-slate-500 dark:text-slate-400">
1133
- <span>Started {exec.startDate}</span>
1134
- <span>Last activity {exec.lastActivity}</span>
1135
- </div>
1136
- <div className="flex items-center gap-2">
1137
- {exec.participants.map((participant) => (
1138
- <MockAvatar
1139
- key={participant.id}
1140
- name={participant.name}
1141
- title={participant.role}
1142
- />
1143
- ))}
1144
- </div>
1145
- </button>
1146
- ))}
1147
- </div>
1148
- {selectedExecution && (
1149
- <MockExecutionDetail execution={selectedExecution} />
1150
- )}
1151
- </div>
1152
- )}
1153
- </div>
1154
- </section>
1155
- )
1156
- }
1157
-
1158
- function StepParticipants({ steps }: { steps: readonly ExecutionStep[] }) {
1159
- "use memo"
1160
-
1161
- const firstParticipant = steps.find(
1162
- (step) =>
1163
- isExternalParticipantStep(step) ||
1164
- (step.status === "Completed" && step.providerUser != null) ||
1165
- ((step.status === "Waiting" || step.status === "Correction Required") &&
1166
- step.role != null),
1167
- )
1168
-
1169
- if (!firstParticipant) {
1170
- return null
1171
- }
1172
-
1173
- const isExternalParticipant = isExternalParticipantStep(firstParticipant)
1174
-
1175
- return (
1176
- <div className="flex flex-wrap items-center gap-2">
1177
- {isExternalParticipant ? (
1178
- <ExternalParticipantChip
1179
- email={firstParticipant.externalSubmitterEmail}
1180
- />
1181
- ) : firstParticipant.providerUser ? (
1182
- <CompletedProviderUserChip
1183
- firstName={firstParticipant.providerUser.firstName}
1184
- lastName={firstParticipant.providerUser.lastName}
1185
- orgUnit={firstParticipant.providerUser.orgUnit}
1186
- picture={firstParticipant.providerUser.picture}
1187
- />
1188
- ) : firstParticipant.role ? (
1189
- <PendingRoleChip roleName={firstParticipant.role.name} />
1190
- ) : null}
1191
- </div>
1192
- )
1193
- }
1194
-
1195
- function isExternalParticipantStep(step: ExecutionStep) {
1196
- if (step.status === "Correction Required") return false
1197
-
1198
- return (
1199
- step.submittedViaEmbeddedForm === true ||
1200
- (step.externalSubmitterEmail != null &&
1201
- step.externalSubmitterEmail.length > 0)
1202
- )
1203
- }
1204
-
1205
- function ExternalParticipantChip({ email }: { email: string | undefined }) {
1206
- "use memo"
1207
-
1208
- return (
1209
- <div className="flex items-center gap-2 rounded-full border border-cyan-400/50 bg-cyan-400/10 py-1 pl-2 pr-3 text-xs text-cyan-700 dark:border-cyan-400/30 dark:bg-cyan-400/10 dark:text-cyan-200">
1210
- <span className="flex h-7 w-7 items-center justify-center rounded-full bg-cyan-500 text-[10px] font-bold tracking-wide text-slate-950">
1211
- EXT
1212
- </span>
1213
- <div>
1214
- <p className="font-semibold">External Participant</p>
1215
- <p className="text-[11px] text-cyan-800/80 dark:text-cyan-200/80">
1216
- {email ?? "Embedded form"}
1217
- </p>
1218
- </div>
1219
- </div>
1220
- )
1221
- }
1222
-
1223
- function CompletedProviderUserChip({
1224
- firstName,
1225
- lastName,
1226
- orgUnit,
1227
- picture,
1228
- }: {
1229
- firstName: string
1230
- lastName: string
1231
- orgUnit: string
1232
- picture?: string
1233
- }) {
1234
- "use memo"
1235
-
1236
- const initials = `${firstName.charAt(0)}${lastName.charAt(0)}`.toUpperCase()
1237
- return (
1238
- <div className="flex items-center gap-2 rounded-full border border-slate-200 bg-slate-50 py-1 pl-2 pr-3 text-xs dark:border-slate-700 dark:bg-slate-800/60">
1239
- {picture ? (
1240
- <Image
1241
- src={picture}
1242
- alt={`${firstName} ${lastName}`}
1243
- width={28}
1244
- height={28}
1245
- className="h-7 w-7 rounded-full"
1246
- />
1247
- ) : (
1248
- <span className="flex h-7 w-7 items-center justify-center rounded-full bg-emerald-600 text-[11px] font-semibold text-white">
1249
- {initials}
1250
- </span>
1251
- )}
1252
- <div>
1253
- <p className="font-semibold text-slate-700 dark:text-slate-200">
1254
- {firstName}
1255
- <br />
1256
- {lastName}
1257
- </p>
1258
- <p className="text-[11px] text-slate-500 dark:text-slate-400">
1259
- {orgUnit}
1260
- </p>
1261
- </div>
1262
- </div>
1263
- )
1264
- }
1265
-
1266
- function PendingRoleChip({ roleName }: { roleName: string }) {
1267
- "use memo"
1268
-
1269
- return (
1270
- <div className="flex items-center gap-2 rounded-full border border-slate-200 bg-slate-50 py-1 pl-2 pr-3 text-xs dark:border-slate-700 dark:bg-slate-800/60">
1271
- <span className="flex h-7 w-7 items-center justify-center rounded-full border-2 border-blue-500 text-[11px] font-semibold text-blue-500">
1272
- ?
1273
- </span>
1274
- <div>
1275
- <p className="font-semibold text-slate-700 dark:text-slate-200">
1276
- {roleName}
1277
- </p>
1278
- </div>
1279
- </div>
1280
- )
1281
- }
1282
-
1283
- function MockAvatar({ name, title }: { name: string; title: string }) {
1284
- const initials = name
1285
- .split(" ")
1286
- .map((part) => part[0])
1287
- .join("")
1288
- .slice(0, 2)
1289
- .toUpperCase()
1290
- return (
1291
- <div className="flex items-center gap-2 rounded-full border border-slate-200 bg-slate-50 px-2 py-1 text-xs dark:border-slate-700 dark:bg-slate-800/60">
1292
- <span className="flex h-7 w-7 items-center justify-center rounded-full bg-blue-600 text-[11px] font-semibold text-white">
1293
- {initials}
1294
- </span>
1295
- <div>
1296
- <p className="font-semibold text-slate-700 dark:text-slate-200">
1297
- {name}
1298
- </p>
1299
- <p className="text-[11px] text-slate-500 dark:text-slate-400">
1300
- {title}
1301
- </p>
1302
- </div>
1303
- </div>
1304
- )
1305
- }
1306
-
1307
- function MockExecutionDetail({ execution }: { execution: Execution }) {
1308
- return (
1309
- <div className="flex flex-col gap-4 rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-900/70">
1310
- <div className="flex flex-wrap items-start justify-between gap-3">
1311
- <div>
1312
- <h3 className="text-2xl font-semibold text-slate-900 dark:text-slate-100">
1313
- {execution.processName} {execution.executionId}
1314
- </h3>
1315
- <p className="text-sm text-slate-500 dark:text-slate-400">
1316
- Started {execution.startDate}. Current assignee{" "}
1317
- {execution.currentRole ? `${execution.currentRole}` : "N/A"}.
1318
- </p>
1319
- </div>
1320
- <div className="flex items-center gap-2">
1321
- <span
1322
- className={cn(
1323
- "inline-flex items-center rounded-full px-3 py-1 text-sm font-semibold",
1324
- mockExecutionStatusTheme[execution.status],
1325
- )}
1326
- >
1327
- {execution.status}
1328
- </span>
1329
- <button
1330
- type="button"
1331
- className="rounded-full border border-slate-200 px-3 py-1.5 text-sm text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-slate-200"
1332
- >
1333
- Share
1334
- </button>
1335
- <button
1336
- type="button"
1337
- className="rounded-full bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-blue-500"
1338
- >
1339
- View audit log
1340
- </button>
1341
- </div>
1342
- </div>
1343
- <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-900/60">
1344
- <h4 className="text-sm font-semibold tracking-wide text-slate-500 uppercase dark:text-slate-400">
1345
- Timeline
1346
- </h4>
1347
- <ul className="mt-4 space-y-4">
1348
- {execution.steps.map((step) => (
1349
- <li key={step.id} className="relative pl-8">
1350
- <span
1351
- className={cn(
1352
- "absolute left-0 top-1.5 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold",
1353
- step.status === "Complete"
1354
- ? "border-emerald-500 bg-emerald-500 text-white"
1355
- : step.status === "Current"
1356
- ? "border-blue-500 bg-blue-500 text-white"
1357
- : step.status === "Upcoming"
1358
- ? "border-slate-300 bg-white text-slate-400 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-500"
1359
- : "border-slate-300 bg-slate-100 text-slate-400",
1360
- )}
1361
- >
1362
- {step.status === "Complete"
1363
- ? "✓"
1364
- : step.status === "Current"
1365
- ? "•"
1366
- : ""}
1367
- </span>
1368
- <div className="flex flex-wrap items-center gap-2">
1369
- <p className="text-sm font-semibold text-slate-900 dark:text-slate-100">
1370
- {step.name}
1371
- </p>
1372
- <span className="rounded-full bg-slate-200 px-2 py-0.5 text-[11px] font-semibold text-slate-600 dark:bg-slate-800/60 dark:text-slate-300">
1373
- {step.role}
1374
- </span>
1375
- {step.assignee && (
1376
- <span className="text-[11px] text-slate-500 dark:text-slate-400">
1377
- Assigned to {step.assignee}
1378
- </span>
1379
- )}
1380
- </div>
1381
- <div className="mt-1 flex flex-wrap items-center gap-3 text-xs text-slate-500 dark:text-slate-400">
1382
- {step.startedAt && <span>Started {step.startedAt}</span>}
1383
- {step.completedAt && <span>Completed {step.completedAt}</span>}
1384
- {step.notes && (
1385
- <span className="rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-amber-600 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200">
1386
- {step.notes}
1387
- </span>
1388
- )}
1389
- </div>
1390
- </li>
1391
- ))}
1392
- </ul>
1393
- </div>
1394
- {execution.failureReason && (
1395
- <div className="rounded-2xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700 dark:border-rose-500/40 dark:bg-rose-900/20 dark:text-rose-200">
1396
- <p className="font-semibold">Failure reason</p>
1397
- <p>{execution.failureReason}</p>
1398
- </div>
1399
- )}
1400
- {execution.abandonedReason && (
1401
- <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4 text-sm text-slate-700 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-200">
1402
- <p className="font-semibold">Abandoned reason</p>
1403
- <p>{execution.abandonedReason}</p>
1404
- </div>
1405
- )}
1406
- <div className="grid gap-4 md:grid-cols-2">
1407
- <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-900/60">
1408
- <h4 className="text-sm font-semibold tracking-wide text-slate-500 uppercase dark:text-slate-400">
1409
- Participants
1410
- </h4>
1411
- <div className="mt-3 space-y-2">
1412
- {execution.participants.map((participant) => (
1413
- <div
1414
- key={participant.id}
1415
- className="flex items-center justify-between rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300"
1416
- >
1417
- <span>{participant.name}</span>
1418
- <span className="text-xs text-slate-500 dark:text-slate-400">
1419
- {participant.role}
1420
- </span>
1421
- </div>
1422
- ))}
1423
- </div>
1424
- </div>
1425
- <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-900/60">
1426
- <h4 className="text-sm font-semibold tracking-wide text-slate-500 uppercase dark:text-slate-400">
1427
- State snapshot
1428
- </h4>
1429
- <dl className="mt-3 grid grid-cols-2 gap-3 text-sm text-slate-600 dark:text-slate-300">
1430
- <div>
1431
- <dt className="text-xs tracking-wide text-slate-400 uppercase dark:text-slate-500">
1432
- Estimated completion
1433
- </dt>
1434
- <dd>In 2 days</dd>
1435
- </div>
1436
- <div>
1437
- <dt className="text-xs tracking-wide text-slate-400 uppercase dark:text-slate-500">
1438
- SLA target
1439
- </dt>
1440
- <dd>Oct 16, 18:00</dd>
1441
- </div>
1442
- <div>
1443
- <dt className="text-xs tracking-wide text-slate-400 uppercase dark:text-slate-500">
1444
- Current form
1445
- </dt>
1446
- <dd>IT account setup</dd>
1447
- </div>
1448
- <div>
1449
- <dt className="text-xs tracking-wide text-slate-400 uppercase dark:text-slate-500">
1450
- Pending approvals
1451
- </dt>
1452
- <dd>1 manager</dd>
1453
- </div>
1454
- </dl>
1455
- </div>
1456
- </div>
1457
- </div>
1458
- )
1459
- }
1460
-
1461
- function MockExecutionKanban({ executions }: { executions: Execution[] }) {
1462
- const columns: { title: string; statuses: Execution["status"][] }[] = [
1463
- { title: "Running", statuses: ["Running", "Paused"] },
1464
- { title: "Completed", statuses: ["Completed"] },
1465
- { title: "Failed", statuses: ["Failed"] },
1466
- ]
1467
-
1468
- return (
1469
- <div className="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
1470
- {columns.map((column) => (
1471
- <div
1472
- key={column.title}
1473
- className="rounded-2xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900/70"
1474
- >
1475
- <div className="flex items-center justify-between">
1476
- <h4 className="text-lg font-semibold text-slate-900 dark:text-slate-100">
1477
- {column.title}
1478
- </h4>
1479
- <span className="rounded-full bg-slate-200 px-2 py-0.5 text-xs font-semibold text-slate-600 dark:bg-slate-800 dark:text-slate-300">
1480
- {
1481
- executions.filter((exec) =>
1482
- column.statuses.includes(exec.status),
1483
- ).length
1484
- }
1485
- </span>
1486
- </div>
1487
- <div className="mt-3 space-y-3">
1488
- {executions
1489
- .filter((exec) => column.statuses.includes(exec.status))
1490
- .map((exec) => (
1491
- <div
1492
- key={exec.id}
1493
- className="rounded-2xl border border-slate-200 bg-slate-50/60 p-3 text-sm text-slate-600 shadow-sm dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300"
1494
- >
1495
- <div className="flex items-center justify-between">
1496
- <p className="font-semibold text-slate-900 dark:text-slate-100">
1497
- {exec.processName} {exec.executionId}
1498
- </p>
1499
- <span
1500
- className={cn(
1501
- "inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-semibold",
1502
- mockExecutionStatusTheme[exec.status],
1503
- )}
1504
- >
1505
- {exec.status}
1506
- </span>
1507
- </div>
1508
- <p className="text-xs text-slate-500 dark:text-slate-400">
1509
- {exec.progress}
1510
- </p>
1511
- <div className="mt-2 flex items-center justify-between text-[11px] text-slate-500 dark:text-slate-400">
1512
- <span>{exec.startDate}</span>
1513
- <span>{exec.lastActivity}</span>
1514
- </div>
1515
- </div>
1516
- ))}
1517
- {executions.filter((exec) => column.statuses.includes(exec.status))
1518
- .length === 0 && (
1519
- <div className="rounded-xl border border-dashed border-slate-300 p-4 text-center text-sm text-slate-500 dark:border-slate-700 dark:text-slate-400">
1520
- No executions here yet
1521
- </div>
1522
- )}
1523
- </div>
1524
- </div>
1525
- ))}
1526
- </div>
1527
- )
1528
- }
1529
-
1530
- // =============================================================================
1531
- // SHARED COMPONENTS
1532
- // =============================================================================
1533
-
1534
- export function ExecutionsPageContent({
1535
- initialSelectedExecutionId = null,
1536
- onMobileBack,
1537
- }: {
1538
- initialSelectedExecutionId?: string | null
1539
- onMobileBack?: () => void
1540
- }) {
1541
- "use memo"
1542
-
1543
- const { collectionPromise } = useExecutionCollection()
1544
- const { showMocks } = useMocks()
1545
- const isMobile = useIsMobile()
1546
- const showMocksSection = !isMobile || initialSelectedExecutionId === null
1547
-
1548
- return (
1549
- <div className="flex-1 space-y-8 overflow-y-auto">
1550
- <Suspense fallback={<ExecutionsSkeleton />}>
1551
- <ExecutionsPageInner
1552
- collectionPromise={collectionPromise}
1553
- initialSelectedExecutionId={initialSelectedExecutionId}
1554
- {...(onMobileBack ? { onMobileBack } : {})}
1555
- />
1556
- </Suspense>
1557
- {showMocks && showMocksSection && <MockExecutionsSection />}
1558
- </div>
1559
- )
1560
- }
1561
-
1562
- export default function ExecutionsPage() {
1563
- return <ExecutionsPageContent />
1564
- }
1565
-
1566
- function EmptyState({
1567
- title,
1568
- description,
1569
- }: {
1570
- title: string
1571
- description: string
1572
- }) {
1573
- "use memo"
1574
-
1575
- return (
1576
- <div className="col-span-full flex flex-col items-center justify-center rounded-3xl border border-dashed border-slate-300 bg-white/60 p-12 text-center dark:border-slate-700 dark:bg-slate-900/40">
1577
- <h3 className="text-lg font-semibold text-slate-900 dark:text-slate-100">
1578
- {title}
1579
- </h3>
1580
- <p className="mt-2 max-w-md text-sm text-slate-500 dark:text-slate-400">
1581
- {description}
1582
- </p>
1583
- <Link
1584
- href="/processes"
1585
- className="mt-5 rounded-full bg-blue-600 px-5 py-2 text-sm font-semibold text-white shadow hover:bg-blue-500"
1586
- >
1587
- Browse processes
1588
- </Link>
1589
- </div>
1590
- )
1591
- }
6
+ export default ExecutionsPage