synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
144 lines (143 loc) • 5.09 kB
JavaScript
import { jsxs as e, jsx as o, Fragment as u } from "react/jsx-runtime";
import K from "../file/upload/MultiFileUploadProgress.js";
import R from "../file/upload/UploadFilePanel.js";
import { SYNAPSE_STORAGE_LOCATION_ID as L } 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 "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import "../../utils/SynapseConstants.js";
import { noop as y } from "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "@tanstack/react-query";
import "../../utils/PermissionLevelToAccessType.js";
import { forwardRef as M, useState as a, useEffect as U, useImperativeHandle as _ } from "react";
import "../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import { Typography as k } 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 N } from "../../synapse-queries/entity/useEntity.js";
import { useGetDefaultUploadDestination as H } from "../../synapse-queries/file/useUploadDestination.js";
import { getUploadDestinationString as W } from "../../utils/functions/FileHandleUtils.js";
import { useUploadFileEntities as Y } from "../../utils/hooks/useUploadFileEntity/useUploadFileEntities.js";
import q from "../FullWidthAlert/FullWidthAlert.js";
import { displayToast as z } from "../ToastMessage/ToastMessage.js";
import { EntityUploadPromptDialog as B } from "./EntityUploadPromptDialog.js";
import { ExternalObjectStoreCredentialsForm as J } from "./ExternalObjectStoreCredentialsForm.js";
import { ProjectStorageLimitAlert as Q } from "./ProjectStorageLimitAlert.js";
const Mt = M(function(S, E) {
const { entityId: i, onStateChange: n = y, onUploadReady: s = y } = S, { data: x, isLoading: h } = N(i), p = x?.concreteType === "org.sagebionetworks.repo.model.FileEntity", { data: t, isLoading: F } = H(i), b = h || F, [m, A] = a(""), [l, P] = a(""), [j, D] = a(!1), {
initiateUpload: I,
state: r,
uploadProgress: v,
activePrompts: T,
isPrecheckingUpload: d,
isUploadReady: c
} = Y(
i,
m,
l,
() => D(!0)
);
U(() => {
n(r);
}, [r, n]), U(() => {
c && s();
}, [c, s]);
function g(C) {
if (t?.projectStorageLocationUsage?.isOverLimit) {
z(
"Cannot upload files because the storage limit has been exceeded.",
"danger"
);
return;
}
const G = Array.from(C).map((f) => p ? { file: f, existingEntityId: i } : {
file: f,
rootContainerId: i
});
I(G);
}
_(E, () => ({
handleUploads: g
}));
const O = d || b, w = d ? "Preparing files for upload..." : "Loading...";
return /* @__PURE__ */ e("div", { children: [
/* @__PURE__ */ o(B, { activePrompts: T }),
t?.projectStorageLocationUsage && /* @__PURE__ */ o(
Q,
{
usage: t.projectStorageLocationUsage,
didUploadsExceedLimit: j
}
),
/* @__PURE__ */ o(
J,
{
uploadDestination: t,
accessKey: m,
setAccessKey: A,
secretKey: l,
setSecretKey: P
}
),
/* @__PURE__ */ o(
R,
{
onUploadFileList: g,
allowMultipleFiles: !p,
isLoading: O,
loadingText: w,
disabled: t?.projectStorageLocationUsage?.isOverLimit,
message: /* @__PURE__ */ e(u, { children: [
/* @__PURE__ */ e(k, { variant: "smallText1", children: [
"All uploaded files will be stored in",
t?.storageLocationId === L && " Synapse storage",
t && t?.storageLocationId !== L && /* @__PURE__ */ e(u, { children: [
":",
/* @__PURE__ */ o("br", {}),
W(t)
] })
] }),
t && t.banner && /* @__PURE__ */ o(
q,
{
sx: {
textAlign: "left"
},
isGlobal: !1,
title: "Storage Location Message",
description: t.banner,
variant: "info"
}
)
] })
}
),
/* @__PURE__ */ o(
K,
{
uploaderState: r,
uploadProgress: v
}
)
] });
});
export {
Mt as EntityUpload
};
//# sourceMappingURL=EntityUpload.js.map