garm/webapp/assets/_app/immutable/chunks/XzGG0o_q.js
Gabriel Adrian Samfira 6fee10c737 Fix double creation of pools
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>
2025-08-25 16:12:01 +00:00

1 line
7.8 KiB
JavaScript

import"./DsnmJJEf.js";import{i as qe}from"./zNh6Oe5P.js";import{p as Fe,E as Ke,o as Ge,f as x,j as t,r,k as s,g as e,m,z as B,t as y,x as ue,u as l,v,n as T,s as i,e as be,c as u,D as He,d as Je}from"./sWNKMed7.js";import{p as ge,i as U}from"./Ccl3fNd2.js";import{e as Qe,i as Ve}from"./BuuPrWMc.js";import{r as me,b as ye,g as Xe}from"./DVl4ZBgx.js";import{a as Ye,b as Ze}from"./CLagxtgo.js";import{p as ea}from"./D4Caz1gY.js";import{e as xe}from"./BZiHL9L3.js";import{M as aa}from"./DN14Fk2Y.js";var ta=x('<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>'),ra=x('<div><span class="text-gray-500 dark:text-gray-400">Owner:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div>'),oa=x('<div class="animate-pulse bg-gray-200 dark:bg-gray-700 h-10 rounded"></div>'),sa=x("<option> </option>"),na=x('<select id="credentials" 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>Keep current credentials</option><!></select>'),ia=x('<div><label for="webhookSecret" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">New Webhook Secret <span class="text-red-500">*</span></label> <input id="webhookSecret" type="password" placeholder="Enter new webhook secret" 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"/> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Leave empty to auto-generate a new secret</p></div>'),da=x('<div class="flex items-center"><div class="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div> Updating...</div>'),la=x('<div class="max-w-2xl w-full"><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"> </h2> <p class="mt-1 text-sm text-gray-500 dark:text-gray-400"> </p></div> <form class="p-6 space-y-6"><!> <div class="bg-gray-50 dark:bg-gray-900 p-4 rounded-lg"><h3 class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"> </h3> <div class="space-y-2 text-sm"><!> <div><span class="text-gray-500 dark:text-gray-400">Name:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div> <div><span class="text-gray-500 dark:text-gray-400">Endpoint:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div> <div><span class="text-gray-500 dark:text-gray-400">Current Credentials:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div> <div><span class="text-gray-500 dark:text-gray-400">Current Pool Balancer:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div></div></div> <div class="space-y-4"><div><label for="credentials" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Credentials</label> <!> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Leave unchanged to keep current credentials</p></div> <div><label for="poolBalancer" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Pool Balancer Type</label> <select id="poolBalancer" 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>Round Robin</option><option>Pack</option></select> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Round Robin distributes jobs evenly across pools, Pack fills pools in order</p></div> <div class="space-y-3"><div class="flex items-center"><input id="changeWebhookSecret" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 dark:border-gray-600 rounded"/> <label for="changeWebhookSecret" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">Change webhook secret</label></div> <!></div></div> <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 _a(fe,D){Fe(D,!1);let d=ge(D,"entity",8),w=ge(D,"entityType",8);const $=Ke();let C=m(!1),k=m(""),M=m([]),R=m(!1),f=m(""),_=m(""),h=m(""),b=m(!1);function _e(){if(w()==="repository"){const c=d();return`${c.owner}/${c.name}`}return d().name||""}function W(){return w().charAt(0).toUpperCase()+w().slice(1)}function he(){return w()==="repository"&&d().owner||""}async function ke(){try{i(R,!0),i(M,await Xe.listCredentials())}catch(c){i(k,xe(c))}finally{i(R,!1)}}function we(){i(f,d().credentials_name||""),i(_,d().pool_balancing_type||"roundrobin"),i(h,""),i(b,!1)}async function Ce(){try{i(C,!0),i(k,"");const c={};let E=!1;if(e(f)&&e(f)!==d().credentials_name&&(c.credentials_name=e(f),E=!0),e(_)&&e(_)!==d().pool_balancing_type&&(c.pool_balancer_type=e(_),E=!0),e(b)){if(!e(h).trim()){i(k,"Please enter a webhook secret or uncheck the option to change it");return}c.webhook_secret=e(h),E=!0}if(!E){$("close");return}$("submit",c)}catch(c){i(k,xe(c))}finally{i(C,!1)}}Ge(()=>{ke(),we()}),qe(),aa(fe,{$$events:{close:()=>$("close")},children:(c,E)=>{var j=la(),A=t(j),N=t(A),Ee=t(N);r(N);var Y=s(N,2),Se=t(Y,!0);r(Y),r(A);var z=s(A,2),Z=t(z);{var Pe=a=>{var o=ta(),n=t(o),p=t(n,!0);r(n),r(o),y(()=>v(p,e(k))),u(a,o)};U(Z,a=>{e(k)&&a(Pe)})}var I=s(Z,2),L=t(I),Ue=t(L);r(L);var ee=s(L,2),ae=t(ee);{var $e=a=>{var o=ra(),n=s(t(o),2),p=t(n,!0);r(n),r(o),y(S=>v(p,S),[()=>l(he)]),u(a,o)};U(ae,a=>{w()==="repository"&&a($e)})}var O=s(ae,2),te=s(t(O),2),Be=t(te,!0);r(te),r(O);var q=s(O,2),re=s(t(q),2),Te=t(re,!0);r(re),r(q);var F=s(q,2),oe=s(t(F),2),De=t(oe,!0);r(oe),r(F);var se=s(F,2),ne=s(t(se),2),Me=t(ne,!0);r(ne),r(se),r(ee),r(I);var K=s(I,2),G=t(K),Re=s(t(G),2);{var We=a=>{var o=oa();u(a,o)},je=a=>{var o=na();y(()=>{e(f),ue(()=>{e(M)})});var n=t(o);n.value=n.__value="";var p=s(n);Qe(p,1,()=>e(M),Ve,(S,g)=>{var P=sa(),Oe=t(P);r(P);var pe={};y(()=>{v(Oe,`${e(g),l(()=>e(g).name)??""} (${e(g),l(()=>e(g).endpoint?.name||"Unknown")??""})`),pe!==(pe=(e(g),l(()=>e(g).name)))&&(P.value=(P.__value=(e(g),l(()=>e(g).name)))??"")}),u(S,P)}),r(o),ye(o,()=>e(f),S=>i(f,S)),u(a,o)};U(Re,a=>{e(R)?a(We):a(je,!1)})}B(2),r(G);var H=s(G,2),J=s(t(H),2);y(()=>{e(_),ue(()=>{})});var Q=t(J);Q.value=Q.__value="roundrobin";var ie=s(Q);ie.value=ie.__value="pack",r(J),B(2),r(H);var de=s(H,2),V=t(de),le=t(V);me(le),B(2),r(V);var Ae=s(V,2);{var Ne=a=>{var o=ia(),n=s(t(o),2);me(n),B(2),r(o),y(()=>n.required=e(b)),Ze(n,()=>e(h),p=>i(h,p)),u(a,o)};U(Ae,a=>{e(b)&&a(Ne)})}r(de),r(K);var ce=s(K,2),ve=t(ce),X=s(ve,2),ze=t(X);{var Ie=a=>{var o=da();u(a,o)},Le=a=>{var o=He();y(n=>v(o,`Update ${n??""}`),[()=>l(W)]),u(a,o)};U(ze,a=>{e(C)?a(Ie):a(Le,!1)})}r(X),r(ce),r(z),r(j),y((a,o,n,p)=>{v(Ee,`Update ${a??""}`),v(Se,o),v(Ue,`${n??""} Information`),v(Be,(T(d()),l(()=>d().name))),v(Te,(T(d()),l(()=>d().endpoint?.name))),v(De,(T(d()),l(()=>d().credentials_name))),v(Me,(T(d()),l(()=>d().pool_balancing_type||"roundrobin"))),X.disabled=p},[()=>l(W),()=>l(_e),()=>l(W),()=>(e(C),e(b),e(h),l(()=>e(C)||e(b)&&!e(h).trim()))]),ye(J,()=>e(_),a=>i(_,a)),Ye(le,()=>e(b),a=>i(b,a)),be("click",ve,()=>$("close")),be("submit",z,ea(Ce)),u(c,j)},$$slots:{default:!0}}),Je()}export{_a as U};