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

140 lines (139 loc) 4.81 kB
import { jsxs as c, Fragment as d, jsx as r } from "react/jsx-runtime"; import "../../../synapse-client/SynapseClient.js"; import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode"; import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse"; import "@sage-bionetworks/synapse-client/util/SynapseClientError"; import { TYPE_FILTER as E, AccessType as i } from "@sage-bionetworks/synapse-types"; import "../../../utils/functions/EntityTypeUtils.js"; import "../../../utils/SynapseConstants.js"; import "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "@tanstack/react-query"; import "../../../utils/PermissionLevelToAccessType.js"; import "react"; import "../../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import { Typography as a, Stack as y, Button as R, RadioGroup as b, FormControlLabel as u, Radio as I } from "@mui/material"; import "../../../utils/hooks/useCookiePreferences.js"; import "../../../utils/hooks/useSourceAppConfigs.js"; import "universal-cookie"; import "../../../utils/AppUtils/session/ApplicationSessionContext.js"; import "../../../utils/context/FullContextProvider.js"; import "../../../utils/context/DocumentMetadataContext.js"; import '../../../style/components/_spinner.css';/* empty css */ import "@tanstack/query-core"; import "lodash-es/isEmpty"; import "lodash-es/isEqual"; import "lodash-es/xorWith"; import "react-router"; import "@sage-bionetworks/synapse-client"; import "../../../utils/types/IsType.js"; import { useGetCurrentUserProfile as v } from "../../../synapse-queries/user/useUserBundle.js"; import w from "../../IconSvg/IconSvg.js"; import { UserBadge as g } from "../../UserCard/UserBadge.js"; import N from "../../UserSearchBox/UserSearchBox.js"; function pe(C) { const { accessorChanges: p, onChange: m, isRenewal: h, helpText: A } = C, { data: l } = v(), f = (e, t) => { t && m((o) => { if (!o.map((s) => s.userId).includes(t.ownerId)) { const s = { userId: t.ownerId, type: i.GAIN_ACCESS }; o.push(s); } return o; }); }, S = (e) => { m((t) => t.filter((o) => o.userId !== e)); }, x = (e, t) => { m((o) => { const n = o.findIndex( (s) => s.userId === t ); return o[n].type = e, o; }); }; return /* @__PURE__ */ c(d, { children: [ /* @__PURE__ */ r(a, { variant: "headline3", sx: { mt: 4, mb: 2 }, children: "Data Requesters" }), /* @__PURE__ */ r( a, { component: "div", variant: "body1", sx: { mb: 1 }, className: "requester-label", children: A } ), /* @__PURE__ */ r( N, { inputId: "requesters", typeFilter: E.USERS_ONLY, onChange: f, filterPredicate: (e) => !p.map((t) => t.userId).includes(e.ownerId), value: null } ), /* @__PURE__ */ r(y, { sx: { my: 1, gap: 1 }, children: p.map((e, t) => /* @__PURE__ */ c("div", { className: "list-items", children: [ /* @__PURE__ */ r( g, { userId: e.userId, showAccountLevelIcon: !0, disableLink: !0, showFullName: !0 } ), // only display delete button if the user profile is not the current user and has not had access before l?.ownerId !== e.userId && e.type === i.GAIN_ACCESS && /* @__PURE__ */ r( R, { "aria-label": "Remove user", variant: "text", sx: { ml: 1, px: 0 }, onClick: () => S(e.userId), children: /* @__PURE__ */ r(w, { icon: "clear" }) } ), // Renewal/Revoke data access, only display if isRenewal is true // TODO: It's possible to that the accessors list is in an illegal state with no way to recover -- see PLFM-7893 h && l?.ownerId !== e.userId && e.type !== i.GAIN_ACCESS && /* @__PURE__ */ r(d, { children: /* @__PURE__ */ c( b, { value: e.type, onChange: (o, n) => x( n, e.userId ), children: [ /* @__PURE__ */ r( u, { control: /* @__PURE__ */ r(I, {}), label: "Renew", value: i.RENEW_ACCESS } ), /* @__PURE__ */ r( u, { control: /* @__PURE__ */ r(I, {}), label: "Revoke", value: i.REVOKE_ACCESS } ) ] } ) }) ] }, `accessor-${t}`)) }) ] }); } export { pe as default }; //# sourceMappingURL=DataAccessRequestAccessorsEditor.js.map