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

266 lines (265 loc) 9.73 kB
import { jsx as t, jsxs as P, Fragment as b } from "react/jsx-runtime"; import { useMemo as M, useState as R, createElement as B, Suspense as x } from "react"; import v from "../download_list/AddToDownloadListConfirmationAlert/AddToDownloadListConfirmationAlert.js"; import { useGetAddToDownloadListRequestForCurrentQuery as O } from "../QueryWrapper/useGetAddToDownloadListRequestForCurrentQuery.js"; import { NoContentPlaceholderType as I } from "../SynapseTable/NoContentPlaceholderType.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 { parseEntityIdAndVersionFromSqlStatement as W, getAdditionalFilters as K } from "../../utils/functions/SqlFunctions.js"; import { isTable as Y } from "../../utils/functions/EntityTypeUtils.js"; import { DEFAULT_PAGE_SIZE as V, BUNDLE_MASK_QUERY_RESULTS as J, BUNDLE_MASK_QUERY_COUNT as $, BUNDLE_MASK_QUERY_SELECT_COLUMNS as k, BUNDLE_MASK_QUERY_MAX_ROWS_PER_PAGE as G, BUNDLE_MASK_QUERY_COLUMN_MODELS as H, BUNDLE_MASK_QUERY_FACETS as j, BUNDLE_MASK_SUM_FILES_SIZE_BYTES as z, BUNDLE_MASK_LAST_UPDATED_ON as X } from "../../utils/SynapseConstants.js"; import "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import { useQuery as Z } from "@tanstack/react-query"; import "../../utils/PermissionLevelToAccessType.js"; import "../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import "@sage-bionetworks/synapse-types"; import { Box as ee } 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 te } from "../../synapse-queries/entity/useEntity.js"; import { useAtomValue as oe } from "jotai"; import { SynapseErrorBoundary as re } from "../error/ErrorBanner.js"; import { FullTextSearch as ie } from "../FullTextSearch/FullTextSearch.js"; import { ModalDownload as ne } from "../ModalDownload/ModalDownload.js"; import { useQueryContext as ae } from "../QueryContext/QueryContext.js"; import { QueryVisualizationWrapper as se } from "../QueryVisualizationWrapper/QueryVisualizationWrapper.js"; import { QueryVisualizationContextConsumer as le } from "../QueryVisualizationWrapper/QueryVisualizationContext.js"; import { QueryWrapper as me } from "../QueryWrapper/QueryWrapper.js"; import { isRowSelectionVisibleAtom as ue } from "../QueryWrapper/TableRowSelectionState.js"; import { QueryWrapperErrorBoundary as de } from "../QueryWrapperErrorBoundary.js"; import ce from "../SynapseTable/SearchV2.js"; import { SqlEditor as Se } from "../SynapseTable/SqlEditor.js"; import fe from "../SynapseTable/TopLevelControls/TopLevelControls.js"; import { CustomControls as Ce } from "../SynapseTable/CustomControls/CustomControls.js"; import pe from "../TotalQueryResults.js"; import he from "../widgets/facet-nav/PlotsContainer.js"; import ye from "../widgets/query-filter/FacetFilterControls.js"; import { RowSetView as Ee } from "./RowSetView.js"; import _e from "../QueryWrapper/QueryWrapperLoadingScreen.js"; const Fe = "isShowingFacetFilters", Le = "isHidingFacetFilters", Qe = "hasSelectedRows"; function Te(e) { const { tableConfiguration: r, name: p, cardConfiguration: h, facetsToPlot: l, availableFacets: y, initialExpandedFacetControls: E, hideDownload: i, hideQueryCount: _, hideSqlEditorControl: m, hideVisualizationsControl: F, searchConfiguration: u, cavaticaConnectAccountURL: d, customControls: c, remount: S, isFullTextSearchEnabled: f, customPlots: L, initialLimit: Q, initialPlotTypeByFacetColumnName: n, hideTopLevelControls: a } = e, o = ae(), [T, A] = R(!1), { hasFacetedSelectColumn: w, queryMetadataQueryOptions: g } = o, { isLoading: q } = Z( g ), U = oe(ue), C = o.currentQueryRequest, D = C?.query.selectedFacets !== void 0 && C.query.selectedFacets.length > 0 || C?.query.additionalFilters !== void 0 && C?.query.additionalFilters.length > 0, N = O(); return /* @__PURE__ */ t(le, { children: (s) => { if (s === void 0) throw new Error( "No queryVisualizationContext found when using QueryVisualizationContextConsumer" ); return /* @__PURE__ */ t( ee, { className: `QueryWrapperPlotNav ${s.showFacetFilter ? Fe : Le} ${U ? Qe : ""} ${a ? "isHidingTopLevelControls" : ""}`, sx: { "*": { cursor: q ? "wait" : void 0 } }, children: /* @__PURE__ */ P(de, { children: [ f ? /* @__PURE__ */ t(ie, { ftsConfig: u?.ftsConfig }) : /* @__PURE__ */ t( ce, { ...u, queryContext: o, queryVisualizationContext: s } ), /* @__PURE__ */ t(Se, {}), s.showDownloadConfirmation && /* @__PURE__ */ t( v, { addToDownloadListRequest: N, onClose: () => s.setShowDownloadConfirmation(!1) } ), !a && /* @__PURE__ */ t(re, { children: /* @__PURE__ */ t( fe, { showColumnSelection: r !== void 0, name: p, hideDownload: i, hideQueryCount: _, hideFacetFilterControl: !w, hideVisualizationsControl: !w || F, hideSqlEditorControl: m, cavaticaConnectAccountURL: d, remount: S, customControls: c } ) }), w && /* @__PURE__ */ t(b, { children: /* @__PURE__ */ t( ye, { availableFacets: y, initialExpandedFacetControls: E } ) }), /* @__PURE__ */ t( pe, { frontText: "", endText: D ? "filtered by" : "", hideIfUnfiltered: !0 } ), /* @__PURE__ */ t( Ce, { customControls: c, remount: S } ), /* @__PURE__ */ t( he, { facetsToPlot: l, customPlots: L, initialPlotTypeByFacetColumnName: n } ), /* @__PURE__ */ t( Ee, { tableConfiguration: r, hideDownload: i, cardConfiguration: h, initialLimit: Q } ), T && /* @__PURE__ */ t( ne, { getLastQueryRequest: o?.getCurrentQueryRequest, onClose: () => A(!1) } ) ] }) } ); } }); } function At(e) { const { sql: r, tableConfiguration: p, isInfinite: h = !p, limit: l = V, showLastUpdatedOn: y, unitDescription: E, additionalFiltersSessionStorageKey: i, helpConfiguration: _, customPlots: m, enabledExternalAnalysisPlatforms: F } = e, u = e.query?.sql ?? r ?? "", { entityId: d, versionNumber: c } = W(u), S = M(() => { if (e.query) return e.query; if (e.initQueryJson) return JSON.parse(e.initQueryJson); { const A = K( e.searchParams, e.sqlOperator, i ); return { sql: r, additionalFilters: A, limit: l, offset: 0 }; } }, [ e.query, e.initQueryJson, e.searchParams, e.sqlOperator, i, r, l ]), [f, L] = R(1), Q = () => { L(f + 1); }, { data: n } = te(d, c), a = { entityId: d ?? "", concreteType: "org.sagebionetworks.repo.model.table.QueryBundleRequest", partMask: J | $ | k | G | H | j | z | X, query: S }, o = (n && Y(n) && n.isSearchEnabled) ?? !1, T = `${JSON.stringify(a)}-${f}`; return /* @__PURE__ */ B( me, { ...e, initQueryRequest: a, key: T, isInfinite: h }, /* @__PURE__ */ t(x, { fallback: /* @__PURE__ */ t(_e, {}), children: /* @__PURE__ */ t( se, { unitDescription: E, rgbIndex: e.rgbIndex, columnAliases: e.columnAliases, helpConfiguration: _, visibleColumnCount: e.visibleColumnCount, defaultShowPlots: e.defaultShowPlots, hideCopyToClipboard: e.hideCopyToClipboard, defaultShowSearchBar: (e.defaultShowSearchBox || o) && !e.hideSearchBarControl, hideSearchBarControl: e.hideSearchBarControl, showLastUpdatedOn: y, noContentPlaceholderType: I.INTERACTIVE, hasCustomPlots: Array.isArray(m) && m.length > 0, enabledExternalAnalysisPlatforms: F, children: /* @__PURE__ */ t( Te, { ...e, isFullTextSearchEnabled: o, remount: Q } ) } ) }) ); } export { Qe as HAS_SELECTED_ROWS_CSS, Le as QUERY_FILTERS_COLLAPSED_CSS, Fe as QUERY_FILTERS_EXPANDED_CSS, At as default }; //# sourceMappingURL=QueryWrapperPlotNav.js.map