synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
147 lines (146 loc) • 5.17 kB
JavaScript
import { jsxs as r, Fragment as I, jsx as e } from "react/jsx-runtime";
import { Card as L, CardContent as N, Box as l, Typography as t, IconButton as u, Link as P } from "@mui/material";
import a from "./PortalCard.module.scss.js";
import { UserCard as y } from "../UserCard/UserCard.js";
import D from "dayjs";
import { useState as b } from "react";
import Y from "../PortalAclEditor/PortalAclEditorModal.js";
import { Settings as w, Delete as O } from "@mui/icons-material";
import { ConfirmationDialog as R } from "../ConfirmationDialog/ConfirmationDialog.js";
import { useDeletePortal as k } from "../../synapse-queries/portal/usePortal.js";
import { displayToast as g } from "../ToastMessage/ToastMessage.js";
const C = "1";
function H({ portal: M }) {
const { id: o, name: i, url: n, createdBy: d, createdOn: c, modifiedBy: m, modifiedOn: h } = M, [x, f] = b(!1), [A, s] = b(!1), p = o && o !== C, S = o && o !== C, { mutate: v } = k({
onSuccess: () => {
g(`Portal "${i}" was successfully deleted`, "success"), s(!1);
},
onError: (E) => {
g(`Failed to delete portal: ${E.reason}`, "danger");
}
});
return /* @__PURE__ */ r(I, { children: [
/* @__PURE__ */ e(L, { className: a.portalCard, children: /* @__PURE__ */ r(N, { children: [
/* @__PURE__ */ r(l, { className: a.header, children: [
/* @__PURE__ */ r(l, { className: a.titleRow, children: [
/* @__PURE__ */ e(t, { variant: "h6", component: "h3", children: i }),
/* @__PURE__ */ r(l, { className: a.actions, children: [
p && /* @__PURE__ */ e(
u,
{
size: "small",
onClick: () => f(!0),
"aria-label": "Manage portal permissions",
title: "Manage portal permissions",
children: /* @__PURE__ */ e(w, { fontSize: "small" })
}
),
S && /* @__PURE__ */ e(
u,
{
size: "small",
onClick: () => s(!0),
"aria-label": "Delete portal",
title: "Delete portal",
color: "error",
children: /* @__PURE__ */ e(O, { fontSize: "small" })
}
)
] })
] }),
n && /* @__PURE__ */ e(
P,
{
href: n,
target: "_blank",
rel: "noopener noreferrer",
className: a.url,
children: n
}
)
] }),
/* @__PURE__ */ r(l, { className: a.metadata, children: [
o && /* @__PURE__ */ r(t, { variant: "body2", color: "text.secondary", children: [
/* @__PURE__ */ e("strong", { children: "ID:" }),
" ",
o
] }),
d && /* @__PURE__ */ r(l, { className: a.userInfo, children: [
/* @__PURE__ */ e(t, { variant: "body2", color: "text.secondary", children: /* @__PURE__ */ e("strong", { children: "Created by:" }) }),
/* @__PURE__ */ e(
y,
{
ownerId: d,
size: "SMALL USER CARD",
hideEmail: !0,
disableLink: !1
}
),
c && /* @__PURE__ */ r(t, { variant: "caption", color: "text.secondary", children: [
"on ",
D(c).format("MMMM D, YYYY")
] })
] }),
m && /* @__PURE__ */ r(l, { className: a.userInfo, children: [
/* @__PURE__ */ e(t, { variant: "body2", color: "text.secondary", children: /* @__PURE__ */ e("strong", { children: "Last modified by:" }) }),
/* @__PURE__ */ e(
y,
{
ownerId: m,
size: "SMALL USER CARD",
hideEmail: !0,
disableLink: !1
}
),
h && /* @__PURE__ */ r(t, { variant: "caption", color: "text.secondary", children: [
"on ",
D(h).format("MMMM D, YYYY")
] })
] })
] })
] }) }),
p && o && /* @__PURE__ */ e(
Y,
{
portalId: o,
open: x,
onClose: () => f(!1)
}
),
o && /* @__PURE__ */ e(
R,
{
open: A,
title: "Delete Portal",
content: /* @__PURE__ */ r(l, { children: [
/* @__PURE__ */ e(t, { variant: "body1", sx: { mb: 2 }, children: "Are you sure you want to delete this portal?" }),
/* @__PURE__ */ r(t, { variant: "body2", sx: { mb: 1 }, children: [
/* @__PURE__ */ e("strong", { children: "Name:" }),
" ",
i
] }),
n && /* @__PURE__ */ r(t, { variant: "body2", children: [
/* @__PURE__ */ e("strong", { children: "URL:" }),
" ",
n
] })
] }),
confirmButtonProps: {
children: "Delete",
color: "error",
variant: "contained"
},
onConfirm: () => {
o && v(o);
},
onCancel: () => s(!1),
maxWidth: "sm"
}
)
] });
}
export {
H as PortalCard,
H as default
};
//# sourceMappingURL=PortalCard.js.map