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

93 lines (92 loc) 3.47 kB
import { jsx as t, jsxs as x } 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 { noop as p } from "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "@tanstack/react-query"; import "../../utils/PermissionLevelToAccessType.js"; import { forwardRef as b, useState as s, useEffect as v, useImperativeHandle as k } from "react"; import "../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import { Box as L, Stack as R, Typography as S, TextField as l, Alert as T } 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 { SynapseSpinner as U } from "../LoadingScreen/LoadingScreen.js"; 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 E } from "../../synapse-queries/entity/useEntity.js"; import { useLinkFileEntityToURL as w } from "../../utils/hooks/useUploadFileEntity/useLinkFileEntityToURL.js"; const pt = b(function(c, d) { const { entityId: o, onIsValidChanged: i = p, onSuccess: u = p } = c, [r, f] = s(""), [n, h] = s(""), { data: a } = E(o), y = a?.concreteType === "org.sagebionetworks.repo.model.FileEntity", { mutate: g, error: m } = w({ onSuccess: u }); return v(() => { const e = r.trim().length > 0; i(e); }, [r, i]), k(d, () => ({ submit: () => { g({ url: r.trim(), name: n.trim(), entityId: o }); } })), a ? /* @__PURE__ */ x( R, { sx: { gap: 2 }, children: [ /* @__PURE__ */ t(S, { variant: "body1", children: "Provide a URL to create a link to a file that is located in external storage or hosted on the web. Metadata, provenance, and annotations related to the file can be stored in Synapse, but the file data itself can only be accessed using the link." }), /* @__PURE__ */ t( l, { label: "URL", required: !0, fullWidth: !0, value: r, onChange: (e) => f(e.target.value) } ), !y && /* @__PURE__ */ t( l, { label: "Name", fullWidth: !0, value: n, onChange: (e) => h(e.target.value) } ), m && /* @__PURE__ */ t(T, { severity: "error", sx: { my: 2 }, children: m?.message ?? "An error occurred while attempting to create the link." }) ] } ) : /* @__PURE__ */ t( L, { sx: { display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ t(U, { size: 40 }) } ); }); export { pt as LinkToURL }; //# sourceMappingURL=LinkToURL.js.map