Each control-plane kind has one store-owned TanStack form, so edits survive navigation and the save bar submits every dirty section. Shared editors emit new values, map entries are written whole, unset resources stay null, and the container runtime page warns when max uptime is under the task limit.
1 line
6.2 KiB
JavaScript
1 line
6.2 KiB
JavaScript
import{A as e,C as t,Ct as n,D as r,M as i,S as a,Tt as o,Xt as s,_t as c,b as l,dt as u,ir as d,jn as f,k as p,l as m,t as h,x as g,xn as _,y as v}from"./PageHeader.js";import{A as y,r as b,rt as x}from"./createLucideIcon.js";import{t as S}from"./input.js";import{r as C}from"./alert.js";import{G as w,I as T,K as E,W as D,a as O,w as k,z as A}from"./index.js";var j={key:0,class:`text-fg-subtle`},M={key:1,role:`alert`,class:`mb-3 text-danger`},N={key:2,class:`mb-3 rounded-lg border border-border p-3`},P={key:3,class:`text-fg-subtle`},F={key:4,class:`divide-y divide-border`,"aria-label":`API tokens`},I={class:`flex-1 truncate text-xs`},L={class:`text-xs text-fg-subtle`},R=i({__name:`PersonalTokensCard`,setup(i){let o=_(!1),h=_([]),v=_(``),x=_(``),C=_(!1);async function w(e){C.value=!0;try{await e(),x.value=``}catch(e){x.value=String(e.message||e)}finally{C.value=!1}}let E=()=>w(async()=>{let e=await b.tokens();o.value=e?.available??!1,h.value=e?.tokens??[]}),D=()=>w(async()=>{v.value=(await b.createToken())?.token??``,await E()}),O=e=>w(async()=>{await b.revokeToken(e),await E()});return u(E),(i,u)=>(c(),g(f(k),{title:`API tokens`,description:o.value?`Send it as Authorization: Bearer <token>.`:void 0},r({default:s(()=>[!o.value&&!C.value&&!x.value?(c(),t(`p`,j,`Personal tokens need a signed-in person.`)):a(``,!0),x.value?(c(),t(`p`,M,d(x.value),1)):a(``,!0),v.value?(c(),t(`div`,N,[u[2]||=l(`p`,{class:`mb-2 text-xs`},`Not shown again.`,-1),e(f(S),{"model-value":v.value,readonly:``,"aria-label":`New token`,onFocus:u[0]||=e=>e.target.select()},null,8,[`model-value`])])):a(``,!0),o.value&&!h.value.length&&!C.value&&!x.value?(c(),t(`p`,P,`No tokens yet.`)):a(``,!0),h.value.length?(c(),t(`ul`,F,[(c(!0),t(m,null,n(h.value,n=>(c(),t(`li`,{key:n.id,class:`flex items-center gap-3 py-2`},[l(`code`,I,d(n.id.slice(0,12)),1),l(`span`,L,[e(f(T),{at:n.created_at},null,8,[`at`])]),e(f(y),{variant:`ghost`,size:`sm`,class:`text-danger`,disabled:C.value,onClick:e=>O(n.id)},{default:s(()=>[...u[3]||=[p(`Revoke`,-1)]]),_:1},8,[`disabled`,`onClick`])]))),128))])):a(``,!0)]),_:2},[o.value?{name:`action`,fn:s(()=>[e(f(y),{size:`sm`,disabled:C.value,onClick:D},{default:s(()=>[e(f(A),{"data-icon":`inline-start`}),u[1]||=p(`New token`,-1)]),_:1},8,[`disabled`])]),key:`0`}:void 0]),1032,[`description`]))}}),z={class:`mx-auto max-w-[80ch]`},B={class:`text-sm text-fg-muted`},V={key:1,role:`alert`,class:`mb-4 text-sm text-danger`},H={key:0,class:`mb-3 divide-y divide-border`},U={class:`min-w-0 flex-1 truncate`},W={key:2,class:`text-fg-muted`},G={key:0,class:`break-all rounded-md border border-border p-3 font-mono`,role:`status`},K={class:`flex justify-end border-t border-border pt-3`},q=i({__name:`AccountPage`,setup(r){let i=_(``),T=()=>J(async()=>{i.value=(await b.recoveryCode()).code}),A=w(),j=_([]),M=_(``),N=_(!1),P=_(``),F=_(``),I=_(``),L=v(()=>D(A.status?.public_url??``));async function q(){try{j.value=(await b.passkeys()).passkeys}catch(e){M.value=String(e.message||e)}}u(q);async function J(e){N.value=!0,M.value=``;try{await e()}catch(e){M.value=String(e.message||e)}finally{N.value=!1}}let Y=()=>J(async()=>{await E(!0,P.value),P.value=``,await q()}),X=e=>J(async()=>{await b.deletePasskey(e),await q()}),Z=()=>J(async()=>{await b.changePassword(F.value,I.value),F.value=I.value=``,window.location.assign(`/`)});return(r,u)=>{let _=o(`RouterLink`);return c(),t(`div`,z,[e(h,{title:`Your account`},{default:s(()=>[l(`span`,B,d(f(A).status?.user?.display_name),1)]),_:1}),r.$route.query.welcome?(c(),g(f(C),{key:0,class:`mb-4`},{default:s(()=>[u[5]||=p(`Your organisation and admin account are ready. Add a passkey below, `,-1),e(_,{class:`underline`,to:`/org/members`},{default:s(()=>[...u[3]||=[p(`add members`,-1)]]),_:1}),u[6]||=p(`, or `,-1),e(_,{class:`underline`,to:`/settings/authentication`},{default:s(()=>[...u[4]||=[p(`configure OIDC`,-1)]]),_:1}),u[7]||=p(`.`,-1)]),_:1})):a(``,!0),M.value?(c(),t(`p`,V,[p(d(M.value)+` `,1),u[8]||=l(`a`,{class:`underline`,href:`/?reauth=1`},`Sign in again`,-1)])):a(``,!0),e(f(k),{title:`Passkeys`},{default:s(()=>[j.value.length?(c(),t(`ul`,H,[(c(!0),t(m,null,n(j.value,n=>(c(),t(`li`,{key:n.id,class:`flex items-center gap-3 py-2`},[l(`span`,U,d(n.name),1),e(f(y),{variant:`ghost`,size:`sm`,class:`text-danger`,disabled:N.value,onClick:e=>X(n.id)},{default:s(()=>[...u[9]||=[p(`Remove`,-1)]]),_:1},8,[`disabled`,`onClick`])]))),128))])):a(``,!0),L.value?(c(),t(`form`,{key:1,class:`flex flex-wrap gap-2`,onSubmit:x(Y,[`prevent`])},[e(f(S),{modelValue:P.value,"onUpdate:modelValue":u[0]||=e=>P.value=e,"aria-label":`Passkey name`,placeholder:`Passkey name (optional)`,maxlength:`200`,class:`min-w-40 flex-1`},null,8,[`modelValue`]),e(f(y),{type:`submit`,disabled:N.value},{default:s(()=>[...u[10]||=[p(`Add passkey`,-1)]]),_:1},8,[`disabled`])],32)):(c(),t(`p`,W,[u[12]||=p(`Passkeys need an HTTPS domain or localhost. Set the instance URL in `,-1),e(_,{class:`underline`,to:`/settings/authentication`},{default:s(()=>[...u[11]||=[p(`Authentication settings`,-1)]]),_:1}),u[13]||=p(`.`,-1)]))]),_:1}),e(R),e(f(k),{title:`Recovery code`,description:`Shown once. Use it to reset your password if you lose access. A new code replaces the old one.`},{action:s(()=>[e(f(y),{size:`sm`,disabled:N.value,onClick:T},{default:s(()=>[...u[14]||=[p(`Generate`,-1)]]),_:1},8,[`disabled`])]),default:s(()=>[i.value?(c(),t(`p`,G,d(i.value),1)):a(``,!0)]),_:1}),e(f(k),{title:`Change password`,description:`Changing your password signs out all your sessions.`},{default:s(()=>[l(`form`,{onSubmit:x(Z,[`prevent`])},[e(f(O),{label:`Current password`,for:`current-password`},{default:s(()=>[e(f(S),{id:`current-password`,modelValue:F.value,"onUpdate:modelValue":u[1]||=e=>F.value=e,type:`password`,autocomplete:`current-password`,required:``,class:`max-w-sm`},null,8,[`modelValue`])]),_:1}),e(f(O),{label:`New password`,for:`new-password`},{default:s(()=>[e(f(S),{id:`new-password`,modelValue:I.value,"onUpdate:modelValue":u[2]||=e=>I.value=e,type:`password`,autocomplete:`new-password`,required:``,minlength:`15`,maxlength:`1024`,class:`max-w-sm`},null,8,[`modelValue`])]),_:1}),l(`div`,K,[e(f(y),{type:`submit`,disabled:N.value},{default:s(()=>[...u[15]||=[p(`Change password`,-1)]]),_:1},8,[`disabled`])])],32)]),_:1})])}}});export{q as default}; |