synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
194 lines (193 loc) • 5.77 kB
JavaScript
import { jsx as e, jsxs as a } from "react/jsx-runtime";
import { useGetRealmPrincipals as w } from "../../synapse-queries/realm/useRealmPrincipals.js";
import { Box as t, Typography as n, Collapse as S, Button as k, Tooltip as D, FormControlLabel as G, Checkbox as M } from "@mui/material";
import { noop as X } from "lodash-es";
import { TransitionGroup as j } from "react-transition-group";
import b from "../IconSvg/IconSvg.js";
import F from "../UserSearchBox/UserSearchBox.js";
import { AclEditorSkeleton as Y } from "./AclEditorSkeleton.js";
import { ResourceAccessItem as H } from "./ResourceAccessItem.js";
const V = "Add a user or team", z = "Make Public", K = "Remove Public Access", W = "Notify people via email";
function te(v) {
const {
resourceAccessList: s,
availablePermissionLevels: I,
canEdit: o,
isInherited: y,
canRemoveEntry: l = o,
isLoading: x = !1,
emptyText: C,
onAddPrincipalToAcl: c,
updateResourceAccessItem: P,
removeResourceAccessItem: p,
showAddRemovePublicButton: L,
showNotifyCheckbox: T,
notifyCheckboxValue: h,
onNotifyCheckboxChange: _ = X,
displayedPermissionLevelOverride: u
} = v, { data: A, isLoading: g } = w(), B = A || {}, {
authenticatedUsers: d,
publicGroup: m,
anonymousUser: R
} = B, f = [
d,
m,
R
].filter((i) => i !== void 0);
if (x || g)
return /* @__PURE__ */ e(Y, {});
const E = !!s.find(
(i) => f.some((r) => i.principalId === Number(r))
) ? {
startIcon: /* @__PURE__ */ e(b, { icon: "close", wrap: !1 }),
children: K,
onClick: () => {
f.forEach((i) => {
p(Number(i));
});
}
} : {
startIcon: /* @__PURE__ */ e(b, { icon: "public", wrap: !1 }),
children: z,
onClick: () => {
m && c(Number(m)), d && c(Number(d));
}
};
return /* @__PURE__ */ a(t, { children: [
/* @__PURE__ */ a(
t,
{
sx: {
mb: "30px"
},
children: [
/* @__PURE__ */ e(
n,
{
variant: "headline3",
sx: {
mb: "10px"
},
children: "Users and Teams with Permissions"
}
),
s.length === 0 ? /* @__PURE__ */ e(n, { variant: "body1Italic", children: C }) : /* @__PURE__ */ e(j, { children: s.map((i) => {
const r = typeof o == "function" ? o(i) : o, N = typeof l == "function" ? l(i) : l, O = u ? u(i) : void 0;
return /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(
H,
{
resourceAccess: i,
availablePermissionLevels: I,
canChangePermission: r,
displayedPermissionLevelOverride: O,
showDeleteButton: N,
onChange: (U) => P(
i.principalId,
U
),
onRemove: () => p(i.principalId)
}
) }, i.principalId);
}) })
]
}
),
o && /* @__PURE__ */ a(t, { children: [
/* @__PURE__ */ e(
n,
{
variant: "headline3",
sx: {
mb: "10px"
},
children: "Add More"
}
),
/* @__PURE__ */ e(
n,
{
sx: {
mb: "20px",
variant: "body1",
lineHeight: "20px",
fontStyle: "italic",
color: "text.secondary"
},
children: "Search for a username or team to add. You can search by username, first or last names, or team name."
}
),
/* @__PURE__ */ a(t, { sx: { mb: 1 }, children: [
/* @__PURE__ */ e(
n,
{
component: "label",
variant: "smallText2",
htmlFor: "reviewer-search",
children: V
}
),
/* @__PURE__ */ e(
F,
{
value: null,
inputId: "reviewer-search",
placeholder: "Username, name (first and last) or team name.",
onChange: (i) => {
const r = parseInt(i || "");
r && c(r);
}
}
)
] }),
/* @__PURE__ */ a(
t,
{
sx: {
display: "flex",
justifyContent: "space-between",
gap: 2
},
children: [
/* @__PURE__ */ e(t, { children: L && /* @__PURE__ */ e(
k,
{
size: "small",
variant: "outlined",
...E
}
) }),
T && /* @__PURE__ */ e(
D,
{
title: "Select to notify newly added people that this item has been shared with them",
children: /* @__PURE__ */ e(
G,
{
sx: { mr: 0 },
control: /* @__PURE__ */ e(
M,
{
value: h,
onChange: () => _(!h)
}
),
label: /* @__PURE__ */ e(n, { variant: "smallText1", children: W })
}
)
}
)
]
}
)
] }),
!o && !y && /* @__PURE__ */ e(n, { variant: "body1", children: "You do not have sufficient privileges to modify the sharing settings." })
] });
}
export {
V as ADD_PRINCIPAL_TO_ACL_COMBOBOX_LABEL,
z as ADD_PUBLIC_PRINCIPALS_BUTTON_TEXT,
te as AclEditor,
W as NOTIFY_NEW_ACL_USERS_CHECKBOX_LABEL,
K as REMOVE_PUBLIC_PRINCIPALS_BUTTON_TEXT
};
//# sourceMappingURL=AclEditor.js.map