UNPKG

@baseplate-dev/project-builder-web

Version:

Web interface for constructing project builder JSON

3 lines (2 loc) 3.62 kB
import{i as s}from"./_virtual___federation_fn_import-DOo8C-zl.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{c as v,H as b,L as g}from"./index-G5ZRloOW.js";import{l as y,q as p}from"./index-DiAhmW9l.js";import{u as D}from"./use-model-form-CMNCrezb.js";import{M as C}from"./model-info-form-BbOo8Z4g.js";const{Button:j,Dialog:N,DialogClose:w,DialogContent:M,DialogFooter:S,DialogHeader:k,DialogTitle:F,DialogTrigger:E,useControlledState:I}=await s("@baseplate-dev/ui-components");function O({open:i,onOpenChange:t,children:a,asChild:r,modelKey:l}){const[c,o]=I(i,t,!1),{form:{control:d,reset:u},onSubmit:n,defaultValues:m}=D({modelKey:l,onSubmitSuccess(){o(!1)}});return e.jsxs(N,{open:c,onOpenChange:f=>{o(f),f||u(m)},children:[a&&e.jsx(E,{asChild:r,children:a}),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(C,{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 s("@baseplate-dev/project-builder-lib"),{useProjectDefinition:L}=await s("@baseplate-dev/project-builder-lib/web"),{Button:$,useConfirmDialog:R}=await s("@baseplate-dev/ui-components"),{useNavigate:q}=await s("@tanstack/react-router");function H({className:i,model:t}){const{definition:a,saveDefinitionWithFeedbackSync:r,isSavingDefinition:l}=L(),c=q(),{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",i),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(a,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 s("@baseplate-dev/ui-components"),{Link:h,Outlet:A}=await s("@tanstack/react-router");function W(){const{model:i}=p.useLoaderData(),{key:t}=p.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(H,{model:i}),e.jsxs(z,{children:[e.jsx(x,{asChild:!0,children:e.jsx(h,{to:"/data/models/edit/$key",params:{key:t},activeOptions:{exact:!0},children:"Fields"})}),e.jsx(x,{asChild:!0,children:e.jsx(h,{to:"/data/models/edit/$key/service",params:{key:t},activeOptions:{exact:!0},children:"Service"})}),e.jsx(x,{asChild:!0,children:e.jsx(h,{to:"/data/models/edit/$key/graphql",params:{key:t},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,{})})]},i.id)}export{W as component}; //# sourceMappingURL=route-D771CD-J.js.map