@baseplate-dev/project-builder-web
Version:
Web interface for constructing project builder JSON
3 lines (2 loc) • 3.62 kB
JavaScript
import{i}from"./_virtual___federation_fn_import-C4el_tlG.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{c as v,H as b,L as g}from"./index--XHV4ygU.js";import{l as y,j as f}from"./index-BsqYBobW.js";import{u as C}from"./use-model-form-DBAMk4je.js";import{M as D}from"./model-info-form-j1G36Ci9.js";const{Button:j,Dialog:N,DialogClose:w,DialogContent:M,DialogFooter:S,DialogHeader:k,DialogTitle:F,DialogTrigger:E,useControlledState:I}=await i("@baseplate-dev/ui-components");function O({open:a,onOpenChange:t,children:s,asChild:r,modelKey:l}){const[c,o]=I(a,t,!1),{form:{control:d,reset:u},onSubmit:n,defaultValues:m}=C({modelKey:l,onSubmitSuccess(){o(!1)}});return e.jsxs(N,{open:c,onOpenChange:p=>{o(p),p||u(m)},children:[s&&e.jsx(E,{asChild:r,children:s}),e.jsx(M,{"aria-describedby":void 0,children:e.jsxs("form",{onSubmit:n,className:"space-y-4",children:[e.jsx(k,{children:e.jsx(F,{children:"Edit Model Info"})}),e.jsx(D,{control:d}),e.jsxs(S,{children:[e.jsx(w,{asChild:!0,children:e.jsx(j,{variant:"secondary",children:"Cancel"})}),e.jsx(j,{type:"submit",children:"Save"})]})]})})]})}const{FeatureUtils:T,modelEntityType:B}=await i("@baseplate-dev/project-builder-lib"),{useProjectDefinition:L}=await i("@baseplate-dev/project-builder-lib/web"),{Button:$,useConfirmDialog:R}=await i("@baseplate-dev/ui-components"),{useNavigate:H}=await i("@tanstack/react-router");function q({className:a,model:t}){const{definition:s,saveDefinitionWithFeedbackSync:r,isSavingDefinition:l}=L(),c=H(),{requestConfirm:o}=R(),d=u=>{r(n=>{n.models=n.models.filter(m=>m.id!==u)},{onSuccess:()=>{c({to:"/data/models"}).catch(y)},successMessage:"Successfully deleted model!"})};return e.jsxs("div",{className:v("flex items-center justify-between border-b py-4",a),children:[e.jsxs("div",{children:[e.jsx(O,{modelKey:B.keyFromId(t.id),asChild:!0,children:e.jsxs("button",{className:"group flex items-center space-x-2 hover:cursor-pointer",type:"button",title:"Edit Model Info",children:[e.jsx("h1",{children:t.name}),e.jsx(b,{className:"invisible size-4 group-hover:visible"})]})}),t.featureRef&&e.jsx("div",{className:"text-xs text-muted-foreground",children:T.getFeatureById(s,t.featureRef)?.name})]}),e.jsx("div",{className:"flex gap-8",children:e.jsxs($,{variant:"outline",size:"icon",disabled:l,onClick:()=>{o({title:"Confirm delete",content:`Are you sure you want to delete ${t.name}?`,buttonConfirmText:"Delete",buttonConfirmVariant:"destructive",onConfirm:()=>{d(t.id)}})},children:[e.jsx(g,{className:"text-destructive"}),e.jsx("div",{className:"sr-only",children:"Delete Model"})]})})]})}const{NavigationTabs:z,NavigationTabsItem:x}=await i("@baseplate-dev/ui-components"),{Link:h,Outlet:A}=await i("@tanstack/react-router"),W=function(){const{model:t}=f.useLoaderData(),{key:s}=f.useParams();return e.jsxs("div",{className:"relative flex h-full flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"max-w-7xl space-y-4 px-4 pb-4",children:[e.jsx(q,{model:t}),e.jsxs(z,{children:[e.jsx(x,{asChild:!0,children:e.jsx(h,{to:"/data/models/edit/$key",params:{key:s},activeOptions:{exact:!0},children:"Fields"})}),e.jsx(x,{asChild:!0,children:e.jsx(h,{to:"/data/models/edit/$key/service",params:{key:s},activeOptions:{exact:!0},children:"Service"})}),e.jsx(x,{asChild:!0,children:e.jsx(h,{to:"/data/models/edit/$key/graphql",params:{key:s},activeOptions:{exact:!0},children:"GraphQL"})})]})]}),e.jsx("div",{className:"mb-(--action-bar-height) flex flex-1 overflow-y-auto",style:{"--action-bar-height":"52px"},children:e.jsx(A,{})})]},t.id)};export{W as component};
//# sourceMappingURL=route-D7PmyI68.js.map