synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
571 lines (570 loc) • 20.9 kB
JavaScript
import { jsxs as t, Fragment as p, jsx as e } from "react/jsx-runtime";
import G from "../../assets/icons/SynapseIconWhite.js";
import U from "../../assets/icons/SynapseLogoName.js";
import "../../synapse-client/SynapseClient.js";
import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode";
import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse";
import "@sage-bionetworks/synapse-client/util/SynapseClientError";
import { Direction as H, SubmissionSortField as $, SubmissionState as B } from "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import "../../utils/SynapseConstants.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "@tanstack/react-query";
import "../../utils/PermissionLevelToAccessType.js";
import { useState as C } from "react";
import { useOneSageURL as L } from "../../utils/hooks/useOneSageURL.js";
import "use-deep-compare-effect";
import { useSynapseContext as V } from "../../utils/context/SynapseContext.js";
import { Drawer as O, List as x, Tooltip as v, TextField as b, InputAdornment as P, ListItemButton as W, Badge as J } from "@mui/material";
import "../../utils/hooks/useCookiePreferences.js";
import "../../utils/hooks/useSourceAppConfigs.js";
import { storeRedirectURLForOneSageLoginAndGotoURL as q } from "../../utils/AppUtils/AppUtils.js";
import { useApplicationSessionContext as Q } from "../../utils/AppUtils/session/ApplicationSessionContext.js";
import "../../utils/context/FullContextProvider.js";
import "../../utils/context/DocumentMetadataContext.js";
import '../../style/components/_spinner.css';/* empty css */
import "@tanstack/query-core";
import "lodash-es/isEmpty";
import "lodash-es/isEqual";
import "lodash-es/xorWith";
import "react-router";
import "@sage-bionetworks/synapse-client";
import "../../utils/types/IsType.js";
import { useSearchAccessSubmissionsInfinite as K } from "../../synapse-queries/dataaccess/useDataAccessSubmission.js";
import { useGetDownloadListStatistics as z } from "../../synapse-queries/download/useDownloadList.js";
import { useGetCurrentUserBundle as Y } from "../../synapse-queries/user/useUserBundle.js";
import { CreateProjectModal as X } from "../CreateProjectModal/CreateProjectModal.js";
import N from "../IconSvg/IconSvg.js";
import { PLANS_LINK as Z } from "../SynapseHomepageV2/SynapseHomepageNavBar.js";
import { UserCard as ee } from "../UserCard/UserCard.js";
import { DEFAULT_SEARCH_QUERY as j } from "../../utils/searchDefaults.js";
var re = /* @__PURE__ */ ((r) => (r[r.PROJECTS = 0] = "PROJECTS", r[r.FAVORITES = 1] = "FAVORITES", r[r.TEAMS = 2] = "TEAMS", r[r.CHALLENGES = 3] = "CHALLENGES", r[r.DOWNLOADS = 4] = "DOWNLOADS", r[r.SEARCH = 5] = "SEARCH", r[r.PROFILE = 6] = "PROFILE", r[r.HELP = 7] = "HELP", r))(re || {});
const We = (r) => {
const o = {
...j,
queryTerm: r
};
return encodeURIComponent(JSON.stringify(o));
}, oe = {
// To support project search, we send this json object in the url.
// We update the queryTerm array based on user input.
...j,
booleanQuery: [
{
key: "node_type",
value: "project"
}
]
}, ne = (r) => {
const o = {
...oe,
queryTerm: r
};
return encodeURIComponent(JSON.stringify(o));
}, l = (r) => {
const {
tooltip: o,
iconName: d,
onClickOpenNavMenu: f,
onClickGoToPlace: c,
additionalChildren: h,
badgeContent: k,
isCurrentlySelectedItem: m = !1,
handleDrawerClose: g,
handleDrawerOpen: u
} = r, w = /* @__PURE__ */ e(v, { title: o, placement: "right", children: /* @__PURE__ */ e(
W,
{
onClick: m || c ? g : () => {
u(f);
},
className: "SRC-whiteText",
selected: m,
children: /* @__PURE__ */ e(J, { badgeContent: k, color: "secondary", children: d ? /* @__PURE__ */ t(p, { children: [
/* @__PURE__ */ e(N, { icon: d }),
" ",
h,
" "
] }) : h })
},
d
) });
return c ? /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
"a",
{
onClick: c,
rel: "noopener noreferrer",
className: "SRC-whiteText",
children: w
}
) }) : /* @__PURE__ */ e("li", { children: w });
};
function Je({
initIsOpen: r = !1,
gotoPlace: o
}) {
const [d, f] = C(r), [c, h] = C(), [k, m] = C(""), [g, u] = C(""), [A, R] = C(!1), { clearSession: w } = Q(), { isAuthenticated: S } = V(), { data: T } = Y(), a = S && T ? T.userProfile : void 0, { data: E } = z({
enabled: S
}), _ = E?.totalNumberOfFiles, { data: D } = K(
{
submissionState: B.SUBMITTED,
sort: [
{
field: $.CREATED_ON,
direction: H.DESC
}
]
},
{
enabled: T?.isARReviewer
}
);
let y = D?.pages[0].results.length ?? 0;
D?.pages[0].nextPageToken && (y = `${y}+`);
const s = (i) => {
f(!0), h(i);
}, n = () => {
f(!1), h(void 0);
}, I = (i) => {
o(
`/SearchV2:default?query=${ne(
i.split(/[ ,]+/)
)}`
);
}, M = L(), F = L("/authenticated/myaccount");
return /* @__PURE__ */ t(p, { children: [
/* @__PURE__ */ t("div", { className: "SynapseNavDrawer", children: [
/* @__PURE__ */ t(
O,
{
variant: "permanent",
className: `SynapseNavDrawerMenu ${d ? "tempDrawerOpen" : ""}`,
children: [
/* @__PURE__ */ e("div", { onClick: n, children: /* @__PURE__ */ e(
"a",
{
className: "synapseIcon",
rel: "noopener noreferrer",
onClick: () => o("/Home:x"),
"aria-label": "Synapse Home",
children: /* @__PURE__ */ e(G, {})
}
) }),
/* @__PURE__ */ t(x, { children: [
S && a && /* @__PURE__ */ t(p, { children: [
/* @__PURE__ */ e(
l,
{
tooltip: "Projects",
iconName: "dashboard",
onClickOpenNavMenu: 0,
isCurrentlySelectedItem: c == 0,
handleDrawerClose: n,
handleDrawerOpen: s
}
),
/* @__PURE__ */ e(
l,
{
tooltip: "Favorites",
iconName: "favTwoTone",
onClickGoToPlace: () => o(
`/Profile:${a.ownerId}/favorites`
),
handleDrawerClose: n,
handleDrawerOpen: s
}
),
/* @__PURE__ */ e(
l,
{
tooltip: "Teams",
iconName: "peopleTwoTone",
onClickGoToPlace: () => o(`/Profile:${a.ownerId}/teams`),
handleDrawerClose: n,
handleDrawerOpen: s
}
),
/* @__PURE__ */ e(
l,
{
tooltip: "Challenges",
iconName: "challengesTwoTone",
onClickGoToPlace: () => o(
`/Profile:${a.ownerId}/challenges`
),
handleDrawerClose: n,
handleDrawerOpen: s
}
),
/* @__PURE__ */ e(
l,
{
tooltip: "Download List",
iconName: "download",
onClickGoToPlace: () => o("/DownloadCart:0"),
badgeContent: _,
handleDrawerClose: n,
handleDrawerOpen: s
}
),
/* @__PURE__ */ e(
l,
{
tooltip: "Trash Can",
iconName: "delete",
onClickGoToPlace: () => o("/Trash:0"),
handleDrawerClose: n,
handleDrawerOpen: s
}
),
T?.isARReviewer && /* @__PURE__ */ e(
l,
{
tooltip: "Data Access Management",
iconName: "accessManagement",
onClickGoToPlace: () => o("/DataAccessManagement:default/Submissions"),
badgeContent: y,
handleDrawerClose: n,
handleDrawerOpen: s
}
)
] }),
/* @__PURE__ */ e(
l,
{
tooltip: "Search",
iconName: "search",
onClickGoToPlace: () => o("/SearchV2:default"),
handleDrawerClose: n,
handleDrawerOpen: s
}
)
] }),
/* @__PURE__ */ e("div", { className: "filler" }),
/* @__PURE__ */ t(x, { children: [
S && a && /* @__PURE__ */ e(
l,
{
tooltip: "Your Account",
onClickOpenNavMenu: 6,
additionalChildren: /* @__PURE__ */ e(
ee,
{
userProfile: a,
size: "AVATAR",
avatarSize: "SMALL"
}
),
isCurrentlySelectedItem: c == 6,
handleDrawerClose: n,
handleDrawerOpen: s
}
),
!S && /* @__PURE__ */ e(
l,
{
tooltip: "Sign in",
iconName: "login",
onClickGoToPlace: () => q(
M.toString()
),
handleDrawerClose: n,
handleDrawerOpen: s
}
),
/* @__PURE__ */ e(
l,
{
tooltip: "Help",
iconName: "helpOutlined",
onClickOpenNavMenu: 7,
isCurrentlySelectedItem: c == 7,
handleDrawerClose: n,
handleDrawerOpen: s
}
)
] })
]
}
),
/* @__PURE__ */ t(
O,
{
variant: "temporary",
open: d,
className: "SynapseNavContentDrawer",
onClose: n,
children: [
/* @__PURE__ */ e("div", { className: "synapseLogoNameContainer", children: /* @__PURE__ */ e(U, {}) }),
/* @__PURE__ */ t("div", { className: "navContentContainer", children: [
c == 0 && /* @__PURE__ */ t(p, { children: [
/* @__PURE__ */ e("div", { className: "header projectHeader", children: "Projects" }),
/* @__PURE__ */ e(v, { title: "Create a New Project", placement: "right", children: /* @__PURE__ */ e(
"a",
{
className: "createProjectLink",
onClick: () => {
R(!0), n();
},
children: /* @__PURE__ */ e(N, { icon: "addCircleOutline" })
}
) }),
/* @__PURE__ */ e(
b,
{
type: "search",
placeholder: "Search All Projects",
value: k,
onChange: (i) => {
m(i.target.value);
},
onKeyDown: (i) => {
i.key === "Enter" && i.target.value !== "" && (m(""), n(), I(
i.target.value
));
},
slotProps: {
input: {
startAdornment: /* @__PURE__ */ e(P, { position: "start", children: /* @__PURE__ */ e(N, { icon: "searchOutlined" }) })
}
}
}
),
/* @__PURE__ */ t("div", { className: "linkList", onClick: n, children: [
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o(
`/Profile:${a?.ownerId}/projects/all`
),
rel: "noopener noreferrer",
children: "All"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o(
`/Profile:${a?.ownerId}/projects/created_by_me`
),
rel: "noopener noreferrer",
children: "Created By Me"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o(
`/Profile:${a?.ownerId}/projects/favorites`
),
rel: "noopener noreferrer",
children: "Favorite Projects"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o(
`/Profile:${a?.ownerId}/projects/shared_directly_with_me`
),
rel: "noopener noreferrer",
children: "Shared With Me"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o(
`/Profile:${a?.ownerId}/projects/all_my_team_projects`
),
rel: "noopener noreferrer",
children: "Team Projects"
}
)
] })
] }),
c == 6 && /* @__PURE__ */ t(p, { children: [
/* @__PURE__ */ t("div", { className: "header", children: [
"Welcome Back,",
/* @__PURE__ */ e("br", {}),
a?.userName,
"!"
] }),
/* @__PURE__ */ t("div", { className: "linkList", onClick: n, children: [
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o(
`/Profile:${a?.ownerId}/profile`
),
rel: "noopener noreferrer",
children: "View Profile"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
href: F.toString(),
target: "_blank",
rel: "noopener noreferrer",
children: "Account Settings"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o("/RequestHistory:default"),
rel: "noopener noreferrer",
children: "Access Requests"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o("/Following:0"),
rel: "noopener noreferrer",
children: "Following"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => {
w();
},
rel: "noopener noreferrer",
children: "Sign Out"
}
)
] })
] }),
c == 7 && /* @__PURE__ */ t(p, { children: [
/* @__PURE__ */ e("div", { className: "header", children: "Help" }),
/* @__PURE__ */ e(
b,
{
type: "search",
placeholder: "Search Documentation",
value: g,
onChange: (i) => {
u(i.target.value);
},
onKeyDown: (i) => {
i.key === "Enter" && i.target.value !== "" && (window.open(
`https://help.synapse.org/search.html?max=10&s=docs&q=${encodeURI(
i.target.value
)}`
), u(""), n());
},
slotProps: {
input: {
startAdornment: /* @__PURE__ */ e(P, { position: "start", children: /* @__PURE__ */ e(N, { icon: "searchOutlined" }) })
}
}
}
),
/* @__PURE__ */ t("div", { className: "linkList", onClick: n, children: [
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
href: "https://help.synapse.org/docs/Getting-Started.2055471150.html",
rel: "noopener noreferrer",
target: "_blank",
children: "Getting Started"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
onClick: () => o(Z),
rel: "noopener noreferrer",
target: "_blank",
children: "Plans"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
href: "https://help.synapse.org/docs/",
rel: "noopener noreferrer",
target: "_blank",
children: "Synapse Web Documentation"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
href: "https://python-docs.synapse.org/en/stable/",
rel: "noopener noreferrer",
target: "_blank",
children: "Python Client Documentation"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
href: "https://r-docs.synapse.org/",
rel: "noopener noreferrer",
target: "_blank",
children: "R Client Documentation"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
href: "https://blog.synapse.org/",
rel: "noopener noreferrer",
children: "Blog"
}
),
/* @__PURE__ */ e(
"a",
{
className: "SRC-whiteText",
href: "https://sagebionetworks.jira.com/servicedesk/customer/portals/",
rel: "noopener noreferrer",
target: "_blank",
children: "Contact Us"
}
)
] })
] })
] })
]
}
)
] }),
/* @__PURE__ */ e(
X,
{
onClose: () => R(!1),
isShowingModal: A
}
)
] });
}
export {
re as NavItem,
Je as SynapseNavDrawer,
Je as default,
We as getSearchToken
};
//# sourceMappingURL=SynapseNavDrawer.js.map