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.01 kB
import { jsx as t, Fragment as o, jsxs as n } 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 "../../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 { useMemo as y } from "react"; import { useSynapseContext as h } from "../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import { Alert as w, Box as T, Button as u, Typography as m } 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 { useGetDownloadListStatistics as C } from "../../synapse-queries/download/useDownloadList.js"; import v from "../SignInButton.js"; import g from "./DownloadDetails.js"; const r = { 2: { severity: "info", infoText: "Would you like to add these files to the download list?", closeText: "Cancel" }, 3: { severity: "info", infoText: /* @__PURE__ */ n(o, { children: [ "Note: Files that you add will be mixed in with the files already in your download list.", /* @__PURE__ */ t("br", {}), "If you don't want to mix these files, clear your download list before continuing." ] }), closeText: "Cancel" }, 1: { severity: "info", infoText: "Adding files to download list", closeText: "Cancel" }, 0: { severity: "info", infoText: "Calculating file size", closeText: "Cancel" }, 4: { severity: "error", closeText: "Close", infoText: /* @__PURE__ */ n(o, { children: [ "Please ", /* @__PURE__ */ t(v, {}), " to add files to your download list." ] }) } }; function S(l) { const { status: i, fileCount: s, fileSize: a } = l; switch (i) { case 0: case 1: return /* @__PURE__ */ n(o, { children: [ /* @__PURE__ */ t("div", { className: "spinner white" }), /* @__PURE__ */ t(m, { variant: "smallText1", children: r[i].infoText }) ] }); case 4: return /* @__PURE__ */ t(m, { variant: "smallText1", children: r[i].infoText }); case 2: case 3: return /* @__PURE__ */ n(o, { children: [ /* @__PURE__ */ t( g, { numFiles: s, numBytes: a } ), /* @__PURE__ */ t(m, { variant: "smallText1", sx: { flexGrow: 1 }, children: r[i].infoText }) ] }); default: return /* @__PURE__ */ t(o, {}); } } function it(l) { const { onAddToDownloadCart: i, onCancel: s, fileCount: a, fileSize: x, isLoadingStats: c = !1, isAddingToDownloadCart: f = !1 } = l, { isAuthenticated: p } = h(), { data: d } = C(), e = y(() => p ? c ? 0 : f ? 1 : d && d.totalNumberOfFiles > 0 ? 3 : 2 : 4, [ p, c, f, d ]); return /* @__PURE__ */ t(o, { children: /* @__PURE__ */ t( w, { sx: { pr: 4, py: 1, display: "flex", justifyContent: "space-between", alignItems: "center" }, icon: r[e].severity === "error" ? void 0 : !1, severity: r[e].severity, className: "download-confirmation", action: /* @__PURE__ */ n(o, { children: [ e !== 1 && /* @__PURE__ */ t(u, { variant: "text", color: "primary", onClick: s, children: r[e].closeText }), (e === 2 || e === 3) && /* @__PURE__ */ t( u, { variant: "contained", color: "primary", onClick: () => { i(); }, sx: { ml: "5px" }, children: "Add" } ) ] }), children: /* @__PURE__ */ t( T, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: /* @__PURE__ */ t( S, { status: e, fileCount: a, fileSize: x } ) } ) } ) }); } export { it as DownloadConfirmationUI, it as default }; //# sourceMappingURL=DownloadConfirmationUI.js.map