synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
129 lines (128 loc) • 3.96 kB
JavaScript
import { jsx as e, jsxs as B, Fragment as S } from "react/jsx-runtime";
import { ReactComponent as L } from "../../assets/icons/DoubleQuotes.svg.js";
import { Skeleton as R, Button as G } from "@mui/material";
import { useGetDOIAssociation as P } from "../../synapse-queries/doi/useDOI.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 "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import "../../utils/SynapseConstants.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "../../utils/context/SynapseContext.js";
import "@tanstack/react-query";
import { useState as s, useRef as U } from "react";
import "@tanstack/query-core";
import k from "../../synapse-queries/entity/useEntityBundle.js";
import "../../utils/PermissionLevelToAccessType.js";
import "use-deep-compare-effect";
import "lodash-es/isEmpty";
import "lodash-es/isEqual";
import "lodash-es/xorWith";
import { DoiObjectType as I } from "@sage-bionetworks/synapse-client";
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 "react-router";
import "../../utils/types/IsType.js";
import { CitationPopoverContent as F } from "../CitationPopover/CitationPopoverContent.js";
import { useGetEntityDoiAssociation as O } from "./EntityCitationUtils.js";
import Y from "../DropdownSelect/DropdownSelect.js";
const bt = ({
projectId: p,
entityId: m,
versionNumber: l
}) => {
const { data: C, isLoading: c } = k(
m,
l
), [g, E] = s(null), [d, r] = s(void 0), [u, n] = s(
null
), [A, D] = s(
void 0
), f = U(null), T = !!g ? "cite-as-popover" : void 0, t = O(
m,
l,
p,
C
), { data: o, isLoading: a } = P(
{
id: p,
version: void 0,
type: I.ENTITY
},
{
enabled: !!p
}
), h = o && t;
function b() {
return h ? "Cite as..." : t && !o ? "Cite page" : !t && o ? "Cite project" : "";
}
const v = b(), y = (i) => {
t && !o ? (r(t.doiUri), n(i.currentTarget)) : !t && o ? (r(o.doiUri), n(i.currentTarget)) : E(i.currentTarget);
}, j = /* @__PURE__ */ e(
F,
{
doi: d,
anchorEl: u,
open: !!u && !!d,
id: T,
onClose: () => {
n(null), r(void 0);
}
}
), w = ["Cite this Project", "Cite only this page"];
return !o && !t ? null : c || a ? /* @__PURE__ */ e(
R,
{
sx: {
width: { xs: "100%", sm: "140px" },
height: "45px"
}
}
) : /* @__PURE__ */ B(S, { children: [
h ? /* @__PURE__ */ e(
Y,
{
disabled: c && a,
options: w,
anchorRef: f,
sx: {
width: { xs: "100%", sm: "initial" }
},
buttonText: "Cite as...",
variant: "outlined",
buttonGroupAriaLabel: "Citation options",
selectedIndex: A,
setSelectedIndex: (i) => {
D(i);
const x = i === 0 ? o?.doiUri : t?.doiUri;
x && (r(x), n(f.current));
}
}
) : /* @__PURE__ */ e(
G,
{
onClick: y,
disabled: c && a,
sx: {
width: { xs: "100%", sm: "initial" }
},
variant: "outlined",
startIcon: /* @__PURE__ */ e(L, { width: 18, height: 18 }),
children: v
}
),
j
] });
};
export {
bt as default
};
//# sourceMappingURL=EntityCitation.js.map