import{d as _,eA as I,r as N,H as x,b,ev as h,f as o,w as s,u as l,aD as A,c as D,bz as R,ex as B}from"./outputWidgets.25dce6ef.js";import{e as F,H as M,K as $}from"./icons.7960dc02.js";import{a as V}from"./asyncComputed.a16c4c65.js";import"./router.e51f5f97.js";import"./index.9de01bc6.js";import{O as d}from"./organization.d50dbffe.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.8fb5f8dd.js";import{C as E}from"./CrudView.95230a58.js";import{B as H}from"./BaseLayout.b828f3a8.js";import{a as L}from"./ant-design.111a07e6.js";import{A as U,F as G}from"./Form.3655a4e5.js";import{M as K}from"./Modal.69a1b2db.js";import"./popupNotifcation.c74dae43.js";import"./index.cf4c23b9.js";import"./record.7f3a448e.js";import"./pubsub.d8283e38.js";import"./logo.084e5d7c.js";import"./Text.b67c302b.js";import"./Base.fa280ef3.js";import"./Typography.339a5435.js";import"./index.d2546a3c.js";import"./ArrowRightOutlined.08fa31dd.js";import"./Paragraph.fadf37c7.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.049638d2.js";import"./url.79cbe7ef.js";import"./index.fc4c597e.js";import"./Title.83602e90.js";import"./index.7c4562af.js";import"./index.bd52bba7.js";import"./hasIn.e0d864a0.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]="6ce35b00-9134-4dae-96e3-45b98a9510b6",i._sentryDebugIdIdentifier="sentry-dbid-6ce35b00-9134-4dae-96e3-45b98a9510b6")}catch{}})();const we=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],p=[{key:"name",label:"Organization Name"}],z=I(),{loading:v,result:c,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 L("Are you sure you want to delete this organization?")&&(await((r=(a=c.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=c.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:F,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(),h(A,null,[o(H,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:p,onCreate:k},null,8,["loading","table"])]),_:1}),o(l(K),{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(),D(l(G),{key:0,layout:"vertical"},{default:s(()=>[o(l(U),{label:"New name"},{default:s(()=>[o(l(R),{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{we as default};
//# sourceMappingURL=Organizations.97d37ddc.js.map
