synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
120 lines (118 loc) • 3.45 kB
JavaScript
import { jsx as r, Fragment as s, jsxs as l } from "react/jsx-runtime";
import { useSynapseContext as f } from "../../utils/context/SynapseContext.js";
import { Stack as h, Box as u, Button as E, Collapse as g } from "@mui/material";
import { SynapseClientError as C } from "@sage-bionetworks/synapse-client/util/SynapseClientError";
import { useState as S } from "react";
import { ErrorBoundary as B } from "react-error-boundary";
import k from "../FullWidthAlert/FullWidthAlert.js";
import v from "../SignInButton.js";
const x = "You are not authorized to access this resource.", y = () => /* @__PURE__ */ l(s, { children: [
"Please ",
/* @__PURE__ */ r(v, {}),
" to view this resource."
] }), w = (o) => {
const [e, c] = S(!1), { isAuthenticated: t } = f(), { error: n } = o, i = (n.status === 403 || n.status === 401) && !t, d = n.status === 403 && t;
return i ? /* @__PURE__ */ r(y, {}) : d ? /* @__PURE__ */ l(s, { children: [
/* @__PURE__ */ l(h, { direction: "row", spacing: 2, children: [
/* @__PURE__ */ r(
u,
{
sx: {
display: "flex",
alignItems: "center"
},
children: x
}
),
/* @__PURE__ */ l(
E,
{
variant: "text",
onClick: () => c((a) => !a),
children: [
e ? "Hide" : "Show",
" details"
]
}
)
] }),
/* @__PURE__ */ r(g, { in: e, children: /* @__PURE__ */ r(
u,
{
sx: {
paddingTop: 1
},
children: /* @__PURE__ */ r("pre", { children: n.reason })
}
) })
] }) : /* @__PURE__ */ r(s, { children: n.reason });
}, p = (o) => {
const { error: e, reloadButtonFn: c } = o;
if (!e)
return /* @__PURE__ */ r(s, {});
let t, n, i;
e instanceof C ? t = e : e instanceof Error ? n = e : typeof e == "string" && (i = e);
const d = t && t.status >= 500;
let a;
return d ? a = {
text: "Report Issue",
onClick: () => {
const m = `https://sagebionetworks.jira.com/servicedesk/customer/portal/9/group/16/create/84?description=${encodeURI(
`A server error occurred:
${t?.reason}`
)}`;
window.open(m, "_blank");
}
} : c && (a = {
text: "Reload",
onClick: c
}), /* @__PURE__ */ r(
k,
{
variant: "danger",
isGlobal: !1,
description: /* @__PURE__ */ l(s, { children: [
t && /* @__PURE__ */ r(w, { error: t }),
n && n.message,
i && i
] }),
primaryButtonConfig: a
}
);
};
function F({
error: o,
resetErrorBoundary: e
}) {
return /* @__PURE__ */ r("div", { className: "SRC-marginBottomTop", children: /* @__PURE__ */ r(
p,
{
error: o,
reloadButtonFn: e
}
) });
}
function U({
error: o,
resetErrorBoundary: e
}) {
return /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", { colSpan: 999, children: /* @__PURE__ */ r(p, { error: o, reloadButtonFn: e }) }) });
}
function O({
error: o,
resetErrorBoundary: e
}) {
return console.error(o), /* @__PURE__ */ r(s, {});
}
const G = (o) => /* @__PURE__ */ r(B, { FallbackComponent: F, ...o });
export {
w as ClientError,
O as EmptyFallbackComponent,
p as ErrorBanner,
F as ErrorFallbackComponent,
y as SignInPrompt,
G as SynapseErrorBoundary,
U as TableRowFallbackComponent,
x as YOU_ARE_NOT_AUTHORIZED_MESSAGE
};
//# sourceMappingURL=ErrorBanner.js.map