@arbidocs/blocks 0.4.75 → 0.4.77
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/dist/agents/index.cjs +341 -253
- package/dist/agents/index.js +3 -3
- package/dist/agents/tasks/TaskActivityTimeline.d.ts +1 -1
- package/dist/agents/tasks/WorkflowThreadStrip.d.ts +44 -1
- package/dist/agents/tasks/index.d.ts +2 -1
- package/dist/agents/tasks/linkedRuns.d.ts +31 -0
- package/dist/agents/workflows/SchemaForm.d.ts +6 -1
- package/dist/agents/workflows/StepParts.d.ts +109 -0
- package/dist/agents/workflows/WorkflowRunner.d.ts +11 -2
- package/dist/agents/workflows/index.d.ts +3 -2
- package/dist/agents/workflows/planSteps.d.ts +10 -1
- package/dist/agents/workflows/run.d.ts +61 -8
- package/dist/agents/workflows/types.d.ts +160 -4
- package/dist/agents/workflows/useWorkflowPreview.d.ts +2 -1
- package/dist/agents/workflows/useWorkflowView.d.ts +19 -0
- package/dist/chat/ChatPage.d.ts +1 -1
- package/dist/chat/WorkflowStepChip.d.ts +24 -0
- package/dist/chat/chat-page-types.d.ts +4 -0
- package/dist/chat/index.cjs +130 -122
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/index.js +2 -2
- package/dist/{chunk-YWYVIQ7T.js → chunk-34UW6XUQ.js} +948 -38
- package/dist/chunk-34UW6XUQ.js.map +1 -0
- package/dist/{chunk-P2RBE3FD.cjs → chunk-3XR3IEGU.cjs} +965 -35
- package/dist/chunk-3XR3IEGU.cjs.map +1 -0
- package/dist/{chunk-ZWA7UUZL.cjs → chunk-7YUFMNFW.cjs} +2 -54
- package/dist/chunk-7YUFMNFW.cjs.map +1 -0
- package/dist/chunk-A24C6BNA.js +92 -0
- package/dist/chunk-A24C6BNA.js.map +1 -0
- package/dist/chunk-AINNADMT.cjs +62 -0
- package/dist/chunk-AINNADMT.cjs.map +1 -0
- package/dist/{chunk-7CVF3DK2.cjs → chunk-EKIUMNCN.cjs} +5 -5
- package/dist/{chunk-7CVF3DK2.cjs.map → chunk-EKIUMNCN.cjs.map} +1 -1
- package/dist/chunk-FE4ULGOR.js +151 -0
- package/dist/chunk-FE4ULGOR.js.map +1 -0
- package/dist/chunk-FT5FFXSJ.js +60 -0
- package/dist/chunk-FT5FFXSJ.js.map +1 -0
- package/dist/{chunk-HITAN7JF.cjs → chunk-GTXOV7IJ.cjs} +4 -4
- package/dist/{chunk-HITAN7JF.cjs.map → chunk-GTXOV7IJ.cjs.map} +1 -1
- package/dist/{chunk-LT2UORRG.js → chunk-HEVVT6IT.js} +205 -38
- package/dist/chunk-HEVVT6IT.js.map +1 -0
- package/dist/{chunk-IPGKTUF7.cjs → chunk-HOD6OM7L.cjs} +68 -3
- package/dist/chunk-HOD6OM7L.cjs.map +1 -0
- package/dist/{chunk-F4LUD3YC.cjs → chunk-JFUN4D7D.cjs} +229 -60
- package/dist/chunk-JFUN4D7D.cjs.map +1 -0
- package/dist/{chunk-UIWLDSTF.js → chunk-NIP5BOP7.js} +68 -5
- package/dist/chunk-NIP5BOP7.js.map +1 -0
- package/dist/{chunk-MK6NJQGF.js → chunk-OEM5ARVM.js} +3 -3
- package/dist/{chunk-MK6NJQGF.js.map → chunk-OEM5ARVM.js.map} +1 -1
- package/dist/{chunk-5EBGRG3X.js → chunk-OPA2Y6YZ.js} +3 -54
- package/dist/chunk-OPA2Y6YZ.js.map +1 -0
- package/dist/chunk-TZR36PPP.cjs +95 -0
- package/dist/chunk-TZR36PPP.cjs.map +1 -0
- package/dist/{chunk-WJEKRSPH.js → chunk-UEU23PTW.js} +3 -3
- package/dist/{chunk-WJEKRSPH.js.map → chunk-UEU23PTW.js.map} +1 -1
- package/dist/chunk-ZVBPRMHJ.cjs +153 -0
- package/dist/chunk-ZVBPRMHJ.cjs.map +1 -0
- package/dist/connect/docx.cjs +10 -88
- package/dist/connect/docx.cjs.map +1 -1
- package/dist/connect/docx.js +6 -86
- package/dist/connect/docx.js.map +1 -1
- package/dist/connect/index.cjs +295 -32
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.js +280 -17
- package/dist/connect/index.js.map +1 -1
- package/dist/connection/ConnectedWorkflowRunner.d.ts +16 -2
- package/dist/connection/WorkflowRunnerDialogs.d.ts +37 -0
- package/dist/connection/useWorkflowThread.d.ts +12 -0
- package/dist/document-tools/index.cjs +7 -143
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.js +5 -144
- package/dist/document-tools/index.js.map +1 -1
- package/dist/docx/index.cjs +18 -17
- package/dist/docx/index.cjs.map +1 -1
- package/dist/docx/index.js +3 -2
- package/dist/docx/index.js.map +1 -1
- package/dist/facts/index.cjs +1 -1
- package/dist/facts/index.js +1 -1
- package/dist/files/index.cjs +1 -1
- package/dist/files/index.js +1 -1
- package/dist/home/index.cjs +1 -1
- package/dist/home/index.js +1 -1
- package/dist/index.cjs +631 -535
- package/dist/index.js +8 -8
- package/dist/settings/index.cjs +1 -1
- package/dist/settings/index.js +1 -1
- package/dist/shell/index.cjs +1 -1
- package/dist/shell/index.js +1 -1
- package/dist/studio/index.cjs +4 -4
- package/dist/studio/index.js +3 -3
- package/dist/workflow-canvas/SignalsEditor.d.ts +41 -0
- package/dist/workflow-canvas/StepActionSettings.d.ts +132 -0
- package/dist/workflow-canvas/StepInspector.d.ts +28 -2
- package/dist/workflow-canvas/TriggerInspector.d.ts +11 -2
- package/dist/workflow-canvas/WorkflowBuilder.d.ts +17 -4
- package/dist/workflow-canvas/WorkflowCanvas.d.ts +27 -2
- package/dist/workflow-canvas/edit.d.ts +9 -1
- package/dist/workflow-canvas/index.cjs +1282 -208
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/dist/workflow-canvas/index.d.ts +2 -1
- package/dist/workflow-canvas/index.js +1255 -188
- package/dist/workflow-canvas/index.js.map +1 -1
- package/dist/workflow-canvas/trigger.d.ts +20 -1
- package/package.json +4 -4
- package/src/workflow-canvas/canvas.css +9 -0
- package/dist/chunk-5EBGRG3X.js.map +0 -1
- package/dist/chunk-F4LUD3YC.cjs.map +0 -1
- package/dist/chunk-IPGKTUF7.cjs.map +0 -1
- package/dist/chunk-LT2UORRG.js.map +0 -1
- package/dist/chunk-P2RBE3FD.cjs.map +0 -1
- package/dist/chunk-UIWLDSTF.js.map +0 -1
- package/dist/chunk-YWYVIQ7T.js.map +0 -1
- package/dist/chunk-ZWA7UUZL.cjs.map +0 -1
package/dist/connect/index.js
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { SettingsSection, ProfileCard, AvatarPicker, IdentityVerificationCard, IdentityVerificationDialog, RequireVerified, SettingsCard, SettingsActionRow, PasswordChangeDialog, EMAIL_NOTIFICATION_KEYS, EMAIL_NOTIFICATION_CATEGORIES, NotificationCategoryList, toNotificationCategories, toActiveSessionViews, SettingsRow, ActiveSessionsDialog, LogoutDialog, toLogoutSessionViews, SettingsDangerZone, DeleteAccountDialog, toDeleteBlockerViews } from '../chunk-GJV2G4FC.js';
|
|
3
|
-
import { useWorkspaceDocs } from '../chunk-
|
|
4
|
-
export { ConnectedAssistantDock, redlineStats, textToArtifact, toRedlineMarkdown, useConnectedAiTask, useConnectedChat, useSemanticSearch, useWorkspaceDocs } from '../chunk-
|
|
3
|
+
import { useWorkspaceDocs } from '../chunk-OEM5ARVM.js';
|
|
4
|
+
export { ConnectedAssistantDock, redlineStats, textToArtifact, toRedlineMarkdown, useConnectedAiTask, useConnectedChat, useSemanticSearch, useWorkspaceDocs } from '../chunk-OEM5ARVM.js';
|
|
5
|
+
import { ConnectedNativeDocxEditor } from '../chunk-A24C6BNA.js';
|
|
5
6
|
import { ConnectionProvider, useConnection } from '../chunk-OYMWV45N.js';
|
|
6
7
|
export { ConnectionProvider, SESSION_EXPIRED_MESSAGE, isAuthenticated, useConnection } from '../chunk-OYMWV45N.js';
|
|
7
|
-
import {
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import { WorkflowRunner, initialRunInputs, workflowSteps, fromPlanSteps, stepStatesFromActivity, toPlanSteps, runThreadTitle, useWorkflowView } from '../chunk-
|
|
8
|
+
import { SignDocumentDialog } from '../chunk-FE4ULGOR.js';
|
|
9
|
+
import '../chunk-OPA2Y6YZ.js';
|
|
10
|
+
import { splitDocRef, WorkflowRunner, initialRunInputs, workflowSteps, fromPlanSteps, stepStatesFromActivity, toPlanSteps, runThreadTitle, useWorkflowView, stepFields } from '../chunk-34UW6XUQ.js';
|
|
10
11
|
import '../chunk-EVUEIBNU.js';
|
|
11
12
|
import '../chunk-XD2M6LIG.js';
|
|
12
|
-
import {
|
|
13
|
+
import { StreamedArtifactFrame } from '../chunk-LOJVUGBJ.js';
|
|
14
|
+
import '../chunk-VILAPTCB.js';
|
|
15
|
+
import { ChatPage } from '../chunk-NIP5BOP7.js';
|
|
13
16
|
import '../chunk-KZJAG7T3.js';
|
|
14
17
|
import '../chunk-HOXKR26S.js';
|
|
15
18
|
import '../chunk-AA3PT6KR.js';
|
|
16
19
|
import '../chunk-NPLYHR2E.js';
|
|
17
20
|
import { initials } from '../chunk-OXF2IFXG.js';
|
|
18
|
-
import '../chunk-TX2ZICS7.js';
|
|
21
|
+
import { ModalScaffold } from '../chunk-TX2ZICS7.js';
|
|
19
22
|
import '../chunk-7F6CBP3Z.js';
|
|
20
23
|
import '../chunk-VUNV25KB.js';
|
|
21
|
-
import { lazy, useState, Suspense,
|
|
24
|
+
import { lazy, useState, Suspense, useRef, useCallback, useMemo, useEffect } from 'react';
|
|
22
25
|
import { QueryClient, QueryClientProvider, useQueryClient, useQuery } from '@tanstack/react-query';
|
|
23
|
-
import { ArbiProvider, useConversations, useRunConversation, useUploadSkillFiles, ArtifactCanvas, useArbi, useDocuments, useWorkspaceUsers, useWorkspaces, useShellWorkspaces, useProfile, useUpdateProfile, useRequestEmailChange, useConfirmEmailChange, useNameEditor, useAvatarCrop, useEmailChange, ImageCropModal, useIdentityVerification, usePasswordChange, usePasswordChangeForm, useNotificationPreferences, useSessions, useCurrentSessionId, useTerminateSession, useLogoutAllSessions, useDeleteAccount, useDeleteAccountFlow, useArbiWebSocket, notify, useWorkNotifications, useAgentSession, useStartAgentSession, useCloseAgentSession, AiAnswer, ArbiWebSocketProvider, useCreateWork, useActOnStep, useConversationActivity, useConversationThreads, useArbiChat } from '@arbidocs/react';
|
|
26
|
+
import { ArbiProvider, useConversations, useRunConversation, useUploadSkillFiles, ArtifactCanvas, useArbi, useDocuments, useWorkspaceUsers, useWorkspaces, useShellWorkspaces, useProfile, useUpdateProfile, useRequestEmailChange, useConfirmEmailChange, useNameEditor, useAvatarCrop, useEmailChange, ImageCropModal, useIdentityVerification, usePasswordChange, usePasswordChangeForm, useNotificationPreferences, useSessions, useCurrentSessionId, useTerminateSession, useLogoutAllSessions, useDeleteAccount, useDeleteAccountFlow, useArbiWebSocket, notify, useWorkNotifications, useAgentSession, useStartAgentSession, useCloseAgentSession, AiAnswer, ArbiWebSocketProvider, useCreateWork, useActOnStep, useConversationActivity, useConversationThreads, useTags, useArbiChat } from '@arbidocs/react';
|
|
24
27
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
25
28
|
import { Button, Label, Input, cn } from '@arbidocs/react/ui';
|
|
26
29
|
import { useStreamedArtifact } from '@arbidocs/react/artifacts';
|
|
27
30
|
import { ExternalLink, UserCircle, KeyRound, Radio, Loader2 } from 'lucide-react';
|
|
31
|
+
import { useOptionalDocumentTools, DocumentToolsProvider } from '@arbidocs/react/document-tools';
|
|
28
32
|
import { useNotify } from '@arbidocs/react/shell';
|
|
29
33
|
|
|
30
34
|
function ConnectionBoundWebSocket({ children }) {
|
|
@@ -185,8 +189,15 @@ function StreamedArtifact({
|
|
|
185
189
|
}
|
|
186
190
|
var STARTING = /* @__PURE__ */ new Set(["pending", "running"]);
|
|
187
191
|
function formValues(step, inputs) {
|
|
188
|
-
|
|
189
|
-
|
|
192
|
+
const fields = stepFields(step);
|
|
193
|
+
if (!fields.length) return void 0;
|
|
194
|
+
if (step.kind === "form")
|
|
195
|
+
return Object.fromEntries(fields.map((f) => [f.name, inputs[f.name] ?? ""]));
|
|
196
|
+
const given = fields.flatMap((f) => {
|
|
197
|
+
const v = inputs[f.name];
|
|
198
|
+
return v === void 0 || v === "" ? [] : [[f.name, v]];
|
|
199
|
+
});
|
|
200
|
+
return given.length ? Object.fromEntries(given) : void 0;
|
|
190
201
|
}
|
|
191
202
|
var ANSWER_RETRY_CAP = 16;
|
|
192
203
|
function answerRetryDelay(attempt) {
|
|
@@ -212,7 +223,7 @@ function useAnswerRetry(missing, refetch) {
|
|
|
212
223
|
}
|
|
213
224
|
function useWorkflowThread(workflow, options = {}) {
|
|
214
225
|
const arbi = useArbi();
|
|
215
|
-
const { ensureWorkspaceOpen } = useConnection();
|
|
226
|
+
const { ensureWorkspaceOpen, status } = useConnection();
|
|
216
227
|
const { wsId } = useWorkspaceDocs();
|
|
217
228
|
const [threadId, setThreadId] = useState(options.conversationId);
|
|
218
229
|
const [localInputs, setLocalInputs] = useState(
|
|
@@ -223,6 +234,17 @@ function useWorkflowThread(workflow, options = {}) {
|
|
|
223
234
|
const createWork = useCreateWork();
|
|
224
235
|
const actOnStep = useActOnStep();
|
|
225
236
|
const conversations = useConversations(wsId, { enabled: !!threadId, live: true });
|
|
237
|
+
const members = useWorkspaceUsers(wsId, {
|
|
238
|
+
enabled: status === "authenticated" && !!wsId,
|
|
239
|
+
beforeFetch: ensureWorkspaceOpen
|
|
240
|
+
});
|
|
241
|
+
const nameOf = useCallback(
|
|
242
|
+
(id) => {
|
|
243
|
+
const u = members.data?.find((m) => m.user.external_id === id)?.user;
|
|
244
|
+
return u ? [u.given_name, u.family_name].filter(Boolean).join(" ") || u.email : void 0;
|
|
245
|
+
},
|
|
246
|
+
[members.data]
|
|
247
|
+
);
|
|
226
248
|
const conversation = conversations.data?.find((c) => c.external_id === threadId);
|
|
227
249
|
const steps = useMemo(
|
|
228
250
|
() => workflowSteps(workflow).length > 0 ? workflowSteps(workflow) : fromPlanSteps(conversation?.plan?.steps ?? []),
|
|
@@ -234,7 +256,7 @@ function useWorkflowThread(workflow, options = {}) {
|
|
|
234
256
|
[activity.data]
|
|
235
257
|
);
|
|
236
258
|
const working = steps.some(
|
|
237
|
-
(s) => s.kind === "agent" && STARTING.has(serverStates[s.id]?.status ?? "pending")
|
|
259
|
+
(s) => (s.kind === "agent" || s.kind === "action") && STARTING.has(serverStates[s.id]?.status ?? "pending")
|
|
238
260
|
);
|
|
239
261
|
const threads = useConversationThreads(wsId, threadId, { enabled: !!threadId, live: working });
|
|
240
262
|
const answers = useMemo(() => {
|
|
@@ -306,7 +328,13 @@ function useWorkflowThread(workflow, options = {}) {
|
|
|
306
328
|
setLocalStates((s) => ({ ...s, [step.id]: { status: "done" } }));
|
|
307
329
|
options.onStarted?.(id);
|
|
308
330
|
}
|
|
309
|
-
|
|
331
|
+
const documents = step.kind === "upload" ? options.documentsFor?.(step.id) : void 0;
|
|
332
|
+
await act(id, {
|
|
333
|
+
step: step.id,
|
|
334
|
+
action: "complete",
|
|
335
|
+
inputs: formValues(step, values),
|
|
336
|
+
...documents?.length ? { documents } : {}
|
|
337
|
+
});
|
|
310
338
|
},
|
|
311
339
|
[inputs, options, localStates, threadId, ensureWorkspaceOpen, createWork, workflow, act]
|
|
312
340
|
);
|
|
@@ -328,6 +356,21 @@ function useWorkflowThread(workflow, options = {}) {
|
|
|
328
356
|
},
|
|
329
357
|
[arbi, threadId, refresh]
|
|
330
358
|
);
|
|
359
|
+
const sendBack = useCallback(
|
|
360
|
+
async (stepId, to, note) => {
|
|
361
|
+
if (!threadId) return;
|
|
362
|
+
await act(threadId, { step: stepId, action: "send_back", to, ...note ? { note } : {} });
|
|
363
|
+
},
|
|
364
|
+
[threadId, act]
|
|
365
|
+
);
|
|
366
|
+
const decline = useCallback(
|
|
367
|
+
async (stepId, note) => {
|
|
368
|
+
if (!threadId) return;
|
|
369
|
+
await act(threadId, { step: stepId, action: "decline", ...note ? { note } : {} });
|
|
370
|
+
},
|
|
371
|
+
[threadId, act]
|
|
372
|
+
);
|
|
373
|
+
const loaded = !options.conversationId || activity.isSuccess || activity.isError;
|
|
331
374
|
const view = useWorkflowView({
|
|
332
375
|
steps,
|
|
333
376
|
states,
|
|
@@ -336,9 +379,171 @@ function useWorkflowThread(workflow, options = {}) {
|
|
|
336
379
|
complete,
|
|
337
380
|
skip,
|
|
338
381
|
retry,
|
|
382
|
+
sendBack,
|
|
383
|
+
decline,
|
|
384
|
+
nameOf,
|
|
385
|
+
loaded,
|
|
339
386
|
isLocked: (id) => states[id]?.status === "done"
|
|
340
387
|
});
|
|
341
|
-
|
|
388
|
+
const people = useMemo(
|
|
389
|
+
() => (members.data ?? []).filter((m) => !m.user.external_id.startsWith("agt-")).map((m) => ({
|
|
390
|
+
value: m.user.external_id,
|
|
391
|
+
label: nameOf(m.user.external_id) ?? m.user.external_id
|
|
392
|
+
})),
|
|
393
|
+
[members.data, nameOf]
|
|
394
|
+
);
|
|
395
|
+
return { view, conversationId: threadId, conversation, nameOf, people };
|
|
396
|
+
}
|
|
397
|
+
var DEFAULT_WORKFLOW_RUNNER_DIALOG_LABELS = {
|
|
398
|
+
loadingDocument: "Opening the document\u2026",
|
|
399
|
+
documentFailed: "The document could not be opened.",
|
|
400
|
+
reviewTitle: "Review",
|
|
401
|
+
reviewDescription: "Each document against each review column.",
|
|
402
|
+
document: "Document",
|
|
403
|
+
empty: "\u2014",
|
|
404
|
+
wordTitle: "Tracked changes"
|
|
405
|
+
};
|
|
406
|
+
function WorkflowSignDialog({
|
|
407
|
+
docRef,
|
|
408
|
+
onClose,
|
|
409
|
+
labels
|
|
410
|
+
}) {
|
|
411
|
+
const arbi = useArbi();
|
|
412
|
+
const { user, ensureWorkspaceOpen } = useConnection();
|
|
413
|
+
const tools = useOptionalDocumentTools();
|
|
414
|
+
const { id, version } = splitDocRef(docRef);
|
|
415
|
+
const [pdf, setPdf] = useState(null);
|
|
416
|
+
const [failed, setFailed] = useState(false);
|
|
417
|
+
useEffect(() => {
|
|
418
|
+
let live = true;
|
|
419
|
+
void (async () => {
|
|
420
|
+
try {
|
|
421
|
+
await ensureWorkspaceOpen();
|
|
422
|
+
const res = await arbi.documents.download(id, version);
|
|
423
|
+
if (!res.ok) throw new Error(String(res.status));
|
|
424
|
+
const blob = await res.blob();
|
|
425
|
+
if (live) setPdf(blob);
|
|
426
|
+
} catch {
|
|
427
|
+
if (live) setFailed(true);
|
|
428
|
+
}
|
|
429
|
+
})();
|
|
430
|
+
return () => {
|
|
431
|
+
live = false;
|
|
432
|
+
};
|
|
433
|
+
}, [arbi, id, version, ensureWorkspaceOpen]);
|
|
434
|
+
if (!pdf)
|
|
435
|
+
return /* @__PURE__ */ jsx(
|
|
436
|
+
ModalScaffold,
|
|
437
|
+
{
|
|
438
|
+
open: true,
|
|
439
|
+
onOpenChange: (o) => !o && onClose(),
|
|
440
|
+
title: labels.loadingDocument,
|
|
441
|
+
size: "sm",
|
|
442
|
+
testId: "workflow-sign-loading",
|
|
443
|
+
children: /* @__PURE__ */ jsx(ModalScaffold.Body, { children: /* @__PURE__ */ jsx("p", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: failed ? labels.documentFailed : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
444
|
+
/* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin" }),
|
|
445
|
+
" ",
|
|
446
|
+
labels.loadingDocument
|
|
447
|
+
] }) }) })
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
const dialog = /* @__PURE__ */ jsx(SignDocumentDialog, { open: true, onOpenChange: (o) => !o && onClose(), documentId: id, pdfBlob: pdf });
|
|
451
|
+
return tools ? dialog : /* @__PURE__ */ jsx(
|
|
452
|
+
DocumentToolsProvider,
|
|
453
|
+
{
|
|
454
|
+
client: arbi.getClient().fetch,
|
|
455
|
+
user: user ? { name: user.name, email: user.email } : null,
|
|
456
|
+
children: dialog
|
|
457
|
+
}
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
function WorkflowWordDialog({
|
|
461
|
+
docRef,
|
|
462
|
+
title,
|
|
463
|
+
onClose,
|
|
464
|
+
labels
|
|
465
|
+
}) {
|
|
466
|
+
const { id } = splitDocRef(docRef);
|
|
467
|
+
return /* @__PURE__ */ jsx(
|
|
468
|
+
ModalScaffold,
|
|
469
|
+
{
|
|
470
|
+
open: true,
|
|
471
|
+
onOpenChange: (o) => !o && onClose(),
|
|
472
|
+
title: title ?? labels.wordTitle,
|
|
473
|
+
size: "xl",
|
|
474
|
+
testId: "workflow-word-dialog",
|
|
475
|
+
children: /* @__PURE__ */ jsx(ModalScaffold.Body, { className: "h-[70dvh] p-0", children: /* @__PURE__ */ jsx(ConnectedNativeDocxEditor, { documentId: id, title: title ?? labels.wordTitle }) })
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
function WorkflowReviewGridDialog({
|
|
480
|
+
tags,
|
|
481
|
+
documents,
|
|
482
|
+
onClose,
|
|
483
|
+
onOpenDocument,
|
|
484
|
+
labels
|
|
485
|
+
}) {
|
|
486
|
+
const { workspaceId } = useConnection();
|
|
487
|
+
const allTags = useTags(workspaceId ?? void 0);
|
|
488
|
+
const all = useDocuments(workspaceId ?? void 0);
|
|
489
|
+
const docs = {
|
|
490
|
+
isLoading: all.isLoading,
|
|
491
|
+
data: (all.data ?? []).filter((d) => documents.includes(d.external_id))
|
|
492
|
+
};
|
|
493
|
+
const columns = useMemo(
|
|
494
|
+
() => tags.map((id) => ({
|
|
495
|
+
id,
|
|
496
|
+
name: allTags.data?.find((t) => t.external_id === id)?.name ?? id
|
|
497
|
+
})),
|
|
498
|
+
[tags, allTags.data]
|
|
499
|
+
);
|
|
500
|
+
return /* @__PURE__ */ jsx(
|
|
501
|
+
ModalScaffold,
|
|
502
|
+
{
|
|
503
|
+
open: true,
|
|
504
|
+
onOpenChange: (o) => !o && onClose(),
|
|
505
|
+
title: labels.reviewTitle,
|
|
506
|
+
description: labels.reviewDescription,
|
|
507
|
+
showDescription: true,
|
|
508
|
+
size: "xl",
|
|
509
|
+
testId: "workflow-review-grid",
|
|
510
|
+
children: /* @__PURE__ */ jsx(ModalScaffold.Body, { className: "overflow-auto", children: docs.isLoading ? /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
511
|
+
/* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin" }),
|
|
512
|
+
" ",
|
|
513
|
+
labels.loadingDocument
|
|
514
|
+
] }) : /* @__PURE__ */ jsxs("table", { className: "w-full border-collapse text-sm", children: [
|
|
515
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
516
|
+
/* @__PURE__ */ jsx("th", { className: "sticky left-0 border-b border-border bg-card p-2 text-left font-medium", children: labels.document }),
|
|
517
|
+
columns.map((c) => /* @__PURE__ */ jsx("th", { className: "border-b border-border p-2 text-left font-medium", children: c.name }, c.id))
|
|
518
|
+
] }) }),
|
|
519
|
+
/* @__PURE__ */ jsx("tbody", { children: (docs.data ?? []).map((d) => /* @__PURE__ */ jsxs("tr", { "data-testid": `workflow-review-grid-row-${d.external_id}`, children: [
|
|
520
|
+
/* @__PURE__ */ jsx("td", { className: "sticky left-0 max-w-56 border-b border-border bg-card p-2 align-top", children: /* @__PURE__ */ jsx(Cell, { onClick: onOpenDocument && (() => onOpenDocument(d.external_id)), children: d.file_name ?? d.external_id }) }),
|
|
521
|
+
columns.map((c) => {
|
|
522
|
+
const note = d.doctags?.find((t) => t.tag_ext_id === c.id)?.note;
|
|
523
|
+
return /* @__PURE__ */ jsx(
|
|
524
|
+
"td",
|
|
525
|
+
{
|
|
526
|
+
className: "max-w-72 border-b border-border p-2 align-top text-muted-foreground",
|
|
527
|
+
children: /* @__PURE__ */ jsx("span", { className: "line-clamp-4 whitespace-pre-line", children: note || labels.empty })
|
|
528
|
+
},
|
|
529
|
+
c.id
|
|
530
|
+
);
|
|
531
|
+
})
|
|
532
|
+
] }, d.external_id)) })
|
|
533
|
+
] }) })
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
function Cell({ onClick, children }) {
|
|
538
|
+
return onClick ? /* @__PURE__ */ jsx(
|
|
539
|
+
"button",
|
|
540
|
+
{
|
|
541
|
+
type: "button",
|
|
542
|
+
onClick,
|
|
543
|
+
className: "truncate text-left font-medium text-primary hover:underline",
|
|
544
|
+
children
|
|
545
|
+
}
|
|
546
|
+
) : /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children });
|
|
342
547
|
}
|
|
343
548
|
var DEFAULT_CONNECTED_WORKFLOW_RUNNER_LABELS = {
|
|
344
549
|
notify: "Ask to approve",
|
|
@@ -352,17 +557,52 @@ function ConnectedWorkflowRunner({
|
|
|
352
557
|
onOpenConversation,
|
|
353
558
|
emptyHint,
|
|
354
559
|
connectedLabels,
|
|
560
|
+
onOpenDocument,
|
|
561
|
+
onOpenDraft,
|
|
562
|
+
onOpenMessage,
|
|
563
|
+
actions: hostActions,
|
|
564
|
+
dialogLabels,
|
|
355
565
|
testIdPrefix = "workflow-run",
|
|
356
566
|
...runnerProps
|
|
357
567
|
}) {
|
|
358
568
|
const l = { ...DEFAULT_CONNECTED_WORKFLOW_RUNNER_LABELS, ...connectedLabels };
|
|
569
|
+
const dl = { ...DEFAULT_WORKFLOW_RUNNER_DIALOG_LABELS, ...dialogLabels };
|
|
359
570
|
const arbi = useArbi();
|
|
360
|
-
const { ensureWorkspaceOpen } = useConnection();
|
|
571
|
+
const { ensureWorkspaceOpen, user } = useConnection();
|
|
361
572
|
const { wsId } = useWorkspaceDocs();
|
|
362
573
|
const { data: docs = [], refetch } = useDocuments(wsId);
|
|
363
574
|
const [uploading, setUploading] = useState(false);
|
|
364
|
-
const { view, conversationId } = useWorkflowThread(workflow, options);
|
|
365
575
|
const [added, setAdded] = useState({});
|
|
576
|
+
const addedRef = useRef(added);
|
|
577
|
+
addedRef.current = added;
|
|
578
|
+
const { view, conversationId, people } = useWorkflowThread(workflow, {
|
|
579
|
+
...options,
|
|
580
|
+
// An upload step records exactly the files added on it (else the server's guess).
|
|
581
|
+
documentsFor: options?.documentsFor ?? ((stepId) => Object.entries(addedRef.current).flatMap(([doc, step]) => step === stepId ? [doc] : []))
|
|
582
|
+
});
|
|
583
|
+
const [dialog, setDialog] = useState(null);
|
|
584
|
+
const nameOfDoc = useCallback(
|
|
585
|
+
(id) => docs.find((d) => d.external_id === id)?.file_name ?? void 0,
|
|
586
|
+
[docs]
|
|
587
|
+
);
|
|
588
|
+
const actions = useMemo(
|
|
589
|
+
() => ({
|
|
590
|
+
me: user?.externalId,
|
|
591
|
+
openDocument: onOpenDocument && ((ref) => {
|
|
592
|
+
const { id, version } = splitDocRef(ref);
|
|
593
|
+
onOpenDocument(id, version);
|
|
594
|
+
}),
|
|
595
|
+
openDraft: onOpenDraft && ((draftId) => onOpenDraft(draftId)),
|
|
596
|
+
openMessage: onOpenMessage,
|
|
597
|
+
sign: hostActions?.sign ?? ((_step, state) => {
|
|
598
|
+
const w = state.waiting;
|
|
599
|
+
if (w?.doc_ext_id) setDialog({ kind: "sign", docRef: w.doc_ext_id });
|
|
600
|
+
}),
|
|
601
|
+
openRedline: hostActions?.openRedline ?? ((ref) => setDialog({ kind: "word", docRef: ref, title: nameOfDoc(splitDocRef(ref).id) ?? "" })),
|
|
602
|
+
openReview: hostActions?.openReview ?? ((tags, documents) => setDialog({ kind: "review", tags, documents }))
|
|
603
|
+
}),
|
|
604
|
+
[user?.externalId, onOpenDocument, onOpenDraft, onOpenMessage, hostActions, nameOfDoc]
|
|
605
|
+
);
|
|
366
606
|
const onUpload = useCallback(
|
|
367
607
|
async (files2, step) => {
|
|
368
608
|
if (!files2.length) return;
|
|
@@ -437,6 +677,7 @@ function ConnectedWorkflowRunner({
|
|
|
437
677
|
/* @__PURE__ */ jsx(
|
|
438
678
|
WorkflowRunner,
|
|
439
679
|
{
|
|
680
|
+
people,
|
|
440
681
|
...runnerProps,
|
|
441
682
|
workflow,
|
|
442
683
|
run: view,
|
|
@@ -453,8 +694,30 @@ function ConnectedWorkflowRunner({
|
|
|
453
694
|
onUpload,
|
|
454
695
|
uploading,
|
|
455
696
|
files,
|
|
697
|
+
actions,
|
|
698
|
+
nameOfDoc,
|
|
456
699
|
testIdPrefix
|
|
457
700
|
}
|
|
701
|
+
),
|
|
702
|
+
dialog?.kind === "sign" && /* @__PURE__ */ jsx(WorkflowSignDialog, { docRef: dialog.docRef, onClose: () => setDialog(null), labels: dl }),
|
|
703
|
+
dialog?.kind === "word" && /* @__PURE__ */ jsx(
|
|
704
|
+
WorkflowWordDialog,
|
|
705
|
+
{
|
|
706
|
+
docRef: dialog.docRef,
|
|
707
|
+
title: dialog.title || void 0,
|
|
708
|
+
onClose: () => setDialog(null),
|
|
709
|
+
labels: dl
|
|
710
|
+
}
|
|
711
|
+
),
|
|
712
|
+
dialog?.kind === "review" && /* @__PURE__ */ jsx(
|
|
713
|
+
WorkflowReviewGridDialog,
|
|
714
|
+
{
|
|
715
|
+
tags: dialog.tags,
|
|
716
|
+
documents: dialog.documents,
|
|
717
|
+
onClose: () => setDialog(null),
|
|
718
|
+
onOpenDocument: onOpenDocument && ((id) => onOpenDocument(id)),
|
|
719
|
+
labels: dl
|
|
720
|
+
}
|
|
458
721
|
)
|
|
459
722
|
] });
|
|
460
723
|
}
|