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>
7 lines
27 KiB
JavaScript
7 lines
27 KiB
JavaScript
import"../chunks/DsnmJJEf.js";import{i as jt}from"../chunks/zNh6Oe5P.js";import{p as Gt,g as e,o as Ut,l as Q,a as qt,f as E,e as f,h as zt,b as Fe,c as $,d as Bt,$ as St,m as y,s as n,i as Lt,j as o,k as a,r as i,u,n as be,q as Le,t as se,v as W,w as rt,x as Nt,y as _,z as X}from"../chunks/sWNKMed7.js";import{i as G,s as Kt,a as Vt}from"../chunks/Ccl3fNd2.js";import{e as Ht,i as Rt}from"../chunks/BuuPrWMc.js";import{h as Yt,r as L,s as je,b as Ot,a as Jt,g as ve}from"../chunks/DVl4ZBgx.js";import{b as N,a as Qt}from"../chunks/CLagxtgo.js";import{p as at}from"../chunks/D4Caz1gY.js";import{P as Wt}from"../chunks/qfys27k5.js";import{F as Xt}from"../chunks/z0u7Z3zm.js";import{D as Zt,A as ot,G as it,a as er}from"../chunks/DCYYzf48.js";import{e as tr,a as Ne}from"../chunks/DA-798Ko.js";import{t as ke}from"../chunks/BZUCTtPY.js";import{f as rr,p as ar,g as Ke,B as nt,c as or}from"../chunks/cjRLNre3.js";import{e as Ve}from"../chunks/BZiHL9L3.js";import"../chunks/C6O4o7G1.js";import{E as ir}from"../chunks/CARsAFuo.js";import{S as nr}from"../chunks/BJXodF8n.js";var dr=E('<div class="flex items-center justify-between"><div class="flex-1 min-w-0"><div class="block"><p class="text-sm font-medium text-gray-900 dark:text-white truncate"> </p> <p class="text-sm text-gray-500 dark:text-gray-400 truncate mt-1"> </p> <div class="flex items-center mt-2 space-x-3"><div class="flex items-center"><!> <span class="ml-1 text-xs text-gray-500 dark:text-gray-400"> </span></div></div></div></div> <div class="flex items-center space-x-3 ml-4"><!> <div class="flex space-x-2"><!> <!></div></div></div>'),sr=E("<option> </option>"),lr=E('<p class="text-xs text-gray-500 dark:text-gray-400 mt-1"> </p>'),cr=E('<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">Gitea only supports PAT authentication</p>'),ur=E('<div><label for="oauth2_token" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Personal Access Token <span class="text-red-500">*</span></label> <input type="password" id="oauth2_token" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" placeholder="ghp_xxxxxxxxxxxxxxxxxxxx"/></div>'),pr=E('<div><label for="app_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">App ID <span class="text-red-500">*</span></label> <input type="text" id="app_id" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" placeholder="123456"/></div> <div><label for="installation_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">App Installation ID <span class="text-red-500">*</span></label> <input type="text" id="installation_id" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" placeholder="12345678"/></div> <div><label for="private_key" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Private Key <span class="text-red-500">*</span></label> <div class="border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-4 text-center hover:border-blue-400 dark:hover:border-blue-400 transition-colors"><input type="file" id="private_key" accept=".pem,.key" class="hidden"/> <div class="space-y-2"><svg class="mx-auto h-8 w-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg> <p class="text-sm text-gray-600 dark:text-gray-400"><button type="button" class="text-gray-900 dark:text-white hover:text-gray-700 dark:hover:text-gray-300 hover:underline cursor-pointer">Choose a file</button> or drag and drop</p> <p class="text-xs text-gray-500 dark:text-gray-400">PEM, KEY files only</p></div></div></div>',1),gr=E('<div class="fixed inset-0 flex items-center justify-center z-50" role="dialog" aria-modal="true"><button class="fixed inset-0 w-full h-full bg-black/30 dark:bg-black/50 cursor-default" aria-label="Close modal"></button> <div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full mx-4 max-h-screen overflow-y-auto relative z-10" role="document"><div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center"><div><h3 class="text-lg font-semibold text-gray-900 dark:text-white">Add Credentials</h3> <p class="text-sm text-gray-600 dark:text-gray-400 mt-1">Create new authentication credentials</p></div> <button class="text-gray-400 hover:text-gray-600 dark:text-gray-300 dark:hover:text-gray-100 cursor-pointer" aria-label="Close modal"><svg class="w-6 h-6" 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></div> <form class="p-6 space-y-4"><!> <div><label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Credentials Name <span class="text-red-500">*</span></label> <input type="text" id="name" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" placeholder="e.g., my-github-credentials"/></div> <div><label for="description" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Description <span class="text-red-500">*</span></label> <textarea id="description" rows="2" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" placeholder="Brief description of these credentials"></textarea></div> <div><label for="endpoint" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Endpoint <span class="text-red-500">*</span></label> <select id="endpoint" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white"><option>Select an endpoint</option><!></select> <!></div> <div role="group" aria-labelledby="auth-type-heading"><div id="auth-type-heading" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Authentication Type <span class="text-red-500">*</span></div> <div class="flex space-x-4"><button type="button">PAT</button> <button type="button">App</button></div> <!></div> <!> <!> <div class="flex justify-end space-x-3 pt-4 border-t border-gray-200 dark:border-gray-700"><button type="button" class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-600 hover:bg-gray-200 dark:hover:bg-gray-500 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 cursor-pointer">Cancel</button> <button type="submit">Create Credentials</button></div></form></div></div>'),yr=E('<div><label for="edit_oauth2_token" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">New Personal Access Token <span class="text-red-500">*</span></label> <input type="password" id="edit_oauth2_token" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" placeholder="Enter new token"/></div>'),br=E('<div><label for="edit_app_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">App ID <span class="text-red-500">*</span></label> <input type="text" id="edit_app_id" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" placeholder="Enter new App ID"/></div> <div><label for="edit_installation_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">App Installation ID <span class="text-red-500">*</span></label> <input type="text" id="edit_installation_id" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" placeholder="Enter new Installation ID"/></div> <div><label for="edit_private_key" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Private Key <span class="text-red-500">*</span></label> <div class="border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-4 text-center hover:border-blue-400 dark:hover:border-blue-400 transition-colors"><input type="file" id="edit_private_key" accept=".pem,.key" class="hidden"/> <div class="space-y-2"><svg class="mx-auto h-8 w-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg> <p class="text-sm text-gray-600 dark:text-gray-400"><button type="button" class="text-gray-900 dark:text-white hover:text-gray-700 dark:hover:text-gray-300 hover:underline cursor-pointer">Choose a new file</button> or drag and drop</p> <p class="text-xs text-gray-500 dark:text-gray-400">PEM, KEY files only. Upload new private key.</p></div></div></div>',1),vr=E("<!> <!>",1),fr=E('<div class="fixed inset-0 flex items-center justify-center z-50" role="dialog" aria-modal="true"><button class="fixed inset-0 w-full h-full bg-black/30 dark:bg-black/50 cursor-default" aria-label="Close modal"></button> <div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-screen overflow-y-auto relative z-10" role="document"><div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center"><div><h3 class="text-lg font-semibold text-gray-900 dark:text-white">Edit Credentials</h3> <p class="text-sm text-gray-600 dark:text-gray-400 mt-1"> </p></div> <button class="text-gray-400 hover:text-gray-600 dark:text-gray-300 dark:hover:text-gray-100 cursor-pointer" aria-label="Close modal"><svg class="w-6 h-6" 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></div> <form class="p-6 space-y-4"><div><label for="edit_name" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Credentials Name <span class="text-red-500">*</span></label> <input type="text" id="edit_name" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white"/></div> <div><label for="edit_description" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Description <span class="text-red-500">*</span></label> <textarea id="edit_description" rows="2" required class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white"></textarea></div> <div><label for="edit-endpoint" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Endpoint</label> <input type="text" id="edit-endpoint" disabled class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"/> <p class="text-xs text-gray-500 dark:text-gray-400 mt-1">Endpoint cannot be changed after creation</p></div> <div><span class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Authentication Type</span> <div class="px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-600"><span class="text-sm font-medium text-gray-700 dark:text-gray-300"> </span></div> <p class="text-xs text-gray-500 dark:text-gray-400 mt-1">Authentication type cannot be changed after creation</p></div> <div class="border-t border-gray-200 dark:border-gray-700 pt-4"><div class="flex items-center"><input id="change_credentials_checkbox" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 dark:border-gray-600 rounded"/> <label for="change_credentials_checkbox" class="ml-2 block text-sm font-medium text-gray-700 dark:text-gray-300">I want to change credentials</label></div> <p class="text-xs text-gray-500 dark:text-gray-400 mt-1">Check this box to update authentication credentials</p></div> <!> <div class="flex justify-end space-x-3 pt-4 border-t border-gray-200 dark:border-gray-700"><button type="button" class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-600 hover:bg-gray-200 dark:hover:bg-gray-500 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 cursor-pointer">Cancel</button> <button type="submit">Update Credentials</button></div></form></div></div>'),mr=E('<div class="fixed inset-0 flex items-center justify-center z-50" role="dialog" aria-modal="true"><button class="fixed inset-0 w-full h-full bg-black/30 dark:bg-black/50 cursor-default" aria-label="Close modal"></button> <div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-xl w-full mx-4 relative z-10" role="document"><div class="px-6 py-4"><div class="flex items-center"><div class="flex-shrink-0"><svg class="h-6 w-6 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"></path></svg></div> <div class="ml-3"><h3 class="text-lg font-medium text-gray-900 dark:text-white">Delete Credentials</h3> <p class="mt-2 text-sm text-gray-500 dark:text-gray-300"> </p></div></div></div> <div class="px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-end space-x-3"><button type="button" class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-600 hover:bg-gray-200 dark:hover:bg-gray-500 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 cursor-pointer">Cancel</button> <button type="button" class="px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-md focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 cursor-pointer">Delete</button></div></div></div>'),xr=E('<div class="space-y-6"><!> <!></div> <!> <!> <!>',1);function zr(dt,st){Gt(st,!1);const[lt,ct]=Kt(),U=()=>Vt(tr,"$eagerCache",lt),Ge=y(),Z=y(),He=y(),Ue=y(),p={PAT:"pat",APP:"app"};let we=y(!0),le=y([]),J=y([]),Ce=y(""),Pe=y(""),K=y(1),ce=y(25),ue=y(1),Ae=y(!1),Te=y(!1),$e=y(!1),D=y(p.PAT),g=y(null),M=y(null),t=y({name:"",description:"",endpoint:"",auth_type:p.PAT,oauth2_token:"",app_id:"",installation_id:"",private_key_bytes:""}),Ee={...e(t)},ee=y(!1);function ut(r){r.key==="Escape"&&(e(Ae)||e(Te)||e($e))&&P()}Ut(async()=>{try{n(we,!0);const[r,d]=await Promise.all([Ne.getCredentials(),Ne.getEndpoints()]);r&&Array.isArray(r)&&n(le,r),d&&Array.isArray(d)&&n(J,d)}catch(r){console.error("Failed to load credentials:",r),n(Ce,r instanceof Error?r.message:"Failed to load credentials")}finally{n(we,!1)}});async function pt(){try{await Ne.retryResource("credentials")}catch(r){console.error("Retry failed:",r)}}async function gt(){Re(),n(Ae,!0),n(x,"github")}let x=y("");function yt(r){n(x,r.detail),_(t,e(t).auth_type=p.PAT),n(D,p.PAT)}async function qe(r){n(g,r),n(t,{name:r.name||"",description:r.description||"",endpoint:r.endpoint?.name||"",auth_type:r["auth-type"]||p.PAT,oauth2_token:"",app_id:"",installation_id:"",private_key_bytes:""}),n(D,r["auth-type"]||p.PAT),Ee={...e(t)},n(ee,!1),n(Te,!0)}function ze(r){n(M,r),n($e,!0)}function Re(){n(t,{name:"",description:"",endpoint:"",auth_type:p.PAT,oauth2_token:"",app_id:"",installation_id:"",private_key_bytes:""}),Ee={...e(t)},n(D,p.PAT),n(ee,!1)}function P(){n(Ae,!1),n(Te,!1),n($e,!1),n(g,null),n(M,null),n(x,""),Re()}function Ye(r){n(D,r),_(t,e(t).auth_type=r)}function bt(){const r={};if(e(t).name!==Ee.name&&e(t).name.trim()!==""&&(r.name=e(t).name.trim()),e(t).description!==Ee.description&&e(t).description.trim()!==""&&(r.description=e(t).description.trim()),e(ee)&&e(g))if(e(g)["auth-type"]===p.PAT)e(t).oauth2_token.trim()!==""&&(r.pat={oauth2_token:e(t).oauth2_token.trim()});else{const d={};let b=!1;if(e(t).app_id.trim()!==""&&(d.app_id=parseInt(e(t).app_id.trim()),b=!0),e(t).installation_id.trim()!==""&&(d.installation_id=parseInt(e(t).installation_id.trim()),b=!0),e(t).private_key_bytes!=="")try{const m=atob(e(t).private_key_bytes);d.private_key_bytes=Array.from(m,l=>l.charCodeAt(0)),b=!0}catch{}b&&(r.app=d)}return r}async function vt(){try{if(e(x)==="github")await ve.createGithubCredentials(e(t));else if(e(x)==="gitea")await ve.createGiteaCredentials(e(t));else throw new Error("Please select a forge type");ke.success("Credentials Created",`Credentials ${e(t).name} have been created successfully.`),P()}catch(r){n(Ce,Ve(r))}}async function ft(){if(!(!e(g)||!e(g).id))try{const r=bt();if(Object.keys(r).length===0){ke.info("No Changes","No fields were modified."),P();return}e(g).forge_type==="github"?await ve.updateGithubCredentials(e(g).id,r):await ve.updateGiteaCredentials(e(g).id,r),ke.success("Credentials Updated",`Credentials ${e(g)?.name||"Unknown"} have been updated successfully.`),P()}catch(r){n(Ce,Ve(r))}}async function mt(){if(!(!e(M)||!e(M).id))try{e(M).forge_type==="github"?await ve.deleteGithubCredentials(e(M).id):await ve.deleteGiteaCredentials(e(M).id),ke.success("Credentials Deleted",`Credentials ${e(M)?.name||"Unknown"} have been deleted successfully.`)}catch(r){const d=Ve(r);ke.error("Delete Failed",d)}finally{P()}}function Oe(r){const b=r.target.files?.[0];if(!b){_(t,e(t).private_key_bytes="");return}const m=new FileReader;m.onload=l=>{const h=l.target?.result;_(t,e(t).private_key_bytes=btoa(h))},m.readAsText(b)}function Je(){return!e(t).name||!e(t).description||!e(t).endpoint?!1:e(t).auth_type===p.PAT?!!e(t).oauth2_token:!!e(t).app_id&&!!e(t).installation_id&&!!e(t).private_key_bytes}function Qe(){return!e(t).name.trim()||!e(t).description.trim()?!1:e(ee)&&e(g)?e(g)["auth-type"]===p.PAT?!!e(t).oauth2_token.trim():!!e(t).app_id.trim()&&!!e(t).installation_id.trim()&&!!e(t).private_key_bytes:!0}function xt(r){return e(J).find(b=>b.name===r)?.endpoint_type||""}function _t(r){return xt(r)==="gitea"}const ht=[{key:"name",title:"Name",cellComponent:it,cellProps:{field:"name"}},{key:"description",title:"Description",cellComponent:it,cellProps:{field:"description",type:"description"}},{key:"endpoint",title:"Endpoint",cellComponent:ir},{key:"auth_type",title:"Auth Type",cellComponent:nr,cellProps:{statusType:"custom",statusField:"auth-type"}},{key:"actions",title:"Actions",align:"right",cellComponent:er}],kt={entityType:"credential",primaryText:{field:"name",isClickable:!1},secondaryText:{field:"description"},customInfo:[{icon:r=>Ke(r?.forge_type||"unknown"),text:r=>r?.endpoint?.name||"Unknown"}],badges:[{type:"auth",field:"auth-type"}],actions:[{type:"edit",handler:r=>qe(r)},{type:"delete",handler:r=>ze(r)}]};function wt(r){n(Pe,r.detail.term),n(K,1)}function Ct(r){n(K,r.detail.page)}function Pt(r){const d=or(r.detail.perPage);n(ce,d.newPerPage),n(K,d.newCurrentPage)}function At(r){qe(r.detail.item)}function Tt(r){ze(r.detail.item)}Q(()=>(e(le),U()),()=>{(!e(le).length||U().loaded.credentials)&&n(le,U().credentials)}),Q(()=>U(),()=>{n(we,U().loading.credentials)}),Q(()=>U(),()=>{n(Ge,U().errorMessages.credentials)}),Q(()=>(e(J),U()),()=>{(!e(J).length||U().loaded.endpoints)&&n(J,U().endpoints)}),Q(()=>(e(le),e(Pe)),()=>{n(Z,rr(e(le),e(Pe)))}),Q(()=>(e(ue),e(Z),e(ce),e(K)),()=>{n(ue,Math.ceil(e(Z).length/e(ce))),e(K)>e(ue)&&e(ue)>0&&n(K,e(ue))}),Q(()=>(e(Z),e(K),e(ce)),()=>{n(He,ar(e(Z),e(K),e(ce)))}),Q(()=>(e(x),e(J)),()=>{n(Ue,e(x)?e(J).filter(r=>r.endpoint_type===e(x)):e(J))}),qt(),jt();var We=xr();f("keydown",Lt,ut),zt(r=>{St.title="Credentials - GARM"});var Be=Fe(We),Xe=o(Be);Wt(Xe,{title:"Credentials",description:"Manage authentication credentials for your GitHub and Gitea endpoints.",actionLabel:"Add Credentials",$$events:{action:gt}});var $t=a(Xe,2);{let r=Le(()=>e(Ge)||e(Ce)),d=Le(()=>!!e(Ge));Zt($t,{get columns(){return ht},get data(){return e(He)},get loading(){return e(we)},get error(){return e(r)},get searchTerm(){return e(Pe)},searchPlaceholder:"Search credentials by name, description, or endpoint...",get currentPage(){return e(K)},get perPage(){return e(ce)},get totalPages(){return e(ue)},get totalItems(){return e(Z),u(()=>e(Z).length)},itemName:"credentials",emptyIconType:"key",get showRetry(){return e(d)},get mobileCardConfig(){return kt},$$events:{search:wt,pageChange:Ct,perPageChange:Pt,retry:pt,edit:At,delete:Tt},$$slots:{"mobile-card":(b,m)=>{const l=Le(()=>m.item);var h=dr(),A=o(h),q=o(A),I=o(q),F=o(I,!0);i(I);var k=a(I,2),V=o(k,!0);i(k);var z=a(k,2),B=o(z),S=o(B);Yt(S,()=>(be(Ke),be(e(l)),u(()=>Ke(e(l).forge_type||"unknown"))));var te=a(S,2),re=o(te,!0);i(te),i(B),i(z),i(q),i(A);var ae=a(A,2),H=o(ae);{var oe=j=>{nt(j,{variant:"success",text:"PAT"})},R=j=>{nt(j,{variant:"info",text:"App"})};G(H,j=>{be(e(l)),u(()=>(e(l)["auth-type"]||"pat")==="pat")?j(oe):j(R,!1)})}var Y=a(H,2),ie=o(Y);ot(ie,{action:"edit",size:"sm",title:"Edit credentials",ariaLabel:"Edit credentials",$$events:{click:()=>qe(e(l))}});var pe=a(ie,2);ot(pe,{action:"delete",size:"sm",title:"Delete credentials",ariaLabel:"Delete credentials",$$events:{click:()=>ze(e(l))}}),i(Y),i(ae),i(h),se(()=>{W(F,(be(e(l)),u(()=>e(l).name))),W(V,(be(e(l)),u(()=>e(l).description))),W(re,(be(e(l)),u(()=>e(l).endpoint?.name||"Unknown")))}),$(b,h)}}})}i(Be);var Ze=a(Be,2);{var Et=r=>{var d=gr(),b=o(d),m=a(b,2),l=o(m),h=a(o(l),2);i(l);var A=a(l,2),q=o(A);Xt(q,{get selectedForgeType(){return e(x)},set selectedForgeType(s){n(x,s)},$$events:{select:yt},$$legacy:!0});var I=a(q,2),F=a(o(I),2);L(F),i(I);var k=a(I,2),V=a(o(k),2);rt(V),i(k);var z=a(k,2),B=a(o(z),2);se(()=>{e(t),Nt(()=>{e(Ue)})});var S=o(B);S.value=S.__value="";var te=a(S);Ht(te,1,()=>e(Ue),Rt,(s,c)=>{var v=sr(),C=o(v);i(v);var T={};se(()=>{W(C,`${e(c),u(()=>e(c).name)??""} (${e(c),u(()=>e(c).endpoint_type)??""})`),T!==(T=(e(c),u(()=>e(c).name)))&&(v.value=(v.__value=(e(c),u(()=>e(c).name)))??"")}),$(s,v)}),i(B);var re=a(B,2);{var ae=s=>{var c=lr(),v=o(c);i(c),se(()=>W(v,`Showing only ${e(x)??""} endpoints`)),$(s,c)};G(re,s=>{e(x)&&s(ae)})}i(z);var H=a(z,2),oe=a(o(H),2),R=o(oe),Y=a(R,2);i(oe);var ie=a(oe,2);{var pe=s=>{var c=cr();$(s,c)};G(ie,s=>{e(x)==="gitea"&&s(pe)})}i(H);var j=a(H,2);{var De=s=>{var c=ur(),v=a(o(c),2);L(v),i(c),N(v,()=>e(t).oauth2_token,C=>_(t,e(t).oauth2_token=C)),$(s,c)};G(j,s=>{e(D),u(()=>e(D)===p.PAT)&&s(De)})}var fe=a(j,2);{var Me=s=>{var c=pr(),v=Fe(c),C=a(o(v),2);L(C),i(v);var T=a(v,2),O=a(o(T),2);L(O),i(T);var de=a(T,2),ge=a(o(de),2),xe=o(ge),_e=a(xe,2),he=a(o(_e),2),Ie=o(he);X(),i(he),X(2),i(_e),i(ge),i(de),N(C,()=>e(t).app_id,ye=>_(t,e(t).app_id=ye)),N(O,()=>e(t).installation_id,ye=>_(t,e(t).installation_id=ye)),f("change",xe,Oe),f("click",Ie,()=>document.getElementById("private_key")?.click()),$(s,c)};G(fe,s=>{e(D),u(()=>e(D)===p.APP)&&s(Me)})}var w=a(fe,2),ne=o(w),me=a(ne,2);i(w),i(A),i(m),i(d),se((s,c,v)=>{je(R,1,`flex-1 py-2 px-4 text-sm font-medium rounded-md border focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer
|
|
${e(D),u(()=>e(D)===p.PAT?"bg-blue-600 text-white border-blue-600":"bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600")??""}
|
|
${s??""}`),Y.disabled=e(x)==="gitea",je(Y,1,`flex-1 py-2 px-4 text-sm font-medium rounded-md border focus:outline-none focus:ring-2 focus:ring-blue-500
|
|
${e(D),u(()=>e(D)===p.APP?"bg-blue-600 text-white border-blue-600":"bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600")??""}
|
|
${e(x)==="gitea"?"opacity-50 cursor-not-allowed":"cursor-pointer"}`),me.disabled=c,je(me,1,`px-4 py-2 text-sm font-medium text-white rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors
|
|
${v??""}`)},[()=>(e(t),u(()=>(e(t).endpoint&&_t(e(t).endpoint),""))),()=>u(()=>!Je()),()=>u(()=>Je()?"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500 cursor-pointer":"bg-gray-400 cursor-not-allowed")]),f("click",b,P),f("click",h,P),N(F,()=>e(t).name,s=>_(t,e(t).name=s)),N(V,()=>e(t).description,s=>_(t,e(t).description=s)),Ot(B,()=>e(t).endpoint,s=>_(t,e(t).endpoint=s)),f("click",R,()=>Ye(p.PAT)),f("click",Y,()=>Ye(p.APP)),f("click",ne,P),f("submit",A,at(vt)),$(r,d)};G(Ze,r=>{e(Ae)&&r(Et)})}var et=a(Ze,2);{var Dt=r=>{var d=fr(),b=o(d),m=a(b,2),l=o(m),h=o(l),A=a(o(h),2),q=o(A);i(A),i(h);var I=a(h,2);i(l);var F=a(l,2),k=o(F),V=a(o(k),2);L(V),i(k);var z=a(k,2),B=a(o(z),2);rt(B),i(z);var S=a(z,2),te=a(o(S),2);L(te),X(2),i(S);var re=a(S,2),ae=a(o(re),2),H=o(ae),oe=o(H,!0);i(H),i(ae),X(2),i(re);var R=a(re,2),Y=o(R),ie=o(Y);L(ie),X(2),i(Y),X(2),i(R);var pe=a(R,2);{var j=w=>{var ne=vr(),me=Fe(ne);{var s=C=>{var T=yr(),O=a(o(T),2);L(O),i(T),N(O,()=>e(t).oauth2_token,de=>_(t,e(t).oauth2_token=de)),$(C,T)};G(me,C=>{e(g),u(()=>e(g)["auth-type"]===p.PAT)&&C(s)})}var c=a(me,2);{var v=C=>{var T=br(),O=Fe(T),de=a(o(O),2);L(de),i(O);var ge=a(O,2),xe=a(o(ge),2);L(xe),i(ge);var _e=a(ge,2),he=a(o(_e),2),Ie=o(he),ye=a(Ie,2),tt=a(o(ye),2),Ft=o(tt);X(),i(tt),X(2),i(ye),i(he),i(_e),N(de,()=>e(t).app_id,Se=>_(t,e(t).app_id=Se)),N(xe,()=>e(t).installation_id,Se=>_(t,e(t).installation_id=Se)),f("change",Ie,Oe),f("click",Ft,()=>document.getElementById("edit_private_key")?.click()),$(C,T)};G(c,C=>{e(g),u(()=>e(g)["auth-type"]===p.APP)&&C(v)})}$(w,ne)};G(pe,w=>{e(ee)&&w(j)})}var De=a(pe,2),fe=o(De),Me=a(fe,2);i(De),i(F),i(m),i(d),se((w,ne)=>{W(q,`Update credentials for ${e(g),u(()=>e(g)?.name||"Unknown")??""}`),Jt(te,(e(t),u(()=>e(t).endpoint))),W(oe,(e(g),u(()=>(e(g)?.["auth-type"]||p.PAT)===p.PAT?"Personal Access Token (PAT)":"GitHub App"))),Me.disabled=w,je(Me,1,`px-4 py-2 text-sm font-medium text-white rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors
|
|
${ne??""}`)},[()=>u(()=>!Qe()),()=>u(()=>Qe()?"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500 cursor-pointer":"bg-gray-400 cursor-not-allowed")]),f("click",b,P),f("click",I,P),N(V,()=>e(t).name,w=>_(t,e(t).name=w)),N(B,()=>e(t).description,w=>_(t,e(t).description=w)),Qt(ie,()=>e(ee),w=>n(ee,w)),f("click",fe,P),f("submit",F,at(ft)),$(r,d)};G(et,r=>{e(Te)&&e(g)&&r(Dt)})}var Mt=a(et,2);{var It=r=>{var d=mr(),b=o(d),m=a(b,2),l=o(m),h=o(l),A=a(o(h),2),q=a(o(A),2),I=o(q);i(q),i(A),i(h),i(l);var F=a(l,2),k=o(F),V=a(k,2);i(F),i(m),i(d),se(()=>W(I,`Are you sure you want to delete the credentials "${e(M),u(()=>e(M)?.name||"Unknown")??""}"? This action cannot be undone.`)),f("click",b,P),f("click",k,P),f("click",V,mt),$(r,d)};G(Mt,r=>{e($e)&&e(M)&&r(It)})}$(dt,We),Bt(),ct()}export{zr as component};
|