This change fixes the creation of pools though the UI. Both the modal and the page were sending a request to create the pool, leading to double pool. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
import"./DsnmJJEf.js";import{i as Lr}from"./zNh6Oe5P.js";import{p as qr,E as Gr,m as s,o as Jr,f as m,k as r,j as o,g as e,r as a,t as v,e as E,c as b,v as T,b as Nr,z as pr,x as W,u as p,s as i,D as Ae,d as Vr}from"./sWNKMed7.js";import{p as mr,i as z}from"./Ccl3fNd2.js";import{e as Oe,i as $e}from"./BuuPrWMc.js";import{s as He,r as h,b as Q,g as C,c as Fr}from"./DVl4ZBgx.js";import{b as w,a as Kr}from"./CLagxtgo.js";import{p as Ur}from"./D4Caz1gY.js";import{M as Wr}from"./DN14Fk2Y.js";import{e as Be}from"./BZiHL9L3.js";import{J as Qr}from"./CkYhV7Br.js";var Xr=m('<div class="rounded-md bg-red-50 dark:bg-red-900 p-4"><p class="text-sm font-medium text-red-800 dark:text-red-200"> </p></div>'),Yr=m('<div class="animate-pulse bg-gray-200 dark:bg-gray-700 h-10 rounded"></div>'),Zr=m("<option><!></option>"),et=m('<select id="entity" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"><option> </option><!></select>'),rt=m('<div class="animate-pulse bg-gray-200 dark:bg-gray-700 h-10 rounded"></div>'),tt=m("<option> </option>"),at=m('<select id="provider" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"><option>Select a provider</option><!></select>'),ot=m('<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200"> <button type="button" class="ml-1 h-4 w-4 rounded-full hover:bg-blue-200 dark:hover:bg-blue-800 flex items-center justify-center cursor-pointer"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg></button></span>'),it=m('<div class="flex flex-wrap gap-2"></div>'),dt=m('<div class="space-y-4"><h3 class="text-lg font-medium text-gray-900 dark:text-white border-b border-gray-200 dark:border-gray-700 pb-2">Entity & Provider Configuration</h3> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div><label for="entity" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"> <span class="text-red-500">*</span></label> <!></div> <div><label for="provider" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Provider <span class="text-red-500">*</span></label> <!></div></div></div> <div class="space-y-4"><h3 class="text-lg font-medium text-gray-900 dark:text-white border-b border-gray-200 dark:border-gray-700 pb-2">Image & OS Configuration</h3> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div><label for="image" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Image <span class="text-red-500">*</span></label> <input id="image" type="text" required placeholder="e.g., ubuntu:22.04" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/></div> <div><label for="flavor" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Flavor <span class="text-red-500">*</span></label> <input id="flavor" type="text" required placeholder="e.g., default" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/></div> <div><label for="osType" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">OS Type</label> <select id="osType" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"><option>Linux</option><option>Windows</option></select></div> <div><label for="osArch" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Architecture</label> <select id="osArch" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"><option>AMD64</option><option>ARM64</option></select></div></div></div> <div class="space-y-4"><h3 class="text-lg font-medium text-gray-900 dark:text-white border-b border-gray-200 dark:border-gray-700 pb-2">Runner Limits & Timing</h3> <div class="grid grid-cols-1 md:grid-cols-3 gap-4"><div><label for="minIdleRunners" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Min Idle Runners</label> <input id="minIdleRunners" type="number" min="0" placeholder="0" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/></div> <div><label for="maxRunners" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Max Runners</label> <input id="maxRunners" type="number" min="1" placeholder="10" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/></div> <div><label for="bootstrapTimeout" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Bootstrap Timeout (min)</label> <input id="bootstrapTimeout" type="number" min="1" placeholder="20" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/></div></div></div> <div class="space-y-4"><h3 class="text-lg font-medium text-gray-900 dark:text-white border-b border-gray-200 dark:border-gray-700 pb-2">Advanced Settings</h3> <div class="grid grid-cols-1 md:grid-cols-3 gap-4"><div><label for="runnerPrefix" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Runner Prefix</label> <input id="runnerPrefix" type="text" placeholder="garm" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/></div> <div><label for="priority" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Priority</label> <input id="priority" type="number" min="1" placeholder="100" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/></div> <div><label for="githubRunnerGroup" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">GitHub Runner Group (optional)</label> <input id="githubRunnerGroup" type="text" placeholder="Default group" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/></div></div> <div><label for="tag-input" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Tags</label> <div class="space-y-2"><div class="flex"><input id="tag-input" type="text" placeholder="Enter a tag" class="flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-l-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"/> <button type="button" class="px-3 py-2 bg-blue-600 text-white rounded-r-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer">Add</button></div> <!></div></div> <fieldset><legend class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Extra Specs (JSON)</legend> <!></fieldset> <div class="flex items-center"><input id="enabled" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 dark:border-gray-600 rounded"/> <label for="enabled" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">Enable pool immediately</label></div></div>',1),st=m('<div class="flex items-center"><div class="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div> Creating...</div>'),lt=m('<div class="max-w-6xl w-full max-h-[90vh] overflow-y-auto"><div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700"><h2 class="text-xl font-semibold text-gray-900 dark:text-white">Create New Pool</h2></div> <form class="p-6 space-y-6"><!> <fieldset><legend class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3">Entity Level <span class="text-red-500">*</span></legend> <div class="grid grid-cols-3 gap-4"><button type="button"><svg class="w-8 h-8 mb-2 text-gray-600 dark:text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5a2 2 0 012-2h4a2 2 0 012 2v2H8V5z"></path></svg> <span class="text-sm font-medium text-gray-900 dark:text-white">Repository</span></button> <button type="button"><svg class="w-8 h-8 mb-2 text-gray-600 dark:text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"></path></svg> <span class="text-sm font-medium text-gray-900 dark:text-white">Organization</span></button> <button type="button"><svg class="w-8 h-8 mb-2 text-gray-600 dark:text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path></svg> <span class="text-sm font-medium text-gray-900 dark:text-white">Enterprise</span></button></div></fieldset> <!> <div class="flex justify-end space-x-3 pt-6 border-t border-gray-200 dark:border-gray-700"><button type="button" class="px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 cursor-pointer">Cancel</button> <button type="submit" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer"><!></button></div></form></div>');function ht(fr,X){qr(X,!1);const G=Gr();let Y=mr(X,"initialEntityType",8,""),De=mr(X,"initialEntityId",8,""),J=s(!1),M=s(""),n=s(Y()),I=s([]),Z=s([]),ee=s(!1),re=s(!1),k=s(De()),S=s(""),B=s(""),D=s(""),te=s(void 0),ae=s(void 0),oe=s(void 0),ie=s(100),de=s("garm"),N=s("linux"),V=s("amd64"),se=s(""),le=s(!0),_=s([]),j=s(""),L=s("{}");async function yr(){try{i(re,!0),i(Z,await C.listProviders())}catch(l){i(M,Be(l))}finally{i(re,!1)}}async function Le(){if(e(n))try{switch(i(ee,!0),i(I,[]),e(n)){case"repository":i(I,await C.listRepositories());break;case"organization":i(I,await C.listOrganizations());break;case"enterprise":i(I,await C.listEnterprises());break}}catch(l){i(M,Be(l))}finally{i(ee,!1)}}function ne(l){e(n)!==l&&(i(n,l),i(k,""),Le())}function qe(){e(j).trim()&&!e(_).includes(e(j).trim())&&(i(_,[...e(_),e(j).trim()]),i(j,""))}function xr(l){i(_,e(_).filter((P,A)=>A!==l))}function hr(l){l.key==="Enter"&&(l.preventDefault(),qe())}async function kr(){if(!e(n)||!e(k)||!e(S)||!e(B)||!e(D)){i(M,"Please fill in all required fields");return}try{i(J,!0),i(M,"");let l={};if(e(L).trim())try{l=JSON.parse(e(L))}catch{throw new Error("Invalid JSON in extra specs")}const P={provider_name:e(S),image:e(B),flavor:e(D),max_runners:e(te)||10,min_idle_runners:e(ae)||0,runner_bootstrap_timeout:e(oe)||20,priority:e(ie),runner_prefix:e(de),os_type:e(N),os_arch:e(V),"github-runner-group":e(se)||void 0,enabled:e(le),tags:e(_),extra_specs:e(L).trim()?l:void 0};if(Y()&&De())G("submit",P);else{switch(e(n)){case"repository":await C.createRepositoryPool(e(k),P);break;case"organization":await C.createOrganizationPool(e(k),P);break;case"enterprise":await C.createEnterprisePool(e(k),P);break;default:throw new Error("Invalid entity level")}G("submit",P)}}catch(l){i(M,Be(l))}finally{i(J,!1)}}Jr(()=>{yr(),Y()&&Le()}),Lr(),Wr(fr,{$$events:{close:()=>G("close")},children:(l,P)=>{var A=lt(),ue=r(o(A),2),Ge=o(ue);{var _r=c=>{var y=Xr(),O=o(y),F=o(O,!0);a(O),a(y),v(()=>T(F,e(M))),b(c,y)};z(Ge,c=>{e(M)&&c(_r)})}var be=r(Ge,2),Je=r(o(be),2),ce=o(Je),ge=r(ce,2),Ne=r(ge,2);a(Je),a(be);var Ve=r(be,2);{var wr=c=>{var y=dt(),O=Nr(y),F=r(o(O),2),pe=o(F),me=o(pe),Rr=o(me);pr(),a(me);var Tr=r(me,2);{var zr=t=>{var u=Yr();b(t,u)},Cr=t=>{var u=et();v(()=>{e(k),W(()=>{e(n),e(I)})});var f=o(u),$=o(f);a(f),f.value=f.__value="";var R=r(f);Oe(R,1,()=>e(I),$e,(g,d)=>{var x=Zr(),U=o(x);{var Br=H=>{var q=Ae();v(()=>T(q,`${e(d),p(()=>e(d).owner)??""}/${e(d),p(()=>e(d).name)??""} (${e(d),p(()=>e(d).endpoint?.name)??""})`)),b(H,q)},Dr=H=>{var q=Ae();v(()=>T(q,`${e(d),p(()=>e(d).name)??""} (${e(d),p(()=>e(d).endpoint?.name)??""})`)),b(H,q)};z(U,H=>{e(n)==="repository"?H(Br):H(Dr,!1)})}a(x);var vr={};v(()=>{vr!==(vr=(e(d),p(()=>e(d).id)))&&(x.value=(x.__value=(e(d),p(()=>e(d).id)))??"")}),b(g,x)}),a(u),v(()=>T($,`Select a ${e(n)??""}`)),Q(u,()=>e(k),g=>i(k,g)),b(t,u)};z(Tr,t=>{e(ee)?t(zr):t(Cr,!1)})}a(pe);var Ue=r(pe,2),Ir=r(o(Ue),2);{var Sr=t=>{var u=rt();b(t,u)},jr=t=>{var u=at();v(()=>{e(S),W(()=>{e(Z)})});var f=o(u);f.value=f.__value="";var $=r(f);Oe($,1,()=>e(Z),$e,(R,g)=>{var d=tt(),x=o(d,!0);a(d);var U={};v(()=>{T(x,(e(g),p(()=>e(g).name))),U!==(U=(e(g),p(()=>e(g).name)))&&(d.value=(d.__value=(e(g),p(()=>e(g).name)))??"")}),b(R,d)}),a(u),Q(u,()=>e(S),R=>i(S,R)),b(t,u)};z(Ir,t=>{e(re)?t(Sr):t(jr,!1)})}a(Ue),a(F),a(O);var fe=r(O,2),We=r(o(fe),2),ye=o(We),Qe=r(o(ye),2);h(Qe),a(ye);var xe=r(ye,2),Xe=r(o(xe),2);h(Xe),a(xe);var he=r(xe,2),ke=r(o(he),2);v(()=>{e(N),W(()=>{})});var _e=o(ke);_e.value=_e.__value="linux";var Ye=r(_e);Ye.value=Ye.__value="windows",a(ke),a(he);var Ze=r(he,2),we=r(o(Ze),2);v(()=>{e(V),W(()=>{})});var Ee=o(we);Ee.value=Ee.__value="amd64";var er=r(Ee);er.value=er.__value="arm64",a(we),a(Ze),a(We),a(fe);var Me=r(fe,2),rr=r(o(Me),2),Pe=o(rr),tr=r(o(Pe),2);h(tr),a(Pe);var Re=r(Pe,2),ar=r(o(Re),2);h(ar),a(Re);var or=r(Re,2),ir=r(o(or),2);h(ir),a(or),a(rr),a(Me);var dr=r(Me,2),Te=r(o(dr),2),ze=o(Te),sr=r(o(ze),2);h(sr),a(ze);var Ce=r(ze,2),lr=r(o(Ce),2);h(lr),a(Ce);var nr=r(Ce,2),ur=r(o(nr),2);h(ur),a(nr),a(Te);var Ie=r(Te,2),br=r(o(Ie),2),Se=o(br),K=o(Se);h(K);var Ar=r(K,2);a(Se);var Or=r(Se,2);{var $r=t=>{var u=it();Oe(u,5,()=>e(_),$e,(f,$,R)=>{var g=ot(),d=o(g),x=r(d);a(g),v(()=>{T(d,`${e($)??""} `),Fr(x,"aria-label",`Remove tag ${e($)}`)}),E("click",x,()=>xr(R)),b(f,g)}),a(u),b(t,u)};z(Or,t=>{e(_),p(()=>e(_).length>0)&&t($r)})}a(br),a(Ie);var je=r(Ie,2),Hr=r(o(je),2);Qr(Hr,{rows:4,placeholder:"{}",get value(){return e(L)},set value(t){i(L,t)},$$legacy:!0}),a(je);var cr=r(je,2),gr=o(cr);h(gr),pr(2),a(cr),a(dr),v(t=>T(Rr,`${t??""} `),[()=>(e(n),p(()=>e(n).charAt(0).toUpperCase()+e(n).slice(1)))]),w(Qe,()=>e(B),t=>i(B,t)),w(Xe,()=>e(D),t=>i(D,t)),Q(ke,()=>e(N),t=>i(N,t)),Q(we,()=>e(V),t=>i(V,t)),w(tr,()=>e(ae),t=>i(ae,t)),w(ar,()=>e(te),t=>i(te,t)),w(ir,()=>e(oe),t=>i(oe,t)),w(sr,()=>e(de),t=>i(de,t)),w(lr,()=>e(ie),t=>i(ie,t)),w(ur,()=>e(se),t=>i(se,t)),w(K,()=>e(j),t=>i(j,t)),E("keydown",K,hr),E("click",Ar,qe),Kr(gr,()=>e(le),t=>i(le,t)),b(c,y)};z(Ve,c=>{e(n)&&c(wr)})}var Fe=r(Ve,2),Ke=o(Fe),ve=r(Ke,2),Er=o(ve);{var Mr=c=>{var y=st();b(c,y)},Pr=c=>{var y=Ae("Create Pool");b(c,y)};z(Er,c=>{e(J)?c(Mr):c(Pr,!1)})}a(ve),a(Fe),a(ue),a(A),v(()=>{He(ce,1,`flex flex-col items-center justify-center p-4 border-2 rounded-lg transition-colors cursor-pointer ${e(n)==="repository"?"border-blue-500 bg-blue-50 dark:bg-blue-900":"border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500"}`),He(ge,1,`flex flex-col items-center justify-center p-4 border-2 rounded-lg transition-colors cursor-pointer ${e(n)==="organization"?"border-blue-500 bg-blue-50 dark:bg-blue-900":"border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500"}`),He(Ne,1,`flex flex-col items-center justify-center p-4 border-2 rounded-lg transition-colors cursor-pointer ${e(n)==="enterprise"?"border-blue-500 bg-blue-50 dark:bg-blue-900":"border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500"}`),ve.disabled=e(J)||!e(n)||!e(k)||!e(S)||!e(B)||!e(D)}),E("click",ce,()=>ne("repository")),E("click",ge,()=>ne("organization")),E("click",Ne,()=>ne("enterprise")),E("click",Ke,()=>G("close")),E("submit",ue,Ur(kr)),b(l,A)},$$slots:{default:!0}}),Vr()}export{ht as C};
|