UNPKG

datajunction-ui

Version:
61 lines (60 loc) 2.22 kB
import { jsxs as l, jsx as e, Fragment as o } from "react/jsx-runtime"; import { D as h, af as a, E as y, s as g, r as x, aH as D, k as b } from "./index-n79cxNwC.js"; import * as I from "react"; import { useContext as N } from "react"; function E({ nodeName: t, iconSize: r = 20 }) { const [d, c] = I.useState(!1), u = N(h).DataJunctionAPI, m = async (n, { setStatus: i }) => { if (!window.confirm("Deleting node " + n.nodeName + ". Are you sure?")) return; const { status: s, json: p } = await u.deactivate(n.nodeName); s === 200 || s === 201 || s === 204 ? (i({ success: /* @__PURE__ */ l(o, { children: [ "Successfully deleted node ", n.nodeName ] }) }), setTimeout(() => c(!0), 1500)) : i({ failure: `${p.message}` }); }, f = { nodeName: t }; return d ? null : /* @__PURE__ */ l( "div", { style: { display: "inline-flex", alignItems: "center", gap: "0.25rem" }, children: [ /* @__PURE__ */ e(a, { content: "Edit node", children: /* @__PURE__ */ e("a", { href: `/nodes/${t}/edit`, "aria-label": `Edit ${t}`, children: /* @__PURE__ */ e(y, { size: r }) }) }), /* @__PURE__ */ e(g, { initialValues: f, onSubmit: m, children: function({ status: i, setFieldValue: s }) { return /* @__PURE__ */ l( x, { className: "deleteNode", style: { display: "flex", alignItems: "flex-start" }, children: [ D(i), /* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(a, { content: "Delete node", children: /* @__PURE__ */ e( "button", { type: "submit", "aria-label": `Delete ${t}`, style: { marginLeft: 0, all: "unset", color: "#005c72", cursor: "pointer" }, children: /* @__PURE__ */ e(b, { size: r }) } ) }) }) ] } ); } }) ] } ); } export { E as N }; //# sourceMappingURL=NodeListActions-BJVAKd6-.js.map