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.2 kB
JavaScript
;(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[972],{1271:(e,t,n)=>{n.r(t),n.d(t,{default:()=>x});var r=n(9950),a=n(4084),o=n(8156),c=n(6713),i=n(7176),s=n(6114),l=n(5488),u=n(3452),f=n(5077),d=n(7348),p=n(127),m=n(5269);var h=n(5900),b=n(4414);const g=function(e){let{items:t,itemType:n,activeSchema:a,toggleDropItem:o,toggleCreate:g,baseUrl:y}=e;const v=(0,f.Zp)(),x=(0,d.MW)(),j=(0,c.O$)(m.A,(e=>e.auth)),A=(0,c.O$)(m.A,(e=>e.url)),[w,N]=(0,r.useState)(!1),[O,k]=(0,r.useState)(!1),[S,C]=(0,r.useState)(!1),[D,I]=(0,r.useState)(!1),[R,_]=(0,r.useState)(!1),P=async e=>{e.preventDefault();let r=!1;if(w&&!t.includes(w)||(k(!0),r=!0),w&&!w.match(/^\w+$/)&&(k(!0),r=!0,x.error("You may only use alphanumeric characters or underscores.")),w&&w.match(/^\d+$/)&&(k(!0),r=!0,x.error("You may not provide a number as a name.")),"table"!==n||S||(r=!0,I(!0)),r)return!1;_(!0);const o={operation:"create_".concat(n)};"table"===n?(o.schema=a,o.table=w,o.hash_attribute=S):o.schema=w;const c=await(0,p.A)({operation:o,auth:j,url:A});return c.error?(_(!1),g(!1),x.error(c.message)):(0,h.A)({auth:j,url:A})};return(0,r.useEffect)((()=>{o()}),[o]),(0,r.useEffect)((()=>{w&&t.find((e=>e===w))&&v("".concat(y,"/").concat(w))}),[t]),(0,b.jsxs)(i.A,{className:"item-row form",children:[(0,b.jsx)(s.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:R,type:"text",name:"name",placeholder:"name"})}),"table"===n&&(0,b.jsx)(s.A,{className:"input-holder",children:(0,b.jsx)(l.A,{id:"hash_attribute",invalid:D,disabled:R,onChange:e=>{I(!1),C(e.target.value)},value:S||"",type:"test",name:"hash_attribute",placeholder:"hash attr."})}),(0,b.jsx)(s.A,{className:"item-action",children:R?(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:P,onKeyDown:e=>13!==e.keyCode||P(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:n,baseUrl:a,isActive:o,toggleDropItem:l,isDropping:g,activeSchema:y}=e;const v=(0,f.Zp)(),x=(0,d.MW)(),[j,A]=(0,r.useState)(!1),[w,N]=(0,r.useState)(!1),O=(0,c.O$)(m.A,(e=>e.auth)),k=(0,c.O$)(m.A,(e=>e.url));return(0,b.jsxs)(i.A,{title:"View".concat(o?"ing":""," ").concat(n," ").concat(t),className:"item-row ".concat(o?"active":""),onClick:()=>{!(o||g||j)&&v("".concat(a,"/").concat(t)),(0,h.A)({auth:O,url:k})},tabIndex:"0",children:[(0,b.jsx)(s.A,{className:"item-label ".concat(j?"text-danger text-nowrap":""),children:j?"drop ".concat(t,"?"):t}),(0,b.jsx)(s.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 ".concat(n," ").concat(t),onClick:()=>{A(!1),N(!0),(async()=>{if(!n||!j)return!1;const e={operation:"drop_".concat(n)};"table"===n?(e.schema=y,e.table=t):e.schema=t;const r=await(0,p.A)({operation:e,auth:O,url:k});r.error?(A(!1),N(!1),x.error(r.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 ".concat(n," ").concat(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 ".concat(n," ").concat(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:n,toggleDropItem:r,isDropping:a,toggleCreate:o,isCreating:c,showForm:l}=e;return(0,b.jsxs)(i.A,{className:"floating-card-header",children:[(0,b.jsxs)(s.A,{children:[n,"s"]}),l&&null!==t&&void 0!==t&&t.length?(0,b.jsxs)(s.A,{className:"text-end",children:[(0,b.jsx)(u.A,{id:"toggleRemove",color:"link",title:"Remove ".concat(n,"s"),className:"add-remove me-3",onClick:()=>{r(!a),o(!1)},children:(0,b.jsx)("i",{className:"fa fa-minus"})}),(0,b.jsx)(u.A,{id:"toggleCreate",color:"link",title:"Add ".concat(n),className:"add-remove me-1",onClick:()=>{o(!c),r(!1)},children:(0,b.jsx)("i",{className:"fa fa-plus"})})]}):null]})};const x=function(e){var t;let{items:n,activeItem:i,activeSchema:s=!1,showForm:l,baseUrl:u,itemType:f}=e;const[d,p]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),j=(0,c.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("".concat(A,".").concat(w));return(0,r.useEffect)((()=>{x(),p()}),[i,s,n]),(0,b.jsxs)("div",{className:"entity-manager",children:[(0,b.jsx)(v,{items:n,itemType:f,isDropping:d,toggleDropItem:p,isCreating:h,toggleCreate:x,showForm:l}),(0,b.jsxs)(a.A,{className:"my-3",children:[n&&n.length?(0,b.jsx)(o.A,{className:"scrollable ".concat(h?"creating":""),children:n.map((e=>(0,b.jsx)(y,{item:e,itemType:f,baseUrl:u,isActive:i===e,isDropping:d,toggleDropItem:p,activeSchema:s},e)))}):null,l&&(n&&!n.length||h)?(0,b.jsx)(o.A,{children:(0,b.jsx)(g,{items:n,itemType:f,baseUrl:u,activeSchema:s,isDropping:d,toggleDropItem:p,isCreating:h,toggleCreate:x})}):!n||n.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,n)=>{n.d(t,{A:()=>x});var r=n(9950),a=n(1942),o=n.n(a),c=n(8738),i=n.n(c),s=n(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 n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f.apply(this,arguments)}function d(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}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 n,r=g(e);if(t){var a=g(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.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,n)}}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:s.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)}(c,e);var t,n,a,o=h(c);function c(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),(t=o.call(this,e)).getRef=t.getRef.bind(b(t)),t.focus=t.focus.bind(b(t)),t}return t=c,(n=[{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,n=e.cssModule,a=e.type,o=void 0===a?"text":a,c=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,s.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),c=y.size,delete y.size);var N=(0,s.qO)(i()(t,p&&"is-invalid",l&&"is-valid",!!c&&(x?"form-select-".concat(c):"form-control-".concat(c)),w),n);return("input"===A||m&&"function"===typeof m)&&(y.type="switch"===o?"checkbox":o),y.children&&!b&&"select"!==o&&"string"===typeof A&&"select"!==A&&((0,s.mc)('Input with a type of "'.concat(o,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete y.children),r.createElement(A,f({},y,{ref:g,className:N,"aria-invalid":p}))}}])&&p(t.prototype,n),a&&p(t,a),Object.defineProperty(t,"prototype",{writable:!1}),c}(r.Component);v.propTypes=y;const x=v}}]);