UNPKG

datajunction-ui

Version:
3 lines (2 loc) 21.2 kB
"use strict";var ve=Object.defineProperty;var ye=(s,t,r)=>t in s?ve(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var V=(s,t,r)=>ye(s,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),l=require("./index-h1A5IisM.cjs");;/* empty css */const R=require("./PreAggDetailsPanel-DbHqhxEA.cjs"),K=require("react-router-dom"),Ne=require("./FullNameField-Q0Vq2ewv.cjs");require("react-dom");function Se(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const r in s)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>s[r]})}}return t.default=s,Object.freeze(t)}const Ce=Se(i),L=class L{constructor(t){this.name=t}};V(L,"Add",new L("add")),V(L,"Edit",new L("edit"));let w=L;function Oe(){const[s,t]=i.useState([]),r=i.useContext(l.DJClientContext).DataJunctionAPI;let{initialNamespace:a}=K.useParams();return i.useEffect(()=>{(async()=>{const m=await r.namespaces();t(m.map(g=>({value:g.namespace,label:g.namespace})))})().catch(console.error)},[r,r.metrics]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"NamespaceInput",children:[e.jsx(l.ErrorMessage,{name:"namespace",component:"span"}),e.jsx("label",{htmlFor:"namespace",children:"Namespace *"}),e.jsx(l.FormikSelect,{selectOptions:s,formikFieldName:"namespace",placeholder:"Choose Namespace",defaultValue:{value:a,label:a}})]}),e.jsxs("div",{className:"DisplayNameInput NodeCreationInput",children:[e.jsx(l.ErrorMessage,{name:"display_name",component:"span"}),e.jsx("label",{htmlFor:"displayName",children:"Display Name *"}),e.jsx(l.Field,{type:"text",name:"display_name",id:"displayName",placeholder:"Human readable display name"})]}),e.jsxs("div",{className:"FullNameInput NodeCreationInput",children:[e.jsx(l.ErrorMessage,{name:"name",component:"span"}),e.jsx("label",{htmlFor:"FullName",children:"Full Name"}),e.jsx(Ne.FullNameField,{type:"text",name:"name"})]})]})}var _e=["defaultOptions","cacheOptions","loadOptions","options","isLoading","onInputChange","filterOption"];function De(s){var t=s.defaultOptions,r=t===void 0?!1:t,a=s.cacheOptions,o=a===void 0?!1:a,m=s.loadOptions;s.options;var g=s.isLoading,S=g===void 0?!1:g,y=s.onInputChange,p=s.filterOption,x=p===void 0?null:p,h=l._objectWithoutProperties(s,_e),n=h.inputValue,u=i.useRef(void 0),c=i.useRef(!1),d=i.useState(Array.isArray(r)?r:void 0),f=l._slicedToArray(d,2),b=f[0],C=f[1],M=i.useState(typeof n<"u"?n:""),N=l._slicedToArray(M,2),v=N[0],_=N[1],O=i.useState(r===!0),j=l._slicedToArray(O,2),T=j[0],E=j[1],J=i.useState(void 0),k=l._slicedToArray(J,2),A=k[0],P=k[1],F=i.useState([]),Q=l._slicedToArray(F,2),le=Q[0],z=Q[1],ce=i.useState(!1),U=l._slicedToArray(ce,2),oe=U[0],q=U[1],de=i.useState({}),X=l._slicedToArray(de,2),$=X[0],Y=X[1],ue=i.useState(void 0),Z=l._slicedToArray(ue,2),me=Z[0],pe=Z[1],fe=i.useState(void 0),G=l._slicedToArray(fe,2),he=G[0],xe=G[1];o!==he&&(Y({}),xe(o)),r!==me&&(C(Array.isArray(r)?r:void 0),pe(r)),i.useEffect(function(){return c.current=!0,function(){c.current=!1}},[]);var H=i.useCallback(function(I,B){if(!m)return B();var D=m(I,B);D&&typeof D.then=="function"&&D.then(B,function(){return B()})},[m]);i.useEffect(function(){r===!0&&H(v,function(I){c.current&&(C(I||[]),E(!!u.current))})},[]);var be=i.useCallback(function(I,B){var D=l.handleInputChange(I,B,y);if(!D){u.current=void 0,_(""),P(""),z([]),E(!1),q(!1);return}if(o&&$[D])_(D),P(D),z($[D]),E(!1),q(!1);else{var je=u.current={};_(D),E(!0),q(!A),H(D,function(W){c&&je===u.current&&(u.current=void 0,E(!1),P(D),z(W||[]),q(!1),Y(W?l._objectSpread2(l._objectSpread2({},$),{},l._defineProperty({},D,W)):$))})}},[o,H,A,$,y]),ge=oe?[]:v&&A?le:b||[];return l._objectSpread2(l._objectSpread2({},h),{},{options:ge,isLoading:T||S,onInputChange:be,filterOption:x})}var we=i.forwardRef(function(s,t){var r=De(s),a=l.useStateManager(r);return Ce.createElement(l.Select,l._extends({ref:t},a))}),Me=we;const Ee=(s,t)=>{let r;return(...a)=>(clearTimeout(r),new Promise(o=>{r=setTimeout(()=>o(s(...a)),t)}))},Pe=s=>s&&s.split(".").slice(0,-1).join(".")||"default",Te=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),Ae=s=>{const{data:t}=s,{namespace:r,gitInfo:a,count:o}=t;return e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",backgroundColor:"#fafafa",borderBottom:"1px solid #eee"},children:[e.jsx("span",{style:{fontWeight:500,color:"#333"},children:r}),(a==null?void 0:a.branch)&&e.jsxs("span",{title:`Branch: ${a.branch}`,style:{marginLeft:"8px",fontSize:"11px",padding:"2px 6px",borderRadius:"3px",backgroundColor:a.isDefaultBranch?"#d4edda":"#fff3cd",color:a.isDefaultBranch?"#155724":"#856404",display:"inline-flex",alignItems:"center",gap:"4px"},children:[e.jsx(Te,{}),a.branch]}),e.jsxs("span",{style:{marginLeft:"8px",color:"#999",fontSize:"12px"},children:["(",o,")"]})]})},Fe=s=>{const t={},r={};return s.forEach(a=>{const o=Pe(a.value);t[o]||(t[o]=[],r[o]=a.gitInfo),t[o].push(a)}),Object.keys(t).sort().map(a=>{const o=r[a],m=t[a].length;return{label:a,namespace:a,gitInfo:o,count:m,options:t[a]}})},Be=(s,{context:t})=>{if(t==="menu"){const m=s.label,g=s.value,S=m!==g;return e.jsxs("div",{children:[e.jsx("div",{children:m}),S&&e.jsx("div",{style:{fontSize:"12px",color:"#999",marginTop:"2px"},children:g})]})}const r=s.label||s.value,a=s.gitInfo,o=(a==null?void 0:a.branch)&&!(a!=null&&a.isDefaultBranch);return e.jsxs("span",{title:s.value,style:{display:"inline-flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:r}),o&&e.jsxs("span",{style:{fontSize:"9px",padding:"1px 4px",borderRadius:"2px",backgroundColor:"rgba(255, 255, 255, 0.6)",color:"#a2283e",border:"1px solid rgba(162, 40, 62, 0.2)",fontWeight:500,letterSpacing:"0.2px"},children:["⎇ ",a.branch]})]})},ee=i.memo(function({cube:t,onChange:r}){const a=i.useContext(l.DJClientContext).DataJunctionAPI,[o,m]=i.useState([]);i.useEffect(()=>{var p;if((p=t==null?void 0:t.current)!=null&&p.cubeMetrics){const x=t.current.cubeMetrics.map(n=>({value:n.name,label:n.displayName||n.name}));m(x),r(x.map(n=>n.value));const h=x.map(n=>n.value);a.getMetricsInfo(h).then(n=>{if(n.length>0){const u=Object.fromEntries(n.map(c=>[c.value,c]));m(c=>c.map(d=>u[d.value]?u[d.value]:d))}})}},[t,r,a]);const g=i.useCallback(Ee(async p=>{if(!p||p.length<2)return[];try{const x=await a.searchMetrics(p,50);return Fe(x)}catch(x){return console.error("Error searching metrics:",x),[]}},300),[a]),S=p=>{m(p||[]),r((p||[]).map(x=>x.value))},y={multiValue:p=>({...p,backgroundColor:"#fad7dd",border:"1px solid rgba(162, 40, 62, 0.3)",borderRadius:"3px",margin:"2px"}),multiValueLabel:p=>({...p,color:"#a2283e",fontSize:"10px",fontWeight:500,padding:"2px 4px 2px 6px"}),multiValueRemove:p=>({...p,color:"#a2283e",padding:"0 4px",":hover":{backgroundColor:"#f5c4cd",color:"#a2283e"}})};return e.jsx(Me,{value:o,loadOptions:g,onChange:S,name:"metrics",placeholder:"Type to search metrics...",noOptionsMessage:({inputValue:p})=>p.length<2?"Type at least 2 characters to search":"No metrics found",loadingMessage:()=>"Searching...",formatOptionLabel:Be,components:{GroupHeading:Ae},styles:y,isMulti:!0,isClearable:!0,closeMenuOnSelect:!1,cacheOptions:!0,defaultOptions:!1})}),Le=s=>!s||s.length===0?0:s.length,se=s=>{if(!s)return"";const t=s.replace(/^\[|\]$/g,"");return t?` [${t}]`:""},ke=s=>{if(!s)return[s,""];const t=s.match(/^(.+?)\[([^\]]+)\]$/);return t?[t[1],t[2]]:[s,""]},$e=s=>s===0?"Direct Dimensions":s===1?"1 Hop Away":`${s} Hops Away`,te=i.memo(function({cube:t,metrics:r,onChange:a}){const o=i.useContext(l.DJClientContext).DataJunctionAPI,[m,g]=i.useState({}),[S,y]=i.useState({}),[p,x]=i.useState([]);i.useEffect(()=>{(async()=>{let d;const f=(t==null?void 0:t.current)??t;if(f!=null&&f.cubeDimensions&&(d=f.cubeDimensions.map(b=>{var C;return{value:b.name,label:l.labelize(b.attribute)+se(b.role)+((C=b.properties)!=null&&C.includes("primary_key")?" (PK)":"")}}),x(d),a(d.map(b=>b.value))),r&&r.length>0){const C=(await o.commonDimensions(r)).reduce((N,v)=>{const _=v.node_name+JSON.stringify(v.path);return N[_]=N[_]??[],N[_].push(v),N},{}),M={};if(Object.values(C).forEach(N=>{const v=Le(N[0].path);M[v]=M[v]??[],M[v].push(N)}),g(M),t&&d){const N={};Object.values(C).forEach(v=>{const _=v[0].node_name+JSON.stringify(v[0].path);N[_]=h(d.filter(O=>v.filter(j=>O.value===j.name).length>0))}),y(N),a(Object.values(N).flat(2))}}else g({})})().catch(console.error)},[o,a,r,t]);const h=c=>c?c.map(d=>d.value):[],n=Object.keys(m).map(Number).sort((c,d)=>c-d),u={multiValue:c=>({...c,backgroundColor:"#ffefd0",border:"1px solid rgba(169, 102, 33, 0.3)",borderRadius:"3px",margin:"2px"}),multiValueLabel:c=>({...c,color:"#a96621",fontSize:"10px",fontWeight:500,padding:"2px 4px 2px 6px"}),multiValueRemove:c=>({...c,color:"#a96621",padding:"0 4px",":hover":{backgroundColor:"#ffe4b3",color:"#a96621"}})};return n.length===0?null:e.jsx("div",{children:n.map(c=>{const d=m[c],f=d.reduce((b,C)=>b+C.length,0);return e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"6px 0",borderBottom:"1px solid #dee2e6",marginBottom:"8px",marginTop:c>0?"24px":"0"},children:[e.jsx("span",{style:{fontWeight:600,color:"#212529",fontSize:"14px"},children:$e(c)}),e.jsxs("span",{style:{marginLeft:"10px",color:"#6c757d",fontSize:"13px"},children:["(",f," dimension",f!==1?"s":"",")"]})]}),e.jsx("div",{style:{paddingLeft:"6px"},children:d.map(b=>{const C=b[0].node_name+JSON.stringify(b[0].path),M=b[0].path.map(O=>{const j=O.split(".").pop();return l.labelize(j)}),N=e.jsxs("h5",{style:{fontWeight:"normal",marginBottom:"5px",marginTop:"10px",fontSize:"13px"},title:b[0].path.join(" → "),children:[e.jsx("a",{href:`/nodes/${b[0].node_name}`,children:e.jsx("b",{children:b[0].node_display_name})}),M.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{style:{color:"#6c757d"},children:"via"})," ",M.map((O,j)=>e.jsxs("span",{children:[j>0&&" → ",e.jsx("a",{href:`/nodes/${b[0].path[j]}`,children:O})]},j))]})]}),v=b.map(O=>{var E;const[j,T]=ke(O.name);return{value:O.name,label:l.labelize(j.split(".").slice(-1)[0])+se(T)+((E=O.properties)!=null&&E.includes("primary_key")?" (PK)":"")}}),_=p.filter(O=>v.filter(j=>O.value===j.value).length>0);return e.jsxs("div",{children:[N,e.jsx("span",{"data-testid":"dimensions-"+b[0].node_name,children:e.jsx(l.StateManagedSelect$1,{className:"",name:"dimensions-"+C,defaultValue:_,options:v,styles:u,isMulti:!0,isClearable:!0,closeMenuOnSelect:!1,onChange:O=>{const j={...S,[C]:h(O)};y(j),a(Object.values(j).flat(2))}})})]},C)})})]},c)})})});l.SyntaxHighlighter.registerLanguage("sql",l.sql);const Ie=(s,t)=>{let r;return(...a)=>{clearTimeout(r),r=setTimeout(()=>s(...a),t)}},Je=i.memo(function({metrics:t=[],dimensions:r=[]}){const a=i.useContext(l.DJClientContext).DataJunctionAPI,[o,m]=i.useState(null),[g,S]=i.useState(!1),[y,p]=i.useState(null),x=i.useCallback(Ie(async(u,c)=>{if(u.length===0||c.length===0){m(null);return}S(!0),p(null);try{const d=await a.metricsV3(u,c,"");d.errors&&d.errors.length>0?(p(d.errors.map(f=>typeof f=="string"?f:f.message||JSON.stringify(f)).join(", ")),m(null)):d.message?(p(d.message),m(null)):m(d)}catch(d){p(d.message||"Failed to generate SQL"),m(null)}finally{S(!1)}},500),[a]);i.useEffect(()=>{x(t,r)},[t,r,x]);const h=R.formatScanEstimate(o==null?void 0:o.scan_estimate),n=i.useMemo(()=>o!=null&&o.sql?e.jsx(l.SyntaxHighlighter,{language:"sql",style:R.atomOneLight,customStyle:{margin:0,padding:0,fontSize:"11px",background:"transparent",border:"none"},children:o.sql}):null,[o==null?void 0:o.sql]);return e.jsxs("div",{className:"cube-preview-panel",children:[e.jsxs("div",{className:"preview-section-header",children:[e.jsx("span",{className:"preview-section-icon",children:"⌘"}),e.jsx("span",{className:"preview-section-title",children:"Generated SQL"})]}),h&&e.jsxs("div",{className:`scan-estimate-banner scan-estimate-${h.level}`,children:[e.jsx("span",{className:"scan-estimate-icon",children:h.icon}),e.jsxs("div",{className:"scan-estimate-content",children:[e.jsxs("div",{className:"scan-estimate-header",children:[e.jsx("strong",{children:"Scan Cost:"})," ",h.totalBytes!==null&&h.totalBytes!==void 0?(h.hasMissingData?"≥ ":"")+R.formatBytes(h.totalBytes):"Unknown"]}),e.jsx("div",{className:"scan-estimate-sources",children:h.sources.map((u,c)=>{let d=u.source_name;return u.schema_&&u.table?d=`${u.schema_}.${u.table}`:u.table&&(d=u.table),e.jsxs("div",{className:"scan-source-item",children:[e.jsx("span",{className:"scan-source-name",title:u.source_name,children:d}),e.jsx("span",{className:"scan-source-size",children:u.total_bytes!==null&&u.total_bytes!==void 0?R.formatBytes(u.total_bytes):"no size data"})]},c)})})]})]}),e.jsxs("div",{className:"preview-sql-container",children:[g&&e.jsx("div",{className:"preview-loading",children:"Generating SQL..."}),y&&e.jsx("div",{className:"preview-error",children:y}),!g&&!y&&!(o!=null&&o.sql)&&e.jsx("div",{className:"preview-empty",children:"Select metrics and dimensions to preview SQL"}),!g&&!y&&n]})]})}),ae=()=>e.jsx(l.FastField,{as:"textarea",id:"Description",name:"description",placeholder:"Describe your cube"}),ne=({defaultValue:s})=>{const t=i.useContext(l.DJClientContext).DataJunctionAPI,[r,,a]=l.useField("tags"),[o,m]=i.useState([]),[g,S]=i.useState(s||[]);i.useEffect(()=>{t.listTags().then(p=>{m(p.map(x=>({value:x.name,label:x.display_name})))})},[t]),i.useEffect(()=>{s&&S(s)},[s]);const y=p=>{S(p||[]),a.setValue((p||[]).map(x=>x.value))};return e.jsx(l.StateManagedSelect$1,{value:g,options:o,onChange:y,isMulti:!0,placeholder:"Select tags..."})},ie=({defaultValue:s,isEdit:t=!1})=>{const r=i.useContext(l.DJClientContext).DataJunctionAPI,{currentUser:a}=l.useCurrentUser(),[o,,m]=l.useField("owners"),[g,S]=i.useState([]),[y,p]=i.useState(s||[]);i.useEffect(()=>{r.users().then(h=>{S(h.map(n=>({value:n.username,label:n.username})))})},[r]),i.useEffect(()=>{if(s)p(s),m.setValue(s.map(h=>h.value));else if(!t&&a){const h=[{value:a.username,label:a.username}];p(h),m.setValue([a.username])}},[s,a,t]);const x=h=>{p(h||[]),m.setValue((h||[]).map(n=>n.value))};return e.jsx(l.StateManagedSelect$1,{value:y,options:g,onChange:x,isMulti:!0,placeholder:"Select owners..."})};function re(){const s=i.useContext(l.DJClientContext).DataJunctionAPI,t=K.useNavigate();let{nodeType:r,initialNamespace:a,name:o}=K.useParams();const m=o!==void 0?w.Edit:w.Add,g=n=>!!n.value,S={name:m===w.Edit?o:"",namespace:m===w.Add?a:"",display_name:"",description:"",mode:"published",metrics:[],dimensions:[],filters:[],tags:[],owners:[]},y=(n,{setSubmitting:u,setStatus:c})=>{m===w.Add?setTimeout(()=>{p(n,c),u(!1)},400):setTimeout(()=>{x(n,c),u(!1)},400),window.scrollTo({top:0,left:0,behavior:"smooth"})},p=async(n,u)=>{const{status:c,json:d}=await s.createCube(n.name,n.display_name,n.description,n.mode,n.metrics,n.dimensions,n.filters||[]);c===200||c===201?(n.tags&&await s.tagsNode(n.name,n.tags),u({success:!0,savedName:d.name})):u({failure:`${d.message}`})},x=async(n,u)=>{const{status:c,json:d}=await s.patchCube(n.name,n.display_name,n.description,n.mode,n.metrics,n.dimensions,n.filters||[],n.owners),f=await s.tagsNode(n.name,(n.tags||[]).map(b=>b));(c===200||c===201)&&f.status===200?u({success:!0,savedName:d.name}):u({failure:`${d.message}`})},h=(n,u,c,d)=>{u("display_name",n.current.displayName||"",!1),u("description",n.current.description||"",!1),u("mode",n.current.mode.toLowerCase()||"draft",!1),u("tags",n.tags.map(f=>f.name)),c(n.tags.map(f=>({value:f.name,label:f.displayName}))),n.owners&&d(n.owners.map(f=>({value:f.username,label:f.username})))};return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mid",children:[e.jsx(l.NamespaceHeader,{namespace:a||(o?o.substring(0,o.lastIndexOf(".")):"")}),e.jsx(l.Formik,{initialValues:S,validate:g,onSubmit:y,children:function({isSubmitting:u,status:c,setFieldValue:d,values:f,props:b}){const[C,M]=i.useState([]),[N,v]=i.useState(null),[_,O]=i.useState(null),[j,T]=i.useState(!1),[E,J]=i.useState(null);i.useEffect(()=>{(async()=>{if(o){const F=await s.getCubeForEditing(o);M(F),h(F,d,v,O)}})().catch(console.error)},[d]);const k=i.useCallback(P=>d("metrics",P),[d]),A=i.useCallback(P=>d("dimensions",P),[d]);return i.useEffect(()=>{if(c!=null&&c.success){T(!0),J(null);const P=c.savedName,F=setTimeout(()=>{P&&t(`/nodes/${P}`)},1200);return()=>clearTimeout(F)}c!=null&&c.failure&&(J(c.failure),T(!1))},[c,t]),e.jsxs(l.Form,{className:"cube-builder",children:[e.jsx("div",{className:"cube-builder-header",children:e.jsxs("h2",{children:[m===w.Edit?"Edit":"Create"," ",e.jsx("span",{className:"node_type__cube node_type_creation_heading",children:"Cube"})]})}),e.jsxs("div",{className:"cube-builder-layout",children:[e.jsxs("div",{className:"cube-builder-main",children:[e.jsx("div",{className:"cube-form-section",children:e.jsx("div",{className:"cube-form-section-body",children:m===w.Add?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"cube-field-row",children:[e.jsxs("div",{className:"cube-field cube-field-grow",children:[e.jsx(l.ErrorMessage,{name:"description",component:"span"}),e.jsx("label",{className:"cube-field-label",htmlFor:"Description",children:"Description"}),e.jsx(ae,{})]}),e.jsxs("div",{className:"cube-field cube-field-small",children:[e.jsx("label",{className:"cube-field-label",htmlFor:"Mode",children:"Mode"}),e.jsxs(l.Field,{as:"select",name:"mode",id:"Mode",children:[e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"published",children:"Published"})]})]})]}),e.jsxs("div",{className:"cube-field-row",children:[e.jsxs("div",{className:"cube-field cube-field-half",children:[e.jsx("label",{className:"cube-field-label",children:"Tags"}),e.jsx(ne,{})]}),e.jsxs("div",{className:"cube-field cube-field-half",children:[e.jsx("label",{className:"cube-field-label",children:"Owners"}),e.jsx(ie,{})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cube-field",children:[e.jsx("label",{className:"cube-field-label",children:"Name"}),e.jsx("div",{className:"cube-field-static",children:o})]}),e.jsxs("div",{className:"cube-field-row",children:[e.jsxs("div",{className:"cube-field cube-field-grow",children:[e.jsx(l.ErrorMessage,{name:"display_name",component:"span"}),e.jsx("label",{className:"cube-field-label",htmlFor:"displayName",children:"Display Name"}),e.jsx(l.FastField,{type:"text",name:"display_name",id:"displayName",placeholder:"Human readable name"})]}),e.jsxs("div",{className:"cube-field cube-field-small",children:[e.jsx("label",{className:"cube-field-label",htmlFor:"Mode",children:"Mode"}),e.jsxs(l.Field,{as:"select",name:"mode",id:"Mode",children:[e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"published",children:"Published"})]})]})]}),e.jsxs("div",{className:"cube-field",children:[e.jsx(l.ErrorMessage,{name:"description",component:"span"}),e.jsx("label",{className:"cube-field-label",htmlFor:"Description",children:"Description"}),e.jsx(ae,{})]}),e.jsxs("div",{className:"cube-field-row",children:[e.jsxs("div",{className:"cube-field cube-field-half",children:[e.jsx("label",{className:"cube-field-label",children:"Tags"}),e.jsx(ne,{defaultValue:N})]}),e.jsxs("div",{className:"cube-field cube-field-half",children:[e.jsx("label",{className:"cube-field-label",children:"Owners"}),e.jsx(ie,{defaultValue:_,isEdit:!0})]})]})]})})}),e.jsxs("div",{className:"cube-form-section",children:[e.jsx("div",{className:"cube-form-section-header",children:e.jsx("h3",{children:"Metrics"})}),e.jsx("div",{className:"cube-form-section-body",children:e.jsx("div",{"data-testid":"select-metrics",children:m===w.Edit?e.jsx(ee,{cube:C,onChange:k}):e.jsx(ee,{onChange:k})})})]}),e.jsxs("div",{className:"cube-form-section",children:[e.jsx("div",{className:"cube-form-section-header",children:e.jsx("h3",{children:"Dimensions"})}),e.jsx("div",{className:"cube-form-section-body",children:e.jsx("div",{"data-testid":"select-dimensions",children:m===w.Edit?e.jsx(te,{cube:C,metrics:f.metrics,onChange:A}):e.jsx(te,{metrics:f.metrics,onChange:A})})})]})]}),e.jsxs("div",{className:"cube-builder-sidebar",children:[e.jsx(Je,{metrics:f.metrics,dimensions:f.dimensions}),e.jsxs("div",{className:"cube-settings",children:[E&&e.jsx("div",{className:"save-error-message",children:E}),e.jsx("button",{type:"submit",disabled:u||j,"aria-label":"CreateCube",className:`save-cube-btn${j?" save-cube-btn--saved":""}${u?" save-cube-btn--loading":""}`,children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"save-spinner","aria-hidden":"true"}),"Saving..."]}):j?"✓ Saved":m===w.Add?"Create Cube":"Save"})]})]})]})]})}})]})})}re.defaultProps={djClient:l.DataJunctionAPI};exports.CubeBuilderPage=re; //# sourceMappingURL=index-ZNcAQhUL.cjs.map