synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
209 lines (208 loc) • 8.32 kB
JavaScript
import { jsx as e, Fragment as y, jsxs as c } 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 { ColumnTypeEnum as a, FileHandleAssociateType as C } from "@sage-bionetworks/synapse-types";
import { isEntityView as R, isDataset as w, isDatasetCollection as F } 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 { memo as A, Fragment as _ } from "react";
import "../../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import { Typography as p, Link 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 "@sage-bionetworks/synapse-client";
import "../../../utils/types/IsType.js";
import { useGetEntity as U } from "../../../synapse-queries/entity/useEntity.js";
import { formatDate as S } from "../../../utils/functions/DateFormatter.js";
import h from "dayjs";
import $ from "../../DirectDownload/DirectDownload.js";
import { EntityLink as I } from "../../EntityLink.js";
import { SynapseCardLabel as G } from "../../GenericCard/SynapseCardLabel.js";
import "../../GenericCard/GenericCard.js";
import "../../Markdown/MarkdownSynapse.js";
import f from "../../GenericCard/Linkify.js";
import { useQueryContext as J } from "../../QueryContext/QueryContext.js";
import k from "../../UserOrTeamBadge/UserOrTeamBadge.js";
import { NOT_SET_DISPLAY_VALUE as V } from "../SynapseTableConstants.js";
import { isFileViewOrDataset as B } from "../SynapseTableUtils.js";
import H from "./EntityIdList.js";
import M from "./EvaluationIdRenderer.js";
import Y from "./JSON/JSONTableCellRenderer.js";
import P from "./UserIdList.js";
function b(d) {
return d.toLowerCase() === "id" ? "id" : "name";
}
function X(d) {
const {
columnType: T,
columnValue: t,
isBold: l,
columnLinkConfig: u,
columnName: s,
selectColumns: E,
columnModels: v,
rowData: L,
rowId: m,
rowVersionNumber: N,
isRowEntityColumn: D
} = d, { entityId: g, versionNumber: O } = J(), { data: i } = U(g, O);
if (!t)
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent SRC-inactive", children: V });
if (u)
return /* @__PURE__ */ e(
G,
{
value: t,
columnName: s,
selectColumns: E,
columnModels: v,
isHeader: !1,
labelLink: u,
rowData: L,
rowId: m
}
);
if ((i && (R(i) || w(i) || F(i)) || D) && (s === "id" || s === "name") && m && N)
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(
I,
{
entity: m,
versionNumber: N,
className: `${l}`,
showIcon: !1,
displayTextField: s
}
) });
switch (T) {
case a.ENTITYID: {
const n = b(s);
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(
I,
{
entity: t,
className: `${l}`,
displayTextField: n,
showIcon: !1
}
) });
}
case a.DATE_LIST: {
const n = JSON.parse(t);
return /* @__PURE__ */ c("div", { className: "SynapseTableCellContent", children: [
n.map((r, o) => /* @__PURE__ */ c("span", { className: l, children: [
S(h(Number(r))),
o !== n.length - 1 ? ", " : ""
] }, o)),
" "
] });
}
case a.BOOLEAN_LIST: {
const n = JSON.parse(t);
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: n.map((r, o) => /* @__PURE__ */ c("span", { className: l, children: [
r ? "true" : "false",
o !== n.length - 1 ? ", " : ""
] }, o)) });
}
case a.FILEHANDLEID: {
let n = i.id, r = C.TableEntity;
return B(i) && s === "dataFileHandleId" && (n = String(m), r = C.FileEntity), /* @__PURE__ */ e(y, { children: i && /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(
$,
{
iconSvgPropOverrides: { sx: { color: "primary.main" } },
associatedObjectId: n,
associatedObjectType: r,
fileHandleId: t,
displayFileName: !0
}
) }) });
}
case a.ENTITYID_LIST: {
const n = b(s), r = JSON.parse(t);
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(
H,
{
entityIdList: r,
displayTextField: n,
showIcon: !1
}
) });
}
case a.USERID_LIST: {
const n = JSON.parse(t);
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(P, { userIds: n }) });
}
// handle other list types
case a.STRING_LIST:
case a.INTEGER_LIST: {
const n = JSON.parse(t);
return /* @__PURE__ */ e("div", { className: `SynapseTableCellContent ${l}`, children: n.map((r, o) => {
const x = T == a.STRING_LIST ? /* @__PURE__ */ e(f, { text: r }) : /* @__PURE__ */ e(y, { children: r });
return /* @__PURE__ */ c(_, { children: [
x,
o !== n.length - 1 ? ", " : ""
] }, r);
}) });
}
case a.EVALUATIONID:
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(M, { evaluationId: t }) });
case a.DATE:
return /* @__PURE__ */ e("div", { className: `SynapseTableCellContent ${l}`, children: S(h(Number(t))) });
case a.USERID:
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(k, { principalId: t }) });
case a.LINK:
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(j, { target: "_blank", rel: "noopener noreferrer", href: t, children: t }) });
case a.STRING:
case a.BOOLEAN:
case a.MEDIUMTEXT:
case a.LARGETEXT:
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(p, { variant: "smallText1", className: l, children: /* @__PURE__ */ e(f, { text: t }) }) });
case a.INTEGER:
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(
p,
{
variant: "smallText1",
sx: { textAlign: "right" },
className: l,
children: parseInt(t).toLocaleString()
}
) });
case a.DOUBLE:
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(
p,
{
variant: "smallText1",
sx: { textAlign: "right" },
className: l,
children: parseFloat(t).toLocaleString()
}
) });
case a.JSON:
return /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(Y, { value: t }) });
default:
return console.warn(
`ColumnType ${T} has unspecified handler. Rendering the column value.`
), /* @__PURE__ */ e("div", { className: "SynapseTableCellContent", children: /* @__PURE__ */ e(p, { variant: "smallText1", className: l, children: t }) });
}
return /* @__PURE__ */ e("div", { className: `SynapseTableCellContent ${l}`, children: t });
}
const Be = A(X);
export {
Be as default
};
//# sourceMappingURL=SynapseTableCell.js.map