import{d as _,ey as I,r as N,F as x,b,et as F,f as o,w as s,u as l,bo as h,c as R,bF as A,ev as B}from"./outputWidgets.4b203988.js";import{e as D,u as M,F as $}from"./icons.b5300508.js";import{a as V}from"./asyncComputed.e3f401af.js";import"./router.b5e476b6.js";import"./jwt-decode.esm.74bd4619.js";import"./index.7a3abf72.js";import{O as d}from"./organization.2698a41b.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.d9750609.js";import{C as E}from"./CrudView.54167740.js";import{B as L}from"./BaseLayout.89faeb15.js";import{a as U}from"./ant-design.af81433d.js";import{A as G}from"./FormItem.dacf5a0e.js";import{F as P}from"./Form.ed264728.js";import{M as S}from"./Modal.96464eb7.js";import"./storage.e938f042.js";import"./index.08241909.js";import"./index.cf4c23b9.js";import"./record.3809e80c.js";import"./pubsub.3a2fa885.js";import"./logo.084e5d7c.js";import"./Text.574763d2.js";import"./index.4ded4700.js";import"./Title.aa160519.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.0a96fdb4.js";import"./url.fcdccb50.js";import"./index.50465e1e.js";import"./index.fc0a25db.js";import"./hasIn.c2d80060.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},m=new Error().stack;m&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[m]="bc4388d2-2953-4b59-84e9-75497b774481",i._sentryDebugIdIdentifier="sentry-dbid-bc4388d2-2953-4b59-84e9-75497b774481")}catch{}})();const ze=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],c=[{key:"name",label:"Organization Name"}],z=I(),{loading:v,result:p,refetch:g}=V(()=>d.list()),f=({key:e})=>{z.push({name:"organization",params:{organizationId:e}})},n=N({state:"idle"});function w(e){n.value={state:"renaming",organizationId:e.id,newName:e.name}}async function y(e){if(n.value.state==="renaming"&&e){const{organizationId:t,newName:a}=n.value;await d.rename(t,a),g()}n.value={state:"idle"}}const k=async e=>{const t=await d.create(e.name);f({key:t.id})},C=async({key:e})=>{var a,r;await U("Are you sure you want to delete this organization?")&&(await((r=(a=p.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:r.delete()),g())},O=x(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=p.value)==null?void 0:e.map(a=>{var r,u;return{key:a.id,cells:[{type:"link",text:a.name,to:(r=`/organizations/${encodeURIComponent(a.id)}`)!=null?r:null},{type:"text",text:(u=a.id)!=null?u:null},{type:"actions",actions:[{icon:D,label:"Go to projects",onClick:f},{icon:M,label:"Rename",onClick:()=>w(a)},{icon:$,label:"Delete",onClick:C,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),F(h,null,[o(L,null,{navbar:s(()=>[o(j,{breadcrumb:m})]),content:s(()=>[o(E,{"entity-name":"organization",loading:l(v),title:"My organizations",description:"An organization is your company\u2019s account. Add co-workers, manage their access, organize projects and billing.","create-button-text":"Create Organization","empty-title":"No organizations here yet",table:O.value,fields:c,onCreate:k},null,8,["loading","table"])]),_:1}),o(l(S),{open:n.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=a=>y(!1)),onOk:t[2]||(t[2]=a=>y(!0))},{default:s(()=>[n.value.state==="renaming"?(b(),R(l(P),{key:0,layout:"vertical"},{default:s(()=>[o(l(G),{label:"New name"},{default:s(()=>[o(l(A),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):B("",!0)]),_:1},8,["open"])],64))}});export{ze as default};
//# sourceMappingURL=Organizations.0f885d51.js.map
