synapse-react-client 4.0.30 → 4.0.32
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/SWC.index.d.ts +4 -0
- package/dist/SWC.index.d.ts.map +1 -1
- package/dist/SWC.index.js +2 -1
- package/dist/SWC.index.js.map +1 -1
- package/dist/assets/illustrations/curie_avatar.svg +52 -0
- package/dist/assets/illustrations/curie_avatar_head.js +91 -0
- package/dist/assets/illustrations/curie_avatar_head.js.map +1 -0
- package/dist/assets/illustrations/curie_avatar_head.svg +21 -0
- package/dist/assets/illustrations/discussions_illustration2.js +96 -0
- package/dist/assets/illustrations/discussions_illustration2.js.map +1 -0
- package/dist/assets/illustrations/discussions_illustration2.svg +17 -0
- package/dist/assets/illustrations/index.d.ts +3 -0
- package/dist/assets/illustrations/index.d.ts.map +1 -1
- package/dist/assets/illustrations/index.js +34 -32
- package/dist/assets/illustrations/index.js.map +1 -1
- package/dist/assets/mui_components/CurieAvatarHead.d.ts +5 -0
- package/dist/assets/mui_components/CurieAvatarHead.d.ts.map +1 -0
- package/dist/assets/mui_components/CurieAvatarHead.js +17 -0
- package/dist/assets/mui_components/CurieAvatarHead.js.map +1 -0
- package/dist/assets/themed_icons/Model.d.ts +3 -0
- package/dist/assets/themed_icons/Model.d.ts.map +1 -0
- package/dist/assets/themed_icons/Model.js +31 -0
- package/dist/assets/themed_icons/Model.js.map +1 -0
- package/dist/assets/themed_icons/index.d.ts +2 -1
- package/dist/assets/themed_icons/index.d.ts.map +1 -1
- package/dist/assets/themed_icons/index.js +19 -18
- package/dist/components/ChallengeDataDownload/ChallengeDataDownload.d.ts.map +1 -1
- package/dist/components/ChallengeDataDownload/ChallengeDataDownload.js +49 -39
- package/dist/components/ChallengeDataDownload/ChallengeDataDownload.js.map +1 -1
- package/dist/components/DataGrid/SynapseGrid.d.ts.map +1 -1
- package/dist/components/DataGrid/SynapseGrid.js +46 -45
- package/dist/components/DataGrid/SynapseGrid.js.map +1 -1
- package/dist/components/DataGrid/utils/DataGridUtils.js +1 -1
- package/dist/components/DataGrid/utils/DataGridUtils.js.map +1 -1
- package/dist/components/EntityFinder/EntityFinder.js +127 -127
- package/dist/components/EntityFinder/EntityFinder.js.map +1 -1
- package/dist/components/EntityFinder/details/view/DetailsView.js +53 -53
- package/dist/components/EntitySidebar/EntitySidebar.css +1 -1
- package/dist/components/EntitySidebar/EntitySidebar.module.js +11 -11
- package/dist/components/EntitySidebar/EntitySidebar.module.js.map +1 -1
- package/dist/components/EntitySidebar/EntitySidebar.module.scss +2 -2
- package/dist/components/EntityTreeTable/EntityTreeTable.d.ts +7 -0
- package/dist/components/EntityTreeTable/EntityTreeTable.d.ts.map +1 -1
- package/dist/components/EntityTreeTable/EntityTreeTable.js +24 -20
- package/dist/components/EntityTreeTable/EntityTreeTable.js.map +1 -1
- package/dist/components/EntityTreeTable/components/CheckboxCell.d.ts +4 -0
- package/dist/components/EntityTreeTable/components/CheckboxCell.d.ts.map +1 -0
- package/dist/components/EntityTreeTable/components/CheckboxCell.js +43 -0
- package/dist/components/EntityTreeTable/components/CheckboxCell.js.map +1 -0
- package/dist/components/EntityTreeTable/components/EntityNameCell.d.ts.map +1 -1
- package/dist/components/EntityTreeTable/components/EntityNameCell.js +10 -9
- package/dist/components/EntityTreeTable/components/EntityNameCell.js.map +1 -1
- package/dist/components/EntityTreeTable/components/EntityTreeTableContext.d.ts +6 -0
- package/dist/components/EntityTreeTable/components/EntityTreeTableContext.d.ts.map +1 -1
- package/dist/components/EntityTreeTable/components/EntityTreeTableContext.js.map +1 -1
- package/dist/components/EntityTreeTable/hooks/useTableColumns.d.ts +1 -1
- package/dist/components/EntityTreeTable/hooks/useTableColumns.d.ts.map +1 -1
- package/dist/components/EntityTreeTable/hooks/useTableColumns.js +49 -39
- package/dist/components/EntityTreeTable/hooks/useTableColumns.js.map +1 -1
- package/dist/components/EntityUpload/EntityUpload.js +6 -6
- package/dist/components/Forum/DiscussionEmpty.css +1 -0
- package/dist/components/Forum/DiscussionEmpty.d.ts +6 -0
- package/dist/components/Forum/DiscussionEmpty.d.ts.map +1 -0
- package/dist/components/Forum/DiscussionEmpty.js +30 -0
- package/dist/components/Forum/DiscussionEmpty.js.map +1 -0
- package/dist/components/Forum/DiscussionEmpty.module.js +10 -0
- package/dist/components/Forum/DiscussionEmpty.module.js.map +1 -0
- package/dist/components/Forum/DiscussionEmpty.module.scss +37 -0
- package/dist/components/Icon/Icon.d.ts.map +1 -1
- package/dist/components/Icon/Icon.js +82 -80
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/ProvenanceGraph/ProvenanceGraph.d.ts.map +1 -1
- package/dist/components/ProvenanceGraph/ProvenanceGraph.js +39 -41
- package/dist/components/ProvenanceGraph/ProvenanceGraph.js.map +1 -1
- package/dist/components/SynapseChat/AccessLevelMenu.d.ts.map +1 -1
- package/dist/components/SynapseChat/AccessLevelMenu.js +1 -0
- package/dist/components/SynapseChat/AccessLevelMenu.js.map +1 -1
- package/dist/components/SynapseChat/GridAgentChat.d.ts.map +1 -1
- package/dist/components/SynapseChat/GridAgentChat.js +34 -25
- package/dist/components/SynapseChat/GridAgentChat.js.map +1 -1
- package/dist/components/SynapseChat/SynapseChat.d.ts +10 -12
- package/dist/components/SynapseChat/SynapseChat.d.ts.map +1 -1
- package/dist/components/SynapseChat/SynapseChat.js +106 -103
- package/dist/components/SynapseChat/SynapseChat.js.map +1 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.css +1 -0
- package/dist/components/SynapseChat/SynapseChatInteraction.d.ts +22 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.d.ts.map +1 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.js +123 -94
- package/dist/components/SynapseChat/SynapseChatInteraction.js.map +1 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.module.js +8 -0
- package/dist/components/SynapseChat/SynapseChatInteraction.module.js.map +1 -0
- package/dist/components/SynapseChat/SynapseChatInteraction.module.scss +25 -0
- package/dist/components/SynapseChat/SynapseChatMessage.d.ts +16 -1
- package/dist/components/SynapseChat/SynapseChatMessage.d.ts.map +1 -1
- package/dist/components/SynapseChat/SynapseChatMessage.js +25 -11
- package/dist/components/SynapseChat/SynapseChatMessage.js.map +1 -1
- package/dist/components/SynapseChat/components/AddFilesDialog/AddFilesDialog.d.ts +27 -0
- package/dist/components/SynapseChat/components/AddFilesDialog/AddFilesDialog.d.ts.map +1 -0
- package/dist/components/SynapseChat/components/AddFilesDialog/AddFilesDialog.js +79 -0
- package/dist/components/SynapseChat/components/AddFilesDialog/AddFilesDialog.js.map +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.css +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.d.ts +33 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.d.ts.map +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.js +77 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.js.map +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.module.js +8 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.module.js.map +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.module.scss +16 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.css +1 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.d.ts +23 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.d.ts.map +1 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.js +24 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.js.map +1 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.module.js +9 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.module.js.map +1 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.module.scss +19 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.css +1 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.d.ts +22 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.d.ts.map +1 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.js +80 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.js.map +1 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.module.js +9 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.module.js.map +1 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.module.scss +39 -0
- package/dist/components/SynapseChat/useChatState.d.ts +12 -4
- package/dist/components/SynapseChat/useChatState.d.ts.map +1 -1
- package/dist/components/SynapseChat/useChatState.js +38 -20
- package/dist/components/SynapseChat/useChatState.js.map +1 -1
- package/dist/components/SynapseChat/utils/constants.d.ts +8 -0
- package/dist/components/SynapseChat/utils/constants.d.ts.map +1 -0
- package/dist/components/SynapseChat/utils/constants.js +12 -0
- package/dist/components/SynapseChat/utils/constants.js.map +1 -0
- package/dist/components/SynapseChat/utils/types.d.ts +13 -0
- package/dist/components/SynapseChat/utils/types.d.ts.map +1 -0
- package/dist/components/SynapseChat/utils/types.js +0 -0
- package/dist/components/SynapseTable/datasets/DatasetItemsEditor.js +101 -101
- package/dist/components/SynapseTable/datasets/DatasetItemsEditor.js.map +1 -1
- package/dist/components/entity/page/action_menu/EntityActionMenu.d.ts +1 -0
- package/dist/components/entity/page/action_menu/EntityActionMenu.d.ts.map +1 -1
- package/dist/components/entity/page/action_menu/EntityActionMenu.js +8 -0
- package/dist/components/entity/page/action_menu/EntityActionMenu.js.map +1 -1
- package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.js +1 -1
- package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.js.map +1 -1
- package/dist/components/file/upload/BasicFileHandleUpload.d.ts +35 -4
- package/dist/components/file/upload/BasicFileHandleUpload.d.ts.map +1 -1
- package/dist/components/file/upload/BasicFileHandleUpload.js +22 -16
- package/dist/components/file/upload/BasicFileHandleUpload.js.map +1 -1
- package/dist/components/file/upload/MultiFileUploadProgress.js +6 -6
- package/dist/components/file/upload/UploadFilePanel.d.ts +32 -0
- package/dist/components/file/upload/UploadFilePanel.d.ts.map +1 -1
- package/dist/components/file/upload/UploadFilePanel.js +58 -42
- package/dist/components/file/upload/UploadFilePanel.js.map +1 -1
- package/dist/components/file/upload/validateFileSelection.d.ts +25 -0
- package/dist/components/file/upload/validateFileSelection.d.ts.map +1 -0
- package/dist/components/file/upload/validateFileSelection.js +18 -0
- package/dist/components/file/upload/validateFileSelection.js.map +1 -0
- package/dist/components/menu/DropdownMenu.d.ts +3 -0
- package/dist/components/menu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/menu/DropdownMenu.js +108 -83
- package/dist/components/menu/DropdownMenu.js.map +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.css +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.module.js +13 -13
- package/dist/features/curator/dashboard/components/CurationTaskCard.module.js.map +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.module.scss +2 -1
- package/dist/features/curator/dashboard/components/CurationTaskCardLayout.d.ts.map +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCardLayout.js +35 -27
- package/dist/features/curator/dashboard/components/CurationTaskCardLayout.js.map +1 -1
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.js +131 -131
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.js.map +1 -1
- package/dist/features/entity/metadata-task/create-task/useCurationTaskFormState.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/create-task/useCurationTaskFormState.js +21 -18
- package/dist/features/entity/metadata-task/create-task/useCurationTaskFormState.js.map +1 -1
- package/dist/features/entity/metadata-task/utils/dueDate.d.ts +1 -1
- package/dist/features/entity/metadata-task/utils/dueDate.js.map +1 -1
- package/dist/mocks/chat/mockChat.d.ts +13 -1
- package/dist/mocks/chat/mockChat.d.ts.map +1 -1
- package/dist/mocks/chat/mockChat.js +34 -9
- package/dist/mocks/chat/mockChat.js.map +1 -1
- package/dist/mocks/msw/handlers/chatHandlers.d.ts +1 -1
- package/dist/mocks/msw/handlers/chatHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/chatHandlers.js +21 -7
- package/dist/mocks/msw/handlers/chatHandlers.js.map +1 -1
- package/dist/synapse-client/SynapseClient.d.ts +2 -2
- package/dist/synapse-client/SynapseClient.d.ts.map +1 -1
- package/dist/synapse-client/SynapseClient.js.map +1 -1
- package/dist/synapse-queries/KeyFactory.d.ts +10 -1
- package/dist/synapse-queries/KeyFactory.d.ts.map +1 -1
- package/dist/synapse-queries/KeyFactory.js +29 -2
- package/dist/synapse-queries/KeyFactory.js.map +1 -1
- package/dist/synapse-queries/asynchronous/usePollAsynchronousJob.d.ts +2 -2
- package/dist/synapse-queries/asynchronous/usePollAsynchronousJob.d.ts.map +1 -1
- package/dist/synapse-queries/asynchronous/usePollAsynchronousJob.js +2 -1
- package/dist/synapse-queries/asynchronous/usePollAsynchronousJob.js.map +1 -1
- package/dist/synapse-queries/chat/useChat.d.ts +3 -2
- package/dist/synapse-queries/chat/useChat.d.ts.map +1 -1
- package/dist/synapse-queries/chat/useChat.js +7 -6
- package/dist/synapse-queries/chat/useChat.js.map +1 -1
- package/dist/synapse-queries/dataaccess/index.d.ts +1 -0
- package/dist/synapse-queries/dataaccess/index.d.ts.map +1 -1
- package/dist/synapse-queries/dataaccess/index.js +4 -3
- package/dist/synapse-queries/dataaccess/useEDuc.d.ts +44 -0
- package/dist/synapse-queries/dataaccess/useEDuc.d.ts.map +1 -0
- package/dist/synapse-queries/dataaccess/useEDuc.js +75 -0
- package/dist/synapse-queries/dataaccess/useEDuc.js.map +1 -0
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.d.ts.map +1 -1
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.js +1 -1
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.js.map +1 -1
- package/dist/synapse-queries/file/useDirectUploadToS3.js +6 -6
- package/dist/synapse-queries/index.js +181 -172
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/SynapseConstants.d.ts +2 -0
- package/dist/utils/SynapseConstants.d.ts.map +1 -1
- package/dist/utils/SynapseConstants.js +122 -120
- package/dist/utils/SynapseConstants.js.map +1 -1
- package/dist/utils/featureflag/FeatureFlags.d.ts +3 -1
- package/dist/utils/featureflag/FeatureFlags.d.ts.map +1 -1
- package/dist/utils/featureflag/FeatureFlags.js +1 -1
- package/dist/utils/featureflag/FeatureFlags.js.map +1 -1
- package/dist/utils/hooks/useUploadFileEntity/useUploadFileEntities.js +5 -5
- package/dist/utils/hooks/useUploadFileEntity/useUploadFiles.js +14 -14
- package/package.json +4 -4
|
@@ -8,22 +8,22 @@ import "../../synapse-queries/index.js";
|
|
|
8
8
|
import { NodeType as s, getLayoutedElements as ee, isArrayEqual as c } from "./ProvenanceUtils.js";
|
|
9
9
|
import { addActivityNode as te, addEntityNode as ne, addEntityPlaceholderNode as re, addExpandNode as l, addExternalNode as u, addUndefinedNode as ie, findEntityNode as ae, isRootEntity as d } from "./ProvenanceGraphUtils.js";
|
|
10
10
|
import { useCallback as f, useEffect as p, useState as m } from "react";
|
|
11
|
-
import { Button as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { USED_ENTITY_CONCRETE_TYPE_VALUE as
|
|
14
|
-
import { useErrorHandler as
|
|
15
|
-
import
|
|
11
|
+
import { Button as oe, CircularProgress as h, Stack as g, Typography as _ } from "@mui/material";
|
|
12
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
13
|
+
import { USED_ENTITY_CONCRETE_TYPE_VALUE as b } from "@sage-bionetworks/synapse-types";
|
|
14
|
+
import { useErrorHandler as x } from "react-error-boundary";
|
|
15
|
+
import S, { Controls as C, ReactFlowProvider as w, getConnectedEdges as se, useEdgesState as ce, useNodesState as le, useReactFlow as ue } from "reactflow";
|
|
16
16
|
import "reactflow/dist/style.css";
|
|
17
17
|
//#region src/components/ProvenanceGraph/ProvenanceGraph.tsx
|
|
18
|
-
var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e) => `We don’t have any provenance information for this ${e} yet.`, k = "#3B4046", fe = "#
|
|
19
|
-
let { entityRefs: w, containerHeight: D = "200px", initialNodes: A = [], initialEdges: j = [], onNodesChangedListener: M, onEdgesChangedListener: N, onEditProvenanceClicked: P } = i, { accessToken: F } = a(), [I, L] = m(A), [R, z] = m(j), [B, V] = le([]), [H, U] = ce([]), [W, G] = m(), [
|
|
18
|
+
var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e) => `We don’t have any provenance information for this ${e} yet.`, k = "#3B4046", fe = "#4D535A", pe = "#9EAAB7", me = "rgba(255, 255, 255, 0.60)", A = (i) => {
|
|
19
|
+
let { entityRefs: w, containerHeight: D = "200px", initialNodes: A = [], initialEdges: j = [], onNodesChangedListener: M, onEdgesChangedListener: N, onEditProvenanceClicked: P } = i, { accessToken: F } = a(), [I, L] = m(A), [R, z] = m(j), [B, V] = le([]), [H, U] = ce([]), [W, G] = m(), [he, ge] = m(!1), K = x(), { data: q, isSuccess: _e } = o(w, { throwOnError: !0 }), ve = [
|
|
20
20
|
s.ENTITY_PLACEHOLDER,
|
|
21
21
|
s.EXTERNAL,
|
|
22
22
|
s.ACTIVITY,
|
|
23
23
|
s.EXPAND
|
|
24
|
-
], ye = B.some((e) =>
|
|
25
|
-
|
|
26
|
-
let
|
|
24
|
+
], ye = B.some((e) => ve.includes(e.data.type)), be = he && !ye;
|
|
25
|
+
_e && q && q.totalNumberOfResults == 0 && K(`Unable to load provenance for the given Synapse IDs: ${w.map((e) => e.targetId).join(",")}`);
|
|
26
|
+
let J = q?.results, Y = J?.[0] ? n(r(J[0])).toLowerCase() : "entity", [X, xe] = m(!1), Z = ue(), Se = f((e, t) => {
|
|
27
27
|
G(t);
|
|
28
28
|
}, []), Q = f(async (e) => {
|
|
29
29
|
let { entityHeader: n, nodesCopy: r, edgesCopy: i, usedInActivity: a } = e;
|
|
@@ -37,7 +37,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
37
37
|
let e = await t.getActivityForEntity(n.id, n.versionNumber, F);
|
|
38
38
|
(!d({
|
|
39
39
|
entityHeader: n,
|
|
40
|
-
rootEntityHeaders:
|
|
40
|
+
rootEntityHeaders: J
|
|
41
41
|
}) || e.used && e.used.length >= T) && l({
|
|
42
42
|
entityHeader: n,
|
|
43
43
|
itemCount: e.used?.length,
|
|
@@ -47,18 +47,18 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
47
47
|
} catch (e) {
|
|
48
48
|
console.error(e), d({
|
|
49
49
|
entityHeader: n,
|
|
50
|
-
rootEntityHeaders:
|
|
50
|
+
rootEntityHeaders: J
|
|
51
51
|
}) && ie({
|
|
52
52
|
entityHeader: n,
|
|
53
53
|
nodesCopy: r,
|
|
54
54
|
edgesCopy: i
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
}, [F,
|
|
57
|
+
}, [F, J]);
|
|
58
58
|
p(() => {
|
|
59
59
|
!X && B.length > 0 && setTimeout(() => {
|
|
60
|
-
if (
|
|
61
|
-
let e = ae(
|
|
60
|
+
if (J) {
|
|
61
|
+
let e = ae(J[0], B);
|
|
62
62
|
if (e) {
|
|
63
63
|
let t = Z.getZoom(), n = t > E ? E : t;
|
|
64
64
|
Z?.setCenter(e.position.x + 150, e.position.y - 30, {
|
|
@@ -66,14 +66,14 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
66
66
|
duration: 0
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
xe(!0);
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
}, [
|
|
73
73
|
X,
|
|
74
74
|
B,
|
|
75
75
|
Z,
|
|
76
|
-
|
|
76
|
+
J
|
|
77
77
|
]);
|
|
78
78
|
let $ = f(async (e) => {
|
|
79
79
|
let { entityHeader: n, nodesCopy: r, edgesCopy: i } = e;
|
|
@@ -87,7 +87,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
87
87
|
}), e.used && e.used.length < T) {
|
|
88
88
|
let n = [];
|
|
89
89
|
e.used.forEach((t) => {
|
|
90
|
-
t.concreteType ==
|
|
90
|
+
t.concreteType == b ? n.push(t.reference) : u({
|
|
91
91
|
usedURL: t,
|
|
92
92
|
activity: e,
|
|
93
93
|
nodesCopy: r,
|
|
@@ -118,9 +118,9 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
118
118
|
}
|
|
119
119
|
}, [F, Q]);
|
|
120
120
|
p(() => {
|
|
121
|
-
if (
|
|
121
|
+
if (J && I.length == 0) {
|
|
122
122
|
let e = [...I], t = [...R], n = [];
|
|
123
|
-
|
|
123
|
+
J.forEach((r) => {
|
|
124
124
|
let i = Q({
|
|
125
125
|
entityHeader: r,
|
|
126
126
|
nodesCopy: e,
|
|
@@ -134,14 +134,14 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
134
134
|
});
|
|
135
135
|
n.push(a);
|
|
136
136
|
}), Promise.allSettled(n).finally(() => {
|
|
137
|
-
L(e), z(t),
|
|
137
|
+
L(e), z(t), ge(!0);
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
}, [
|
|
141
141
|
Q,
|
|
142
142
|
K,
|
|
143
143
|
$,
|
|
144
|
-
|
|
144
|
+
J,
|
|
145
145
|
w,
|
|
146
146
|
R,
|
|
147
147
|
I
|
|
@@ -153,7 +153,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
153
153
|
e("Web visualization does not support expanding this many items at this time.", "danger");
|
|
154
154
|
return;
|
|
155
155
|
} else {
|
|
156
|
-
t.label = /* @__PURE__ */
|
|
156
|
+
t.label = /* @__PURE__ */ v(h, { size: 30 });
|
|
157
157
|
let e = I.filter((e) => e.id != W.id), r = se([W], R)[0], i = R.filter((e) => e != r);
|
|
158
158
|
$({
|
|
159
159
|
entityHeader: n.entityHeader,
|
|
@@ -186,19 +186,17 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
186
186
|
M,
|
|
187
187
|
N
|
|
188
188
|
]);
|
|
189
|
-
let
|
|
189
|
+
let Ce = f((e) => {
|
|
190
190
|
e && e.deltaX !== void 0 && e.deltaY !== void 0 && window.scrollTo(window.scrollX + e.deltaX, window.scrollY + e.deltaY);
|
|
191
191
|
}, []);
|
|
192
|
-
return /* @__PURE__ */
|
|
192
|
+
return /* @__PURE__ */ v("div", {
|
|
193
193
|
className: "ProvenanceWidget",
|
|
194
194
|
role: "graphics-doc",
|
|
195
195
|
style: {
|
|
196
196
|
width: "100%",
|
|
197
|
-
height: D
|
|
198
|
-
backgroundColor: fe,
|
|
199
|
-
padding: "15px"
|
|
197
|
+
height: D
|
|
200
198
|
},
|
|
201
|
-
children: be ? /* @__PURE__ */
|
|
199
|
+
children: be ? /* @__PURE__ */ y(g, {
|
|
202
200
|
sx: {
|
|
203
201
|
display: "flex",
|
|
204
202
|
height: "100%",
|
|
@@ -207,7 +205,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
207
205
|
textAlign: "center"
|
|
208
206
|
},
|
|
209
207
|
children: [
|
|
210
|
-
/* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ v(_, {
|
|
211
209
|
sx: {
|
|
212
210
|
color: k,
|
|
213
211
|
fontSize: "16px",
|
|
@@ -217,23 +215,23 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
217
215
|
},
|
|
218
216
|
children: O
|
|
219
217
|
}),
|
|
220
|
-
/* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ v(_, {
|
|
221
219
|
sx: {
|
|
222
220
|
color: k,
|
|
223
221
|
fontSize: "14px",
|
|
224
222
|
lineHeight: "20px",
|
|
225
223
|
fontWeight: 440
|
|
226
224
|
},
|
|
227
|
-
children: de(
|
|
225
|
+
children: de(Y)
|
|
228
226
|
}),
|
|
229
|
-
P && /* @__PURE__ */
|
|
227
|
+
P && /* @__PURE__ */ v(oe, {
|
|
230
228
|
variant: "outlined",
|
|
231
229
|
sx: {
|
|
232
230
|
borderRadius: "6px",
|
|
233
231
|
border: "1px solid",
|
|
234
|
-
borderColor:
|
|
235
|
-
background:
|
|
236
|
-
color:
|
|
232
|
+
borderColor: pe,
|
|
233
|
+
background: me,
|
|
234
|
+
color: fe,
|
|
237
235
|
fontWeight: 540,
|
|
238
236
|
lineHeight: "12px",
|
|
239
237
|
letterSpacing: "-0.24px",
|
|
@@ -245,7 +243,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
245
243
|
children: "Edit Provenance"
|
|
246
244
|
})
|
|
247
245
|
]
|
|
248
|
-
}) : /* @__PURE__ */
|
|
246
|
+
}) : /* @__PURE__ */ v(S, {
|
|
249
247
|
defaultViewport: {
|
|
250
248
|
x: 0,
|
|
251
249
|
y: 0,
|
|
@@ -253,15 +251,15 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
253
251
|
},
|
|
254
252
|
nodes: B,
|
|
255
253
|
edges: H,
|
|
256
|
-
onNodeClick:
|
|
254
|
+
onNodeClick: Se,
|
|
257
255
|
attributionPosition: "bottom-right",
|
|
258
256
|
onConnect: void 0,
|
|
259
257
|
zoomOnScroll: !1,
|
|
260
|
-
onPaneScroll:
|
|
261
|
-
children: /* @__PURE__ */
|
|
258
|
+
onPaneScroll: Ce,
|
|
259
|
+
children: /* @__PURE__ */ v(C, {})
|
|
262
260
|
})
|
|
263
261
|
});
|
|
264
|
-
}, j = (e) => /* @__PURE__ */
|
|
262
|
+
}, j = (e) => /* @__PURE__ */ v(i, { children: /* @__PURE__ */ v(w, { children: /* @__PURE__ */ v(A, { ...e }) }) });
|
|
265
263
|
//#endregion
|
|
266
264
|
export { D as EDIT_PROVENANCE_TEXT, O as NO_PROVENANCE_TITLE, j as default };
|
|
267
265
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProvenanceGraph.js","names":[],"sources":["../../../src/components/ProvenanceGraph/ProvenanceGraph.tsx"],"sourcesContent":["import SynapseClient from '@/synapse-client'\nimport { useGetEntityHeaders } from '@/synapse-queries'\nimport {\n entityTypeToFriendlyName,\n getEntityTypeFromHeader,\n} from '@/utils/functions/EntityTypeUtils'\nimport { useSynapseContext } from '@/utils/context/SynapseContext'\nimport { CircularProgress, Typography, Button, Stack } from '@mui/material'\nimport {\n Activity,\n EntityHeader,\n ReferenceList,\n Used,\n USED_ENTITY_CONCRETE_TYPE_VALUE,\n UsedEntity,\n UsedURL,\n} from '@sage-bionetworks/synapse-types'\nimport { MouseEvent, useCallback, useEffect, useState, WheelEvent } from 'react'\nimport { useErrorHandler } from 'react-error-boundary'\nimport ReactFlow, {\n Controls,\n Edge,\n getConnectedEdges,\n Node,\n ReactFlowProvider,\n useEdgesState,\n useNodesState,\n useReactFlow,\n} from 'reactflow'\nimport { SynapseErrorBoundary } from '../error/ErrorBanner'\nimport { displayToast } from '../ToastMessage/ToastMessage'\nimport { ExpandGraphNodeDataProps } from './ExpandGraphNodeLabel'\nimport {\n addActivityNode,\n addEntityNode,\n addEntityPlaceholderNode,\n addExpandNode,\n addExternalNode,\n addUndefinedNode,\n findEntityNode,\n isRootEntity,\n} from './ProvenanceGraphUtils'\nimport {\n getLayoutedElements,\n isArrayEqual,\n NodeType,\n ProvenanceNodeData,\n} from './ProvenanceUtils'\nimport 'reactflow/dist/style.css'\n\nexport type ProvenanceProps = {\n // what entity nodes should we start with?\n entityRefs: ReferenceList\n containerHeight?: string\n initialNodes?: Node[]\n initialEdges?: Edge[]\n onNodesChangedListener?: (nodes: Node[]) => void\n onEdgesChangedListener?: (edges: Edge[]) => void\n onEditProvenanceClicked?: () => void\n}\n\nconst MAX_ACTIVITY_EXPAND_NODES = 400\nconst DEFAULT_ZOOM = 0.85\nexport const EDIT_PROVENANCE_TEXT = 'Edit Provenance'\nexport const NO_PROVENANCE_TITLE = 'No provenance data'\nconst NO_PROVENANCE_MESSAGE = (entityTypeName: string) =>\n `We don’t have any provenance information for this ${entityTypeName} yet.`\nconst NO_PROVENANCE_TEXT_COLOR = '#3B4046'\nconst PROVENANCE_BACKGROUND_COLOR = '#F9F9FA'\nconst EDIT_PROVENANCE_BUTTON_TEXT_COLOR = '#4D535A'\nconst EDIT_PROVENANCE_BUTTON_BORDER_COLOR = '#9EAAB7'\nconst EDIT_PROVENANCE_BUTTON_BACKGROUND_COLOR = 'rgba(255, 255, 255, 0.60)'\n\n/**\n * Renders a Provenance Graph for a set of entities.\n * New Nodes are added to tempNodes, and new Edges are added to tempEdges.\n * On change, these are fed into the dagre js graph library to figure out the node positions,\n * and the output stored in 'nodes' and 'edges'. The 'nodes' and 'edges' arrays are used by the\n * ReactFlow component.\n */\nconst ProvenanceReactFlow = (props: ProvenanceProps): React.ReactNode => {\n const {\n entityRefs: rootEntityRefs,\n containerHeight = '200px',\n initialNodes = [],\n initialEdges = [],\n onNodesChangedListener,\n onEdgesChangedListener,\n onEditProvenanceClicked,\n } = props\n const { accessToken } = useSynapseContext()\n const [tempNodes, setTempNodes] = useState<Node[]>(initialNodes)\n const [tempEdges, setTempEdges] = useState<Edge[]>(initialEdges)\n const [nodes, setNodes] = useNodesState([])\n const [edges, setEdges] = useEdgesState([])\n const [clickedNode, setClickedNode] = useState<Node>()\n const [initialBuildComplete, setInitialBuildComplete] =\n useState<boolean>(false)\n const handleError = useErrorHandler()\n\n const { data: rootEntityHeadersPage, isSuccess } = useGetEntityHeaders(\n rootEntityRefs,\n { throwOnError: true },\n )\n\n const PROVENANCE_NODE_TYPES = [\n NodeType.ENTITY_PLACEHOLDER,\n NodeType.EXTERNAL,\n NodeType.ACTIVITY,\n NodeType.EXPAND,\n ]\n const hasProvenanceNodes = nodes.some(node =>\n PROVENANCE_NODE_TYPES.includes((node.data as ProvenanceNodeData).type),\n )\n\n const showNoProvenance = initialBuildComplete && !hasProvenanceNodes\n\n if (\n isSuccess &&\n rootEntityHeadersPage &&\n rootEntityHeadersPage.totalNumberOfResults == 0\n ) {\n const synapseIds = rootEntityRefs.map(ref => ref.targetId).join(',')\n handleError(\n `Unable to load provenance for the given Synapse IDs: ${synapseIds}`,\n )\n }\n const rootEntityHeaders = rootEntityHeadersPage?.results\n const entityTypeName = rootEntityHeaders?.[0]\n ? entityTypeToFriendlyName(\n getEntityTypeFromHeader(rootEntityHeaders[0]),\n ).toLowerCase()\n : 'entity'\n const [initializedPosition, setInitializedPosition] = useState<boolean>(false)\n\n // Get the react flow instance so we attempt to properly center the view.\n const reactFlowInstance = useReactFlow()\n\n const onClickNode = useCallback((_event: MouseEvent, node: Node) => {\n setClickedNode(node)\n }, [])\n\n /**\n * Called when we have a new entity to add to the graph. This will result in adding\n * a new Entity Node to the nodesCopy, a link from the usedInActivity to the new Entity Node,\n * AND it will look for an Activity associated with the new entity. If an Activity is found,\n * it will add an Expand Node for the user to click (to expand to see this Activity!).\n * If this is a root node (starting entity node), then we automatically add the Activity Node\n * and process it.\n */\n const addEntity = useCallback(\n async (params: {\n entityHeader: EntityHeader\n usedInActivity?: Activity\n nodesCopy: Node[]\n edgesCopy: Edge[]\n }) => {\n const { entityHeader, nodesCopy, edgesCopy, usedInActivity } = params\n addEntityNode({\n entityHeader,\n activity: usedInActivity,\n nodesCopy,\n edgesCopy,\n })\n //look for Activity\n try {\n const activity = await SynapseClient.getActivityForEntity(\n entityHeader.id,\n entityHeader.versionNumber,\n accessToken,\n )\n // if this is not a root node (or there are too many items to show), add an expand node\n if (\n !isRootEntity({ entityHeader, rootEntityHeaders }) ||\n (activity.used && activity.used.length >= MAX_ACTIVITY_EXPAND_NODES)\n ) {\n addExpandNode({\n entityHeader,\n itemCount: activity.used?.length,\n nodesCopy,\n edgesCopy,\n })\n }\n } catch (e) {\n // Activity is not accessible\n console.error(e)\n if (\n isRootEntity({\n entityHeader,\n rootEntityHeaders,\n })\n ) {\n // add provenance undefined node\n addUndefinedNode({\n entityHeader,\n nodesCopy,\n edgesCopy,\n })\n }\n }\n },\n [accessToken, rootEntityHeaders],\n )\n\n /**\n * This effect attempts to center the graph on one of the root nodes.\n * Only initializes after after a root node has been added to the graph.\n */\n useEffect(() => {\n if (!initializedPosition && nodes.length > 0) {\n setTimeout(() => {\n if (rootEntityHeaders) {\n const rootEntityNode = findEntityNode(rootEntityHeaders[0], nodes)\n if (rootEntityNode) {\n const currentZoom = reactFlowInstance.getZoom()\n const zoom = currentZoom > DEFAULT_ZOOM ? DEFAULT_ZOOM : currentZoom\n reactFlowInstance?.setCenter(\n rootEntityNode.position.x + 150,\n rootEntityNode.position.y - 30,\n { zoom, duration: 0 },\n )\n }\n setInitializedPosition(true)\n }\n })\n }\n }, [initializedPosition, nodes, reactFlowInstance, rootEntityHeaders])\n\n /**\n * This is called when the user clicks on an Expand Node. It will add the associated Activity\n * and all \"used\" items (entities and urls) to the graph by adding items to the nodesCopy and edgesCopy arrays.\n */\n const onExpandEntity = useCallback(\n async (params: {\n entityHeader: EntityHeader\n nodesCopy: Node[]\n edgesCopy: Edge[]\n }) => {\n const { entityHeader, nodesCopy, edgesCopy } = params\n try {\n const activity = await SynapseClient.getActivityForEntity(\n entityHeader.id,\n entityHeader.versionNumber,\n accessToken,\n )\n addActivityNode({\n activity,\n entityHeader,\n nodesCopy,\n edgesCopy,\n })\n // go through Activity.used array to add these nodes/edges\n if (activity.used && activity.used.length < MAX_ACTIVITY_EXPAND_NODES) {\n const usedEntityReferences: ReferenceList = []\n activity.used.forEach((usedItem: Used) => {\n if (usedItem.concreteType == USED_ENTITY_CONCRETE_TYPE_VALUE) {\n usedEntityReferences.push((usedItem as UsedEntity).reference)\n } else {\n // UsedURL\n const usedURL = usedItem as UsedURL\n addExternalNode({ usedURL, activity, nodesCopy, edgesCopy })\n }\n })\n const usedEntityHeadersPage = await SynapseClient.getEntityHeaders(\n usedEntityReferences,\n accessToken,\n )\n const { results: usedEntityHeaderPageResults } = usedEntityHeadersPage\n // find refs that were not returned by the entity header call\n const refsMissingEntityHeaders = usedEntityReferences.filter(ref => {\n return (\n usedEntityHeaderPageResults.find(header => {\n return header.id == ref.targetId\n }) == undefined\n )\n })\n refsMissingEntityHeaders.forEach(ref => {\n addEntityPlaceholderNode({ ref, activity, nodesCopy, edgesCopy })\n })\n const addEntityPromises: Promise<void>[] = []\n usedEntityHeaderPageResults.forEach(header => {\n addEntityPromises.push(\n addEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n usedInActivity: activity,\n }),\n )\n })\n await Promise.allSettled(addEntityPromises)\n }\n } catch (e) {\n // Activity is not accessible\n console.error(e)\n }\n },\n [accessToken, addEntity],\n )\n\n /**\n * This effect code executes when no nodes have been added.\n * It will add the root nodes, and attempt to expand the root nodes.\n */\n useEffect(() => {\n if (rootEntityHeaders && tempNodes.length == 0) {\n const nodesCopy = [...tempNodes]\n const edgesCopy = [...tempEdges]\n const addAndExpandPromises: Promise<void>[] = []\n rootEntityHeaders.forEach(header => {\n const addEntityPromise = addEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n })\n addAndExpandPromises.push(addEntityPromise)\n\n const expandEntityPromise = onExpandEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n })\n addAndExpandPromises.push(expandEntityPromise)\n })\n Promise.allSettled(addAndExpandPromises).finally(() => {\n setTempNodes(nodesCopy)\n setTempEdges(edgesCopy)\n setInitialBuildComplete(true)\n })\n }\n }, [\n addEntity,\n handleError,\n onExpandEntity,\n rootEntityHeaders,\n rootEntityRefs,\n tempEdges,\n tempNodes,\n ])\n\n /**\n * This effect code executes when a node is clicked.\n * We check to see if it is an expand node. If it is, then we remove the expand node (and associated edge)\n * and ask for the Activity and associated \"used\" nodes (entities and URLs)\n */\n useEffect(() => {\n const nodeData: ProvenanceNodeData = clickedNode?.data as ProvenanceNodeData\n if (clickedNode && nodeData?.type == NodeType.EXPAND) {\n const expandNodeDataProps = nodeData.props as ExpandGraphNodeDataProps\n if (expandNodeDataProps.itemCount > MAX_ACTIVITY_EXPAND_NODES) {\n displayToast(\n 'Web visualization does not support expanding this many items at this time.',\n 'danger',\n )\n return\n } else {\n // graph will be used outside of synapse, so show a non-branded spinner\n nodeData.label = <CircularProgress size={30} />\n // remove clicked node\n const nodesWithoutExpandNode = tempNodes.filter(\n node => node.id != clickedNode.id,\n )\n const edgeToRemove = getConnectedEdges([clickedNode], tempEdges)[0]\n const edgesWithoutExpandEdge = tempEdges.filter(\n edge => edge != edgeToRemove,\n )\n onExpandEntity({\n entityHeader: expandNodeDataProps.entityHeader,\n nodesCopy: nodesWithoutExpandNode,\n edgesCopy: edgesWithoutExpandEdge,\n }).finally(() => {\n setTempNodes(nodesWithoutExpandNode)\n setTempEdges(edgesWithoutExpandEdge)\n })\n }\n setClickedNode(undefined)\n }\n }, [clickedNode, tempNodes, tempEdges, onExpandEntity])\n\n /**\n * This effect code is run when the graph nodes or edges change.\n * It feeds the nodes and edges into our layout library to figure out where they should be positioned.\n * The result is saved in the state variable \"nodes\" and \"edges\".\n */\n useEffect(() => {\n const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(\n tempNodes,\n tempEdges,\n 'TB',\n )\n // hack: ProvenanceUtils.getProvenanceNode() returns a new object every time, so check to see if\n // there were any real changes\n if (!isArrayEqual(layoutedNodes, nodes)) {\n setNodes(layoutedNodes)\n if (onNodesChangedListener) {\n onNodesChangedListener(layoutedNodes)\n }\n }\n if (!isArrayEqual(layoutedEdges, edges)) {\n setEdges(layoutedEdges)\n if (onEdgesChangedListener) {\n onEdgesChangedListener(layoutedEdges)\n }\n }\n }, [\n tempNodes,\n tempEdges,\n nodes,\n edges,\n setNodes,\n setEdges,\n initializedPosition,\n reactFlowInstance,\n rootEntityRefs,\n onNodesChangedListener,\n onEdgesChangedListener,\n ])\n\n const onPaneScrollFunction: (event?: WheelEvent) => void = useCallback(\n event => {\n // Cannot simply check the truthy value of event.deltaX (or Y) because the value might be 0 (or -0), which is falsy\n if (\n event &&\n typeof event.deltaX !== 'undefined' &&\n typeof event.deltaY !== 'undefined'\n ) {\n window.scrollTo(\n window.scrollX + event.deltaX,\n window.scrollY + event.deltaY,\n )\n }\n },\n [],\n )\n return (\n <div\n className=\"ProvenanceWidget\"\n role=\"graphics-doc\" //https://www.w3.org/wiki/SVG_Accessibility/ARIA_roles_for_charts#Document_Roles\n style={{\n width: '100%',\n height: containerHeight,\n backgroundColor: PROVENANCE_BACKGROUND_COLOR,\n padding: '15px',\n }}\n >\n {showNoProvenance ? (\n <Stack\n sx={{\n display: 'flex',\n height: '100%',\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center',\n }}\n >\n <Typography\n sx={{\n color: NO_PROVENANCE_TEXT_COLOR,\n fontSize: '16px',\n lineHeight: '24px',\n fontWeight: 540,\n marginBottom: '12px',\n }}\n >\n {NO_PROVENANCE_TITLE}\n </Typography>\n <Typography\n sx={{\n color: NO_PROVENANCE_TEXT_COLOR,\n fontSize: '14px',\n lineHeight: '20px',\n fontWeight: 440,\n }}\n >\n {NO_PROVENANCE_MESSAGE(entityTypeName)}\n </Typography>\n {onEditProvenanceClicked && (\n <Button\n variant=\"outlined\"\n sx={{\n borderRadius: '6px',\n border: '1px solid',\n borderColor: EDIT_PROVENANCE_BUTTON_BORDER_COLOR,\n background: EDIT_PROVENANCE_BUTTON_BACKGROUND_COLOR,\n color: EDIT_PROVENANCE_BUTTON_TEXT_COLOR,\n fontWeight: 540,\n lineHeight: '12px' /* 100% */,\n letterSpacing: '-0.24px',\n marginTop: '20px',\n height: '28px',\n padding: '8px',\n }}\n onClick={onEditProvenanceClicked}\n >\n {EDIT_PROVENANCE_TEXT}\n </Button>\n )}\n </Stack>\n ) : (\n <ReactFlow\n defaultViewport={{ x: 0, y: 0, zoom: DEFAULT_ZOOM }}\n nodes={nodes}\n edges={edges}\n onNodeClick={onClickNode}\n // onNodesChange={onNodesChange} // SWC-6804: When the nodes/edges are updated (expanded) the graph is already re-rendered.\n // onEdgesChange={onEdgesChange} // Specifying these callbacks causes an infinite re-rendering loop.\n attributionPosition=\"bottom-right\"\n onConnect={undefined}\n zoomOnScroll={false}\n onPaneScroll={onPaneScrollFunction}\n >\n <Controls />\n </ReactFlow>\n )}\n </div>\n )\n}\n\nconst ProvenanceGraph = (props: ProvenanceProps): React.ReactNode => {\n return (\n <SynapseErrorBoundary>\n <ReactFlowProvider>\n <ProvenanceReactFlow {...props} />\n </ReactFlowProvider>\n </SynapseErrorBoundary>\n )\n}\n\nexport default ProvenanceGraph\n"],"mappings":";;;;;;;;;;;;;;;;;AA6DA,IAAM,IAA4B,KAC5B,IAAe,KACR,IAAuB,mBACvB,IAAsB,sBAC7B,MAAyB,MAC7B,qDAAqD,EAAe,QAChE,IAA2B,WAC3B,KAA8B,WAC9B,KAAoC,WACpC,KAAsC,WACtC,KAA0C,6BAS1C,KAAuB,MAA4C;CACvE,IAAM,EACJ,YAAY,GACZ,qBAAkB,SAClB,kBAAe,CAAC,GAChB,kBAAe,CAAC,GAChB,2BACA,2BACA,+BACE,GACE,EAAE,mBAAgB,EAAkB,GACpC,CAAC,GAAW,KAAgB,EAAiB,CAAY,GACzD,CAAC,GAAW,KAAgB,EAAiB,CAAY,GACzD,CAAC,GAAO,KAAY,GAAc,CAAC,CAAC,GACpC,CAAC,GAAO,KAAY,GAAc,CAAC,CAAC,GACpC,CAAC,GAAa,KAAkB,EAAe,GAC/C,CAAC,IAAsB,MAC3B,EAAkB,EAAK,GACnB,IAAc,EAAgB,GAE9B,EAAE,MAAM,GAAuB,kBAA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AA,EAChB,CAAA,EACC,CAAA"}
|
|
1
|
+
{"version":3,"file":"ProvenanceGraph.js","names":[],"sources":["../../../src/components/ProvenanceGraph/ProvenanceGraph.tsx"],"sourcesContent":["import SynapseClient from '@/synapse-client'\nimport { useGetEntityHeaders } from '@/synapse-queries'\nimport {\n entityTypeToFriendlyName,\n getEntityTypeFromHeader,\n} from '@/utils/functions/EntityTypeUtils'\nimport { useSynapseContext } from '@/utils/context/SynapseContext'\nimport { CircularProgress, Typography, Button, Stack } from '@mui/material'\nimport {\n Activity,\n EntityHeader,\n ReferenceList,\n Used,\n USED_ENTITY_CONCRETE_TYPE_VALUE,\n UsedEntity,\n UsedURL,\n} from '@sage-bionetworks/synapse-types'\nimport { MouseEvent, useCallback, useEffect, useState, WheelEvent } from 'react'\nimport { useErrorHandler } from 'react-error-boundary'\nimport ReactFlow, {\n Controls,\n Edge,\n getConnectedEdges,\n Node,\n ReactFlowProvider,\n useEdgesState,\n useNodesState,\n useReactFlow,\n} from 'reactflow'\nimport { SynapseErrorBoundary } from '../error/ErrorBanner'\nimport { displayToast } from '../ToastMessage/ToastMessage'\nimport { ExpandGraphNodeDataProps } from './ExpandGraphNodeLabel'\nimport {\n addActivityNode,\n addEntityNode,\n addEntityPlaceholderNode,\n addExpandNode,\n addExternalNode,\n addUndefinedNode,\n findEntityNode,\n isRootEntity,\n} from './ProvenanceGraphUtils'\nimport {\n getLayoutedElements,\n isArrayEqual,\n NodeType,\n ProvenanceNodeData,\n} from './ProvenanceUtils'\nimport 'reactflow/dist/style.css'\n\nexport type ProvenanceProps = {\n // what entity nodes should we start with?\n entityRefs: ReferenceList\n containerHeight?: string\n initialNodes?: Node[]\n initialEdges?: Edge[]\n onNodesChangedListener?: (nodes: Node[]) => void\n onEdgesChangedListener?: (edges: Edge[]) => void\n onEditProvenanceClicked?: () => void\n}\n\nconst MAX_ACTIVITY_EXPAND_NODES = 400\nconst DEFAULT_ZOOM = 0.85\nexport const EDIT_PROVENANCE_TEXT = 'Edit Provenance'\nexport const NO_PROVENANCE_TITLE = 'No provenance data'\nconst NO_PROVENANCE_MESSAGE = (entityTypeName: string) =>\n `We don’t have any provenance information for this ${entityTypeName} yet.`\nconst NO_PROVENANCE_TEXT_COLOR = '#3B4046'\nconst EDIT_PROVENANCE_BUTTON_TEXT_COLOR = '#4D535A'\nconst EDIT_PROVENANCE_BUTTON_BORDER_COLOR = '#9EAAB7'\nconst EDIT_PROVENANCE_BUTTON_BACKGROUND_COLOR = 'rgba(255, 255, 255, 0.60)'\n\n/**\n * Renders a Provenance Graph for a set of entities.\n * New Nodes are added to tempNodes, and new Edges are added to tempEdges.\n * On change, these are fed into the dagre js graph library to figure out the node positions,\n * and the output stored in 'nodes' and 'edges'. The 'nodes' and 'edges' arrays are used by the\n * ReactFlow component.\n */\nconst ProvenanceReactFlow = (props: ProvenanceProps): React.ReactNode => {\n const {\n entityRefs: rootEntityRefs,\n containerHeight = '200px',\n initialNodes = [],\n initialEdges = [],\n onNodesChangedListener,\n onEdgesChangedListener,\n onEditProvenanceClicked,\n } = props\n const { accessToken } = useSynapseContext()\n const [tempNodes, setTempNodes] = useState<Node[]>(initialNodes)\n const [tempEdges, setTempEdges] = useState<Edge[]>(initialEdges)\n const [nodes, setNodes] = useNodesState([])\n const [edges, setEdges] = useEdgesState([])\n const [clickedNode, setClickedNode] = useState<Node>()\n const [initialBuildComplete, setInitialBuildComplete] =\n useState<boolean>(false)\n const handleError = useErrorHandler()\n\n const { data: rootEntityHeadersPage, isSuccess } = useGetEntityHeaders(\n rootEntityRefs,\n { throwOnError: true },\n )\n\n const PROVENANCE_NODE_TYPES = [\n NodeType.ENTITY_PLACEHOLDER,\n NodeType.EXTERNAL,\n NodeType.ACTIVITY,\n NodeType.EXPAND,\n ]\n const hasProvenanceNodes = nodes.some(node =>\n PROVENANCE_NODE_TYPES.includes((node.data as ProvenanceNodeData).type),\n )\n\n const showNoProvenance = initialBuildComplete && !hasProvenanceNodes\n\n if (\n isSuccess &&\n rootEntityHeadersPage &&\n rootEntityHeadersPage.totalNumberOfResults == 0\n ) {\n const synapseIds = rootEntityRefs.map(ref => ref.targetId).join(',')\n handleError(\n `Unable to load provenance for the given Synapse IDs: ${synapseIds}`,\n )\n }\n const rootEntityHeaders = rootEntityHeadersPage?.results\n const entityTypeName = rootEntityHeaders?.[0]\n ? entityTypeToFriendlyName(\n getEntityTypeFromHeader(rootEntityHeaders[0]),\n ).toLowerCase()\n : 'entity'\n const [initializedPosition, setInitializedPosition] = useState<boolean>(false)\n\n // Get the react flow instance so we attempt to properly center the view.\n const reactFlowInstance = useReactFlow()\n\n const onClickNode = useCallback((_event: MouseEvent, node: Node) => {\n setClickedNode(node)\n }, [])\n\n /**\n * Called when we have a new entity to add to the graph. This will result in adding\n * a new Entity Node to the nodesCopy, a link from the usedInActivity to the new Entity Node,\n * AND it will look for an Activity associated with the new entity. If an Activity is found,\n * it will add an Expand Node for the user to click (to expand to see this Activity!).\n * If this is a root node (starting entity node), then we automatically add the Activity Node\n * and process it.\n */\n const addEntity = useCallback(\n async (params: {\n entityHeader: EntityHeader\n usedInActivity?: Activity\n nodesCopy: Node[]\n edgesCopy: Edge[]\n }) => {\n const { entityHeader, nodesCopy, edgesCopy, usedInActivity } = params\n addEntityNode({\n entityHeader,\n activity: usedInActivity,\n nodesCopy,\n edgesCopy,\n })\n //look for Activity\n try {\n const activity = await SynapseClient.getActivityForEntity(\n entityHeader.id,\n entityHeader.versionNumber,\n accessToken,\n )\n // if this is not a root node (or there are too many items to show), add an expand node\n if (\n !isRootEntity({ entityHeader, rootEntityHeaders }) ||\n (activity.used && activity.used.length >= MAX_ACTIVITY_EXPAND_NODES)\n ) {\n addExpandNode({\n entityHeader,\n itemCount: activity.used?.length,\n nodesCopy,\n edgesCopy,\n })\n }\n } catch (e) {\n // Activity is not accessible\n console.error(e)\n if (\n isRootEntity({\n entityHeader,\n rootEntityHeaders,\n })\n ) {\n // add provenance undefined node\n addUndefinedNode({\n entityHeader,\n nodesCopy,\n edgesCopy,\n })\n }\n }\n },\n [accessToken, rootEntityHeaders],\n )\n\n /**\n * This effect attempts to center the graph on one of the root nodes.\n * Only initializes after after a root node has been added to the graph.\n */\n useEffect(() => {\n if (!initializedPosition && nodes.length > 0) {\n setTimeout(() => {\n if (rootEntityHeaders) {\n const rootEntityNode = findEntityNode(rootEntityHeaders[0], nodes)\n if (rootEntityNode) {\n const currentZoom = reactFlowInstance.getZoom()\n const zoom = currentZoom > DEFAULT_ZOOM ? DEFAULT_ZOOM : currentZoom\n reactFlowInstance?.setCenter(\n rootEntityNode.position.x + 150,\n rootEntityNode.position.y - 30,\n { zoom, duration: 0 },\n )\n }\n setInitializedPosition(true)\n }\n })\n }\n }, [initializedPosition, nodes, reactFlowInstance, rootEntityHeaders])\n\n /**\n * This is called when the user clicks on an Expand Node. It will add the associated Activity\n * and all \"used\" items (entities and urls) to the graph by adding items to the nodesCopy and edgesCopy arrays.\n */\n const onExpandEntity = useCallback(\n async (params: {\n entityHeader: EntityHeader\n nodesCopy: Node[]\n edgesCopy: Edge[]\n }) => {\n const { entityHeader, nodesCopy, edgesCopy } = params\n try {\n const activity = await SynapseClient.getActivityForEntity(\n entityHeader.id,\n entityHeader.versionNumber,\n accessToken,\n )\n addActivityNode({\n activity,\n entityHeader,\n nodesCopy,\n edgesCopy,\n })\n // go through Activity.used array to add these nodes/edges\n if (activity.used && activity.used.length < MAX_ACTIVITY_EXPAND_NODES) {\n const usedEntityReferences: ReferenceList = []\n activity.used.forEach((usedItem: Used) => {\n if (usedItem.concreteType == USED_ENTITY_CONCRETE_TYPE_VALUE) {\n usedEntityReferences.push((usedItem as UsedEntity).reference)\n } else {\n // UsedURL\n const usedURL = usedItem as UsedURL\n addExternalNode({ usedURL, activity, nodesCopy, edgesCopy })\n }\n })\n const usedEntityHeadersPage = await SynapseClient.getEntityHeaders(\n usedEntityReferences,\n accessToken,\n )\n const { results: usedEntityHeaderPageResults } = usedEntityHeadersPage\n // find refs that were not returned by the entity header call\n const refsMissingEntityHeaders = usedEntityReferences.filter(ref => {\n return (\n usedEntityHeaderPageResults.find(header => {\n return header.id == ref.targetId\n }) == undefined\n )\n })\n refsMissingEntityHeaders.forEach(ref => {\n addEntityPlaceholderNode({ ref, activity, nodesCopy, edgesCopy })\n })\n const addEntityPromises: Promise<void>[] = []\n usedEntityHeaderPageResults.forEach(header => {\n addEntityPromises.push(\n addEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n usedInActivity: activity,\n }),\n )\n })\n await Promise.allSettled(addEntityPromises)\n }\n } catch (e) {\n // Activity is not accessible\n console.error(e)\n }\n },\n [accessToken, addEntity],\n )\n\n /**\n * This effect code executes when no nodes have been added.\n * It will add the root nodes, and attempt to expand the root nodes.\n */\n useEffect(() => {\n if (rootEntityHeaders && tempNodes.length == 0) {\n const nodesCopy = [...tempNodes]\n const edgesCopy = [...tempEdges]\n const addAndExpandPromises: Promise<void>[] = []\n rootEntityHeaders.forEach(header => {\n const addEntityPromise = addEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n })\n addAndExpandPromises.push(addEntityPromise)\n\n const expandEntityPromise = onExpandEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n })\n addAndExpandPromises.push(expandEntityPromise)\n })\n Promise.allSettled(addAndExpandPromises).finally(() => {\n setTempNodes(nodesCopy)\n setTempEdges(edgesCopy)\n setInitialBuildComplete(true)\n })\n }\n }, [\n addEntity,\n handleError,\n onExpandEntity,\n rootEntityHeaders,\n rootEntityRefs,\n tempEdges,\n tempNodes,\n ])\n\n /**\n * This effect code executes when a node is clicked.\n * We check to see if it is an expand node. If it is, then we remove the expand node (and associated edge)\n * and ask for the Activity and associated \"used\" nodes (entities and URLs)\n */\n useEffect(() => {\n const nodeData: ProvenanceNodeData = clickedNode?.data as ProvenanceNodeData\n if (clickedNode && nodeData?.type == NodeType.EXPAND) {\n const expandNodeDataProps = nodeData.props as ExpandGraphNodeDataProps\n if (expandNodeDataProps.itemCount > MAX_ACTIVITY_EXPAND_NODES) {\n displayToast(\n 'Web visualization does not support expanding this many items at this time.',\n 'danger',\n )\n return\n } else {\n // graph will be used outside of synapse, so show a non-branded spinner\n nodeData.label = <CircularProgress size={30} />\n // remove clicked node\n const nodesWithoutExpandNode = tempNodes.filter(\n node => node.id != clickedNode.id,\n )\n const edgeToRemove = getConnectedEdges([clickedNode], tempEdges)[0]\n const edgesWithoutExpandEdge = tempEdges.filter(\n edge => edge != edgeToRemove,\n )\n onExpandEntity({\n entityHeader: expandNodeDataProps.entityHeader,\n nodesCopy: nodesWithoutExpandNode,\n edgesCopy: edgesWithoutExpandEdge,\n }).finally(() => {\n setTempNodes(nodesWithoutExpandNode)\n setTempEdges(edgesWithoutExpandEdge)\n })\n }\n setClickedNode(undefined)\n }\n }, [clickedNode, tempNodes, tempEdges, onExpandEntity])\n\n /**\n * This effect code is run when the graph nodes or edges change.\n * It feeds the nodes and edges into our layout library to figure out where they should be positioned.\n * The result is saved in the state variable \"nodes\" and \"edges\".\n */\n useEffect(() => {\n const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(\n tempNodes,\n tempEdges,\n 'TB',\n )\n // hack: ProvenanceUtils.getProvenanceNode() returns a new object every time, so check to see if\n // there were any real changes\n if (!isArrayEqual(layoutedNodes, nodes)) {\n setNodes(layoutedNodes)\n if (onNodesChangedListener) {\n onNodesChangedListener(layoutedNodes)\n }\n }\n if (!isArrayEqual(layoutedEdges, edges)) {\n setEdges(layoutedEdges)\n if (onEdgesChangedListener) {\n onEdgesChangedListener(layoutedEdges)\n }\n }\n }, [\n tempNodes,\n tempEdges,\n nodes,\n edges,\n setNodes,\n setEdges,\n initializedPosition,\n reactFlowInstance,\n rootEntityRefs,\n onNodesChangedListener,\n onEdgesChangedListener,\n ])\n\n const onPaneScrollFunction: (event?: WheelEvent) => void = useCallback(\n event => {\n // Cannot simply check the truthy value of event.deltaX (or Y) because the value might be 0 (or -0), which is falsy\n if (\n event &&\n typeof event.deltaX !== 'undefined' &&\n typeof event.deltaY !== 'undefined'\n ) {\n window.scrollTo(\n window.scrollX + event.deltaX,\n window.scrollY + event.deltaY,\n )\n }\n },\n [],\n )\n return (\n <div\n className=\"ProvenanceWidget\"\n role=\"graphics-doc\" //https://www.w3.org/wiki/SVG_Accessibility/ARIA_roles_for_charts#Document_Roles\n style={{\n width: '100%',\n height: containerHeight,\n }}\n >\n {showNoProvenance ? (\n <Stack\n sx={{\n display: 'flex',\n height: '100%',\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center',\n }}\n >\n <Typography\n sx={{\n color: NO_PROVENANCE_TEXT_COLOR,\n fontSize: '16px',\n lineHeight: '24px',\n fontWeight: 540,\n marginBottom: '12px',\n }}\n >\n {NO_PROVENANCE_TITLE}\n </Typography>\n <Typography\n sx={{\n color: NO_PROVENANCE_TEXT_COLOR,\n fontSize: '14px',\n lineHeight: '20px',\n fontWeight: 440,\n }}\n >\n {NO_PROVENANCE_MESSAGE(entityTypeName)}\n </Typography>\n {onEditProvenanceClicked && (\n <Button\n variant=\"outlined\"\n sx={{\n borderRadius: '6px',\n border: '1px solid',\n borderColor: EDIT_PROVENANCE_BUTTON_BORDER_COLOR,\n background: EDIT_PROVENANCE_BUTTON_BACKGROUND_COLOR,\n color: EDIT_PROVENANCE_BUTTON_TEXT_COLOR,\n fontWeight: 540,\n lineHeight: '12px' /* 100% */,\n letterSpacing: '-0.24px',\n marginTop: '20px',\n height: '28px',\n padding: '8px',\n }}\n onClick={onEditProvenanceClicked}\n >\n {EDIT_PROVENANCE_TEXT}\n </Button>\n )}\n </Stack>\n ) : (\n <ReactFlow\n defaultViewport={{ x: 0, y: 0, zoom: DEFAULT_ZOOM }}\n nodes={nodes}\n edges={edges}\n onNodeClick={onClickNode}\n // onNodesChange={onNodesChange} // SWC-6804: When the nodes/edges are updated (expanded) the graph is already re-rendered.\n // onEdgesChange={onEdgesChange} // Specifying these callbacks causes an infinite re-rendering loop.\n attributionPosition=\"bottom-right\"\n onConnect={undefined}\n zoomOnScroll={false}\n onPaneScroll={onPaneScrollFunction}\n >\n <Controls />\n </ReactFlow>\n )}\n </div>\n )\n}\n\nconst ProvenanceGraph = (props: ProvenanceProps): React.ReactNode => {\n return (\n <SynapseErrorBoundary>\n <ReactFlowProvider>\n <ProvenanceReactFlow {...props} />\n </ReactFlowProvider>\n </SynapseErrorBoundary>\n )\n}\n\nexport default ProvenanceGraph\n"],"mappings":";;;;;;;;;;;;;;;;;AA6DA,IAAM,IAA4B,KAC5B,IAAe,KACR,IAAuB,mBACvB,IAAsB,sBAC7B,MAAyB,MAC7B,qDAAqD,EAAe,QAChE,IAA2B,WAC3B,KAAoC,WACpC,KAAsC,WACtC,KAA0C,6BAS1C,KAAuB,MAA4C;CACvE,IAAM,EACJ,YAAY,GACZ,qBAAkB,SAClB,kBAAe,CAAC,GAChB,kBAAe,CAAC,GAChB,2BACA,2BACA,+BACE,GACE,EAAE,mBAAgB,EAAkB,GACpC,CAAC,GAAW,KAAgB,EAAiB,CAAY,GACzD,CAAC,GAAW,KAAgB,EAAiB,CAAY,GACzD,CAAC,GAAO,KAAY,GAAc,CAAC,CAAC,GACpC,CAAC,GAAO,KAAY,GAAc,CAAC,CAAC,GACpC,CAAC,GAAa,KAAkB,EAAe,GAC/C,CAAC,IAAsB,MAC3B,EAAkB,EAAK,GACnB,IAAc,EAAgB,GAE9B,EAAE,MAAM,GAAuB,kBAAc,EACjD,GACA,EAAE,cAAc,GAAK,CACvB,GAEM,KAAwB;EAC5B,EAAS;EACT,EAAS;EACT,EAAS;EACT,EAAS;CACX,GACM,KAAqB,EAAM,MAAK,MACpC,GAAsB,SAAU,EAAK,KAA4B,IAAI,CACvE,GAEM,KAAmB,MAAwB,CAAC;CAElD,AACE,MACA,KACA,EAAsB,wBAAwB,KAG9C,EACE,wDAFiB,EAAe,KAAI,MAAO,EAAI,QAAQ,EAAE,KAAK,GAEN,GAC1D;CAEF,IAAM,IAAoB,GAAuB,SAC3C,IAAiB,IAAoB,KACvC,EACE,EAAwB,E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C,GAAD;GACE,IAAI;IACF,SAAS;IACT,QAAQ;IACR,YAAY;IACZ,gBAAgB;IAChB,WAAW;GACb;aAPF;IASE,kBAAC,GAAD;KACE,IAAI;MACF,OAAO;MACP,UAAU;MACV,YAAY;MACZ,YAAY;MACZ,cAAc;KAChB;eAEC;IACS,CAAA;IACZ,kBAAC,GAAD;KACE,IAAI;MACF,OAAO;MACP,UAAU;MACV,YAAY;MACZ,YAAY;KACd;eAEC,GAAsB,CAAc;IAC3B,CAAA;IACX,KACC,kBAAC,IAAD;KACE,SAAQ;KACR,IAAI;MACF,cAAc;MACd,QAAQ;MACR,aAAa;MACb,YAAY;MACZ,OAAO;MACP,YAAY;MACZ,YAAY;MACZ,eAAe;MACf,WAAW;MACX,QAAQ;MACR,SAAS;KACX;KACA,SAAS;;IAGH,CAAA;GAEL;OAEP,kBAAC,GAAD;GACE,iBAAiB;IAAE,GAAG;IAAG,GAAG;IAAG,MAAM;GAAa;GAC3C;GACA;GACP,aAAa;GAGb,qBAAoB;GACpB,WAAW,KAAA;GACX,cAAc;GACd,cAAc;aAEd,kBAAC,GAAD,CAAW,CAAA;EACF,CAAA;CAEV,CAAA;AAET,GAEM,KAAmB,MAErB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAqB,GAAI,EAAQ,CAAA,EAChB,CAAA,EACC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessLevelMenu.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseChat/AccessLevelMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAGlE,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,gBAAgB,CAAA;IACjC,QAAQ,EAAE,CAAC,cAAc,EAAE,gBAAgB,KAAK,IAAI,CAAA;CACrD,CAAA;AAcD,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,eAAe,GAChB,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"AccessLevelMenu.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseChat/AccessLevelMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAGlE,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,gBAAgB,CAAA;IACjC,QAAQ,EAAE,CAAC,cAAc,EAAE,gBAAgB,KAAK,IAAI,CAAA;CACrD,CAAA;AAcD,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,eAAe,GAChB,EAAE,oBAAoB,2CAkCtB;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessLevelMenu.js","names":[],"sources":["../../../src/components/SynapseChat/AccessLevelMenu.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { Box, Typography } from '@mui/material'\nimport { AgentAccessLevel } from '@sage-bionetworks/synapse-types'\nimport DropdownSelect from '../DropdownSelect'\n\nexport type AccessLevelMenuProps = {\n initAccessLevel: AgentAccessLevel\n onChange: (newAccessLevel: AgentAccessLevel) => void\n}\n\nconst accessLevelOptions = [\n { value: AgentAccessLevel.PUBLICLY_ACCESSIBLE, label: 'Public Data Only' },\n {\n value: AgentAccessLevel.READ_YOUR_PRIVATE_DATA,\n label: 'Read Your Private Data',\n },\n {\n value: AgentAccessLevel.WRITE_YOUR_PRIVATE_DATA,\n label: 'Read & Write Your Data',\n },\n]\n\nexport function AccessLevelMenu({\n onChange,\n initAccessLevel,\n}: AccessLevelMenuProps) {\n const initOption = accessLevelOptions.findIndex(\n v => v.value == initAccessLevel,\n )\n const options = accessLevelOptions.map(v => v.label)\n const [selectedIndex, setSelectedIndex] = useState(initOption)\n return (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'flex-end',\n mt: '20px',\n }}\n >\n <Typography\n variant=\"label\"\n sx={{ gridColumn: '2', mt: '10px', mr: '15px' }}\n >\n Access:\n </Typography>\n <DropdownSelect\n variant={'outlined'}\n options={options}\n selectedIndex={selectedIndex}\n setSelectedIndex={index => {\n if (selectedIndex !== index) {\n setSelectedIndex(index)\n onChange(accessLevelOptions[index].value)\n }\n }}\n />\n </Box>\n )\n}\n\nexport default AccessLevelMenu\n"],"mappings":";;;;;;AAUA,IAAM,IAAqB;CACzB;EAAE,OAAO,EAAiB;EAAqB,OAAO;CAAmB;CACzE;EACE,OAAO,EAAiB;EACxB,OAAO;CACT;CACA;EACE,OAAO,EAAiB;EACxB,OAAO;CACT;AACF;AAEA,SAAgB,EAAgB,EAC9B,aACA,sBACuB;CACvB,IAAM,IAAa,EAAmB,WACpC,MAAK,EAAE,SAAS,CAClB,GACM,IAAU,EAAmB,KAAI,MAAK,EAAE,KAAK,GAC7C,CAAC,GAAe,KAAoB,EAAS,CAAU;CAC7D,OACE,kBAAC,GAAD;EACE,IAAI;GACF,SAAS;GACT,gBAAgB;GAChB,IAAI;EACN;YALF,CAOE,kBAAC,GAAD;GACE,SAAQ;GACR,IAAI;IAAE,YAAY;IAAK,IAAI;IAAQ,IAAI;GAAO;aAC/C;EAEW,CAAA,GACZ,kBAAC,GAAD;GACE,SAAS;
|
|
1
|
+
{"version":3,"file":"AccessLevelMenu.js","names":[],"sources":["../../../src/components/SynapseChat/AccessLevelMenu.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { Box, Typography } from '@mui/material'\nimport { AgentAccessLevel } from '@sage-bionetworks/synapse-types'\nimport DropdownSelect from '../DropdownSelect'\n\nexport type AccessLevelMenuProps = {\n initAccessLevel: AgentAccessLevel\n onChange: (newAccessLevel: AgentAccessLevel) => void\n}\n\nconst accessLevelOptions = [\n { value: AgentAccessLevel.PUBLICLY_ACCESSIBLE, label: 'Public Data Only' },\n {\n value: AgentAccessLevel.READ_YOUR_PRIVATE_DATA,\n label: 'Read Your Private Data',\n },\n {\n value: AgentAccessLevel.WRITE_YOUR_PRIVATE_DATA,\n label: 'Read & Write Your Data',\n },\n]\n\nexport function AccessLevelMenu({\n onChange,\n initAccessLevel,\n}: AccessLevelMenuProps) {\n const initOption = accessLevelOptions.findIndex(\n v => v.value == initAccessLevel,\n )\n const options = accessLevelOptions.map(v => v.label)\n const [selectedIndex, setSelectedIndex] = useState(initOption)\n return (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'flex-end',\n mt: '20px',\n }}\n >\n <Typography\n variant=\"label\"\n sx={{ gridColumn: '2', mt: '10px', mr: '15px' }}\n >\n Access:\n </Typography>\n <DropdownSelect\n variant={'outlined'}\n buttonGroupAriaLabel={'Access Level Menu'}\n options={options}\n selectedIndex={selectedIndex}\n setSelectedIndex={index => {\n if (selectedIndex !== index) {\n setSelectedIndex(index)\n onChange(accessLevelOptions[index].value)\n }\n }}\n />\n </Box>\n )\n}\n\nexport default AccessLevelMenu\n"],"mappings":";;;;;;AAUA,IAAM,IAAqB;CACzB;EAAE,OAAO,EAAiB;EAAqB,OAAO;CAAmB;CACzE;EACE,OAAO,EAAiB;EACxB,OAAO;CACT;CACA;EACE,OAAO,EAAiB;EACxB,OAAO;CACT;AACF;AAEA,SAAgB,EAAgB,EAC9B,aACA,sBACuB;CACvB,IAAM,IAAa,EAAmB,WACpC,MAAK,EAAE,SAAS,CAClB,GACM,IAAU,EAAmB,KAAI,MAAK,EAAE,KAAK,GAC7C,CAAC,GAAe,KAAoB,EAAS,CAAU;CAC7D,OACE,kBAAC,GAAD;EACE,IAAI;GACF,SAAS;GACT,gBAAgB;GAChB,IAAI;EACN;YALF,CAOE,kBAAC,GAAD;GACE,SAAQ;GACR,IAAI;IAAE,YAAY;IAAK,IAAI;IAAQ,IAAI;GAAO;aAC/C;EAEW,CAAA,GACZ,kBAAC,GAAD;GACE,SAAS;GACT,sBAAsB;GACb;GACM;GACf,mBAAkB,MAAS;IACzB,AAAI,MAAkB,MACpB,EAAiB,CAAK,GACtB,EAAS,EAAmB,GAAO,KAAK;GAE5C;EACD,CAAA,CACE;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridAgentChat.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseChat/GridAgentChat.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GridAgentChat.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseChat/GridAgentChat.tsx"],"names":[],"mappings":"AAmBA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,iEAAiE;IACjE,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED,wBAAgB,aAAa,CAAC,EAC5B,aAAa,EACb,cAAc,EACd,WAA8B,EAC9B,cAAc,EACd,IAAI,EACJ,OAAO,EACP,mBAAmB,GACpB,EAAE,kBAAkB,2CAsCpB;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import n from "
|
|
1
|
+
import { useGetFeatureFlag as e } from "../../synapse-queries/featureflags/useGetFeatureFlag.js";
|
|
2
|
+
import { FeatureFlagEnum as t } from "../../utils/featureflag/FeatureFlags.js";
|
|
3
|
+
import { useChatState as n } from "./useChatState.js";
|
|
4
|
+
import { SynapseChat as r } from "./SynapseChat.js";
|
|
5
|
+
import i from "../DraggableDialog/DraggableDialog.js";
|
|
4
6
|
import "./index.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { ForwardRef as a } from "../../assets/illustrations/curie_avatar_head.js";
|
|
8
|
+
import { useState as o } from "react";
|
|
9
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
10
|
+
import { AgentAccessLevel as c } from "@sage-bionetworks/synapse-types";
|
|
8
11
|
//#region src/components/SynapseChat/GridAgentChat.tsx
|
|
9
|
-
var
|
|
12
|
+
var l = [
|
|
10
13
|
"Help me fill this out",
|
|
11
14
|
"Help me understand this",
|
|
12
15
|
"Find missing fields"
|
|
13
16
|
];
|
|
14
|
-
function
|
|
15
|
-
let [
|
|
16
|
-
return /* @__PURE__ */ i
|
|
17
|
-
open:
|
|
18
|
-
onClose:
|
|
19
|
-
title:
|
|
20
|
-
children: /* @__PURE__ */
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
function u({ gridSessionId: u, usersReplicaId: d, chatbotName: f = "Grid Assistant", initialMessage: p, open: m, onClose: h, agentRegistrationId: g }) {
|
|
18
|
+
let [_, v] = o(), y = n(_), b = e(t.GRID_AGENT_V2);
|
|
19
|
+
return /* @__PURE__ */ s(i, {
|
|
20
|
+
open: m,
|
|
21
|
+
onClose: h,
|
|
22
|
+
title: f,
|
|
23
|
+
children: /* @__PURE__ */ s(r, {
|
|
24
|
+
agentAvatar: /* @__PURE__ */ s(a, {
|
|
25
|
+
width: 35,
|
|
26
|
+
height: "auto"
|
|
27
|
+
}),
|
|
28
|
+
agentRegistrationId: g,
|
|
29
|
+
chatbotName: f,
|
|
30
|
+
initialMessage: p,
|
|
24
31
|
sessionContext: {
|
|
25
32
|
concreteType: "org.sagebionetworks.repo.model.agent.GridAgentSessionContext",
|
|
26
|
-
gridSessionId:
|
|
27
|
-
usersReplicaId:
|
|
33
|
+
gridSessionId: u,
|
|
34
|
+
usersReplicaId: d,
|
|
35
|
+
experimental: b
|
|
28
36
|
},
|
|
29
37
|
textboxPositionOffset: "16px",
|
|
30
38
|
hideTitle: !0,
|
|
31
39
|
showAccessLevelMenu: !1,
|
|
32
|
-
defaultAgentAccessLevel:
|
|
33
|
-
externalSession:
|
|
34
|
-
setExternalSession:
|
|
35
|
-
externalChatState:
|
|
36
|
-
suggestedPrompts:
|
|
40
|
+
defaultAgentAccessLevel: c.WRITE_YOUR_PRIVATE_DATA,
|
|
41
|
+
externalSession: _,
|
|
42
|
+
setExternalSession: v,
|
|
43
|
+
externalChatState: y,
|
|
44
|
+
suggestedPrompts: l,
|
|
45
|
+
allowAttachments: b
|
|
37
46
|
})
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
//#endregion
|
|
41
|
-
export {
|
|
50
|
+
export { u as GridAgentChat, u as default };
|
|
42
51
|
|
|
43
52
|
//# sourceMappingURL=GridAgentChat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridAgentChat.js","names":[],"sources":["../../../src/components/SynapseChat/GridAgentChat.tsx"],"sourcesContent":["import { useChatState } from '@/components/SynapseChat/useChatState'\nimport {
|
|
1
|
+
{"version":3,"file":"GridAgentChat.js","names":[],"sources":["../../../src/components/SynapseChat/GridAgentChat.tsx"],"sourcesContent":["import { useChatState } from '@/components/SynapseChat/useChatState'\nimport {\n AgentSession,\n GridAgentSessionContext,\n} from '@sage-bionetworks/synapse-client'\nimport { AgentAccessLevel } from '@sage-bionetworks/synapse-types'\nimport { useState } from 'react'\nimport DraggableDialog from '../DraggableDialog/DraggableDialog'\nimport { SynapseChat } from './index'\nimport { ReactComponent as CurieAvatarHead } from '@/assets/illustrations/curie_avatar_head.svg'\nimport { useGetFeatureFlag } from '@/synapse-queries/featureflags/useGetFeatureFlag'\nimport { FeatureFlagEnum } from '@/utils/featureflag/FeatureFlags'\n\nconst suggestedPrompts = [\n 'Help me fill this out',\n 'Help me understand this',\n 'Find missing fields',\n]\n\nexport type GridAgentChatProps = {\n gridSessionId: string\n usersReplicaId: number\n chatbotName?: string\n initialMessage?: string\n open: boolean\n onClose: () => void\n /** Optional ID to use a different agent registered in Synapse */\n agentRegistrationId?: string\n}\n\nexport function GridAgentChat({\n gridSessionId,\n usersReplicaId,\n chatbotName = 'Grid Assistant',\n initialMessage,\n open,\n onClose,\n agentRegistrationId,\n}: GridAgentChatProps) {\n // Storing state for the chat session here preserves chat history while the dialog is opened and closed.\n const [agentSession, setAgentSession] = useState<AgentSession | undefined>()\n const chatState = useChatState(agentSession)\n\n // Feature flag to enable the new Grid Agent V2 functionality (multi-agent and attachment support).\n const useGridAgentV2 = useGetFeatureFlag(FeatureFlagEnum.GRID_AGENT_V2)\n\n // Create session context for grid sessions\n const sessionContext: GridAgentSessionContext = {\n concreteType:\n 'org.sagebionetworks.repo.model.agent.GridAgentSessionContext',\n gridSessionId,\n usersReplicaId,\n experimental: useGridAgentV2,\n }\n\n return (\n <DraggableDialog open={open} onClose={onClose} title={chatbotName}>\n <SynapseChat\n agentAvatar={<CurieAvatarHead width={35} height=\"auto\" />}\n agentRegistrationId={agentRegistrationId}\n chatbotName={chatbotName}\n initialMessage={initialMessage}\n sessionContext={sessionContext}\n textboxPositionOffset=\"16px\"\n hideTitle={true}\n showAccessLevelMenu={false}\n defaultAgentAccessLevel={AgentAccessLevel.WRITE_YOUR_PRIVATE_DATA}\n // lift state: allow GridAgentChat to control the agent session and interactions\n externalSession={agentSession}\n setExternalSession={setAgentSession}\n externalChatState={chatState}\n suggestedPrompts={suggestedPrompts}\n allowAttachments={useGridAgentV2}\n />\n </DraggableDialog>\n )\n}\n\nexport default GridAgentChat\n"],"mappings":";;;;;;;;;;;AAaA,IAAM,IAAmB;CACvB;CACA;CACA;AACF;AAaA,SAAgB,EAAc,EAC5B,kBACA,mBACA,iBAAc,kBACd,mBACA,SACA,YACA,0BACqB;CAErB,IAAM,CAAC,GAAc,KAAmB,EAAmC,GACrE,IAAY,EAAa,CAAY,GAGrC,IAAiB,EAAkB,EAAgB,aAAa;CAWtE,OACE,kBAAC,GAAD;EAAuB;EAAe;EAAS,OAAO;YACpD,kBAAC,GAAD;GACE,aAAa,kBAAC,GAAD;IAAiB,OAAO;IAAI,QAAO;GAAQ,CAAA;GACnC;GACR;GACG;GACA,gBAAA;IAdpB,cACE;IACF;IACA;IACA,cAAc;GAUM;GAChB,uBAAsB;GACtB,WAAW;GACX,qBAAqB;GACrB,yBAAyB,EAAiB;GAE1C,iBAAiB;GACjB,oBAAoB;GACpB,mBAAmB;GACD;GAClB,kBAAkB;EACnB,CAAA;CACc,CAAA;AAErB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChatState } from '@/components/SynapseChat/useChatState';
|
|
2
|
-
import { GridAgentSessionContext } from '@sage-bionetworks/synapse-client';
|
|
3
|
-
import { AgentAccessLevel
|
|
2
|
+
import { AgentSession, GridAgentSessionContext } from '@sage-bionetworks/synapse-client';
|
|
3
|
+
import { AgentAccessLevel } from '@sage-bionetworks/synapse-types';
|
|
4
4
|
export type SynapseChatProps = {
|
|
5
5
|
initialMessage?: string;
|
|
6
6
|
agentRegistrationId?: string;
|
|
@@ -21,16 +21,14 @@ export type SynapseChatProps = {
|
|
|
21
21
|
onChatResponse?: (responseText: string) => void;
|
|
22
22
|
/** Optional list of prompt suggestions shown as clickable pills above the text input */
|
|
23
23
|
suggestedPrompts?: string[];
|
|
24
|
+
/** Optional custom avatar for the chatbot agent */
|
|
25
|
+
agentAvatar?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Whether to allow the user to attach local files to their chat message.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
allowAttachments?: boolean;
|
|
24
31
|
};
|
|
25
|
-
export
|
|
26
|
-
userMessage: string;
|
|
27
|
-
chatResponseText?: string;
|
|
28
|
-
chatErrorReason?: string;
|
|
29
|
-
chatResponseTrace?: TraceEventWithFriendlyMessage[];
|
|
30
|
-
};
|
|
31
|
-
export type TraceEventWithFriendlyMessage = {
|
|
32
|
-
friendlyMessage?: string;
|
|
33
|
-
} & TraceEvent;
|
|
34
|
-
export declare function SynapseChat({ initialMessage, agentRegistrationId, chatbotName, hideTitle, textboxPositionOffset, sessionContext, externalSession, setExternalSession, externalChatState, showAccessLevelMenu, onChatResponse, suggestedPrompts, }: SynapseChatProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare function SynapseChat({ initialMessage, agentRegistrationId, chatbotName, agentAvatar, hideTitle, textboxPositionOffset, sessionContext, externalSession, setExternalSession, externalChatState, showAccessLevelMenu, onChatResponse, suggestedPrompts, allowAttachments, }: SynapseChatProps): import("react/jsx-runtime").JSX.Element;
|
|
35
33
|
export default SynapseChat;
|
|
36
34
|
//# sourceMappingURL=SynapseChat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SynapseChat.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseChat/SynapseChat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,MAAM,uCAAuC,CAAA;
|
|
1
|
+
{"version":3,"file":"SynapseChat.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseChat/SynapseChat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,MAAM,uCAAuC,CAAA;AAO/E,OAAO,EACL,YAAY,EAEZ,uBAAuB,EACxB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AA4BlE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAE9B,cAAc,CAAC,EAAE,uBAAuB,CAAA;IAExC,eAAe,CAAC,EAAE,YAAY,CAAA;IAE9B,kBAAkB,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,GAAG,SAAS,KAAK,IAAI,CAAA;IAE1D,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAE7B,uBAAuB,CAAC,EAAE,gBAAgB,CAAA;IAE1C,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,C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