import{d as _,eA as I,r as N,G as x,b as y,ev as A,f as o,w as r,u as s,bq as h,c as F,bH as R,ex as B}from"./outputWidgets.bf79c6b8.js";import{e as D,u as M,F as $}from"./icons.cf4b109d.js";import{a as V}from"./asyncComputed.42c5da60.js";import"./authorManager.09a2317d.js";import"./index.1e489b02.js";import{O as l}from"./organization.009d0f7f.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.2e07ac98.js";import{C as E}from"./CrudView.255ead71.js";import{B as G}from"./BaseLayout.6d45bc41.js";import{a as L}from"./ant-design.c701093a.js";import{A as U}from"./FormItem.56138d9e.js";import{F as q}from"./Form.b42a9c68.js";import{M as H}from"./Title.1751190b.js";import"./index.cf4c23b9.js";import"./record.fe4e890f.js";import"./pubsub.8fba7f4f.js";import"./gateway.8adee4a2.js";import"./logo.084e5d7c.js";import"./Text.db5ef3fa.js";import"./index.ee7a1582.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.fc0b8e07.js";import"./router.08175d4d.js";import"./index.e5b14e39.js";import"./url.379334d1.js";import"./index.934b837d.js";import"./index.bcfb1cc8.js";import"./index.9404929f.js";import"./index.6f699e42.js";import"./hasIn.36ac051b.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]="3a1b8c76-ad59-4e8f-880a-4272c171e287",i._sentryDebugIdIdentifier="sentry-dbid-3a1b8c76-ad59-4e8f-880a-4272c171e287")}catch{}})();const ve=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],u=[{key:"name",label:"Organization Name"}],b=I(),{loading:z,result:d,refetch:c}=V(()=>l.list()),p=({key:e})=>{b.push({name:"organization",params:{organizationId:e}})},n=N({state:"idle"});function v(e){n.value={state:"renaming",organizationId:e.id,newName:e.name}}async function f(e){if(n.value.state==="renaming"&&e){const{organizationId:a,newName:t}=n.value;await l.rename(a,t),c()}n.value={state:"idle"}}const w=async e=>{const a=await l.create(e.name);p({key:a.id})},k=async({key:e})=>{var t,g;await L("Are you sure you want to delete this organization?")&&(await((g=(t=d.value)==null?void 0:t.find(O=>O.id===e))==null?void 0:g.delete()),c())},C=x(()=>{var e,a;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"Actions",align:"right"}],rows:(a=(e=d.value)==null?void 0:e.map(t=>({key:t.id,cells:[{text:t.name,link:`/organizations/${encodeURIComponent(t.id)}`},{text:t.id},{text:"",actions:[{icon:D,label:"Go to projects",onClick:p},{icon:M,label:"Rename",onClick:()=>v(t)},{icon:$,label:"Delete",onClick:k,dangerous:!0}]}]})))!=null?a:[]}});return(e,a)=>(y(),A(h,null,[o(G,null,{navbar:r(()=>[o(j,{breadcrumb:m})]),content:r(()=>[o(E,{"entity-name":"organization",loading:s(z),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:C.value,fields:u,onCreate:w},null,8,["loading","table"])]),_:1}),o(s(H),{open:n.value.state==="renaming",title:"Rename organization",onCancel:a[1]||(a[1]=t=>f(!1)),onOk:a[2]||(a[2]=t=>f(!0))},{default:r(()=>[n.value.state==="renaming"?(y(),F(s(q),{key:0,layout:"vertical"},{default:r(()=>[o(s(U),{label:"New name"},{default:r(()=>[o(s(R),{value:n.value.newName,"onUpdate:value":a[0]||(a[0]=t=>n.value.newName=t)},null,8,["value"])]),_:1})]),_:1})):B("",!0)]),_:1},8,["open"])],64))}});export{ve as default};
//# sourceMappingURL=Organizations.8292d1f1.js.map
