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

155 lines (154 loc) 5.12 kB
import { jsx as o, jsxs as i, Fragment as c } 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 "@sage-bionetworks/synapse-types"; import "../../utils/functions/EntityTypeUtils.js"; import "../../utils/SynapseConstants.js"; import { noop as u } from "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "@tanstack/react-query"; import "../../utils/PermissionLevelToAccessType.js"; import { useState as l } from "react"; import "../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import { Box as f, Button as h, TextField as W, Alert as E } 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 { SynapseSpinner as I } from "../LoadingScreen/LoadingScreen.js"; 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 { useUpdateWikiPage as b } from "../../synapse-queries/wiki/useWiki.js"; import { ConfirmationDialog as D } from "../ConfirmationDialog/ConfirmationDialog.js"; import { DialogBase as T } from "../DialogBase.js"; import { MarkdownEditor as P } from "../Markdown/MarkdownEditor.js"; const M = "Unsaved Changes", N = "Any unsaved changes may be lost. Are you sure that you would like to navigate away from this editor?", _ = "Could not save your changes. It is recommended that you copy your version of the wiki text so that it is not lost. "; function gt(g) { const { open: w, ownerObjectId: k, ownerObjectType: C, wikiPage: t, onCancel: s = u, onSave: x = u } = g, [m, y] = l(t.title), [r, v] = l(t.markdown), [S, n] = l(!1), p = () => { t && t.markdown !== r ? n(!0) : s(); }, { mutate: A, isPending: e, error: d } = b({ onSuccess: () => x() }); return /* @__PURE__ */ o( T, { open: w, onCancel: p, maxWidth: "xl", fullWidth: !0, title: "Edit Wiki Markdown", content: /* @__PURE__ */ i(c, { children: [ e && /* @__PURE__ */ o(I, {}), t && /* @__PURE__ */ i(c, { children: [ t.parentWikiId && /* @__PURE__ */ o( W, { label: "Title", placeholder: "Title", fullWidth: !0, sx: { mb: 2 }, value: m, onChange: (a) => y(a.target.value) } ), /* @__PURE__ */ o(P, { text: r, setText: v }), /* @__PURE__ */ o( D, { open: S, title: M, content: N, onCancel: () => n(!1), onConfirm: () => { n(!1), s(); } } ) ] }), d && /* @__PURE__ */ o(E, { severity: "error", children: _ + d.reason }) ] }), actions: /* @__PURE__ */ i( f, { sx: { display: "flex", flexDirection: "row-reverse", justifyContent: "space-between", width: "100%" }, children: [ /* @__PURE__ */ i( f, { sx: { display: "flex", gap: 1 }, children: [ /* @__PURE__ */ o( h, { variant: "outlined", disabled: e, onClick: p, children: "Cancel" } ), /* @__PURE__ */ o( h, { variant: "contained", color: "primary", disabled: e, onClick: () => { if (t) { const a = { ownerObjectId: k, ownerObjectType: C, wikiPage: { ...t, title: m, markdown: r } }; A(a); } }, children: e ? "Saving..." : "Save" } ) ] } ), !1 ] } ) } ); } export { _ as ERROR_SAVING_WIKI, N as NAVIGATE_AWAY_CONFIRMATION_MESSAGE, M as UNSAVED_CHANGES, gt as WikiMarkdownEditor, gt as default }; //# sourceMappingURL=WikiMarkdownEditor.js.map