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.88 kB
import { jsx as u } from "react/jsx-runtime"; import y from "../../synapse-queries/entity/useGetQueryResultBundle.js"; import { BUNDLE_MASK_QUERY_COUNT as g } from "../../utils/SynapseConstants.js"; import { parseEntityIdFromSqlStatement as b } from "../../utils/functions/SqlFunctions.js"; import { Button as k, Box as R } from "@mui/material"; import { NavigateNext as q } from "@mui/icons-material"; import C from "react"; import { useInRouterContext as B, Link as I } from "react-router"; function U(p) { const { sql: a, href: t, prefixText: r = "", suffixText: n = "", ...c } = p, l = b(a), m = B(), f = { concreteType: "org.sagebionetworks.repo.model.table.QueryBundleRequest", query: { sql: a }, entityId: l, partMask: g }, { data: d, isLoading: s } = y(f), i = d?.queryCount, x = t?.startsWith("http://") || t?.startsWith("https://"); let e = {}; x ? e = { href: t, target: "_blank", rel: "noopener noreferrer", component: "a" } : m ? e = { to: t, component: I } : e = { href: t, component: "a" }; const h = C.useMemo(() => { const o = []; return r && o.push(r), !s && i !== void 0 && o.push(i.toLocaleString()), n && o.push(n), o.join(" "); }, [r, i, n, s]); return /* @__PURE__ */ u( k, { ...c, ...e, endIcon: /* @__PURE__ */ u( R, { sx: { display: "flex", alignItems: "center", justifyContent: "center", backgroundColor: "background.paper", borderRadius: "50%", width: 24, height: 24 }, children: /* @__PURE__ */ u(q, { sx: { color: "primary.main", fontSize: 20 } }) } ), loading: s, children: h } ); } export { U as QueryCountButton, U as default }; //# sourceMappingURL=QueryCountButton.js.map