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

63 lines (62 loc) 1.95 kB
import { jsx as r } from "react/jsx-runtime"; import { useSynapseContext as p } from "../../utils/context/SynapseContext.js"; import { isFileEntity as c, implementsCloudProviderFileHandleInterface as m } from "../../utils/types/IsType.js"; import { Alert as y } from "@mui/material"; import { FileHandleAssociateType as l } from "@sage-bionetworks/synapse-types"; import { SignInPrompt as H } from "../error/ErrorBanner.js"; import d from "./FileHandleContentRenderer.js"; import { PreviewRendererType as a } from "./PreviewRendererType.js"; import { getOriginalFileHandleRenderer as F, getPreviewFileHandleRenderer as w } from "./PreviewUtils.js"; function A(s) { const { bundle: i } = s, { isAuthenticated: f } = p(); if (!c(i.entity)) throw new Error(`Entity ${i.entity.id} is not a FileEntity`); const o = i.entity.dataFileHandleId, t = i.fileHandles.find( (e) => e.id === o ); if (!t && !f) return /* @__PURE__ */ r(y, { severity: "error", children: /* @__PURE__ */ r(H, {}) }); if (t) { const e = F(t); if (e !== a.NONE) return /* @__PURE__ */ r( d, { fileHandle: t, fileHandleAssociation: { fileHandleId: o, associateObjectId: i.entity.id, associateObjectType: l.FileEntity }, previewType: e } ); } const n = i.fileHandles.find( (e) => m(e) && e.isPreview ); if (n && t) { const e = w( n, t ); if (e !== a.NONE) return /* @__PURE__ */ r( d, { fileHandle: n, fileHandleAssociation: { fileHandleId: n.id, associateObjectId: i.entity.id, associateObjectType: l.FileEntity }, previewType: e } ); } throw new Error(`Could not render a preview for entity: ${i.entity.id}`); } export { A as default }; //# sourceMappingURL=FileEntityPreview.js.map