UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

209 lines (208 loc) 7.54 kB
import { jsx as i, Fragment as A } 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 R } from "@sage-bionetworks/synapse-types"; import "../../utils/functions/EntityTypeUtils.js"; import "../../utils/SynapseConstants.js"; import { isEqual as E } from "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "@tanstack/react-query"; import "../../utils/PermissionLevelToAccessType.js"; import { useCallback as h } from "react"; import "../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import { Checkbox as N } 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 { useGetEntityHeader as V } from "../../synapse-queries/entity/useGetEntityHeaders.js"; import { createColumnHelper as z } from "@tanstack/react-table"; import { useAtomValue as L, useAtom as k } from "jotai"; import H from "../AddToDownloadListV2.js"; import M from "../DirectDownload/FileEntityDirectDownload.js"; import { HasAccessV2 as F } from "../HasAccess/HasAccessV2.js"; import { useQueryContext as O } from "../QueryContext/QueryContext.js"; import { useGetQueryMetadata as S } from "../QueryWrapper/useGetQueryMetadata.js"; import { useQueryVisualizationContext as P } from "../QueryVisualizationWrapper/QueryVisualizationContext.js"; import { isRowSelectedAtom as B, selectedRowsAtom as $ } from "../QueryWrapper/TableRowSelectionState.js"; import q from "../TanStackTable/ColumnHeader.js"; import { EnumFacetFilter as Q } from "../widgets/query-filter/EnumFacetFilter/EnumFacetFilter.js"; import j from "./EntityIDColumnCopyIcon.js"; import G from "./SynapseTableCell/SynapseTableCell.js"; import { useSynapseTableContext as v } from "./SynapseTableContext.js"; import { useInView as Y } from "react-intersection-observer"; const C = "org.sagebionetworks.web.client.SynapseTablePredefinedColumn", y = z(); function _(o) { const { row: e, table: n } = o, t = n.options.meta?.rowSet, l = L(B), [d, r] = k($); return /* @__PURE__ */ i("div", { children: /* @__PURE__ */ i( N, { inputProps: { "aria-label": "Select row" }, checked: l(e.original, t.headers), onChange: (c, s) => { const m = [...d]; if (s) m.push(e.original); else { const u = m.findIndex( (a) => E(a, e.original) ); u > -1 && m.splice(u, 1); } r(m); } } ) }); } const je = y.display({ id: `${C}.RowSelectionColumn`, enableResizing: !1, cell: _, maxSize: 36, meta: { textAlign: "center" } }); function J(o) { const e = g(o), n = b(o), t = n ? parseInt(n) : void 0, { data: l } = V(e); return /* @__PURE__ */ i("div", { "data-testid": "AddToDownloadListCell", children: l?.type === "org.sagebionetworks.repo.model.FileEntity" && /* @__PURE__ */ i( H, { entityId: e, entityVersionNumber: t } ) }); } const Ge = y.display({ id: `${C}.AddToDownloadListColumn`, enableResizing: !1, cell: J, maxSize: 50, meta: { textAlign: "center" } }); function K(o) { const e = g(o), n = b(o); return /* @__PURE__ */ i("div", { "data-testid": "DirectDownloadCell", children: /* @__PURE__ */ i( M, { entityId: e, entityVersionNumber: n, iconSvgPropOverrides: { sx: { color: "primary.main" } } } ) }); } const Ye = y.display({ id: `${C}.DirectDownload`, enableResizing: !1, cell: K, maxSize: 50, meta: { textAlign: "center" } }); function g(o) { const { row: e, table: n } = o, t = n.options.meta?.rowEntityIDColumnIndex; return t !== void 0 ? e.original.values[t] : e.original.rowId?.toString(); } function U(o) { const { table: e } = o; return e.options.meta?.rowEntityVersionColumnIndex !== void 0; } function b(o) { const { row: e, table: n } = o, t = n.options.meta?.rowEntityVersionColumnIndex; return t !== void 0 ? e.original.values[t] : e.original.versionNumber?.toString(); } function W(o) { const { showExternalAccessIcon: e } = v(), { ref: n, inView: t } = Y({ triggerOnce: !0 }), l = g(o); return /* @__PURE__ */ i("div", { ref: n, "data-testid": "AccessCell", children: (!e || e && t) && /* @__PURE__ */ i( F, { entityId: l, showButtonText: !1, showExternalAccessIcon: e }, l ) }); } const _e = y.display({ id: `${C}.Access`, enableResizing: !1, cell: W, maxSize: 50, meta: { textAlign: "center" } }); function Je(o) { const { column: e } = o, { lockedColumn: n } = O(), { data: t } = S(), l = t?.columnModels ?? [], r = (t?.selectColumns ?? []).find((p) => p.name === e.id), c = l.find((p) => p.name === e.id), s = t?.facets ?? [], { getColumnDisplayName: m, getHelpText: u } = P(), a = r ? m(r.name) : e.id, I = r ? u(r.name) : void 0, f = s.findIndex( (p) => p.columnName === c?.name && // Exclude JSON subcolumn facets, since there may be more than one on a given column p.jsonPath == null ), w = f !== -1 && s[f].facetType === "enumeration", D = s[f], x = r && r.name.toLowerCase() === n?.columnName?.toLowerCase(), T = r && r.name == "id" && r.columnType == R.ENTITYID; return o.column.getCanFilter = h( () => !!(w && !x && c), [w, x, c] ), /* @__PURE__ */ i( q, { ...o, title: a, helpText: I, filterControl: /* @__PURE__ */ i("span", { children: /* @__PURE__ */ i( Q, { containerAs: "Dropdown", facet: D, defaultShowAllValues: !0 } ) }), additionalButtons: /* @__PURE__ */ i(A, { children: T && /* @__PURE__ */ i(j, { size: "small" }) }) } ); } function Ke(o) { const { cell: e, table: n } = o, { data: t } = S(), l = g(o), d = b(o), r = d !== void 0 ? parseInt(d) : void 0, c = n.options.meta?.rowSet?.headers ?? [], s = c.find((a) => a.name === e.column.id), m = t?.columnModels ?? [], { columnLinks: u } = v(); if (s) { const a = (u ?? []).find((w) => w.matchColumnName === s.name), I = s.columnType, f = e.column.getIsSorted() ? "SRC-boldText" : ""; return /* @__PURE__ */ i( G, { columnType: I, columnValue: e.getValue(), isBold: f, columnLinkConfig: a, columnName: s.name, rowData: e.row.original.values, selectColumns: c, columnModels: m, rowId: l, rowVersionNumber: r, isRowEntityColumn: U(o) }, e.id ); } else return /* @__PURE__ */ i("td", {}, e.id); } export { Ke as TableDataCell, Je as TableDataColumnHeader, _e as accessColumn, Ge as addToDownloadListColumn, Ye as directDownloadColumn, je as rowSelectionColumn }; //# sourceMappingURL=SynapseTableRenderers.js.map