synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
68 lines (67 loc) • 2.75 kB
JavaScript
import { jsxs as o, jsx as e, Fragment as C } from "react/jsx-runtime";
import { useSynapseContext as I } from "../../utils/context/SynapseContext.js";
import { calculateFriendlyFileSize as k } from "../../utils/functions/calculateFriendlyFileSize.js";
import { testDownloadSpeed as D } from "../../utils/functions/testDownloadSpeed.js";
import { InsertDriveFileTwoTone as N, LayersTwoTone as E, WatchLaterTwoTone as F } from "@mui/icons-material";
import { Tooltip as u } from "@mui/material";
import l from "dayjs";
import v from "dayjs/plugin/duration";
import B from "dayjs/plugin/relativeTime";
import { useState as R, useEffect as j } from "react";
import { SkeletonInlineBlock as s } from "../Skeleton/SkeletonInlineBlock.js";
import { TOOLTIP_DELAY_SHOW as w } from "../SynapseTable/SynapseTableConstants.js";
l.extend(v);
l.extend(B);
function G(S) {
const { numFiles: t, numBytes: i } = S, { accessToken: r, isAuthenticated: m } = I(), n = !!i, [T, y] = R({
isLoading: n,
// figure out the estimated download time iff we were given a byte count
downloadSpeed: 0
}), { isLoading: d, downloadSpeed: c } = T;
j(() => {
m && D(r).then((L) => {
y({
isLoading: !1,
downloadSpeed: L
});
});
}, [m, r]);
const p = d || c === 0 || !i ? 0 : i / c, a = p === 0, x = a ? "" : l.duration({ seconds: p }).humanize(), f = t === 0, g = f ? "SRC-inactive" : "SRC-primary-text-color", h = a ? "SRC-inactive" : "SRC-primary-text-color";
return /* @__PURE__ */ o("span", { className: "download-details-container", children: [
t != null && /* @__PURE__ */ o("span", { children: [
/* @__PURE__ */ e(N, { className: g }),
f ? /* @__PURE__ */ e(s, { width: 50 }) : /* @__PURE__ */ o(C, { children: [
t.toLocaleString(),
" files"
] })
] }),
n && /* @__PURE__ */ e(
u,
{
title: "This is the total size of all files. Zipped package(s) will likely be smaller.",
enterNextDelay: w,
placement: "top",
children: /* @__PURE__ */ o("span", { "data-testid": "numBytesUI", children: [
/* @__PURE__ */ e(E, { className: h }),
a ? /* @__PURE__ */ e(s, { width: 50 }) : k(i)
] })
}
),
n && /* @__PURE__ */ e(
u,
{
title: "This is an estimate of how long package download will take.",
enterNextDelay: w,
placement: "top",
children: /* @__PURE__ */ o("span", { "data-testid": "downloadTimeEstimateUI", children: [
/* @__PURE__ */ e(F, { className: h }),
d && t != null && t > 0 ? /* @__PURE__ */ e(s, { width: 50 }) : x
] })
}
)
] });
}
export {
G as default
};
//# sourceMappingURL=DownloadDetails.js.map