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

164 lines (163 loc) 5.7 kB
import { jsxs as h, jsx as e, Fragment as E } from "react/jsx-runtime"; import * as x from "../../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 { parseEntityIdFromSqlStatement as q, getAdditionalFilters as B } from "../../utils/functions/SqlFunctions.js"; import "../../utils/functions/EntityTypeUtils.js"; import { BUNDLE_MASK_QUERY_RESULTS as F } from "../../utils/SynapseConstants.js"; import "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "../../utils/PermissionLevelToAccessType.js"; import { useState as I } from "react"; import { useSynapseContext as $ } from "../../utils/context/SynapseContext.js"; import { useDeepCompareEffectNoCheck as j } from "use-deep-compare-effect"; import "@tanstack/react-query"; import "@tanstack/query-core"; import "lodash-es/isEmpty"; import "lodash-es/isEqual"; import "lodash-es/xorWith"; import { Typography as A } from "@mui/material"; import "@sage-bionetworks/synapse-client"; import { ColumnTypeEnum as m } from "@sage-bionetworks/synapse-types"; import "../../utils/types/IsType.js"; 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 { Markdown as C } from "../Markdown/MarkdownSynapse.js"; import { SkeletonTable as U } from "../Skeleton/SkeletonTable.js"; const M = [ m.BOOLEAN_LIST, m.DATE_LIST, m.ENTITYID_LIST, m.INTEGER_LIST, m.STRING_LIST ]; function Te({ sql: u, searchParams: y, sqlOperator: T, isMarkdown: d = !1, columnLink: i, friendlyValuesMap: _, columnNameIsSectionTitle: g = !1, limit: D, additionalFiltersSessionStorageKey: L }) { const { accessToken: w } = $(), [s, k] = I(), [N, b] = I(); j(() => { (async function() { b(!0); const t = q(u), p = B( y, T, L ), a = { partMask: F, concreteType: "org.sagebionetworks.repo.model.table.QueryBundleRequest", entityId: t, query: { sql: u, limit: D, additionalFilters: p } }, l = await x.getQueryTableResults( a, w ); b(!1); const o = l?.queryResult?.queryResults; o ? k(o) : console.log("SubsectionRowRenderer: Error getting data"); })(); }, [u, w, y, T]); const c = (r) => { if (!_) return r; const t = _[r]; return t || r; }; return /* @__PURE__ */ h("div", { className: "SubsectionRowRenderer", children: [ N && /* @__PURE__ */ e(U, { numRows: 2, numCols: 1 }), !N && s && s.rows.length > 0 && s.headers.map((r, t) => i && r.name == i.linkColumnName ? /* @__PURE__ */ e(E, {}) : /* @__PURE__ */ h( "div", { className: "SubsectionRowRenderer__item", role: "table", children: [ /* @__PURE__ */ e( A, { variant: g ? "sectionTitle" : "subsectionHeader", role: "heading", style: { paddingTop: "10px", marginBottom: "5px" }, children: r.name } ), g && /* @__PURE__ */ e("hr", {}), /* @__PURE__ */ e("div", { role: "rowgroup", children: s.rows.map((p, f) => { const a = p.values[t]; if (!a) return /* @__PURE__ */ e(E, {}); let l; if (M.includes(r.columnType)) l = JSON.parse(a).map((n, S) => /* @__PURE__ */ h( "div", { className: "SubsectionRowRenderer__item__value", role: "row", children: [ d && /* @__PURE__ */ e(C, { markdown: c(n) }), !d && /* @__PURE__ */ e("p", { children: c(n) }) ] }, `row-${f}-col-${t}-multi-value` )); else { let o; const n = c(a); if (d) o = /* @__PURE__ */ e(C, { markdown: n }); else if (i && i.matchColumnName == r.name) { const S = s.headers.findIndex( (R) => R.name == i.linkColumnName ), v = p.values; v.some((R) => R === null) && console.warn( "Row has null value(s) when no nulls expected" ), S > -1 ? o = /* @__PURE__ */ e( "a", { rel: "noopener noreferrer", target: "_blank", href: v[S], children: n } ) : o = /* @__PURE__ */ e("p", { children: n }); } else o = /* @__PURE__ */ e("p", { children: n }); l = /* @__PURE__ */ e( "div", { className: "SubsectionRowRenderer__item__value", role: "row", children: o }, `row-${f}-col-${t}-single` ); } return l; }) }) ] }, `header-${t}` )) ] }); } export { Te as default }; //# sourceMappingURL=SubsectionRowRenderer.js.map