harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
1 lines • 10 kB
JavaScript
;(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[972],{1271:(e,t,r)=>{r.r(t),r.d(t,{default:()=>x});var n=r(9950),a=r(4084),o=r(8156),i=r(6713),s=r(7176),c=r(6114),l=r(5488),u=r(3452),f=r(625),d=r(7348),p=r(127),m=r(5269);var h=r(5900),b=r(4414);const g=function(e){let{items:t,itemType:r,activeSchema:a,toggleDropItem:o,toggleCreate:g,baseUrl:y}=e;const v=(0,f.Zp)(),x=(0,d.MW)(),j=(0,i.O$)(m.A,(e=>e.auth)),A=(0,i.O$)(m.A,(e=>e.url)),[w,N]=(0,n.useState)(!1),[O,k]=(0,n.useState)(!1),[$,S]=(0,n.useState)(!1),[C,D]=(0,n.useState)(!1),[I,R]=(0,n.useState)(!1),_=async e=>{e.preventDefault();let n=!1;if(w&&!t.includes(w)||(k(!0),n=!0),w&&!w.match(/^\w+$/)&&(k(!0),n=!0,x.error("You may only use alphanumeric characters or underscores.")),w&&w.match(/^\d+$/)&&(k(!0),n=!0,x.error("You may not provide a number as a name.")),"table"!==r||$||(n=!0,D(!0)),n)return!1;R(!0);const o={operation:`create_${r}`};"table"===r?(o.schema=a,o.table=w,o.hash_attribute=$):o.schema=w;const i=await(0,p.A)({operation:o,auth:j,url:A});return i.error?(R(!1),g(!1),x.error(i.message)):(0,h.A)({auth:j,url:A})};return(0,n.useEffect)((()=>{o()}),[o]),(0,n.useEffect)((()=>{w&&t.find((e=>e===w))&&v(`${y}/${w}`)}),[t]),(0,b.jsxs)(s.A,{className:"item-row form",children:[(0,b.jsx)(c.A,{className:"input-holder",children:(0,b.jsx)(l.A,{id:"name",invalid:O,onChange:e=>{k(!1),N(e.target.value)},value:w||"",disabled:I,type:"text",name:"name",placeholder:"name"})}),"table"===r&&(0,b.jsx)(c.A,{className:"input-holder",children:(0,b.jsx)(l.A,{id:"hash_attribute",invalid:C,disabled:I,onChange:e=>{D(!1),S(e.target.value)},value:$||"",type:"test",name:"hash_attribute",placeholder:"hash attr."})}),(0,b.jsx)(c.A,{className:"item-action",children:I?(0,b.jsx)(u.A,{id:"creatingItem",color:"success",className:"round",children:(0,b.jsx)("i",{className:"fa fa-spinner fa-spin text-white"})}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(u.A,{id:"createItem",color:"success",className:"round me-1",onClick:_,onKeyDown:e=>13!==e.keyCode||_(e),children:(0,b.jsx)("i",{className:"fa fa-check text-white"})}),(0,b.jsx)(u.A,{id:"toggleCreate",color:"black",className:"round",onClick:()=>g(!1),children:(0,b.jsx)("i",{className:"fa fa-times text-white"})})]})})]})};const y=function(e){let{item:t,itemType:r,baseUrl:a,isActive:o,toggleDropItem:l,isDropping:g,activeSchema:y}=e;const v=(0,f.Zp)(),x=(0,d.MW)(),[j,A]=(0,n.useState)(!1),[w,N]=(0,n.useState)(!1),O=(0,i.O$)(m.A,(e=>e.auth)),k=(0,i.O$)(m.A,(e=>e.url));return(0,b.jsxs)(s.A,{title:`View${o?"ing":""} ${r} ${t}`,className:"item-row "+(o?"active":""),onClick:()=>{!(o||g||j)&&v(`${a}/${t}`),(0,h.A)({auth:O,url:k})},tabIndex:"0",children:[(0,b.jsx)(c.A,{className:"item-label "+(j?"text-danger text-nowrap":""),children:j?`drop ${t}?`:t}),(0,b.jsx)(c.A,{className:"item-action",children:w?(0,b.jsx)(u.A,{tabIndex:"-1",disabled:!0,color:"purple",className:"round",children:(0,b.jsx)("i",{className:"fa fa-spinner fa-spin"})}):j?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(u.A,{id:"confirmDropItem",color:"danger",className:"round me-1",title:`confirm drop ${r} ${t}`,onClick:()=>{A(!1),N(!0),(async()=>{if(!r||!j)return!1;const e={operation:`drop_${r}`};"table"===r?(e.schema=y,e.table=t):e.schema=t;const n=await(0,p.A)({operation:e,auth:O,url:k});n.error?(A(!1),N(!1),x.error(n.message)):(await(0,h.A)({auth:O,url:k}),v(a))})()},children:(0,b.jsx)("i",{className:"text-white fa fa-check"})}),(0,b.jsx)(u.A,{id:"cancelDropItem",color:"black",className:"round",title:`Cancel drop ${r} ${t}`,onClick:()=>{A(!1)},children:(0,b.jsx)("i",{className:"text-white fa fa-times"})})]}):g?(0,b.jsx)(u.A,{id:"dropItem",color:"danger",className:"round",title:`Drop ${r} ${t}`,onClick:()=>{A(t),l(!1)},children:(0,b.jsx)("i",{className:"text-white fa fa-minus"})}):o?(0,b.jsx)(u.A,{tabIndex:"-1",color:"purple",className:"round",children:(0,b.jsx)("i",{className:"fa fa-chevron-right"})}):null})]},t)};const v=function(e){let{items:t,itemType:r,toggleDropItem:n,isDropping:a,toggleCreate:o,isCreating:i,showForm:l}=e;return(0,b.jsxs)(s.A,{className:"floating-card-header",children:[(0,b.jsxs)(c.A,{children:[r,"s"]}),l&&null!==t&&void 0!==t&&t.length?(0,b.jsxs)(c.A,{className:"text-end",children:[(0,b.jsx)(u.A,{id:"toggleRemove",color:"link",title:`Remove ${r}s`,className:"add-remove me-3",onClick:()=>{n(!a),o(!1)},children:(0,b.jsx)("i",{className:"fa fa-minus"})}),(0,b.jsx)(u.A,{id:"toggleCreate",color:"link",title:`Add ${r}`,className:"add-remove me-1",onClick:()=>{o(!i),n(!1)},children:(0,b.jsx)("i",{className:"fa fa-plus"})})]}):null]})};const x=function(e){var t;let{items:r,activeItem:s,activeSchema:c=!1,showForm:l,baseUrl:u,itemType:f}=e;const[d,p]=(0,n.useState)(!1),[h,x]=(0,n.useState)(!1),j=(0,i.O$)(m.A,(e=>e.registration)),[A,w]=(null===j||void 0===j||null===(t=j.version)||void 0===t?void 0:t.split("."))||[],N=parseFloat(`${A}.${w}`);return(0,n.useEffect)((()=>{x(),p()}),[s,c,r]),(0,b.jsxs)("div",{className:"entity-manager",children:[(0,b.jsx)(v,{items:r,itemType:f,isDropping:d,toggleDropItem:p,isCreating:h,toggleCreate:x,showForm:l}),(0,b.jsxs)(a.A,{className:"my-3",children:[r&&r.length?(0,b.jsx)(o.A,{className:"scrollable "+(h?"creating":""),children:r.map((e=>(0,b.jsx)(y,{item:e,itemType:f,baseUrl:u,isActive:s===e,isDropping:d,toggleDropItem:p,activeSchema:c},e)))}):null,l&&(r&&!r.length||h)?(0,b.jsx)(o.A,{children:(0,b.jsx)(g,{items:r,itemType:f,baseUrl:u,activeSchema:c,isDropping:d,toggleDropItem:p,isCreating:h,toggleCreate:x})}):!r||r.length||l?null:(0,b.jsx)(o.A,{children:(0,b.jsxs)("div",{className:"py-3 text-center no-content",children:["no visible ",N>=4.2?"databases":"schemas"," or tables"]})})]})]})}},5488:(e,t,r)=>{r.d(t,{A:()=>x});var n=r(9950),a=r(1942),o=r.n(a),i=r(8738),s=r.n(i),c=r(1497);function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}var u=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f.apply(this,arguments)}function d(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function h(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=g(e);if(t){var a=g(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===l(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return b(e)}(this,r)}}function b(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}var y={children:o().node,type:o().string,size:o().oneOfType([o().number,o().string]),bsSize:o().string,valid:o().bool,invalid:o().bool,tag:c.Wx,innerRef:o().oneOfType([o().object,o().func,o().string]),plaintext:o().bool,addon:o().bool,className:o().string,cssModule:o().object},v=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}(i,e);var t,r,a,o=h(i);function i(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),(t=o.call(this,e)).getRef=t.getRef.bind(b(t)),t.focus=t.focus.bind(b(t)),t}return t=i,(r=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var e=this.props,t=e.className,r=e.cssModule,a=e.type,o=void 0===a?"text":a,i=e.bsSize,l=e.valid,p=e.invalid,m=e.tag,h=e.addon,b=e.plaintext,g=e.innerRef,y=d(e,u),v=["switch","radio","checkbox"].indexOf(o)>-1,x="select"===o,j="range"===o,A=m||(x||"textarea"===o?o:"input"),w="form-control";b?(w="".concat(w,"-plaintext"),A=m||"input"):j?w="form-range":x?w="form-select":v&&(w=h?null:"form-check-input"),y.size&&/\D/g.test(y.size)&&((0,c.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),i=y.size,delete y.size);var N=(0,c.qO)(s()(t,p&&"is-invalid",l&&"is-valid",!!i&&(x?"form-select-".concat(i):"form-control-".concat(i)),w),r);return("input"===A||m&&"function"===typeof m)&&(y.type="switch"===o?"checkbox":o),y.children&&!b&&"select"!==o&&"string"===typeof A&&"select"!==A&&((0,c.mc)('Input with a type of "'.concat(o,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete y.children),n.createElement(A,f({},y,{ref:g,className:N,"aria-invalid":p}))}}])&&p(t.prototype,r),a&&p(t,a),Object.defineProperty(t,"prototype",{writable:!1}),i}(n.Component);v.propTypes=y;const x=v}}]);