synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
237 lines (236 loc) • 9.08 kB
JavaScript
import { jsxs as g, Fragment as a, jsx as t } from "react/jsx-runtime";
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 { RestrictableObjectType as m, SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as y, TERMS_OF_USE_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as ee, MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as E, ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as te, LOCK_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as re } 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 T, useMemo as D } from "react";
import { useOneSageURL as oe } from "../../utils/hooks/useOneSageURL.js";
import "use-deep-compare-effect";
import { useSynapseContext as ie } from "../../utils/context/SynapseContext.js";
import { Typography as _, DialogContent as se, DialogActions as ne, Button as ce, Dialog as ae, styled as me } from "@mui/material";
import "../../utils/hooks/useCookiePreferences.js";
import "../../utils/hooks/useSourceAppConfigs.js";
import { storeRedirectURLForOneSageLoginAndGotoURL as de } from "../../utils/AppUtils/AppUtils.js";
import "../../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 { useGetAccessRequirementsForTeam as ue, useGetAccessRequirementsForEntity as pe, useSortAccessRequirementIdsByCompletion as le } from "../../synapse-queries/dataaccess/useAccessRequirements.js";
import F from "lodash-es/noop";
import Re from "lodash-es/groupBy";
import { DialogBaseTitle as Te } from "../DialogBase.js";
import { EntityLink as Ee } from "../EntityLink.js";
import Ae from "../IconSvg/IconSvg.js";
import fe from "../UserOrTeamBadge/UserOrTeamBadge.js";
import { AccessRequirementListItem as Ce } from "./AccessRequirementListItem.js";
import { useCanShowManagedACTWikiInWizard as Se } from "./AccessRequirementListUtils.js";
import qe from "./ManagedACTAccessRequirementRequestFlow/CancelRequestDataAccess.js";
import he from "./ManagedACTAccessRequirementRequestFlow/DataAccessRequestAccessorsFilesForm/DataAccessRequestAccessorsFilesForm.js";
import ge from "./ManagedACTAccessRequirementRequestFlow/RequestDataAccessSuccess.js";
import ye from "./ManagedACTAccessRequirementRequestFlow/ResearchProjectForm/ResearchProjectForm.js";
import _e from "./RequirementItem/AuthenticatedRequirement.js";
import Ie from "./RequirementItem/CertificationRequirement.js";
import be from "./RequirementItem/TwoFactorAuthEnabledRequirement.js";
import Pe from "./RequirementItem/ValidationRequirement.js";
const j = [
y,
ee,
E,
te,
re
], Ue = new Set(j), N = me(
_,
{
label: "DialogSubsectionHeader"
}
)(({ theme: r }) => ({
marginTop: r.spacing(4),
marginBottom: r.spacing(2),
paddingBottom: r.spacing(1),
fontSize: "18px",
fontWeight: "bold",
borderBottom: "1px solid",
borderColor: r.palette.grey[200]
})), It = (r) => r.some(De), De = (r) => !Ue.has(r.concreteType);
function bt(r) {
const {
onHide: i = F,
renderAsModal: A = !1,
numberOfFilesAffected: f,
requestObjectName: C,
customDialogActions: I,
onSubmissionCreated: L = F
} = r, b = "entityId" in r, P = "teamId" in r, M = "accessRequirementFromProps" in r, o = "subjectId" in r ? r.subjectId : b ? r.entityId : P ? r.teamId : void 0, s = "subjectType" in r ? r.subjectType : b ? m.ENTITY : P ? m.TEAM : void 0;
let { dialogTitle: S = "Data Access Request" } = r;
const { isAuthenticated: O } = ie(), [U, v] = T(
0
/* SHOW_ALL_ARS */
), x = oe(), [q, k] = T(), [w, B] = T(""), [Y, W] = T(), V = Se(), { data: Q } = ue(
o,
{
enabled: o !== void 0 && s === m.TEAM
}
), { data: G } = pe(o, {
enabled: o !== void 0 && s === m.ENTITY
}), n = (M ? r.accessRequirementFromProps : void 0) ?? G ?? Q, { data: h } = le(
(n ?? []).map((e) => String(e.id)),
{
enabled: !!n,
// Set the stale time to infinity because we don't want to refetch this and change the order
staleTime: 1 / 0
}
), H = D(() => {
if (n && h) {
const e = Re(
n,
"concreteType"
);
return j.map((d) => {
const l = e[d];
return l ? h.map(
(R) => l.find((Z) => R === String(Z.id))
) : [];
}).flat().filter((d) => d !== void 0);
}
}, [n, h]), u = (e) => {
const {
managedACTAccessRequirement: p,
step: d,
researchProjectId: l,
dataAccessRequest: R
} = e;
p && k(p), l && B(l), R && W(R), v(d);
}, z = n?.some(
(e) => e.concreteType === E && e.isTwoFaRequired
), $ = n?.some(
(e) => (e.concreteType === E || e.concreteType === y) && e.isCertifiedUserRequired
), K = n?.some(
(e) => (e.concreteType === E || e.concreteType === y) && e.isValidatedProfileRequired
), J = D(() => C || (f ? /* @__PURE__ */ g(a, { children: [
/* @__PURE__ */ t(Ae, { icon: "file", sx: { width: "30px" } }),
" ",
f,
" ",
"File(s)"
] }) : o !== void 0 && s === m.ENTITY ? /* @__PURE__ */ t(Ee, { entity: o }) : s === m.TEAM ? /* @__PURE__ */ t(fe, { principalId: o }) : (console.warn(
`Unhandled case for AccessRequirementList requestDetails: ${s}: ${o}`
), /* @__PURE__ */ t(a, {}))), [f, C, o, s]), X = [
2,
1
/* UPDATE_RESEARCH_PROJECT */
].includes(U) && V ? "xl" : "md";
let c = /* @__PURE__ */ t(a, {});
switch (U) {
case 1:
c = /* @__PURE__ */ t(
ye,
{
managedACTAccessRequirement: q,
onSave: (e) => {
u({
managedACTAccessRequirement: q,
step: 2,
researchProjectId: e.id
});
},
onHide: i
}
);
break;
case 2:
c = /* @__PURE__ */ t(
he,
{
researchProjectId: w,
managedACTAccessRequirement: q,
subjectId: o ?? "",
subjectType: s ?? m.ENTITY,
onHide: i,
onCancel: (e) => {
u({
step: 3,
dataAccessRequest: e
});
},
onSubmissionCreated: (e) => {
u({
step: 5
/* COMPLETE */
}), L(e);
},
onBackClicked: () => {
u({
step: 1
/* UPDATE_RESEARCH_PROJECT */
});
}
}
);
break;
case 3:
c = /* @__PURE__ */ t(
qe,
{
modifiedDataAccessRequest: Y,
onHide: i
}
);
break;
case 4:
de(x.toString()), S = "Please Log In", c = /* @__PURE__ */ t(a, {});
break;
case 5:
c = /* @__PURE__ */ t(ge, { onHide: i });
break;
default:
c = /* @__PURE__ */ g(a, { children: [
A ? /* @__PURE__ */ t(Te, { title: S, onCancel: i }) : /* @__PURE__ */ t(_, { variant: "h5", sx: { mb: 2 }, children: S }),
/* @__PURE__ */ g(se, { children: [
/* @__PURE__ */ t(N, { variant: "h4", sx: { mt: 0 }, children: "What is this request for?" }),
/* @__PURE__ */ t(_, { variant: "body1", component: "span", children: J }),
/* @__PURE__ */ t(N, { variant: "h4", children: "What do I need to do?" }),
/* @__PURE__ */ t(_e, {}),
$ && /* @__PURE__ */ t(Ie, {}),
K && /* @__PURE__ */ t(Pe, {}),
z && /* @__PURE__ */ t(be, {}),
H?.map((e) => /* @__PURE__ */ t(
Ce,
{
accessRequirement: e,
subjectId: o,
subjectType: s,
onHide: i,
onRequestAccess: (p) => {
u({
managedACTAccessRequirement: p,
step: O ? 1 : 4
});
}
},
e.id
))
] }),
/* @__PURE__ */ t(ne, { children: I || /* @__PURE__ */ t(a, { children: A && /* @__PURE__ */ t(ce, { variant: "contained", onClick: i, children: "Close" }) }) })
] });
}
return A ? /* @__PURE__ */ t(ae, { maxWidth: X, fullWidth: !0, open: !0, onClose: i, children: c }) : /* @__PURE__ */ t(a, { children: c });
}
export {
It as checkHasUnsupportedRequirement,
bt as default
};
//# sourceMappingURL=AccessRequirementList.js.map