1import{aL as S,aN as f,aO as w,r as u,bv as y,bw as F,au as M,af as a,aC as h}from"./vendor-BgWhiDrf.js";import{b as E,u5 as L,h7 as N,p as O,aU as P,aV as T,D as A,C as B,aX as p,bJ as q,dQ as U,e3 as $,bN as k,i as z,aW as R,ba as V}from"./main-COyT_q74.js";import{c as W}from"./permissions-DfhkLsaG.js";import{u as Z}from"./use-chart-configure-permission-CbO4EWYP.js";import"./bounded-range-fetch-CggGfMWc.js";import"./vendor-charts-34qQJjVh.js";const G=S().shape({parentModelId:w().nullable().required("Parent model is required"),name:f().required("Name is required"),description:f().nullable()}),H=[],ne=({isOpen:j,closeModal:b})=>{var v;const g=E(),x=u.useRef(y(new Date,Intl.DateTimeFormat().resolvedOptions().timeZone,"MM-dd-yyyy hh:mma z")),_=L(),d=N(void 0,{select:e=>F(e.segments,["connection.plan_in_warehouse","name"],["desc","asc"])}),{modelFilter:C}=Z(),t=u.useMemo(()=>(d==null?void 0:d.data)||[],[d==null?void 0:d.data]),{workspace:m}=O(),i=P({onSubmit:async e=>{var n,c,r;const o=await _.mutateAsync({input:{name:e.name,description:e.description?e.description:null,parent_model_id:(n=e.parentModelId)==null?void 0:n.toString(),layout:H}});if(o.insert_dashboards_one){const l=o.insert_dashboards_one.id,s=t.find(({id:I})=>I==e.parentModelId);V("Dashboard Created",{workspace_id:m==null?void 0:m.id,id:l,total_charts:void 0,parent_model_id:s==null?void 0:s.id,parent_model_name:s==null?void 0:s.name,parent_model_connection:(r=(c=s==null?void 0:s.connection)==null?void 0:c.definition)==null?void 0:r.name}),g(`/dashboards/${l}/edit`)}},resolver:M(G),success:!1,values:{name:`Dashboard created ${x.current}`,description:null,parentModelId:null}}),D=()=>{i.reset(),b?b():g("/dashboards")};return u.useEffect(()=>{var e,o;(t==null?void 0:t.length)===1&&((e=t[0])!=null&&e.connection)&&i.reset({name:`Dashboard created ${x.current}`,description:null,parentModelId:((o=t.find(n=>C(n.id)))==null?void 0:o.id)??null})},[t,i.reset]),a.jsx(T,{form:i,children:a.jsx(A,{isOpen:j,title:"Create dashboard",variant:"form",onClose:D,actions:a.jsxs(k,{children:[a.jsx(z,{onClick:D,children:"Cancel"}),a.jsx(R,{enablePristineSubmit:!0,permission:W((v=i.watch("parentModelId"))==null?void 0:v.toString()),size:"md",children:"Create dashboard"})]}),children:a.jsxs(B,{gap:4,children:[a.jsx(h,{control:i.control,name:"parentModelId",render:({field:e,fieldState:o})=>{var n,c;return a.jsx(p,{label:"Select a parent model",error:(n=o.error)==null?void 0:n.message,children:a.jsx(q,{isInvalid:!!((c=o.error)!=null&&c.message),isOptionDisabled:r=>!r.connection||!C(r.id),isLoading:d.isLoading,placeholder:"Select a parent model",optionLabel:r=>r.name,optionValue:r=>r.id,optionAccessories:r=>{var l;return{leftAccessory:{type:"image",url:((l=r.connection)==null?void 0:l.definition.icon)??""}}},options:t,width:"100%",value:e.value,onChange:e.onChange})})}}),a.jsx(h,{control:i.control,name:"name",render:({field:e,fieldState:o})=>{var n;return a.jsx(p,{label:"Dashboard name",error:(n=o.error)==null?void 0:n.message,children:a.jsx(U,{placeholder:"Enter a nameâ¦",width:"100%",value:e.value,onChange:e.onChange})})}}),a.jsx(h,{control:i.control,name:"description",render:({field:e,fieldState:o})=>{var n;return a.jsx(p,{isOptional:!0,label:"Dashboard description",error:(n=o.error)==null?void 0:n.message,children:a.jsx($,{placeholder:"Enter a descriptionâ¦",width:"100%",value:e.value??"",onChange:e.onChange})})}})]})})})};export{ne as NewDashboardModal}; 2//# sourceMappingURL=new-dashboard-B9e7pOQx.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.