diff --git a/dev.livemd b/dev.livemd index 2a4f7e5..5297adf 100644 --- a/dev.livemd +++ b/dev.livemd @@ -17,26 +17,10 @@ Mix.install([{:kino_k8s, path: "~/src/community/kino_k8s"}]) ) ``` - + ```elixir -connect_to_pod = fn terminal_kino_pid -> - {:ok, send_to_websocket} = - K8s.Client.connect( - "v1", - "pods/exec", - [namespace: "kube-system", name: "kindnet-p5nv5"], - container: "kindnet-cni", - command: "/bin/sh", - tty: true - ) - |> K8s.Client.put_conn(conn) - |> K8s.Client.stream_to(terminal_kino_pid) - - send_to_websocket -end - -KinoK8s.KinoTerminal.open(connect_to_pod) + ``` @@ -54,21 +38,5 @@ KinoK8s.KinoTerminal.open(connect_to_pod) ```elixir -import YamlElixir.Sigil - -{:ok, applied_resource} = - ~y""" - kind: ConfigMap - apiVersion: v1 - metadata: - name: kino-k8s-cm - namespace: default - data: - key: default - """ - |> K8s.Client.create() - |> K8s.Client.put_conn(conn) - |> K8s.Client.run() - -applied_resource |> Ymlr.document!() |> IO.puts() + ``` diff --git a/lib/assets/apply_cell/main.js b/lib/assets/apply_cell/main.js index 706a11e..667172c 100644 --- a/lib/assets/apply_cell/main.js +++ b/lib/assets/apply_cell/main.js @@ -1,301 +1,4 @@ -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __commonJS = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod -)); - -// node_modules/classnames/index.js -var require_classnames = __commonJS({ - "node_modules/classnames/index.js"(exports, module) { - (function() { - "use strict"; - var hasOwn = {}.hasOwnProperty; - var nativeCodeString = "[native code]"; - function classNames3() { - var classes = []; - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) - continue; - var argType = typeof arg; - if (argType === "string" || argType === "number") { - classes.push(arg); - } else if (Array.isArray(arg)) { - if (arg.length) { - var inner = classNames3.apply(null, arg); - if (inner) { - classes.push(inner); - } - } - } else if (argType === "object") { - if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) { - classes.push(arg.toString()); - continue; - } - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); - } - } - } - } - return classes.join(" "); - } - if (typeof module !== "undefined" && module.exports) { - classNames3.default = classNames3; - module.exports = classNames3; - } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) { - define("classnames", [], function() { - return classNames3; - }); - } else { - window.classNames = classNames3; - } - })(); - } -}); - -// assets/shared/error.tsx -var Error2 = ({ message }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "flex rounded-md border border-dashed border-red-700 bg-red-100 p-2" }, /* @__PURE__ */ React.createElement( - "svg", - { - className: "h-6 w-6 flex-none text-red-700", - fill: "none", - viewBox: "0 0 24 24", - "stroke-width": "1.5", - stroke: "currentColor", - "aria-hidden": "true" - }, - /* @__PURE__ */ React.createElement( - "path", - { - "stroke-linecap": "round", - "stroke-linejoin": "round", - d: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" - } - ) -), /* @__PURE__ */ React.createElement("div", { className: "font-inter px-2 text-sm font-medium text-red-700" }, message))); -var error_default = Error2; - -// assets/shared/utils.ts -var loadReact = async (ctx, attrs) => { - if (attrs.mix_env == "dev") { - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js" - ); - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js" - ); - } else { - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.js" - ); - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js" - ); - } -}; - -// assets/shared/attr_state.tsx -var useAttrsState = (ctx, initialAttrs) => { - const [attrs, setAttrs] = React.useState(initialAttrs); - const updateAttr = (attrName) => (attrValue) => { - setAttrs((attrs2) => ({ ...attrs2, [attrName]: attrValue })); - console.log("Pushing ${attrName} to server", attrValue); - ctx.pushEvent(`update_${attrName}`, attrValue); - }; - React.useEffect(() => { - ctx.handleEvent("update", (updates) => { - console.log("Attribute update from server", updates); - setAttrs((attrs2) => ({ - ...Object.assign(attrs2, updates) - })); - }); - }, []); - return [attrs, updateAttr]; -}; -var attr_state_default = useAttrsState; - -// assets/shared/conn_notice.tsx -var ConnNotice = () => /* @__PURE__ */ React.createElement("div", { className: "mb-5 rounded-md bg-gray-100 p-4 font-inter text-sm font-medium text-gray-500" }, /* @__PURE__ */ React.createElement("p", null, "To make requests to the Kubernetes cluster, you need at least one connection to a cluster."), /* @__PURE__ */ React.createElement("p", { className: "pt-1" }, "To create a cluster connection, you can add the", " ", /* @__PURE__ */ React.createElement("span", { className: "text-gray-600" }, "Cluster Connection"), " smart cell.")); -var conn_notice_default = ConnNotice; - -// assets/shared/form/input.tsx -var import_classnames = __toESM(require_classnames()); -var Input = ({ - name, - label, - defaultValue, - onChange, - orientation = "vert" -}) => { - return /* @__PURE__ */ React.createElement( - "div", - { - className: (0, import_classnames.default)({ - "flex flex-row items-baseline": orientation == "horiz" - }) - }, - /* @__PURE__ */ React.createElement( - "label", - { - htmlFor: name, - className: (0, import_classnames.default)( - { - block: orientation == "vert", - "pr-1 uppercase": orientation == "horiz" - }, - "mb-1 text-sm font-medium" - ) - }, - label - ), - /* @__PURE__ */ React.createElement( - "input", - { - type: "text", - value: defaultValue, - name, - onChange: (e) => onChange(e.target.value), - className: (0, import_classnames.default)( - { "block w-full": orientation == "vert" }, - "rounded-lg border border-gray-300 bg-gray-50 p-1.5 text-sm focus:border-blue-500 focus:ring-blue-500" - ) - } - ) - ); -}; -var input_default = Input; - -// assets/shared/form/select.tsx -var import_classnames2 = __toESM(require_classnames()); -var Select = ({ - name, - label, - options, - selectedOption, - onChange, - className = "", - orientation = "vert" -}) => /* @__PURE__ */ React.createElement( - "div", - { - className: (0, import_classnames2.default)( - { - "flex flex-row items-baseline": orientation == "horiz" - }, - className - ) - }, - /* @__PURE__ */ React.createElement( - "label", - { - htmlFor: name, - className: (0, import_classnames2.default)( - { - block: orientation == "vert", - "pr-1 uppercase": orientation == "horiz" - }, - "mb-1 text-sm font-medium" - ) - }, - label - ), - /* @__PURE__ */ React.createElement( - "select", - { - id: name, - value: selectedOption || void 0, - onChange: (e) => onChange(e.target.value), - className: (0, import_classnames2.default)( - { "block w-full": orientation == "vert" }, - " bg-caret-down appearance-none rounded-lg border border-gray-300 bg-gray-50 bg-[length:10px] bg-[center_right_10px] bg-no-repeat p-2 pr-5 text-sm focus:border-blue-500 focus:ring-blue-500" - ) - }, - options.map((option) => /* @__PURE__ */ React.createElement("option", { key: option.value, value: option.value }, option.label)) - ) -); -var select_default = Select; - -// assets/apply_cell/app.tsx -var App = ({ initialAttrs, ctx }) => { - const [attrs, updateAttr] = attr_state_default(ctx, initialAttrs); - return /* @__PURE__ */ React.createElement(React.Fragment, null, !attrs.connection && /* @__PURE__ */ React.createElement(conn_notice_default, null), /* @__PURE__ */ React.createElement("div", { className: "rounded-md border-t border-solid border-gray-300 font-inter font-medium text-gray-600" }, /* @__PURE__ */ React.createElement("div", { className: "border-b-solid flex gap-x-5 gap-y-3 border-b border-b-gray-300 bg-blue-100 p-3" }, /* @__PURE__ */ React.createElement( - select_default, - { - name: "connection", - label: "Connection", - options: attrs.connections.map((connection) => ({ - label: connection.variable, - value: connection.variable - })), - selectedOption: attrs.connection?.variable?.toString(), - onChange: updateAttr("connection"), - orientation: "horiz" - } - ), /* @__PURE__ */ React.createElement( - select_default, - { - name: "method", - label: "Method", - options: attrs.methods.map((method) => ({ - label: method.toUpperCase(), - value: method - })), - selectedOption: attrs.method, - onChange: updateAttr("method"), - orientation: "horiz" - } - ), /* @__PURE__ */ React.createElement( - input_default, - { - label: "Assign To", - name: "assign_to", - defaultValue: attrs["result_variable"], - onChange: updateAttr("result_variable"), - orientation: "horiz" - } - )))); -}; -var app_default = App; - -// assets/apply_cell/main.tsx -var init = async (ctx, attrs) => { - await loadReact(ctx, attrs); - ctx.root.innerHTML = "loading..."; - ctx.importCSS("main.css"); - ctx.importCSS( - "https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" - ); - const root = ReactDOM.createRoot(ctx.root); - if (attrs.error) { - return root.render(/* @__PURE__ */ React.createElement(error_default, { message: attrs.error })); - } - root.render(/* @__PURE__ */ React.createElement(app_default, { initialAttrs: attrs, ctx })); -}; -export { - init -}; +var C=Object.create;var f=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var P=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of S(t))!j.call(e,o)&&o!==r&&f(e,o,{get:()=>t[o],enumerable:!(s=N(t,o))||s.enumerable});return e};var b=(e,t,r)=>(r=e!=null?C(T(e)):{},P(t||!e||!e.__esModule?f(r,"default",{value:e,enumerable:!0}):r,e));var c=w((U,l)=>{(function(){"use strict";var e={}.hasOwnProperty,t="[native code]";function r(){for(var s=[],o=0;oReact.createElement(React.Fragment,null,React.createElement("div",{className:"flex rounded-md border border-dashed border-red-700 bg-red-100 p-2"},React.createElement("svg",{className:"h-6 w-6 flex-none text-red-700",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},React.createElement("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})),React.createElement("div",{className:"font-inter px-2 text-sm font-medium text-red-700"},e))),v=z;var g=async(e,t)=>{t.mix_env=="dev"?(await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js"),await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js")):(await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.js"),await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"))};var k=(e,t)=>{let[r,s]=React.useState(t),o=n=>a=>{s(i=>({...i,[n]:a})),console.log("Pushing ${attrName} to server",a),e.pushEvent(`update_${n}`,a)};return React.useEffect(()=>{e.handleEvent("update",n=>{console.log("Attribute update from server",n),s(a=>({...Object.assign(a,n)}))})},[]),[r,o]},h=k;var R=()=>React.createElement("div",{className:"mb-5 rounded-md bg-gray-100 p-4 font-inter text-sm font-medium text-gray-500"},React.createElement("p",null,"To make requests to the Kubernetes cluster, you need at least one connection to a cluster."),React.createElement("p",{className:"pt-1"},"To create a cluster connection, you can add the"," ",React.createElement("span",{className:"text-gray-600"},"Cluster Connection")," smart cell.")),y=R;var p=b(c()),K=({name:e,label:t,defaultValue:r,onChange:s,orientation:o="vert"})=>React.createElement("div",{className:(0,p.default)({"flex flex-row items-baseline":o=="horiz"})},React.createElement("label",{htmlFor:e,className:(0,p.default)({block:o=="vert","pr-1 uppercase":o=="horiz"},"mb-1 text-sm font-medium")},t),React.createElement("input",{type:"text",value:r,name:e,onChange:n=>s(n.target.value),className:(0,p.default)({"block w-full":o=="vert"},"rounded-lg border border-gray-300 bg-gray-50 p-1.5 text-sm focus:border-blue-500 focus:ring-blue-500")})),x=K;var d=b(c()),O=({name:e,label:t,options:r,selectedOption:s,onChange:o,className:n="",orientation:a="vert"})=>React.createElement("div",{className:(0,d.default)({"flex flex-row items-baseline":a=="horiz"},n)},React.createElement("label",{htmlFor:e,className:(0,d.default)({block:a=="vert","pr-1 uppercase":a=="horiz"},"mb-1 text-sm font-medium")},t),React.createElement("select",{id:e,value:s||void 0,onChange:i=>o(i.target.value),className:(0,d.default)({"block w-full":a=="vert"}," bg-caret-down appearance-none rounded-lg border border-gray-300 bg-gray-50 bg-[length:10px] bg-[center_right_10px] bg-no-repeat p-2 pr-5 text-sm focus:border-blue-500 focus:ring-blue-500")},r.map(i=>React.createElement("option",{key:i.value,value:i.value},i.label)))),u=O;var _=({initialAttrs:e,ctx:t})=>{let[r,s]=h(t,e);return React.createElement(React.Fragment,null,!r.connection&&React.createElement(y,null),React.createElement("div",{className:"rounded-md border-t border-solid border-gray-300 font-inter font-medium text-gray-600"},React.createElement("div",{className:"border-b-solid flex gap-x-5 gap-y-3 border-b border-b-gray-300 bg-blue-100 p-3"},React.createElement(u,{name:"connection",label:"Connection",options:r.connections.map(o=>({label:o.variable,value:o.variable})),selectedOption:r.connection?.variable?.toString(),onChange:s("connection"),orientation:"horiz"}),React.createElement(u,{name:"method",label:"Method",options:r.methods.map(o=>({label:o.toUpperCase(),value:o})),selectedOption:r.method,onChange:s("method"),orientation:"horiz"}),React.createElement(x,{label:"Assign To",name:"assign_to",defaultValue:r.result_variable,onChange:s("result_variable"),orientation:"horiz"}))))},A=_;var X=async(e,t)=>{await g(e,t),e.root.innerHTML="loading...",e.importCSS("main.css"),e.importCSS("https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap");let r=ReactDOM.createRoot(e.root);if(t.error)return r.render(React.createElement(v,{message:t.error}));r.render(React.createElement(A,{initialAttrs:t,ctx:e}))};export{X as init}; /*! Bundled license information: classnames/index.js: diff --git a/lib/assets/connection_cell/main.js b/lib/assets/connection_cell/main.js index 02f3e38..d6088b8 100644 --- a/lib/assets/connection_cell/main.js +++ b/lib/assets/connection_cell/main.js @@ -1,318 +1,4 @@ -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __commonJS = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod -)); - -// node_modules/classnames/index.js -var require_classnames = __commonJS({ - "node_modules/classnames/index.js"(exports, module) { - (function() { - "use strict"; - var hasOwn = {}.hasOwnProperty; - var nativeCodeString = "[native code]"; - function classNames3() { - var classes = []; - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) - continue; - var argType = typeof arg; - if (argType === "string" || argType === "number") { - classes.push(arg); - } else if (Array.isArray(arg)) { - if (arg.length) { - var inner = classNames3.apply(null, arg); - if (inner) { - classes.push(inner); - } - } - } else if (argType === "object") { - if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) { - classes.push(arg.toString()); - continue; - } - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); - } - } - } - } - return classes.join(" "); - } - if (typeof module !== "undefined" && module.exports) { - classNames3.default = classNames3; - module.exports = classNames3; - } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) { - define("classnames", [], function() { - return classNames3; - }); - } else { - window.classNames = classNames3; - } - })(); - } -}); - -// assets/shared/error.tsx -var Error2 = ({ message }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "flex rounded-md border border-dashed border-red-700 bg-red-100 p-2" }, /* @__PURE__ */ React.createElement( - "svg", - { - className: "h-6 w-6 flex-none text-red-700", - fill: "none", - viewBox: "0 0 24 24", - "stroke-width": "1.5", - stroke: "currentColor", - "aria-hidden": "true" - }, - /* @__PURE__ */ React.createElement( - "path", - { - "stroke-linecap": "round", - "stroke-linejoin": "round", - d: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" - } - ) -), /* @__PURE__ */ React.createElement("div", { className: "font-inter px-2 text-sm font-medium text-red-700" }, message))); -var error_default = Error2; - -// assets/shared/utils.ts -var loadReact = async (ctx, attrs) => { - if (attrs.mix_env == "dev") { - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js" - ); - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js" - ); - } else { - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.js" - ); - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js" - ); - } -}; - -// assets/shared/attr_state.tsx -var useAttrsState = (ctx, initialAttrs) => { - const [attrs, setAttrs] = React.useState(initialAttrs); - const updateAttr = (attrName) => (attrValue) => { - setAttrs((attrs2) => ({ ...attrs2, [attrName]: attrValue })); - console.log("Pushing ${attrName} to server", attrValue); - ctx.pushEvent(`update_${attrName}`, attrValue); - }; - React.useEffect(() => { - ctx.handleEvent("update", (updates) => { - console.log("Attribute update from server", updates); - setAttrs((attrs2) => ({ - ...Object.assign(attrs2, updates) - })); - }); - }, []); - return [attrs, updateAttr]; -}; -var attr_state_default = useAttrsState; - -// assets/shared/form/input.tsx -var import_classnames = __toESM(require_classnames()); -var Input = ({ - name, - label, - defaultValue, - onChange, - orientation = "vert" -}) => { - return /* @__PURE__ */ React.createElement( - "div", - { - className: (0, import_classnames.default)({ - "flex flex-row items-baseline": orientation == "horiz" - }) - }, - /* @__PURE__ */ React.createElement( - "label", - { - htmlFor: name, - className: (0, import_classnames.default)( - { - block: orientation == "vert", - "pr-1 uppercase": orientation == "horiz" - }, - "mb-1 text-sm font-medium" - ) - }, - label - ), - /* @__PURE__ */ React.createElement( - "input", - { - type: "text", - value: defaultValue, - name, - onChange: (e) => onChange(e.target.value), - className: (0, import_classnames.default)( - { "block w-full": orientation == "vert" }, - "rounded-lg border border-gray-300 bg-gray-50 p-1.5 text-sm focus:border-blue-500 focus:ring-blue-500" - ) - } - ) - ); -}; -var input_default = Input; - -// assets/shared/form/select.tsx -var import_classnames2 = __toESM(require_classnames()); -var Select = ({ - name, - label, - options, - selectedOption, - onChange, - className = "", - orientation = "vert" -}) => /* @__PURE__ */ React.createElement( - "div", - { - className: (0, import_classnames2.default)( - { - "flex flex-row items-baseline": orientation == "horiz" - }, - className - ) - }, - /* @__PURE__ */ React.createElement( - "label", - { - htmlFor: name, - className: (0, import_classnames2.default)( - { - block: orientation == "vert", - "pr-1 uppercase": orientation == "horiz" - }, - "mb-1 text-sm font-medium" - ) - }, - label - ), - /* @__PURE__ */ React.createElement( - "select", - { - id: name, - value: selectedOption || void 0, - onChange: (e) => onChange(e.target.value), - className: (0, import_classnames2.default)( - { "block w-full": orientation == "vert" }, - " bg-caret-down appearance-none rounded-lg border border-gray-300 bg-gray-50 bg-[length:10px] bg-[center_right_10px] bg-no-repeat p-2 pr-5 text-sm focus:border-blue-500 focus:ring-blue-500" - ) - }, - options.map((option) => /* @__PURE__ */ React.createElement("option", { key: option.value, value: option.value }, option.label)) - ) -); -var select_default = Select; - -// assets/connection_cell/app.tsx -var App = ({ initialAttrs, ctx }) => { - const [attrs, updateAttr] = attr_state_default(ctx, initialAttrs); - const source_type_options = [ - { label: "File", value: "file" }, - { label: "Environment Variable", value: "env" } - ]; - source_type_options.push({ label: "K8s Service Account", value: "k8s" }); - return /* @__PURE__ */ React.createElement("div", { className: "rounded-md border border-solid border-gray-300 font-inter font-medium text-gray-600" }, /* @__PURE__ */ React.createElement("div", { className: "border-b-solid flex flex-wrap gap-x-5 gap-y-3 border-b border-b-gray-300 bg-blue-100 p-3" }, /* @__PURE__ */ React.createElement( - select_default, - { - name: "source_type", - label: "Source Type", - options: source_type_options, - selectedOption: attrs["source_type"], - onChange: updateAttr("source_type"), - orientation: "horiz" - } - ), /* @__PURE__ */ React.createElement( - input_default, - { - label: "Assign To", - name: "assign_to", - defaultValue: attrs["result_variable"], - onChange: updateAttr("result_variable"), - orientation: "horiz" - } - )), /* @__PURE__ */ React.createElement("div", { className: "flex flex-wrap gap-x-5 p-3" }, attrs["source_type"] != "k8s" && /* @__PURE__ */ React.createElement( - input_default, - { - label: attrs["source_type"] == "file" ? "File Path" : "Env Var", - name: "source", - defaultValue: attrs["source"], - onChange: updateAttr("source"), - orientation: "vert" - } - ), attrs["source_type"] != "k8s" && /* @__PURE__ */ React.createElement( - input_default, - { - label: "Context", - name: "context", - defaultValue: attrs.opts.context || "", - onChange: (value) => updateAttr("opts")({ ...attrs.opts, context: value }) - } - ), /* @__PURE__ */ React.createElement( - select_default, - { - name: "insecure_skip_tls_verify", - label: "Insecure Skip TLS Verify", - options: [ - { label: "Yes", value: "true" }, - { label: "No", value: "false" } - ], - selectedOption: attrs.opts.insecure_skip_tls_verify.toString(), - onChange: (value) => updateAttr("opts")({ - ...attrs.opts, - insecure_skip_tls_verify: JSON.parse(value) - }) - } - ))); -}; -var app_default = App; - -// assets/connection_cell/main.tsx -var init = async (ctx, attrs) => { - await loadReact(ctx, attrs); - ctx.root.innerHTML = "loading..."; - ctx.importCSS("main.css"); - ctx.importCSS( - "https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" - ); - const root = ReactDOM.createRoot(ctx.root); - if (attrs.error) { - return root.render(/* @__PURE__ */ React.createElement(error_default, { message: attrs.error })); - } - root.render(/* @__PURE__ */ React.createElement(app_default, { initialAttrs: attrs, ctx })); -}; -export { - init -}; +var A=Object.create;var v=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var w=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var N=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of S(r))!T.call(e,n)&&n!==t&&v(e,n,{get:()=>r[n],enumerable:!(s=C(r,n))||s.enumerable});return e};var b=(e,r,t)=>(t=e!=null?A(_(e)):{},N(r||!e||!e.__esModule?v(t,"default",{value:e,enumerable:!0}):t,e));var m=w((I,l)=>{(function(){"use strict";var e={}.hasOwnProperty,r="[native code]";function t(){for(var s=[],n=0;nReact.createElement(React.Fragment,null,React.createElement("div",{className:"flex rounded-md border border-dashed border-red-700 bg-red-100 p-2"},React.createElement("svg",{className:"h-6 w-6 flex-none text-red-700",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},React.createElement("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})),React.createElement("div",{className:"font-inter px-2 text-sm font-medium text-red-700"},e))),g=j;var y=async(e,r)=>{r.mix_env=="dev"?(await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js"),await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js")):(await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.js"),await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"))};var k=(e,r)=>{let[t,s]=React.useState(r),n=o=>a=>{s(i=>({...i,[o]:a})),console.log("Pushing ${attrName} to server",a),e.pushEvent(`update_${o}`,a)};return React.useEffect(()=>{e.handleEvent("update",o=>{console.log("Attribute update from server",o),s(a=>({...Object.assign(a,o)}))})},[]),[t,n]},h=k;var p=b(m()),P=({name:e,label:r,defaultValue:t,onChange:s,orientation:n="vert"})=>React.createElement("div",{className:(0,p.default)({"flex flex-row items-baseline":n=="horiz"})},React.createElement("label",{htmlFor:e,className:(0,p.default)({block:n=="vert","pr-1 uppercase":n=="horiz"},"mb-1 text-sm font-medium")},r),React.createElement("input",{type:"text",value:t,name:e,onChange:o=>s(o.target.value),className:(0,p.default)({"block w-full":n=="vert"},"rounded-lg border border-gray-300 bg-gray-50 p-1.5 text-sm focus:border-blue-500 focus:ring-blue-500")})),c=P;var u=b(m()),z=({name:e,label:r,options:t,selectedOption:s,onChange:n,className:o="",orientation:a="vert"})=>React.createElement("div",{className:(0,u.default)({"flex flex-row items-baseline":a=="horiz"},o)},React.createElement("label",{htmlFor:e,className:(0,u.default)({block:a=="vert","pr-1 uppercase":a=="horiz"},"mb-1 text-sm font-medium")},r),React.createElement("select",{id:e,value:s||void 0,onChange:i=>n(i.target.value),className:(0,u.default)({"block w-full":a=="vert"}," bg-caret-down appearance-none rounded-lg border border-gray-300 bg-gray-50 bg-[length:10px] bg-[center_right_10px] bg-no-repeat p-2 pr-5 text-sm focus:border-blue-500 focus:ring-blue-500")},t.map(i=>React.createElement("option",{key:i.value,value:i.value},i.label)))),f=z;var R=({initialAttrs:e,ctx:r})=>{let[t,s]=h(r,e),n=[{label:"File",value:"file"},{label:"Environment Variable",value:"env"}];return n.push({label:"K8s Service Account",value:"k8s"}),React.createElement("div",{className:"rounded-md border border-solid border-gray-300 font-inter font-medium text-gray-600"},React.createElement("div",{className:"border-b-solid flex flex-wrap gap-x-5 gap-y-3 border-b border-b-gray-300 bg-blue-100 p-3"},React.createElement(f,{name:"source_type",label:"Source Type",options:n,selectedOption:t.source_type,onChange:s("source_type"),orientation:"horiz"}),React.createElement(c,{label:"Assign To",name:"assign_to",defaultValue:t.result_variable,onChange:s("result_variable"),orientation:"horiz"})),React.createElement("div",{className:"flex flex-wrap gap-x-5 p-3"},t.source_type!="k8s"&&React.createElement(c,{label:t.source_type=="file"?"File Path":"Env Var",name:"source",defaultValue:t.source,onChange:s("source"),orientation:"vert"}),t.source_type!="k8s"&&React.createElement(c,{label:"Context",name:"context",defaultValue:t.opts.context||"",onChange:o=>s("opts")({...t.opts,context:o})}),React.createElement(f,{name:"insecure_skip_tls_verify",label:"Insecure Skip TLS Verify",options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],selectedOption:t.opts.insecure_skip_tls_verify.toString(),onChange:o=>s("opts")({...t.opts,insecure_skip_tls_verify:JSON.parse(o)})})))},x=R;var Y=async(e,r)=>{await y(e,r),e.root.innerHTML="loading...",e.importCSS("main.css"),e.importCSS("https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap");let t=ReactDOM.createRoot(e.root);if(r.error)return t.render(React.createElement(g,{message:r.error}));t.render(React.createElement(x,{initialAttrs:r,ctx:e}))};export{Y as init}; /*! Bundled license information: classnames/index.js: diff --git a/lib/assets/get_cell/main.js b/lib/assets/get_cell/main.js index 6c409f3..cb5b18a 100644 --- a/lib/assets/get_cell/main.js +++ b/lib/assets/get_cell/main.js @@ -1,480 +1,4 @@ -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __commonJS = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod -)); - -// node_modules/classnames/index.js -var require_classnames = __commonJS({ - "node_modules/classnames/index.js"(exports, module) { - (function() { - "use strict"; - var hasOwn = {}.hasOwnProperty; - var nativeCodeString = "[native code]"; - function classNames4() { - var classes = []; - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) - continue; - var argType = typeof arg; - if (argType === "string" || argType === "number") { - classes.push(arg); - } else if (Array.isArray(arg)) { - if (arg.length) { - var inner = classNames4.apply(null, arg); - if (inner) { - classes.push(inner); - } - } - } else if (argType === "object") { - if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) { - classes.push(arg.toString()); - continue; - } - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); - } - } - } - } - return classes.join(" "); - } - if (typeof module !== "undefined" && module.exports) { - classNames4.default = classNames4; - module.exports = classNames4; - } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) { - define("classnames", [], function() { - return classNames4; - }); - } else { - window.classNames = classNames4; - } - })(); - } -}); - -// assets/shared/error.tsx -var Error2 = ({ message }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "flex rounded-md border border-dashed border-red-700 bg-red-100 p-2" }, /* @__PURE__ */ React.createElement( - "svg", - { - className: "h-6 w-6 flex-none text-red-700", - fill: "none", - viewBox: "0 0 24 24", - "stroke-width": "1.5", - stroke: "currentColor", - "aria-hidden": "true" - }, - /* @__PURE__ */ React.createElement( - "path", - { - "stroke-linecap": "round", - "stroke-linejoin": "round", - d: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" - } - ) -), /* @__PURE__ */ React.createElement("div", { className: "font-inter px-2 text-sm font-medium text-red-700" }, message))); -var error_default = Error2; - -// assets/shared/utils.ts -var debounce = (callback, timeout) => { - let timer; - return (...args) => { - clearTimeout(timer); - timer = setTimeout(() => { - callback(...args); - }, timeout); - }; -}; -var loadReact = async (ctx, attrs) => { - if (attrs.mix_env == "dev") { - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js" - ); - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js" - ); - } else { - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.js" - ); - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js" - ); - } -}; - -// assets/shared/attr_state.tsx -var useAttrsState = (ctx, initialAttrs) => { - const [attrs, setAttrs] = React.useState(initialAttrs); - const updateAttr = (attrName) => (attrValue) => { - setAttrs((attrs2) => ({ ...attrs2, [attrName]: attrValue })); - console.log("Pushing ${attrName} to server", attrValue); - ctx.pushEvent(`update_${attrName}`, attrValue); - }; - React.useEffect(() => { - ctx.handleEvent("update", (updates) => { - console.log("Attribute update from server", updates); - setAttrs((attrs2) => ({ - ...Object.assign(attrs2, updates) - })); - }); - }, []); - return [attrs, updateAttr]; -}; -var attr_state_default = useAttrsState; - -// assets/shared/conn_notice.tsx -var ConnNotice = () => /* @__PURE__ */ React.createElement("div", { className: "mb-5 rounded-md bg-gray-100 p-4 font-inter text-sm font-medium text-gray-500" }, /* @__PURE__ */ React.createElement("p", null, "To make requests to the Kubernetes cluster, you need at least one connection to a cluster."), /* @__PURE__ */ React.createElement("p", { className: "pt-1" }, "To create a cluster connection, you can add the", " ", /* @__PURE__ */ React.createElement("span", { className: "text-gray-600" }, "Cluster Connection"), " smart cell.")); -var conn_notice_default = ConnNotice; - -// assets/shared/form/input.tsx -var import_classnames = __toESM(require_classnames()); -var Input = ({ - name, - label, - defaultValue, - onChange, - orientation = "vert" -}) => { - return /* @__PURE__ */ React.createElement( - "div", - { - className: (0, import_classnames.default)({ - "flex flex-row items-baseline": orientation == "horiz" - }) - }, - /* @__PURE__ */ React.createElement( - "label", - { - htmlFor: name, - className: (0, import_classnames.default)( - { - block: orientation == "vert", - "pr-1 uppercase": orientation == "horiz" - }, - "mb-1 text-sm font-medium" - ) - }, - label - ), - /* @__PURE__ */ React.createElement( - "input", - { - type: "text", - value: defaultValue, - name, - onChange: (e) => onChange(e.target.value), - className: (0, import_classnames.default)( - { "block w-full": orientation == "vert" }, - "rounded-lg border border-gray-300 bg-gray-50 p-1.5 text-sm focus:border-blue-500 focus:ring-blue-500" - ) - } - ) - ); -}; -var input_default = Input; - -// assets/shared/form/search_select.tsx -var import_classnames2 = __toESM(require_classnames()); -var SearchInput = ({ - name, - selectedValue, - searchTerm, - onSearch, - placeholder -}) => { - const performSearch = debounce((searchTerm2) => { - onSearch(searchTerm2.toLowerCase()); - }, 300); - const [localSearchTerm, setLocalSearchTerm] = React.useState(searchTerm ?? ""); - React.useEffect(() => { - selectedValue && setLocalSearchTerm(selectedValue); - }, [selectedValue]); - return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "relative" }, /* @__PURE__ */ React.createElement("div", { className: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3" }, /* @__PURE__ */ React.createElement( - "svg", - { - xmlns: "http://www.w3.org/2000/svg", - fill: "none", - viewBox: "0 0 24 24", - "aria-hidden": "true", - strokeWidth: 1.5, - stroke: "currentColor", - className: (0, import_classnames2.default)("h-5 w-5", { - "bg-green-200": selectedValue, - "text-green-800": selectedValue, - "border-green-800": selectedValue, - "rounded-lg": selectedValue - }) - }, - selectedValue ? /* @__PURE__ */ React.createElement( - "path", - { - strokeLinecap: "round", - strokeLinejoin: "round", - d: "M9 12.75L11.25 15 15 9.75M21 12c0 1.268-.63 2.39-1.593 3.068a3.745 3.745 0 01-1.043 3.296 3.745 3.745 0 01-3.296 1.043A3.745 3.745 0 0112 21c-1.268 0-2.39-.63-3.068-1.593a3.746 3.746 0 01-3.296-1.043 3.745 3.745 0 01-1.043-3.296A3.745 3.745 0 013 12c0-1.268.63-2.39 1.593-3.068a3.745 3.745 0 011.043-3.296 3.746 3.746 0 013.296-1.043A3.746 3.746 0 0112 3c1.268 0 2.39.63 3.068 1.593a3.746 3.746 0 013.296 1.043 3.746 3.746 0 011.043 3.296A3.745 3.745 0 0121 12z" - } - ) : /* @__PURE__ */ React.createElement( - "path", - { - strokeLinecap: "round", - strokeLinejoin: "round", - d: "M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z" - } - ) - )), /* @__PURE__ */ React.createElement( - "input", - { - type: "text", - value: localSearchTerm, - name, - autoComplete: "off", - placeholder, - onInput: (e) => { - setLocalSearchTerm(e.target.value); - performSearch(e.target.value); - }, - className: "block w-full rounded-lg border border-gray-300 bg-gray-50 p-2 pl-9 text-sm focus:border-blue-500 focus:ring-blue-500" - } - ))); -}; -var SearchResult = ({ - resultItems, - itemRenderer, - onSelect, - resultItemsKeyField -}) => { - return /* @__PURE__ */ React.createElement("div", { className: "max-h-36 overflow-auto rounded-b-lg border-b border-l border-r border-gray-300" }, /* @__PURE__ */ React.createElement("div", { className: "w-max min-w-full" }, resultItems.map((item) => /* @__PURE__ */ React.createElement( - "div", - { - key: item[resultItemsKeyField], - onClick: () => onSelect(item), - className: "border-b-solid last:border-b-none cursor-pointer border-b border-b-gray-300 bg-gray-50 px-2 py-0.5 hover:bg-blue-600 hover:text-white" - }, - itemRenderer(item) - )))); -}; -var SearchSelect = ({ - name, - label, - searchTerm, - onSearch, - resultItems, - resultItemsKeyField, - itemRenderer, - className, - onSelect, - selectedValue, - placeholder -}) => { - return /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement("label", { htmlFor: name, className: "mb-1 block text-sm font-medium" }, label), /* @__PURE__ */ React.createElement( - SearchInput, - { - name, - onSearch, - searchTerm, - selectedValue, - placeholder - } - ), (resultItems && resultItems.length) > 0 && /* @__PURE__ */ React.createElement( - SearchResult, - { - resultItems, - itemRenderer, - onSelect, - resultItemsKeyField - } - )); -}; -var search_select_default = SearchSelect; - -// assets/shared/form/select.tsx -var import_classnames3 = __toESM(require_classnames()); -var Select = ({ - name, - label, - options, - selectedOption, - onChange, - className = "", - orientation = "vert" -}) => /* @__PURE__ */ React.createElement( - "div", - { - className: (0, import_classnames3.default)( - { - "flex flex-row items-baseline": orientation == "horiz" - }, - className - ) - }, - /* @__PURE__ */ React.createElement( - "label", - { - htmlFor: name, - className: (0, import_classnames3.default)( - { - block: orientation == "vert", - "pr-1 uppercase": orientation == "horiz" - }, - "mb-1 text-sm font-medium" - ) - }, - label - ), - /* @__PURE__ */ React.createElement( - "select", - { - id: name, - value: selectedOption || void 0, - onChange: (e) => onChange(e.target.value), - className: (0, import_classnames3.default)( - { "block w-full": orientation == "vert" }, - " bg-caret-down appearance-none rounded-lg border border-gray-300 bg-gray-50 bg-[length:10px] bg-[center_right_10px] bg-no-repeat p-2 pr-5 text-sm focus:border-blue-500 focus:ring-blue-500" - ) - }, - options.map((option) => /* @__PURE__ */ React.createElement("option", { key: option.value, value: option.value }, option.label)) - ) -); -var select_default = Select; - -// assets/shared/gvk_option.tsx -var GVKOption = ({ gvk }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "text-xs text-gray-400" }, gvk.api_version), /* @__PURE__ */ React.createElement("div", { className: "text-sm" }, gvk.kind)); -var gvk_option_default = GVKOption; - -// assets/get_cell/app.tsx -var App = ({ initialAttrs, ctx }) => { - const [attrs, updateAttr] = attr_state_default(ctx, initialAttrs); - const result_types = attrs.result_types[attrs.request_type]; - return /* @__PURE__ */ React.createElement(React.Fragment, null, !attrs.connection && /* @__PURE__ */ React.createElement(conn_notice_default, null), /* @__PURE__ */ React.createElement("div", { className: "rounded-md border border-solid border-gray-300 font-inter font-medium text-gray-600" }, /* @__PURE__ */ React.createElement("div", { className: "border-b-solid flex gap-x-5 gap-y-3 border-b border-b-gray-300 bg-blue-100 p-3" }, /* @__PURE__ */ React.createElement( - select_default, - { - name: "connection", - label: "Connection", - options: attrs.connections.map((connection) => ({ - label: connection.variable, - value: connection.variable - })), - selectedOption: attrs.connection?.variable?.toString(), - onChange: updateAttr("connection"), - orientation: "horiz" - } - ), /* @__PURE__ */ React.createElement( - select_default, - { - name: "request_type", - label: "Request Type", - options: attrs.request_types.map((request_type) => ({ - label: request_type.toUpperCase(), - value: request_type - })), - selectedOption: attrs.request_type, - onChange: updateAttr("request_type"), - orientation: "horiz" - } - ), result_types && /* @__PURE__ */ React.createElement( - select_default, - { - name: "result_type", - label: "Result Type", - options: result_types.map((result_type) => ({ - label: result_type.toUpperCase(), - value: result_type - })), - selectedOption: attrs.result_type, - onChange: updateAttr("result_type"), - orientation: "horiz" - } - ), /* @__PURE__ */ React.createElement( - input_default, - { - label: "Assign To", - name: "assign_to", - defaultValue: attrs.result_variable, - onChange: updateAttr("result_variable"), - orientation: "horiz" - } - )), /* @__PURE__ */ React.createElement("div", { className: "flex gap-x-5 p-3" }, attrs.connection && /* @__PURE__ */ React.createElement( - search_select_default, - { - className: "max-w-full", - name: "gvk", - label: "Resource Kind", - onSearch: updateAttr("search_term"), - searchTerm: attrs.search_term, - resultItemsKeyField: "index", - resultItems: attrs.search_result_items, - onSelect: updateAttr("gvk"), - itemRenderer: (item) => /* @__PURE__ */ React.createElement(gvk_option_default, { gvk: item }), - selectedValue: attrs.gvk?.kind, - placeholder: "apps/v1 Deployment" - } - ), attrs.namespaces && /* @__PURE__ */ React.createElement( - select_default, - { - name: "namespace", - label: "Namespace", - options: attrs.namespaces.map((ns) => ({ - label: ns, - value: ns - })), - selectedOption: attrs.namespace, - onChange: updateAttr("namespace") - } - ), attrs.resources && /* @__PURE__ */ React.createElement( - select_default, - { - name: "resource", - label: "Resource Name", - options: attrs.resources.map((ns) => ({ - label: ns, - value: ns - })), - selectedOption: attrs.resource, - onChange: updateAttr("resource") - } - )))); -}; -var app_default = App; - -// assets/get_cell/main.tsx -var init = async (ctx, attrs) => { - await loadReact(ctx, attrs); - ctx.root.innerHTML = "loading..."; - ctx.importCSS("main.css"); - ctx.importCSS( - "https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" - ); - const root = ReactDOM.createRoot(ctx.root); - if (attrs.error) { - return root.render(/* @__PURE__ */ React.createElement(error_default, { message: attrs.error })); - } - root.render(/* @__PURE__ */ React.createElement(app_default, { initialAttrs: attrs, ctx })); -}; -export { - init -}; +var R=Object.create;var f=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var K=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var L=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of P(r))!_.call(e,a)&&a!==t&&f(e,a,{get:()=>r[a],enumerable:!(s=I(r,a))||s.enumerable});return e};var b=(e,r,t)=>(t=e!=null?R(j(e)):{},L(r||!e||!e.__esModule?f(t,"default",{value:e,enumerable:!0}):t,e));var m=K((X,c)=>{(function(){"use strict";var e={}.hasOwnProperty,r="[native code]";function t(){for(var s=[],a=0;aReact.createElement(React.Fragment,null,React.createElement("div",{className:"flex rounded-md border border-dashed border-red-700 bg-red-100 p-2"},React.createElement("svg",{className:"h-6 w-6 flex-none text-red-700",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},React.createElement("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})),React.createElement("div",{className:"font-inter px-2 text-sm font-medium text-red-700"},e))),v=z;var g=(e,r)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>{e(...s)},r)}},h=async(e,r)=>{r.mix_env=="dev"?(await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js"),await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js")):(await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.js"),await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"))};var O=(e,r)=>{let[t,s]=React.useState(r),a=o=>n=>{s(i=>({...i,[o]:n})),console.log("Pushing ${attrName} to server",n),e.pushEvent(`update_${o}`,n)};return React.useEffect(()=>{e.handleEvent("update",o=>{console.log("Attribute update from server",o),s(n=>({...Object.assign(n,o)}))})},[]),[t,a]},y=O;var F=()=>React.createElement("div",{className:"mb-5 rounded-md bg-gray-100 p-4 font-inter text-sm font-medium text-gray-500"},React.createElement("p",null,"To make requests to the Kubernetes cluster, you need at least one connection to a cluster."),React.createElement("p",{className:"pt-1"},"To create a cluster connection, you can add the"," ",React.createElement("span",{className:"text-gray-600"},"Cluster Connection")," smart cell.")),x=F;var d=b(m()),E=({name:e,label:r,defaultValue:t,onChange:s,orientation:a="vert"})=>React.createElement("div",{className:(0,d.default)({"flex flex-row items-baseline":a=="horiz"})},React.createElement("label",{htmlFor:e,className:(0,d.default)({block:a=="vert","pr-1 uppercase":a=="horiz"},"mb-1 text-sm font-medium")},r),React.createElement("input",{type:"text",value:t,name:e,onChange:o=>s(o.target.value),className:(0,d.default)({"block w-full":a=="vert"},"rounded-lg border border-gray-300 bg-gray-50 p-1.5 text-sm focus:border-blue-500 focus:ring-blue-500")})),S=E;var C=b(m());var M=({name:e,selectedValue:r,searchTerm:t,onSearch:s,placeholder:a})=>{let o=g(l=>{s(l.toLowerCase())},300),[n,i]=React.useState(t??"");return React.useEffect(()=>{r&&i(r)},[r]),React.createElement(React.Fragment,null,React.createElement("div",{className:"relative"},React.createElement("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3"},React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",strokeWidth:1.5,stroke:"currentColor",className:(0,C.default)("h-5 w-5",{"bg-green-200":r,"text-green-800":r,"border-green-800":r,"rounded-lg":r})},r?React.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12c0 1.268-.63 2.39-1.593 3.068a3.745 3.745 0 01-1.043 3.296 3.745 3.745 0 01-3.296 1.043A3.745 3.745 0 0112 21c-1.268 0-2.39-.63-3.068-1.593a3.746 3.746 0 01-3.296-1.043 3.745 3.745 0 01-1.043-3.296A3.745 3.745 0 013 12c0-1.268.63-2.39 1.593-3.068a3.745 3.745 0 011.043-3.296 3.746 3.746 0 013.296-1.043A3.746 3.746 0 0112 3c1.268 0 2.39.63 3.068 1.593a3.746 3.746 0 013.296 1.043 3.746 3.746 0 011.043 3.296A3.745 3.745 0 0121 12z"}):React.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"}))),React.createElement("input",{type:"text",value:n,name:e,autoComplete:"off",placeholder:a,onInput:l=>{i(l.target.value),o(l.target.value)},className:"block w-full rounded-lg border border-gray-300 bg-gray-50 p-2 pl-9 text-sm focus:border-blue-500 focus:ring-blue-500"})))},G=({resultItems:e,itemRenderer:r,onSelect:t,resultItemsKeyField:s})=>React.createElement("div",{className:"max-h-36 overflow-auto rounded-b-lg border-b border-l border-r border-gray-300"},React.createElement("div",{className:"w-max min-w-full"},e.map(a=>React.createElement("div",{key:a[s],onClick:()=>t(a),className:"border-b-solid last:border-b-none cursor-pointer border-b border-b-gray-300 bg-gray-50 px-2 py-0.5 hover:bg-blue-600 hover:text-white"},r(a))))),q=({name:e,label:r,searchTerm:t,onSearch:s,resultItems:a,resultItemsKeyField:o,itemRenderer:n,className:i,onSelect:l,selectedValue:w,placeholder:k})=>React.createElement("div",{className:i},React.createElement("label",{htmlFor:e,className:"mb-1 block text-sm font-medium"},r),React.createElement(M,{name:e,onSearch:s,searchTerm:t,selectedValue:w,placeholder:k}),(a&&a.length)>0&&React.createElement(G,{resultItems:a,itemRenderer:n,onSelect:l,resultItemsKeyField:o})),A=q;var u=b(m()),J=({name:e,label:r,options:t,selectedOption:s,onChange:a,className:o="",orientation:n="vert"})=>React.createElement("div",{className:(0,u.default)({"flex flex-row items-baseline":n=="horiz"},o)},React.createElement("label",{htmlFor:e,className:(0,u.default)({block:n=="vert","pr-1 uppercase":n=="horiz"},"mb-1 text-sm font-medium")},r),React.createElement("select",{id:e,value:s||void 0,onChange:i=>a(i.target.value),className:(0,u.default)({"block w-full":n=="vert"}," bg-caret-down appearance-none rounded-lg border border-gray-300 bg-gray-50 bg-[length:10px] bg-[center_right_10px] bg-no-repeat p-2 pr-5 text-sm focus:border-blue-500 focus:ring-blue-500")},t.map(i=>React.createElement("option",{key:i.value,value:i.value},i.label)))),p=J;var U=({gvk:e})=>React.createElement(React.Fragment,null,React.createElement("div",{className:"text-xs text-gray-400"},e.api_version),React.createElement("div",{className:"text-sm"},e.kind)),T=U;var V=({initialAttrs:e,ctx:r})=>{let[t,s]=y(r,e),a=t.result_types[t.request_type];return React.createElement(React.Fragment,null,!t.connection&&React.createElement(x,null),React.createElement("div",{className:"rounded-md border border-solid border-gray-300 font-inter font-medium text-gray-600"},React.createElement("div",{className:"border-b-solid flex gap-x-5 gap-y-3 border-b border-b-gray-300 bg-blue-100 p-3"},React.createElement(p,{name:"connection",label:"Connection",options:t.connections.map(o=>({label:o.variable,value:o.variable})),selectedOption:t.connection?.variable?.toString(),onChange:s("connection"),orientation:"horiz"}),React.createElement(p,{name:"request_type",label:"Request Type",options:t.request_types.map(o=>({label:o.toUpperCase(),value:o})),selectedOption:t.request_type,onChange:s("request_type"),orientation:"horiz"}),a&&React.createElement(p,{name:"result_type",label:"Result Type",options:a.map(o=>({label:o.toUpperCase(),value:o})),selectedOption:t.result_type,onChange:s("result_type"),orientation:"horiz"}),React.createElement(S,{label:"Assign To",name:"assign_to",defaultValue:t.result_variable,onChange:s("result_variable"),orientation:"horiz"})),React.createElement("div",{className:"flex gap-x-5 p-3"},t.connection&&React.createElement(A,{className:"max-w-full",name:"gvk",label:"Resource Kind",onSearch:s("search_term"),searchTerm:t.search_term,resultItemsKeyField:"index",resultItems:t.search_result_items,onSelect:s("gvk"),itemRenderer:o=>React.createElement(T,{gvk:o}),selectedValue:t.gvk?.kind,placeholder:"apps/v1 Deployment"}),t.namespaces&&React.createElement(p,{name:"namespace",label:"Namespace",options:t.namespaces.map(o=>({label:o,value:o})),selectedOption:t.namespace,onChange:s("namespace")}),t.resources&&React.createElement(p,{name:"resource",label:"Resource Name",options:t.resources.map(o=>({label:o,value:o})),selectedOption:t.resource,onChange:s("resource")}))))},N=V;var de=async(e,r)=>{await h(e,r),e.root.innerHTML="loading...",e.importCSS("main.css"),e.importCSS("https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap");let t=ReactDOM.createRoot(e.root);if(r.error)return t.render(React.createElement(v,{message:r.error}));t.render(React.createElement(N,{initialAttrs:r,ctx:e}))};export{de as init}; /*! Bundled license information: classnames/index.js: diff --git a/lib/assets/kino_terminal/main.js b/lib/assets/kino_terminal/main.js index c43e0bc..00ca4f9 100644 --- a/lib/assets/kino_terminal/main.js +++ b/lib/assets/kino_terminal/main.js @@ -1,26 +1,5 @@ -// assets/kino_terminal/main.ts -async function init(ctx, attrs) { - await ctx.importCSS("https://cdn.jsdelivr.net/npm/xterm@5.0.0/css/xterm.css"); - await ctx.importJS( - "https://cdn.jsdelivr.net/npm/xterm@5.0.0/lib/xterm.min.js" - ); - ctx.root.innerHTML = ` +async function o(e,i){await e.importCSS("https://cdn.jsdelivr.net/npm/xterm@5.0.0/css/xterm.css"),await e.importJS("https://cdn.jsdelivr.net/npm/xterm@5.0.0/lib/xterm.min.js"),e.root.innerHTML=`
- `; - const rootContainer = ctx.root.querySelector( - ".k8s-xtermjs-container" - ); - if (rootContainer) { - const k8s_xterm = new Terminal({ convertEol: true }); - k8s_xterm.onKey((key) => ctx.pushEvent("key", key.key)); - k8s_xterm.open(rootContainer); - ctx.handleEvent("print-terminal", (data) => k8s_xterm.write(data)); - ctx.handleEvent("dispose-terminal", () => k8s_xterm.dispose()); - k8s_xterm.write(attrs.buffer); - } -} -export { - init -}; + `;let r=e.root.querySelector(".k8s-xtermjs-container");if(r){let t=new Terminal({convertEol:!0});t.onKey(n=>e.pushEvent("key",n.key)),t.open(r),e.handleEvent("print-terminal",n=>t.write(n)),e.handleEvent("dispose-terminal",()=>t.dispose()),t.write(i.buffer)}}export{o as init}; diff --git a/lib/assets/terminal_cell/main.js b/lib/assets/terminal_cell/main.js index 8898f3e..09021b1 100644 --- a/lib/assets/terminal_cell/main.js +++ b/lib/assets/terminal_cell/main.js @@ -1,281 +1,4 @@ -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __commonJS = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod -)); - -// node_modules/classnames/index.js -var require_classnames = __commonJS({ - "node_modules/classnames/index.js"(exports, module) { - (function() { - "use strict"; - var hasOwn = {}.hasOwnProperty; - var nativeCodeString = "[native code]"; - function classNames2() { - var classes = []; - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) - continue; - var argType = typeof arg; - if (argType === "string" || argType === "number") { - classes.push(arg); - } else if (Array.isArray(arg)) { - if (arg.length) { - var inner = classNames2.apply(null, arg); - if (inner) { - classes.push(inner); - } - } - } else if (argType === "object") { - if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) { - classes.push(arg.toString()); - continue; - } - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); - } - } - } - } - return classes.join(" "); - } - if (typeof module !== "undefined" && module.exports) { - classNames2.default = classNames2; - module.exports = classNames2; - } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) { - define("classnames", [], function() { - return classNames2; - }); - } else { - window.classNames = classNames2; - } - })(); - } -}); - -// assets/shared/error.tsx -var Error2 = ({ message }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "flex rounded-md border border-dashed border-red-700 bg-red-100 p-2" }, /* @__PURE__ */ React.createElement( - "svg", - { - className: "h-6 w-6 flex-none text-red-700", - fill: "none", - viewBox: "0 0 24 24", - "stroke-width": "1.5", - stroke: "currentColor", - "aria-hidden": "true" - }, - /* @__PURE__ */ React.createElement( - "path", - { - "stroke-linecap": "round", - "stroke-linejoin": "round", - d: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" - } - ) -), /* @__PURE__ */ React.createElement("div", { className: "font-inter px-2 text-sm font-medium text-red-700" }, message))); -var error_default = Error2; - -// assets/shared/utils.ts -var loadReact = async (ctx, attrs) => { - if (attrs.mix_env == "dev") { - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js" - ); - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js" - ); - } else { - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.js" - ); - await ctx.importJS( - "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js" - ); - } -}; - -// assets/shared/attr_state.tsx -var useAttrsState = (ctx, initialAttrs) => { - const [attrs, setAttrs] = React.useState(initialAttrs); - const updateAttr = (attrName) => (attrValue) => { - setAttrs((attrs2) => ({ ...attrs2, [attrName]: attrValue })); - console.log("Pushing ${attrName} to server", attrValue); - ctx.pushEvent(`update_${attrName}`, attrValue); - }; - React.useEffect(() => { - ctx.handleEvent("update", (updates) => { - console.log("Attribute update from server", updates); - setAttrs((attrs2) => ({ - ...Object.assign(attrs2, updates) - })); - }); - }, []); - return [attrs, updateAttr]; -}; -var attr_state_default = useAttrsState; - -// assets/shared/conn_notice.tsx -var ConnNotice = () => /* @__PURE__ */ React.createElement("div", { className: "mb-5 rounded-md bg-gray-100 p-4 font-inter text-sm font-medium text-gray-500" }, /* @__PURE__ */ React.createElement("p", null, "To make requests to the Kubernetes cluster, you need at least one connection to a cluster."), /* @__PURE__ */ React.createElement("p", { className: "pt-1" }, "To create a cluster connection, you can add the", " ", /* @__PURE__ */ React.createElement("span", { className: "text-gray-600" }, "Cluster Connection"), " smart cell.")); -var conn_notice_default = ConnNotice; - -// assets/shared/form/select.tsx -var import_classnames = __toESM(require_classnames()); -var Select = ({ - name, - label, - options, - selectedOption, - onChange, - className = "", - orientation = "vert" -}) => /* @__PURE__ */ React.createElement( - "div", - { - className: (0, import_classnames.default)( - { - "flex flex-row items-baseline": orientation == "horiz" - }, - className - ) - }, - /* @__PURE__ */ React.createElement( - "label", - { - htmlFor: name, - className: (0, import_classnames.default)( - { - block: orientation == "vert", - "pr-1 uppercase": orientation == "horiz" - }, - "mb-1 text-sm font-medium" - ) - }, - label - ), - /* @__PURE__ */ React.createElement( - "select", - { - id: name, - value: selectedOption || void 0, - onChange: (e) => onChange(e.target.value), - className: (0, import_classnames.default)( - { "block w-full": orientation == "vert" }, - " bg-caret-down appearance-none rounded-lg border border-gray-300 bg-gray-50 bg-[length:10px] bg-[center_right_10px] bg-no-repeat p-2 pr-5 text-sm focus:border-blue-500 focus:ring-blue-500" - ) - }, - options.map((option) => /* @__PURE__ */ React.createElement("option", { key: option.value, value: option.value }, option.label)) - ) -); -var select_default = Select; - -// assets/terminal_cell/app.tsx -var App = ({ initialAttrs, ctx }) => { - const [attrs, updateAttr] = attr_state_default(ctx, initialAttrs); - return /* @__PURE__ */ React.createElement(React.Fragment, null, !attrs.connection && /* @__PURE__ */ React.createElement(conn_notice_default, null), /* @__PURE__ */ React.createElement("div", { className: "rounded-md border border-solid border-gray-300 font-inter font-medium text-gray-600" }, /* @__PURE__ */ React.createElement("div", { className: "border-b-solid flex gap-x-5 gap-y-3 border-b border-b-gray-300 bg-blue-100 p-3" }, /* @__PURE__ */ React.createElement( - select_default, - { - name: "connection", - label: "Connection", - options: attrs.connections.map((connection) => ({ - label: connection.variable, - value: connection.variable - })), - selectedOption: attrs.connection?.variable?.toString(), - onChange: updateAttr("connection"), - orientation: "horiz" - } - ), /* @__PURE__ */ React.createElement( - select_default, - { - name: "connect_to", - label: "connect_to", - options: attrs.connect_tos.map((connect_to) => ({ - label: connect_to, - value: connect_to - })), - selectedOption: attrs.connect_to?.toString(), - onChange: updateAttr("connect_to"), - orientation: "horiz" - } - )), /* @__PURE__ */ React.createElement("div", { className: "flex gap-x-5 p-3" }, attrs["namespaces"] && /* @__PURE__ */ React.createElement( - select_default, - { - name: "namespace", - label: "Namespace", - options: attrs.namespaces.map((ns) => ({ - label: ns, - value: ns - })), - selectedOption: attrs["namespace"], - onChange: updateAttr("namespace") - } - ), attrs.pods && /* @__PURE__ */ React.createElement( - select_default, - { - name: "pod", - label: "Pod Name", - options: attrs.pods.map((ns) => ({ - label: ns, - value: ns - })), - selectedOption: attrs["pod"], - onChange: updateAttr("pod") - } - ), attrs.containers && /* @__PURE__ */ React.createElement( - select_default, - { - name: "container", - label: "Container Name", - options: attrs.containers.map((ns) => ({ - label: ns, - value: ns - })), - selectedOption: attrs["container"], - onChange: updateAttr("container") - } - )))); -}; -var app_default = App; - -// assets/terminal_cell/main.tsx -var init = async (ctx, attrs) => { - await loadReact(ctx, attrs); - ctx.root.innerHTML = "loading..."; - ctx.importCSS("main.css"); - ctx.importCSS( - "https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" - ); - const root = ReactDOM.createRoot(ctx.root); - if (attrs.error) { - return root.render(/* @__PURE__ */ React.createElement(error_default, { message: attrs.error })); - } - root.render(/* @__PURE__ */ React.createElement(app_default, { initialAttrs: attrs, ctx })); -}; -export { - init -}; +var x=Object.create;var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var S=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var N=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of A(r))!T.call(e,o)&&o!==t&&m(e,o,{get:()=>r[o],enumerable:!(a=y(r,o))||a.enumerable});return e};var j=(e,r,t)=>(t=e!=null?x(C(e)):{},N(r||!e||!e.__esModule?m(t,"default",{value:e,enumerable:!0}):t,e));var g=S((J,p)=>{(function(){"use strict";var e={}.hasOwnProperty,r="[native code]";function t(){for(var a=[],o=0;oReact.createElement(React.Fragment,null,React.createElement("div",{className:"flex rounded-md border border-dashed border-red-700 bg-red-100 p-2"},React.createElement("svg",{className:"h-6 w-6 flex-none text-red-700",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},React.createElement("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})),React.createElement("div",{className:"font-inter px-2 text-sm font-medium text-red-700"},e))),u=w;var f=async(e,r)=>{r.mix_env=="dev"?(await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js"),await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js")):(await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.js"),await e.importJS("https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"))};var P=(e,r)=>{let[t,a]=React.useState(r),o=n=>s=>{a(i=>({...i,[n]:s})),console.log("Pushing ${attrName} to server",s),e.pushEvent(`update_${n}`,s)};return React.useEffect(()=>{e.handleEvent("update",n=>{console.log("Attribute update from server",n),a(s=>({...Object.assign(s,n)}))})},[]),[t,o]},b=P;var O=()=>React.createElement("div",{className:"mb-5 rounded-md bg-gray-100 p-4 font-inter text-sm font-medium text-gray-500"},React.createElement("p",null,"To make requests to the Kubernetes cluster, you need at least one connection to a cluster."),React.createElement("p",{className:"pt-1"},"To create a cluster connection, you can add the"," ",React.createElement("span",{className:"text-gray-600"},"Cluster Connection")," smart cell.")),v=O;var c=j(g()),K=({name:e,label:r,options:t,selectedOption:a,onChange:o,className:n="",orientation:s="vert"})=>React.createElement("div",{className:(0,c.default)({"flex flex-row items-baseline":s=="horiz"},n)},React.createElement("label",{htmlFor:e,className:(0,c.default)({block:s=="vert","pr-1 uppercase":s=="horiz"},"mb-1 text-sm font-medium")},r),React.createElement("select",{id:e,value:a||void 0,onChange:i=>o(i.target.value),className:(0,c.default)({"block w-full":s=="vert"}," bg-caret-down appearance-none rounded-lg border border-gray-300 bg-gray-50 bg-[length:10px] bg-[center_right_10px] bg-no-repeat p-2 pr-5 text-sm focus:border-blue-500 focus:ring-blue-500")},t.map(i=>React.createElement("option",{key:i.value,value:i.value},i.label)))),l=K;var _=({initialAttrs:e,ctx:r})=>{let[t,a]=b(r,e);return React.createElement(React.Fragment,null,!t.connection&&React.createElement(v,null),React.createElement("div",{className:"rounded-md border border-solid border-gray-300 font-inter font-medium text-gray-600"},React.createElement("div",{className:"border-b-solid flex gap-x-5 gap-y-3 border-b border-b-gray-300 bg-blue-100 p-3"},React.createElement(l,{name:"connection",label:"Connection",options:t.connections.map(o=>({label:o.variable,value:o.variable})),selectedOption:t.connection?.variable?.toString(),onChange:a("connection"),orientation:"horiz"}),React.createElement(l,{name:"connect_to",label:"connect_to",options:t.connect_tos.map(o=>({label:o,value:o})),selectedOption:t.connect_to?.toString(),onChange:a("connect_to"),orientation:"horiz"})),React.createElement("div",{className:"flex gap-x-5 p-3"},t.namespaces&&React.createElement(l,{name:"namespace",label:"Namespace",options:t.namespaces.map(o=>({label:o,value:o})),selectedOption:t.namespace,onChange:a("namespace")}),t.pods&&React.createElement(l,{name:"pod",label:"Pod Name",options:t.pods.map(o=>({label:o,value:o})),selectedOption:t.pod,onChange:a("pod")}),t.containers&&React.createElement(l,{name:"container",label:"Container Name",options:t.containers.map(o=>({label:o,value:o})),selectedOption:t.container,onChange:a("container")}))))},h=_;var I=async(e,r)=>{await f(e,r),e.root.innerHTML="loading...",e.importCSS("main.css"),e.importCSS("https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap");let t=ReactDOM.createRoot(e.root);if(r.error)return t.render(React.createElement(u,{message:r.error}));t.render(React.createElement(h,{initialAttrs:r,ctx:e}))};export{I as init}; /*! Bundled license information: classnames/index.js: diff --git a/package.json b/package.json index 78c8467..5101411 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "tailwind:build:get_cell": "tailwindcss --content './assets/{get_cell,shared}/**/*.{ts,tsx}' -i assets/get_cell/main.css -o ./lib/assets/get_cell/main.css", "tailwind:build:terminal_cell": "tailwindcss --content './assets/{terminal_cell,shared}/**/*.{ts,tsx}' -i assets/terminal_cell/main.css -o ./lib/assets/terminal_cell/main.css", "tailwind": "npm-run-all --parallel tailwind:build:*", - "es:build": "esbuild assets/*/main.ts* --external:react --external:react-dom/client --external:xterm --entry-names=[dir]/[name] --outbase=assets --outdir=lib/assets --target=es2020 --format=esm --bundle", + "es:build": "esbuild assets/*/main.ts* --minify --external:react --external:react-dom/client --external:xterm --entry-names=[dir]/[name] --outbase=assets --outdir=lib/assets --target=es2020 --format=esm --bundle", "es:watch": "npm run es:build -- --sourcemap=inline --watch", "start": "npm-run-all --parallel 'tailwind:build:* -- --watch' es:watch", "build": "npm run clean && npm-run-all --parallel tailwind es:build",