var f=Object.defineProperty;var p=(i,e,t)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var a=(i,e,t)=>(p(i,typeof e!="symbol"?e+"":e,t),t);import{C as g}from"./CrudView.c9a70a38.js";import{f as n,g as c,es as b,d as w,e4 as y,e3 as I,c as v,u as l,o as M}from"./index.b7bd503f.js";import{a as h}from"./gateway.6db311e2.js";import{M as z}from"./member.409d2e96.js";import"./columns.c99cb402.js";import{a as u}from"./ant-design.9ec9316b.js";import"./router.7c58172b.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.a6841fb4.js";import"./url.c0ede6d9.js";import"./PhDotsThreeVertical.vue.5c0a03a4.js";import"./Badge.53ab4d2d.js";import"./index.173038d0.js";import"./index.78ee4489.js";import"./popupNotifcation.bbf38424.js";import"./record.c86f39d9.js";import"./string.9a3a939b.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="8a003b1e-e7cd-4c08-a2da-9381dd1b9a05",i._sentryDebugIdIdentifier="sentry-dbid-8a003b1e-e7cd-4c08-a2da-9381dd1b9a05")}catch{}})();class C{constructor({authorEmail:e,organizationId:t,api:o,handlers:s}){a(this,"members",n([]));a(this,"selectedMember",n(null));a(this,"draftMember",n(null));a(this,"creationFields",c(()=>this.getCreationFields()));a(this,"table",c(()=>this.makeCrudViewTable()));a(this,"loading",n(!1));a(this,"authorEmail");a(this,"organizationId");a(this,"api");a(this,"handlers");a(this,"currentMember",n(null));a(this,"confirmAddMember",async e=>{await this.api.create({organizationId:this.organizationId,email:e.email.trim(),teams:e.teams}),await this.fetchState()});this.authorEmail=e,this.organizationId=t,this.api=o,this.handlers=s}async fetchState(){this.loading.value=!0,await this.fetchMembers(),this.setCurrentMember(),this.loading.value=!1}setCurrentMember(){var e;this.currentMember.value=(e=this.members.value.find(t=>t.email===this.authorEmail))!=null?e:null}async fetchMembers(){this.members.value=await this.api.list(this.organizationId)}async removeMember(e){var o;if(((o=h.getAuthor())==null?void 0:o.claims.email)===e.email){await u("Removing your own access will block you from this organization. Are you sure?",{okText:"Remove",cancelText:"Cancel"})&&(await this.api.delete({organizationId:this.organizationId,authorId:e.authorId}),this.handlers.onSelfRemove());return}await u(`Are you sure you want to remove ${e.email} access?`,{okText:"Remove",cancelText:"Cancel"})&&(await this.api.delete({organizationId:this.organizationId,authorId:e.authorId}),await this.fetchMembers())}getCreationFields(){return[{key:"email",label:"Email",type:"text"}]}makeCrudViewTable(){return{columns:[{title:"Email",align:"center"},{title:"",align:"right"}],rows:this.members.value.map(e=>({key:e.email,cells:[{type:"text",text:e.email},{type:"actions",actions:[{icon:b,label:"Remove access",onClick:()=>this.removeMember(e),dangerous:!0}]}]}))}}}const J=w({__name:"EditorsView",setup(i){var m;const e=y(),t=I(),o=e.params.organizationId,s=new z,d=(m=h.getAuthor())==null?void 0:m.claims.email;if(!d)throw new Error("Author email is not available");const r=new C({organizationId:o,api:s,authorEmail:d,handlers:{onSelfRemove:()=>{t.push("organizations")}}});return r.fetchState(),(k,E)=>(M(),v(g,{"entity-name":"editor",loading:l(r).loading.value,title:"Editors",description:"Manage people who can edit projects within your organization","empty-title":"No editors yet",table:l(r).table.value,"create-button-text":"Invite Editor",fields:l(r).creationFields.value,create:l(r).confirmAddMember},null,8,["loading","table","fields","create"]))}});export{J as default};
//# sourceMappingURL=EditorsView.176c4d3c.js.map
