synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
115 lines (114 loc) • 3.51 kB
JavaScript
import { jsx as e, Fragment as m, jsxs as d } 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 I, RestrictionLevel as y } from "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import { SRC_SIGN_IN_CLASS as N } from "../../utils/SynapseConstants.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "@tanstack/react-query";
import "../../utils/PermissionLevelToAccessType.js";
import { useMemo as x } from "react";
import "../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import { Button as T, Box as k } from "@mui/material";
import "../../utils/hooks/useCookiePreferences.js";
import "../../utils/hooks/useSourceAppConfigs.js";
import "universal-cookie";
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 { useGetRestrictionInformation as v } from "../../synapse-queries/dataaccess/useRestrictionInformation.js";
import { RestrictionUiType as w } from "./AccessIcon.js";
import C from "./useHasAccess.js";
const h = { p: "0px", minWidth: "unset" };
function ct(s) {
const {
entityId: p,
showButtonText: a = !0,
showExternalAccessIcon: A = !1
} = s, {
restrictionUiType: t,
accessText: R,
icon: r,
handleGetAccess: l,
accessRequirementDialog: u
} = C(p, !0, void 0, { showExternalAccessIcon: A }), { data: i } = v({
restrictableObjectType: I.ENTITY,
objectId: p
}), f = x(() => t === w.AccessBlockedToAnonymous ? /* @__PURE__ */ e(
T,
{
sx: h,
className: N,
onClick: (o) => {
if (o.isTrusted) {
const n = new MouseEvent("click", { bubbles: !0 });
o.currentTarget.dispatchEvent(n);
}
},
children: r
}
) : r, [t]), b = x(() => {
if (!i || !t)
return /* @__PURE__ */ e(m, {});
const o = i?.hasUnmetAccessRequirement, n = i?.restrictionLevel;
let c = "";
if (o)
c = "Request Access";
else {
if (y.OPEN === n)
return f;
c = "View Terms";
}
return /* @__PURE__ */ d(m, { children: [
/* @__PURE__ */ d(
T,
{
sx: h,
className: s.className,
onClick: l,
children: [
r,
a && /* @__PURE__ */ e(
k,
{
sx: {
ml: "5px"
},
children: c
}
)
]
}
),
u
] });
}, [
i,
t,
f,
l,
s.className,
a,
u,
R,
r
]);
return t ? /* @__PURE__ */ e("span", { style: { whiteSpace: "nowrap" }, children: b }) : /* @__PURE__ */ e(m, {});
}
export {
ct as HasAccessV2,
ct as default
};
//# sourceMappingURL=HasAccessV2.js.map