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.7ee1756b.js";import{e as D,u as M,F as $}from"./icons.585003a3.js";import{a as V}from"./asyncComputed.794f0362.js";import"./router.3c970a49.js";import"./jwt-decode.esm.74bd4619.js";import"./index.ea08ffce.js";import{O as c}from"./organization.5d9c2f13.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.19ca85a9.js";import{C as E}from"./CrudView.c009ea30.js";import{B as L}from"./BaseLayout.381c73ac.js";import{a as U}from"./ant-design.152429cf.js";import{A as G}from"./FormItem.8fc4846a.js";import{F as P}from"./Form.37419728.js";import{M as S}from"./Modal.219ca627.js";import"./storage.622dbde6.js";import"./index.58e1a282.js";import"./index.cf4c23b9.js";import"./record.e7d815e3.js";import"./pubsub.d041bfb3.js";import"./logo.084e5d7c.js";import"./Text.521fd491.js";import"./index.8b3bc040.js";import"./Title.b0edd946.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.27cdda90.js";import"./url.6dccf316.js";import"./index.5015fd70.js";import"./index.34cf4bd3.js";import"./hasIn.07bf6468.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]="522f658c-0bc4-4655-950b-fa39d29cb038",i._sentryDebugIdIdentifier="sentry-dbid-522f658c-0bc4-4655-950b-fa39d29cb038")}catch{}})();const ze=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],z=I(),{loading:v,result:p,refetch:f}=V(()=>c.list()),g=({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 c.rename(t,a),f()}n.value={state:"idle"}}const k=async e=>{const t=await c.create(e.name);g({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()),f())},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:g},{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:d,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.edf30dbf.js.map
