synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
164 lines (163 loc) • 6.06 kB
JavaScript
import { jsx as e, jsxs as a, Fragment as p } 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 "@sage-bionetworks/synapse-types";
import { isVersionableEntity as K, isEntityRefCollectionView as V } from "../../../../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 F } from "react";
import "../../../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import { Link as d, Box as j } 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 { EntityType as H, DoiObjectType as R } from "@sage-bionetworks/synapse-client";
import "../../../../utils/types/IsType.js";
import { useGetEntityChildren as N } from "../../../../synapse-queries/entity/useGetEntityChildren.js";
import { useGetDOIAssociation as P } from "../../../../synapse-queries/doi/useDOI.js";
import { calculateFriendlyFileSize as Y } from "../../../../utils/functions/calculateFriendlyFileSize.js";
import _ from "../../../../utils/hooks/useGetEntityMetadata.js";
import { CopyToClipboardString as O } from "../../../CopyToClipboardString/CopyToClipboardString.js";
import { HasAccessV2 as $ } from "../../../HasAccess/HasAccessV2.js";
import { CitationsDialog as E } from "./CitationsDialog.js";
import { useDataCiteUsage as q, maxCitationCount as J } from "./useDataCiteUsage.js";
import { useGetMentions as Q } from "./useGetMentions.js";
import W from "../../../GenericCard/Linkify.js";
function Kt(o, I) {
const {
entityBundle: i,
fileHandle: r,
downloadAlias: u,
isContainer: s,
fileHandleStorageInfo: t,
uploadDestinationString: y
} = _(o, I), [M, f] = F(!1), [U, C] = F(!1), { data: T } = N(
{
parentId: o,
includeTypes: Object.values(H),
includeTotalChildCount: !0
},
{ enabled: s }
), k = i && !i.doiAssociation && K(i.entity) && i.entity.isLatestVersion, { data: z } = P(
{ id: o, version: void 0, type: R.ENTITY },
{
enabled: k
}
), g = r?.contentSize && Y(r.contentSize), v = t && "location" in t && t.location, D = t && "endpoint" in t && t.endpoint, h = t && "bucket" in t && t.bucket, S = t && "fileKey" in t && t.fileKey, b = t && "url" in t && t.url, x = r?.contentMd5, c = k ? z : i?.doiAssociation, { data: n } = q(c?.doiUri), m = c && `https://doi.org/${c?.doiUri}`, w = !!n && n.citationCount > 0, L = T?.totalChildCount, A = i?.entity && V(i.entity) ? ((i?.entity).items ?? []).length : null, { data: l } = Q(o), B = !!l && l.length > 0;
return [
{
key: "id",
title: "SynID",
value: /* @__PURE__ */ e(O, { value: o })
},
{
key: "access",
title: "Access",
value: /* @__PURE__ */ e($, { entityId: o })
},
g && { key: "fileSize", title: "Size", value: g },
L != null && {
key: "containerItems",
title: "Items",
value: L.toLocaleString()
},
A != null && {
key: "entityRefCollectionItems",
title: "Items",
value: A.toLocaleString()
},
m && {
key: "doi",
title: "DOI",
value: /* @__PURE__ */ e(d, { href: m, rel: "noopener noreferrer", target: "_blank", children: m })
},
w && {
key: "citations",
title: "Citations",
value: /* @__PURE__ */ a(p, { children: [
/* @__PURE__ */ a(d, { onClick: () => f(!0), children: [
n.citationCount.toLocaleString(),
n.citationCount == J && "+"
] }),
/* @__PURE__ */ e(
E,
{
open: M,
onClose: () => f(!1),
citations: n.citations
}
)
] })
},
B && {
key: "mentions",
title: "Mentions",
value: /* @__PURE__ */ a(p, { children: [
/* @__PURE__ */ e(d, { onClick: () => C(!0), children: l.length.toLocaleString() }),
/* @__PURE__ */ e(
E,
{
open: U,
onClose: () => C(!1),
citations: l,
title: "Mentioned in"
}
)
] })
},
x && {
key: "fileMd5",
title: "MD5",
value: /* @__PURE__ */ e(O, { value: x })
},
!s && v && {
key: "fileStorageLocation",
title: "Storage Location",
value: v
},
s && y && {
key: "uploadDestination",
title: "Upload Destination",
value: y
},
D && {
key: "externalFileEndpoint",
title: "Endpoint",
value: D
},
b && {
key: "externalUrl",
title: "URL",
value: /* @__PURE__ */ e(W, { text: b })
},
h && { key: "externalFileBucket", title: "Bucket", value: h },
S && { key: "externalFileKey", title: "File Key", value: S },
u && {
key: "fileAlias",
title: "Alias",
value: /* @__PURE__ */ a(p, { children: [
"Name when downloaded will be: ",
/* @__PURE__ */ e(j, { sx: { display: "inline", fontFamily: "monospace" }, children: u })
] })
}
].filter((G) => !!G);
}
export {
Kt as useGetEntityTitleBarProperties
};
//# sourceMappingURL=useGetEntityTitleBarProperties.js.map