@samyx/preview-stacks-ui 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActionButton.vue_vue_type_script_setup_true_lang-D8Xlp6c9.js → ActionButton.vue_vue_type_script_setup_true_lang-AGS1FKpY.js} +2 -2
- package/dist/assets/{ActionButton.vue_vue_type_script_setup_true_lang-D8Xlp6c9.js.map → ActionButton.vue_vue_type_script_setup_true_lang-AGS1FKpY.js.map} +1 -1
- package/dist/assets/{AxesTab-BWzsbFAx.js → AxesTab-DlGjhnwi.js} +2 -2
- package/dist/assets/{AxesTab-BWzsbFAx.js.map → AxesTab-DlGjhnwi.js.map} +1 -1
- package/dist/assets/{ConfigTab-ucr87rD6.js → ConfigTab-BiqFZrvm.js} +2 -2
- package/dist/assets/{ConfigTab-ucr87rD6.js.map → ConfigTab-BiqFZrvm.js.map} +1 -1
- package/dist/assets/{ConfigView-BbRYGyvZ.js → ConfigView-CsQJIt52.js} +2 -2
- package/dist/assets/{ConfigView-BbRYGyvZ.js.map → ConfigView-CsQJIt52.js.map} +1 -1
- package/dist/assets/{ConflictNote.vue_vue_type_script_setup_true_lang-DDt6qe65.js → ConflictNote.vue_vue_type_script_setup_true_lang-BxG7GEFo.js} +2 -2
- package/dist/assets/{ConflictNote.vue_vue_type_script_setup_true_lang-DDt6qe65.js.map → ConflictNote.vue_vue_type_script_setup_true_lang-BxG7GEFo.js.map} +1 -1
- package/dist/assets/{DangerTab-BimKNJab.js → DangerTab-COq-R4Dz.js} +2 -2
- package/dist/assets/{DangerTab-BimKNJab.js.map → DangerTab-COq-R4Dz.js.map} +1 -1
- package/dist/assets/{DashboardView-DK0qDo-f.js → DashboardView-DTI9n2-Z.js} +2 -2
- package/dist/assets/{DashboardView-DK0qDo-f.js.map → DashboardView-DTI9n2-Z.js.map} +1 -1
- package/dist/assets/{DeploymentDetailView-BcImKApM.js → DeploymentDetailView-BBMtQ9vE.js} +2 -2
- package/dist/assets/{DeploymentDetailView-BcImKApM.js.map → DeploymentDetailView-BBMtQ9vE.js.map} +1 -1
- package/dist/assets/{DeploymentsView-Cx9BqQ8Q.js → DeploymentsView-BCXfIFud.js} +2 -2
- package/dist/assets/{DeploymentsView-Cx9BqQ8Q.js.map → DeploymentsView-BCXfIFud.js.map} +1 -1
- package/dist/assets/{DialogTrigger-nWkfUj3N.js → DialogTrigger-D4yBGqUf.js} +2 -2
- package/dist/assets/{DialogTrigger-nWkfUj3N.js.map → DialogTrigger-D4yBGqUf.js.map} +1 -1
- package/dist/assets/{EquivalentCommand-D92xDU0_.js → EquivalentCommand-D0dyw0Wd.js} +2 -2
- package/dist/assets/{EquivalentCommand-D92xDU0_.js.map → EquivalentCommand-D0dyw0Wd.js.map} +1 -1
- package/dist/assets/{ErrorNote.vue_vue_type_script_setup_true_lang-DVbGiVTB.js → ErrorNote.vue_vue_type_script_setup_true_lang-BrBUwK6j.js} +2 -2
- package/dist/assets/{ErrorNote.vue_vue_type_script_setup_true_lang-DVbGiVTB.js.map → ErrorNote.vue_vue_type_script_setup_true_lang-BrBUwK6j.js.map} +1 -1
- package/dist/assets/{HelpModal.vue_vue_type_script_setup_true_lang-CSOdBT2E.js → HelpModal.vue_vue_type_script_setup_true_lang-CTbPBhLs.js} +2 -2
- package/dist/assets/{HelpModal.vue_vue_type_script_setup_true_lang-CSOdBT2E.js.map → HelpModal.vue_vue_type_script_setup_true_lang-CTbPBhLs.js.map} +1 -1
- package/dist/assets/{JobDetailView-B1sXXVJ5.js → JobDetailView-DIEijrhl.js} +2 -2
- package/dist/assets/{JobDetailView-B1sXXVJ5.js.map → JobDetailView-DIEijrhl.js.map} +1 -1
- package/dist/assets/{JobsView-DjP5lXHk.js → JobsView-Dw4-yNCj.js} +2 -2
- package/dist/assets/{JobsView-DjP5lXHk.js.map → JobsView-Dw4-yNCj.js.map} +1 -1
- package/dist/assets/{LogViewer.vue_vue_type_script_setup_true_lang-Bhy_5cyC.js → LogViewer.vue_vue_type_script_setup_true_lang-B3YVBpn-.js} +2 -2
- package/dist/assets/{LogViewer.vue_vue_type_script_setup_true_lang-Bhy_5cyC.js.map → LogViewer.vue_vue_type_script_setup_true_lang-B3YVBpn-.js.map} +1 -1
- package/dist/assets/{LoginView-CIkI9Qm_.js → LoginView-NgcWC4N0.js} +2 -2
- package/dist/assets/{LoginView-CIkI9Qm_.js.map → LoginView-NgcWC4N0.js.map} +1 -1
- package/dist/assets/{LogsTab-D8zhR7Eb.js → LogsTab-oWjSPx9O.js} +2 -2
- package/dist/assets/{LogsTab-D8zhR7Eb.js.map → LogsTab-oWjSPx9O.js.map} +1 -1
- package/dist/assets/{NotFoundView-aUtqh2Qi.js → NotFoundView-DnQQJSu_.js} +2 -2
- package/dist/assets/{NotFoundView-aUtqh2Qi.js.map → NotFoundView-DnQQJSu_.js.map} +1 -1
- package/dist/assets/{NotifiersView-aRHInxVx.js → NotifiersView-CvP3L81J.js} +2 -2
- package/dist/assets/{NotifiersView-aRHInxVx.js.map → NotifiersView-CvP3L81J.js.map} +1 -1
- package/dist/assets/{OverviewTab-ChCj5LAj.js → OverviewTab-C10J0ywh.js} +2 -2
- package/dist/assets/{OverviewTab-ChCj5LAj.js.map → OverviewTab-C10J0ywh.js.map} +1 -1
- package/dist/assets/{PublicLogsView-DIWJH7qL.js → PublicLogsView-DqMmMbtf.js} +2 -2
- package/dist/assets/{PublicLogsView-DIWJH7qL.js.map → PublicLogsView-DqMmMbtf.js.map} +1 -1
- package/dist/assets/{RefreshButton.vue_vue_type_script_setup_true_lang-P7VwWcRa.js → RefreshButton.vue_vue_type_script_setup_true_lang-8Tme6z_i.js} +2 -2
- package/dist/assets/{RefreshButton.vue_vue_type_script_setup_true_lang-P7VwWcRa.js.map → RefreshButton.vue_vue_type_script_setup_true_lang-8Tme6z_i.js.map} +1 -1
- package/dist/assets/{RegistriesView-D2aCsYIu.js → RegistriesView-DIa3mCyc.js} +2 -2
- package/dist/assets/{RegistriesView-D2aCsYIu.js.map → RegistriesView-DIa3mCyc.js.map} +1 -1
- package/dist/assets/{RelativeTime.vue_vue_type_script_setup_true_lang-NGvUfuKC.js → RelativeTime.vue_vue_type_script_setup_true_lang-eoX10cnp.js} +2 -2
- package/dist/assets/{RelativeTime.vue_vue_type_script_setup_true_lang-NGvUfuKC.js.map → RelativeTime.vue_vue_type_script_setup_true_lang-eoX10cnp.js.map} +1 -1
- package/dist/assets/{RequiresTab-3BhU5BHd.js → RequiresTab-Dde68lOF.js} +2 -2
- package/dist/assets/{RequiresTab-3BhU5BHd.js.map → RequiresTab-Dde68lOF.js.map} +1 -1
- package/dist/assets/{RouteTarget.vue_vue_type_script_setup_true_lang-Caee0wEB.js → RouteTarget.vue_vue_type_script_setup_true_lang-DgcXRES0.js} +2 -2
- package/dist/assets/{RouteTarget.vue_vue_type_script_setup_true_lang-Caee0wEB.js.map → RouteTarget.vue_vue_type_script_setup_true_lang-DgcXRES0.js.map} +1 -1
- package/dist/assets/{RoutingView-T9afX8_M.js → RoutingView-oXXCIL07.js} +2 -2
- package/dist/assets/{RoutingView-T9afX8_M.js.map → RoutingView-oXXCIL07.js.map} +1 -1
- package/dist/assets/{RuntimeTab-Bh2gGuhj.js → RuntimeTab-DFxU8OLh.js} +2 -2
- package/dist/assets/{RuntimeTab-Bh2gGuhj.js.map → RuntimeTab-DFxU8OLh.js.map} +1 -1
- package/dist/assets/{SelectMenu.vue_vue_type_script_setup_true_lang-BtHqT6G1.js → SelectMenu.vue_vue_type_script_setup_true_lang-Bjd8KlYw.js} +2 -2
- package/dist/assets/{SelectMenu.vue_vue_type_script_setup_true_lang-BtHqT6G1.js.map → SelectMenu.vue_vue_type_script_setup_true_lang-Bjd8KlYw.js.map} +1 -1
- package/dist/assets/SettingsView-DwSmnNbU.js +2 -0
- package/dist/assets/SettingsView-DwSmnNbU.js.map +1 -0
- package/dist/assets/{SkeletonList.vue_vue_type_script_setup_true_lang-BmeRGmxf.js → SkeletonList.vue_vue_type_script_setup_true_lang-CvoOnzDO.js} +2 -2
- package/dist/assets/{SkeletonList.vue_vue_type_script_setup_true_lang-BmeRGmxf.js.map → SkeletonList.vue_vue_type_script_setup_true_lang-CvoOnzDO.js.map} +1 -1
- package/dist/assets/{SpecDetailView-Bd4Hx-bI.js → SpecDetailView-D10gsC8W.js} +2 -2
- package/dist/assets/{SpecDetailView-Bd4Hx-bI.js.map → SpecDetailView-D10gsC8W.js.map} +1 -1
- package/dist/assets/{SpecsView-B9qQPzkG.js → SpecsView-BU962Blv.js} +2 -2
- package/dist/assets/{SpecsView-B9qQPzkG.js.map → SpecsView-BU962Blv.js.map} +1 -1
- package/dist/assets/{SsoMark.vue_vue_type_script_setup_true_lang-BBiCq_4w.js → SsoMark.vue_vue_type_script_setup_true_lang-BzRkYwRn.js} +2 -2
- package/dist/assets/{SsoMark.vue_vue_type_script_setup_true_lang-BBiCq_4w.js.map → SsoMark.vue_vue_type_script_setup_true_lang-BzRkYwRn.js.map} +1 -1
- package/dist/assets/SsoView-AzBjKwF_.css +1 -0
- package/dist/assets/SsoView-BJO4vMED.js +2 -0
- package/dist/assets/SsoView-BJO4vMED.js.map +1 -0
- package/dist/assets/{StateBadge.vue_vue_type_script_setup_true_lang-nD6Zdx0q.js → StateBadge.vue_vue_type_script_setup_true_lang-CzLuB-ZI.js} +2 -2
- package/dist/assets/{StateBadge.vue_vue_type_script_setup_true_lang-nD6Zdx0q.js.map → StateBadge.vue_vue_type_script_setup_true_lang-CzLuB-ZI.js.map} +1 -1
- package/dist/assets/{SubmitView-D-jg5Wxy.js → SubmitView-CChPoIvR.js} +2 -2
- package/dist/assets/{SubmitView-D-jg5Wxy.js.map → SubmitView-CChPoIvR.js.map} +1 -1
- package/dist/assets/{SwarmView-CqFndUrV.js → SwarmView-xPA-5INc.js} +2 -2
- package/dist/assets/{SwarmView-CqFndUrV.js.map → SwarmView-xPA-5INc.js.map} +1 -1
- package/dist/assets/{Teleport-I0XiM19H.js → Teleport-Bg1yDCl9.js} +2 -2
- package/dist/assets/{Teleport-I0XiM19H.js.map → Teleport-Bg1yDCl9.js.map} +1 -1
- package/dist/assets/{TerminalTab-Dleba0ru.js → TerminalTab-jUQlwJpM.js} +2 -2
- package/dist/assets/{TerminalTab-Dleba0ru.js.map → TerminalTab-jUQlwJpM.js.map} +1 -1
- package/dist/assets/{UsersView-BrZbuuOg.js → UsersView-DcjfdY6Q.js} +2 -2
- package/dist/assets/{UsersView-BrZbuuOg.js.map → UsersView-DcjfdY6Q.js.map} +1 -1
- package/dist/assets/{VarEditor.vue_vue_type_script_setup_true_lang-uPHU_Ugp.js → VarEditor.vue_vue_type_script_setup_true_lang-gohbG3IW.js} +2 -2
- package/dist/assets/{VarEditor.vue_vue_type_script_setup_true_lang-uPHU_Ugp.js.map → VarEditor.vue_vue_type_script_setup_true_lang-gohbG3IW.js.map} +1 -1
- package/dist/assets/{VarIO-BldCQ6Xx.js → VarIO-gtGLr9Br.js} +2 -2
- package/dist/assets/{VarIO-BldCQ6Xx.js.map → VarIO-gtGLr9Br.js.map} +1 -1
- package/dist/assets/{VariablesView-CQp0T7Q6.js → VariablesView-DSXnmTTH.js} +2 -2
- package/dist/assets/{VariablesView-CQp0T7Q6.js.map → VariablesView-DSXnmTTH.js.map} +1 -1
- package/dist/assets/{index-Cqe_7QZw.js → index-DB2WhG8N.js} +3 -3
- package/dist/assets/{index-Cqe_7QZw.js.map → index-DB2WhG8N.js.map} +1 -1
- package/dist/assets/{useDeployment-BDbkdxpo.js → useDeployment-B7wpJY-X.js} +2 -2
- package/dist/assets/{useDeployment-BDbkdxpo.js.map → useDeployment-B7wpJY-X.js.map} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/SettingsView-DIKjdBdy.js +0 -2
- package/dist/assets/SettingsView-DIKjdBdy.js.map +0 -1
- package/dist/assets/SsoView-CltdTdwt.js +0 -2
- package/dist/assets/SsoView-CltdTdwt.js.map +0 -1
- package/dist/assets/SsoView-JmlPQGWM.css +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xterm-D6Mng-DB.js","assets/_commonjsHelpers-CqkleIqs.js","assets/addon-fit-CevVMrUA.js","assets/xterm-DYP7pi_n.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{d as W,N as O,Q as F,c as m,a as t,f as a,e as E,w as H,_ as j,z as M,g as _,t as P,j as c,k as V,p as Q,C as X,W as S,n as Y,X as R,o as p}from"./index-
|
|
3
|
-
//# sourceMappingURL=TerminalTab-
|
|
2
|
+
import{d as W,N as O,Q as F,c as m,a as t,f as a,e as E,w as H,_ as j,z as M,g as _,t as P,j as c,k as V,p as Q,C as X,W as S,n as Y,X as R,o as p}from"./index-DB2WhG8N.js";import{_ as G}from"./ErrorNote.vue_vue_type_script_setup_true_lang-BrBUwK6j.js";import{_ as U}from"./SelectMenu.vue_vue_type_script_setup_true_lang-Bjd8KlYw.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./Teleport-Bg1yDCl9.js";const K={class:"stack"},Z={class:"banner warn"},ee={class:"row wrap",style:{gap:"var(--s3)","align-items":"end"}},ne={class:"field"},oe={class:"field"},te=["disabled"],le={key:2,class:"badge ok"},se={key:1,class:"hint"},ae={key:2,class:"hint"},ie=["data-state"],re=W({__name:"TerminalTab",setup(ue){const k=Y(),C=V(()=>String(k.params.id)),B=["sh","bash","ash","zsh","fish"],$=c(null),f=c(""),u=c(""),y=c("sh"),n=c("idle"),h=c(""),v=c(null),w=R(null),I=R(null),b=R(null);let i=null;const D=V(()=>g.value.map(o=>({value:o.name,label:o.name,hint:o.service??void 0}))),g=V(()=>{var o;return((o=$.value)==null?void 0:o.containers.filter(e=>e.state==="running"))??[]});async function x(){var d;const o=await Q.get(`/api/deployments/${encodeURIComponent(C.value)}/runtime`);if(!o.ok){f.value=X(o,"list this deployment's containers");return}if(f.value="",$.value=o.body,u.value)return;const e=typeof k.query.container=="string"?k.query.container:"",l=g.value.find(T=>T.name===e);u.value=(l==null?void 0:l.name)??((d=g.value[0])==null?void 0:d.name)??""}x();async function q(){var L;if(n.value==="connecting"||n.value==="open")return;h.value="",n.value="connecting";const[{Terminal:o},{FitAddon:e}]=await Promise.all([S(()=>import("./xterm-D6Mng-DB.js").then(s=>s.x),__vite__mapDeps([0,1])),S(()=>import("./addon-fit-CevVMrUA.js").then(s=>s.a),__vite__mapDeps([2,1]))]);await S(()=>Promise.resolve({}),__vite__mapDeps([3])),(L=w.value)==null||L.dispose();const l=new o({convertEol:!0,fontSize:13,fontFamily:"var(--font-mono, ui-monospace, monospace)",cursorBlink:!0,theme:{background:"#0b0e14"}}),d=new e;l.loadAddon(d),v.value&&(v.value.innerHTML="",l.open(v.value),d.fit()),w.value=l,I.value=d,i==null||i.disconnect(),i=new ResizeObserver(()=>{try{d.fit()}catch{}}),v.value&&i.observe(v.value);const T=location.protocol==="https:"?"wss":"ws",z=new URLSearchParams({container:u.value,shell:y.value}),r=new WebSocket(`${T}://${location.host}/api/deployments/${encodeURIComponent(C.value)}/terminal?${z}`);r.binaryType="arraybuffer",b.value=r,r.onopen=()=>{n.value="open",l.focus()},r.onmessage=s=>l.write(typeof s.data=="string"?s.data:new Uint8Array(s.data)),r.onclose=s=>{n.value="closed",h.value=s.reason||(s.code===1006?"the connection dropped (the upgrade may have been refused)":`code ${s.code}`)},r.onerror=()=>{n.value==="connecting"&&(h.value="could not open the connection")},l.onData(s=>{r.readyState===WebSocket.OPEN&&r.send(s)})}function N(){var o;(o=b.value)==null||o.close(1e3,"closed by the operator")}function A(){var o,e;i==null||i.disconnect(),i=null,(o=b.value)==null||o.close(),b.value=null,(e=w.value)==null||e.dispose(),w.value=null}return O([u,y],()=>{(n.value==="open"||n.value==="connecting")&&N()}),O(C,()=>{A(),n.value="idle",x()}),F(A),(o,e)=>(p(),m("section",K,[t("div",Z,[e[3]||(e[3]=t("b",null,"No TTY.",-1)),e[4]||(e[4]=a(" The shell runs without a terminal device, so there is no prompt, no ",-1)),e[5]||(e[5]=t("code",null,"Ctrl-C",-1)),e[6]||(e[6]=a(", and no full-screen programs (",-1)),e[7]||(e[7]=t("code",null,"top",-1)),e[8]||(e[8]=a(", ",-1)),e[9]||(e[9]=t("code",null,"vim",-1)),e[10]||(e[10]=a("). Type a command and press Enter. ",-1)),E(j,{label:"why"},{default:H(()=>[...e[2]||(e[2]=[a(" A pseudo-terminal needs a wrapper (",-1),t("code",null,"script",-1),a(") whose flags differ across distributions, and it was never verified on a real host — so pstack ships the half it can stand behind. Everything an operator usually opens a shell for (",-1),t("code",null,"ls",-1),a(", ",-1),t("code",null,"cat",-1),a(", ",-1),t("code",null,"env",-1),a(", ",-1),t("code",null,"psql",-1),a(", a migration) works. ",-1)])]),_:1})]),f.value?(p(),M(G,{key:0,text:f.value,title:"Could not list this deployment's containers."},null,8,["text"])):_("",!0),t("div",ee,[t("label",ne,[e[11]||(e[11]=t("span",null,"Container",-1)),E(U,{modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=l=>u.value=l),label:"Container",disabled:n.value==="open"||n.value==="connecting",options:D.value},null,8,["modelValue","disabled","options"])]),t("label",oe,[e[12]||(e[12]=t("span",null,"Shell",-1)),E(U,{modelValue:y.value,"onUpdate:modelValue":e[1]||(e[1]=l=>y.value=l),label:"Shell",disabled:n.value==="open"||n.value==="connecting",options:B.map(l=>({value:l,label:l}))},null,8,["modelValue","disabled","options"])]),n.value!=="open"?(p(),m("button",{key:0,class:"primary",disabled:!u.value||n.value==="connecting",onClick:q},P(n.value==="connecting"?"Connecting…":"Open shell"),9,te)):(p(),m("button",{key:1,onClick:N},"Close shell")),e[14]||(e[14]=t("span",{class:"grow"},null,-1)),n.value==="open"?(p(),m("span",le,[...e[13]||(e[13]=[t("span",{class:"dot pulse"},null,-1),a("connected",-1)])])):_("",!0)]),!g.value.length&&!f.value?(p(),m("p",se," Nothing is running for this deployment, so there is nothing to open a shell in. ")):_("",!0),n.value==="closed"&&h.value?(p(),m("p",ae,"Session ended — "+P(h.value)+".",1)):_("",!0),t("div",{ref_key:"host",ref:v,class:"terminal-host","data-state":n.value},null,8,ie),e[15]||(e[15]=t("p",{class:"hint"}," Every session is recorded — who, which container, when — and the record is written when the shell opens, so a session that dies with the process still leaves one. ",-1))]))}}),fe=J(re,[["__scopeId","data-v-2d8bfa2e"]]);export{fe as default};
|
|
3
|
+
//# sourceMappingURL=TerminalTab-jUQlwJpM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";otBA0BA,MAAMA,EAAQC,EAAA,EACRC,EAAKC,EAAS,IAAM,OAAOH,EAAM,OAAO,EAAE,CAAC,EAE3CI,EAAS,CAAC,KAAM,OAAQ,MAAO,MAAO,MAAM,EAE5CC,EAAKC,EAA4B,IAAI,EACrCC,EAAYD,EAAI,EAAE,EAClBE,EAAYF,EAAI,EAAE,EAClBG,EAAQH,EAAI,IAAI,EAChBI,EAAQJ,EAA+C,MAAM,EAC7DK,EAAcL,EAAI,EAAE,EAEpBM,EAAON,EAA2B,IAAI,EAEtCO,EAAOC,EAAmD,IAAI,EAC9DC,EAAMD,EAAuD,IAAI,EACjEE,EAASF,EAA6B,IAAI,EAChD,IAAIG,EAAkC,KAEtC,MAAMC,EAAmBf,EAAS,IAChCgB,EAAQ,MAAM,IAAKC,IAAO,CAAE,MAAOA,EAAE,KAAM,MAAOA,EAAE,KAAM,KAAMA,EAAE,SAAW,QAAY,GAGrFD,EAAUhB,EAAS,WAAM,QAAAkB,EAAAhB,EAAG,QAAH,YAAAgB,EAAU,WAAW,OAAQD,GAAMA,EAAE,QAAU,aAAc,GAAE,EAE9F,eAAeE,GAAiB,OAC9B,MAAMC,EAAI,MAAMC,EAAI,IAClB,oBAAoB,mBAAmBtB,EAAG,KAAK,CAAC,YAElD,GAAI,CAACqB,EAAE,GAAI,CACThB,EAAU,MAAQkB,EAAQF,EAAG,mCAAmC,EAChE,MACF,CAGA,GAFAhB,EAAU,MAAQ,GAClBF,EAAG,MA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AmD,EAAA,QAEVf,EAAuD,gBAAvC,QAAON,CAAA,EAAY,aAAW,iBAC9CQ,EAAqB,QAAf,MAAM,QAAM,UACNtC,EAAA,QAAK,QAAjBmC,EAAA,EAAAC,EAAyF,OAAzFgB,GAAyF,IAAAZ,EAAA,MAAAA,EAAA,KAA1CF,EAA0B,QAApB,MAAM,aAAW,WAAG,YAAS,qBAG1E7B,EAAA,MAAQ,QAAM,CAAKZ,EAAA,WAA7BuC,EAEI,IAFJiB,GAAqD,mFAErD,YAESrD,EAAA,kBAAsBC,EAAA,OAA/BkC,EAAA,EAAAC,EAA+F,IAA/FkB,GAAyD,mBAAgBC,EAAGtD,EAAA,KAAW,EAAG,IAAC,aAE3FqC,EAA4D,eAAnD,OAAJ,IAAIpC,EAAO,MAAM,gBAAiB,aAAYF,EAAA,kBAEnDwC,EAAA,MAAAA,EAAA,IAAAF,EAGI,KAHD,MAAM,QAAO,uKAGhB","names":["route","useRoute","id","computed","SHELLS","rt","ref","loadError","container","shell","state","closeReason","host","term","shallowRef","fit","socket","observer","containerOptions","running","c","_a","loadContainers","r","api","problem","wanted","match","connect","Terminal","FitAddon","__vitePreload","n","t","f","proto","qs","ws","e","d","disconnect","teardown","_b","watch","onBeforeUnmount","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_cache","_createVNode","InfoHint","_createBlock","ErrorNote","_hoisted_3","_hoisted_4","SelectMenu","$event","_hoisted_5","s","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_toDisplayString"],"ignoreList":[],"sources":["../../src/views/tabs/TerminalTab.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * A shell inside one of this deployment's containers.\n *\n * THE SERVER DECIDES WHICH CONTAINER. This picker is filled from `/runtime`, i.e. the containers the\n * deployment actually owns, and the server checks the name again on upgrade — a hand-typed\n * `?container=pstack-control` is a 404 there, not here. The picker is a convenience, never the\n * boundary.\n *\n * THE COOKIE IS THE CREDENTIAL. A browser cannot set an `Authorization` header on a WebSocket, which\n * is exactly why sessions are cookies (0.10.0) — the handshake is a same-origin GET and carries the\n * session automatically. There is no token in this URL and there must never be one: a URL lands in\n * proxy logs and browser history.\n *\n * NO PTY. The server runs `docker exec -i`, not `-it`, so there is no prompt, no ^C and no `top`.\n * That is stated on the page rather than left for the operator to discover as \"the terminal is\n * broken\" — see the banner below and the comment at the head of `terminal.ts`.\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue';\nimport { useRoute } from 'vue-router';\nimport { api, problem } from '../../api/client';\nimport type { RuntimeResponse } from '../../api/types';\nimport ErrorNote from '../../components/ErrorNote.vue';\nimport InfoHint from '../../components/InfoHint.vue';\nimport SelectMenu from '../../components/SelectMenu.vue';\n\nconst route = useRoute();\nconst id = computed(() => String(route.params.id));\n\nconst SHELLS = ['sh', 'bash', 'ash', 'zsh', 'fish'];\n\nconst rt = ref<RuntimeResponse | null>(null);\nconst loadError = ref('');\nconst container = ref('');\nconst shell = ref('sh');\nconst state = ref<'idle' | 'connecting' | 'open' | 'closed'>('idle');\nconst closeReason = ref('');\n\nconst host = ref<HTMLDivElement | null>(null);\n/** shallowRef: xterm's Terminal is a large mutable object and must not be made reactive. */\nconst term = shallowRef<import('@xterm/xterm').Terminal | null>(null);\nconst fit = shallowRef<import('@xterm/addon-fit').FitAddon | null>(null);\nconst socket = shallowRef<WebSocket | null>(null);\nlet observer: ResizeObserver | null = null;\n\nconst containerOptions = computed(() =>\n running.value.map((c) => ({ value: c.name, label: c.name, hint: c.service ?? undefined })),\n);\n\nconst running = computed(() => rt.value?.containers.filter((c) => c.state === 'running') ?? []);\n\nasync function loadContainers() {\n const r = await api.get<RuntimeResponse>(\n `/api/deployments/${encodeURIComponent(id.value)}/runtime`,\n );\n if (!r.ok) {\n loadError.value = problem(r, \"list this deployment's containers\");\n return;\n }\n loadError.value = '';\n rt.value = r.body;\n if (container.value) return;\n /*\n * `?container=` is how the Containers table jumps straight to a shell here. Honoured only when it\n * names a container this deployment actually owns and is running — an unknown name falls back to\n * the first, because the alternative is a picker sitting on a container that does not exist and a\n * Connect button that 404s. (The server checks the name again on upgrade; this is convenience.)\n */\n const wanted = typeof route.query.container === 'string' ? route.query.container : '';\n const match = running.value.find((c) => c.name === wanted);\n container.value = match?.name ?? running.value[0]?.name ?? '';\n}\nvoid loadContainers();\n\nasync function connect() {\n if (state.value === 'connecting' || state.value === 'open') return;\n closeReason.value = '';\n state.value = 'connecting';\n\n // Loaded on demand, not in the app shell: xterm is ~250KB and only this tab needs it.\n const [{ Terminal }, { FitAddon }] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ]);\n await import('@xterm/xterm/css/xterm.css');\n\n term.value?.dispose();\n const t = new Terminal({\n // The OUTPUT half of the line discipline the missing pty would have provided. A real terminal\n // converts NL to CR-NL on the way out (ONLCR); without it every `\\n` moves DOWN a row without\n // returning the carriage, and `ls` renders as a staircase marching off the right edge. The input\n // half — CR to NL — is done server-side; see `crToNl` in api.ts.\n convertEol: true,\n fontSize: 13,\n fontFamily: 'var(--font-mono, ui-monospace, monospace)',\n cursorBlink: true,\n theme: { background: '#0b0e14' },\n });\n const f = new FitAddon();\n t.loadAddon(f);\n if (host.value) {\n host.value.innerHTML = '';\n t.open(host.value);\n f.fit();\n }\n term.value = t;\n fit.value = f;\n\n observer?.disconnect();\n observer = new ResizeObserver(() => {\n try {\n f.fit();\n } catch {\n /* the element is detached mid-transition */\n }\n });\n if (host.value) observer.observe(host.value);\n\n const proto = location.protocol === 'https:' ? 'wss' : 'ws';\n const qs = new URLSearchParams({ container: container.value, shell: shell.value });\n const ws = new WebSocket(\n `${proto}://${location.host}/api/deployments/${encodeURIComponent(id.value)}/terminal?${qs}`,\n );\n ws.binaryType = 'arraybuffer';\n socket.value = ws;\n\n ws.onopen = () => {\n state.value = 'open';\n t.focus();\n };\n // Bytes, not text: decoding per frame would corrupt a multi-byte character split across two\n // reads. xterm takes a Uint8Array and handles the boundary itself.\n ws.onmessage = (e) =>\n t.write(typeof e.data === 'string' ? e.data : new Uint8Array(e.data as ArrayBuffer));\n ws.onclose = (e) => {\n state.value = 'closed';\n // A close CODE alone tells an operator nothing. 1006 in particular is the browser's \"it just\n // went away\", which here almost always means the upgrade was refused.\n closeReason.value =\n e.reason || (e.code === 1006 ? 'the connection dropped (the upgrade may have been refused)' : `code ${e.code}`);\n };\n ws.onerror = () => {\n if (state.value === 'connecting') closeReason.value = 'could not open the connection';\n };\n t.onData((d) => {\n if (ws.readyState === WebSocket.OPEN) ws.send(d);\n });\n}\n\nfunction disconnect() {\n socket.value?.close(1000, 'closed by the operator');\n}\n\nfunction teardown() {\n observer?.disconnect();\n observer = null;\n socket.value?.close();\n socket.value = null;\n term.value?.dispose();\n term.value = null;\n}\n\n// Switching container or shell must not leave the old shell running against a dead view.\nwatch([container, shell], () => {\n if (state.value === 'open' || state.value === 'connecting') disconnect();\n});\nwatch(id, () => {\n teardown();\n state.value = 'idle';\n void loadContainers();\n});\nonBeforeUnmount(teardown);\n</script>\n\n<template>\n <section class=\"stack\">\n <div class=\"banner warn\">\n <b>No TTY.</b> The shell runs without a terminal device, so there is no prompt, no\n <code>Ctrl-C</code>, and no full-screen programs (<code>top</code>, <code>vim</code>). Type a\n command and press Enter.\n <InfoHint label=\"why\">\n A pseudo-terminal needs a wrapper (<code>script</code>) whose flags differ across\n distributions, and it was never verified on a real host — so pstack ships the half it can\n stand behind. Everything an operator usually opens a shell for (<code>ls</code>,\n <code>cat</code>, <code>env</code>, <code>psql</code>, a migration) works.\n </InfoHint>\n </div>\n\n <ErrorNote v-if=\"loadError\" :text=\"loadError\" title=\"Could not list this deployment's containers.\" />\n\n <div class=\"row wrap\" style=\"gap: var(--s3); align-items: end\">\n <label class=\"field\">\n <span>Container</span>\n <SelectMenu v-model=\"container\" label=\"Container\" :disabled=\"state === 'open' || state === 'connecting'\" :options=\"containerOptions\" />\n </label>\n <label class=\"field\">\n <span>Shell</span>\n <SelectMenu v-model=\"shell\" label=\"Shell\" :disabled=\"state === 'open' || state === 'connecting'\" :options=\"SHELLS.map((s) => ({ value: s, label: s }))\" />\n </label>\n <button\n v-if=\"state !== 'open'\"\n class=\"primary\"\n :disabled=\"!container || state === 'connecting'\"\n @click=\"connect\"\n >\n {{ state === 'connecting' ? 'Connecting…' : 'Open shell' }}\n </button>\n <button v-else @click=\"disconnect\">Close shell</button>\n <span class=\"grow\" />\n <span v-if=\"state === 'open'\" class=\"badge ok\"><span class=\"dot pulse\" />connected</span>\n </div>\n\n <p v-if=\"!running.length && !loadError\" class=\"hint\">\n Nothing is running for this deployment, so there is nothing to open a shell in.\n </p>\n\n <p v-if=\"state === 'closed' && closeReason\" class=\"hint\">Session ended — {{ closeReason }}.</p>\n\n <div ref=\"host\" class=\"terminal-host\" :data-state=\"state\" />\n\n <p class=\"hint\">\n Every session is recorded — who, which container, when — and the record is written when the\n shell opens, so a session that dies with the process still leaves one.\n </p>\n </section>\n</template>\n\n<style scoped>\n.terminal-host {\n min-height: 26rem;\n border: 1px solid var(--line);\n border-radius: var(--r3);\n background: #0b0e14;\n padding: var(--s2);\n overflow: hidden;\n}\n.terminal-host[data-state='idle'] {\n display: none;\n}\n</style>\n"],"file":"assets/TerminalTab-Dleba0ru.js"}
|
|
1
|
+
{"version":3,"mappings":";otBA0BA,MAAMA,EAAQC,EAAA,EACRC,EAAKC,EAAS,IAAM,OAAOH,EAAM,OAAO,EAAE,CAAC,EAE3CI,EAAS,CAAC,KAAM,OAAQ,MAAO,MAAO,MAAM,EAE5CC,EAAKC,EAA4B,IAAI,EACrCC,EAAYD,EAAI,EAAE,EAClBE,EAAYF,EAAI,EAAE,EAClBG,EAAQH,EAAI,IAAI,EAChBI,EAAQJ,EAA+C,MAAM,EAC7DK,EAAcL,EAAI,EAAE,EAEpBM,EAAON,EAA2B,IAAI,EAEtCO,EAAOC,EAAmD,IAAI,EAC9DC,EAAMD,EAAuD,IAAI,EACjEE,EAASF,EAA6B,IAAI,EAChD,IAAIG,EAAkC,KAEtC,MAAM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YAAa,SAAUhD,EAAA,QAAK,QAAeA,EAAA,QAAK,aAAoB,QAASQ,EAAA,qDAErH8B,EAGQ,QAHRW,GAGQ,CAFNT,EAAA,MAAAA,EAAA,IAAAF,EAAkB,YAAZ,QAAK,KACXG,EAA0JM,EAAA,YAArIhD,EAAA,2CAAAA,EAAK,MAAAiD,GAAE,MAAM,QAAS,SAAUhD,EAAA,QAAK,QAAeA,EAAA,QAAK,aAAoB,QAASN,EAAO,IAAKwD,IAAC,OAAeA,EAAC,MAASA,GAAC,iDAG5IlD,EAAA,QAAK,YADboC,EAOS,gBALP,MAAM,UACL,SAAQ,CAAGtC,EAAA,OAAaE,EAAA,QAAK,aAC7B,QAAOkB,CAAA,IAELlB,EAAA,QAAK,2CAAAmD,EAAA,QAEVf,EAAuD,gBAAvC,QAAON,CAAA,EAAY,aAAW,iBAC9CQ,EAAqB,QAAf,MAAM,QAAM,UACNtC,EAAA,QAAK,QAAjBmC,EAAA,EAAAC,EAAyF,OAAzFgB,GAAyF,IAAAZ,EAAA,MAAAA,EAAA,KAA1CF,EAA0B,QAApB,MAAM,aAAW,WAAG,YAAS,qBAG1E7B,EAAA,MAAQ,QAAM,CAAKZ,EAAA,WAA7BuC,EAEI,IAFJiB,GAAqD,mFAErD,YAESrD,EAAA,kBAAsBC,EAAA,OAA/BkC,EAAA,EAAAC,EAA+F,IAA/FkB,GAAyD,mBAAgBC,EAAGtD,EAAA,KAAW,EAAG,IAAC,aAE3FqC,EAA4D,eAAnD,OAAJ,IAAIpC,EAAO,MAAM,gBAAiB,aAAYF,EAAA,kBAEnDwC,EAAA,MAAAA,EAAA,IAAAF,EAGI,KAHD,MAAM,QAAO,uKAGhB","names":["route","useRoute","id","computed","SHELLS","rt","ref","loadError","container","shell","state","closeReason","host","term","shallowRef","fit","socket","observer","containerOptions","running","c","_a","loadContainers","r","api","problem","wanted","match","connect","Terminal","FitAddon","__vitePreload","n","t","f","proto","qs","ws","e","d","disconnect","teardown","_b","watch","onBeforeUnmount","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_cache","_createVNode","InfoHint","_createBlock","ErrorNote","_hoisted_3","_hoisted_4","SelectMenu","$event","_hoisted_5","s","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_toDisplayString"],"ignoreList":[],"sources":["../../src/views/tabs/TerminalTab.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * A shell inside one of this deployment's containers.\n *\n * THE SERVER DECIDES WHICH CONTAINER. This picker is filled from `/runtime`, i.e. the containers the\n * deployment actually owns, and the server checks the name again on upgrade — a hand-typed\n * `?container=pstack-control` is a 404 there, not here. The picker is a convenience, never the\n * boundary.\n *\n * THE COOKIE IS THE CREDENTIAL. A browser cannot set an `Authorization` header on a WebSocket, which\n * is exactly why sessions are cookies (0.10.0) — the handshake is a same-origin GET and carries the\n * session automatically. There is no token in this URL and there must never be one: a URL lands in\n * proxy logs and browser history.\n *\n * NO PTY. The server runs `docker exec -i`, not `-it`, so there is no prompt, no ^C and no `top`.\n * That is stated on the page rather than left for the operator to discover as \"the terminal is\n * broken\" — see the banner below and the comment at the head of `terminal.ts`.\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue';\nimport { useRoute } from 'vue-router';\nimport { api, problem } from '../../api/client';\nimport type { RuntimeResponse } from '../../api/types';\nimport ErrorNote from '../../components/ErrorNote.vue';\nimport InfoHint from '../../components/InfoHint.vue';\nimport SelectMenu from '../../components/SelectMenu.vue';\n\nconst route = useRoute();\nconst id = computed(() => String(route.params.id));\n\nconst SHELLS = ['sh', 'bash', 'ash', 'zsh', 'fish'];\n\nconst rt = ref<RuntimeResponse | null>(null);\nconst loadError = ref('');\nconst container = ref('');\nconst shell = ref('sh');\nconst state = ref<'idle' | 'connecting' | 'open' | 'closed'>('idle');\nconst closeReason = ref('');\n\nconst host = ref<HTMLDivElement | null>(null);\n/** shallowRef: xterm's Terminal is a large mutable object and must not be made reactive. */\nconst term = shallowRef<import('@xterm/xterm').Terminal | null>(null);\nconst fit = shallowRef<import('@xterm/addon-fit').FitAddon | null>(null);\nconst socket = shallowRef<WebSocket | null>(null);\nlet observer: ResizeObserver | null = null;\n\nconst containerOptions = computed(() =>\n running.value.map((c) => ({ value: c.name, label: c.name, hint: c.service ?? undefined })),\n);\n\nconst running = computed(() => rt.value?.containers.filter((c) => c.state === 'running') ?? []);\n\nasync function loadContainers() {\n const r = await api.get<RuntimeResponse>(\n `/api/deployments/${encodeURIComponent(id.value)}/runtime`,\n );\n if (!r.ok) {\n loadError.value = problem(r, \"list this deployment's containers\");\n return;\n }\n loadError.value = '';\n rt.value = r.body;\n if (container.value) return;\n /*\n * `?container=` is how the Containers table jumps straight to a shell here. Honoured only when it\n * names a container this deployment actually owns and is running — an unknown name falls back to\n * the first, because the alternative is a picker sitting on a container that does not exist and a\n * Connect button that 404s. (The server checks the name again on upgrade; this is convenience.)\n */\n const wanted = typeof route.query.container === 'string' ? route.query.container : '';\n const match = running.value.find((c) => c.name === wanted);\n container.value = match?.name ?? running.value[0]?.name ?? '';\n}\nvoid loadContainers();\n\nasync function connect() {\n if (state.value === 'connecting' || state.value === 'open') return;\n closeReason.value = '';\n state.value = 'connecting';\n\n // Loaded on demand, not in the app shell: xterm is ~250KB and only this tab needs it.\n const [{ Terminal }, { FitAddon }] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ]);\n await import('@xterm/xterm/css/xterm.css');\n\n term.value?.dispose();\n const t = new Terminal({\n // The OUTPUT half of the line discipline the missing pty would have provided. A real terminal\n // converts NL to CR-NL on the way out (ONLCR); without it every `\\n` moves DOWN a row without\n // returning the carriage, and `ls` renders as a staircase marching off the right edge. The input\n // half — CR to NL — is done server-side; see `crToNl` in api.ts.\n convertEol: true,\n fontSize: 13,\n fontFamily: 'var(--font-mono, ui-monospace, monospace)',\n cursorBlink: true,\n theme: { background: '#0b0e14' },\n });\n const f = new FitAddon();\n t.loadAddon(f);\n if (host.value) {\n host.value.innerHTML = '';\n t.open(host.value);\n f.fit();\n }\n term.value = t;\n fit.value = f;\n\n observer?.disconnect();\n observer = new ResizeObserver(() => {\n try {\n f.fit();\n } catch {\n /* the element is detached mid-transition */\n }\n });\n if (host.value) observer.observe(host.value);\n\n const proto = location.protocol === 'https:' ? 'wss' : 'ws';\n const qs = new URLSearchParams({ container: container.value, shell: shell.value });\n const ws = new WebSocket(\n `${proto}://${location.host}/api/deployments/${encodeURIComponent(id.value)}/terminal?${qs}`,\n );\n ws.binaryType = 'arraybuffer';\n socket.value = ws;\n\n ws.onopen = () => {\n state.value = 'open';\n t.focus();\n };\n // Bytes, not text: decoding per frame would corrupt a multi-byte character split across two\n // reads. xterm takes a Uint8Array and handles the boundary itself.\n ws.onmessage = (e) =>\n t.write(typeof e.data === 'string' ? e.data : new Uint8Array(e.data as ArrayBuffer));\n ws.onclose = (e) => {\n state.value = 'closed';\n // A close CODE alone tells an operator nothing. 1006 in particular is the browser's \"it just\n // went away\", which here almost always means the upgrade was refused.\n closeReason.value =\n e.reason || (e.code === 1006 ? 'the connection dropped (the upgrade may have been refused)' : `code ${e.code}`);\n };\n ws.onerror = () => {\n if (state.value === 'connecting') closeReason.value = 'could not open the connection';\n };\n t.onData((d) => {\n if (ws.readyState === WebSocket.OPEN) ws.send(d);\n });\n}\n\nfunction disconnect() {\n socket.value?.close(1000, 'closed by the operator');\n}\n\nfunction teardown() {\n observer?.disconnect();\n observer = null;\n socket.value?.close();\n socket.value = null;\n term.value?.dispose();\n term.value = null;\n}\n\n// Switching container or shell must not leave the old shell running against a dead view.\nwatch([container, shell], () => {\n if (state.value === 'open' || state.value === 'connecting') disconnect();\n});\nwatch(id, () => {\n teardown();\n state.value = 'idle';\n void loadContainers();\n});\nonBeforeUnmount(teardown);\n</script>\n\n<template>\n <section class=\"stack\">\n <div class=\"banner warn\">\n <b>No TTY.</b> The shell runs without a terminal device, so there is no prompt, no\n <code>Ctrl-C</code>, and no full-screen programs (<code>top</code>, <code>vim</code>). Type a\n command and press Enter.\n <InfoHint label=\"why\">\n A pseudo-terminal needs a wrapper (<code>script</code>) whose flags differ across\n distributions, and it was never verified on a real host — so pstack ships the half it can\n stand behind. Everything an operator usually opens a shell for (<code>ls</code>,\n <code>cat</code>, <code>env</code>, <code>psql</code>, a migration) works.\n </InfoHint>\n </div>\n\n <ErrorNote v-if=\"loadError\" :text=\"loadError\" title=\"Could not list this deployment's containers.\" />\n\n <div class=\"row wrap\" style=\"gap: var(--s3); align-items: end\">\n <label class=\"field\">\n <span>Container</span>\n <SelectMenu v-model=\"container\" label=\"Container\" :disabled=\"state === 'open' || state === 'connecting'\" :options=\"containerOptions\" />\n </label>\n <label class=\"field\">\n <span>Shell</span>\n <SelectMenu v-model=\"shell\" label=\"Shell\" :disabled=\"state === 'open' || state === 'connecting'\" :options=\"SHELLS.map((s) => ({ value: s, label: s }))\" />\n </label>\n <button\n v-if=\"state !== 'open'\"\n class=\"primary\"\n :disabled=\"!container || state === 'connecting'\"\n @click=\"connect\"\n >\n {{ state === 'connecting' ? 'Connecting…' : 'Open shell' }}\n </button>\n <button v-else @click=\"disconnect\">Close shell</button>\n <span class=\"grow\" />\n <span v-if=\"state === 'open'\" class=\"badge ok\"><span class=\"dot pulse\" />connected</span>\n </div>\n\n <p v-if=\"!running.length && !loadError\" class=\"hint\">\n Nothing is running for this deployment, so there is nothing to open a shell in.\n </p>\n\n <p v-if=\"state === 'closed' && closeReason\" class=\"hint\">Session ended — {{ closeReason }}.</p>\n\n <div ref=\"host\" class=\"terminal-host\" :data-state=\"state\" />\n\n <p class=\"hint\">\n Every session is recorded — who, which container, when — and the record is written when the\n shell opens, so a session that dies with the process still leaves one.\n </p>\n </section>\n</template>\n\n<style scoped>\n.terminal-host {\n min-height: 26rem;\n border: 1px solid var(--line);\n border-radius: var(--r3);\n background: #0b0e14;\n padding: var(--s2);\n overflow: hidden;\n}\n.terminal-host[data-state='idle'] {\n display: none;\n}\n</style>\n"],"file":"assets/TerminalTab-jUQlwJpM.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as oe,a6 as te,M as I,c as n,a as s,f as C,e as u,w as A,_ as L,z as U,g as f,t as c,F as W,r as B,u as r,a7 as R,h as D,i as V,v as x,b as k,T as ne,j as p,k as M,p as h,C as y,o as t,U as g,s as le}from"./index-Cqe_7QZw.js";import{_ as Y}from"./ActionButton.vue_vue_type_script_setup_true_lang-D8Xlp6c9.js";import{E as F}from"./EquivalentCommand-D92xDU0_.js";import{_ as re}from"./ErrorNote.vue_vue_type_script_setup_true_lang-DVbGiVTB.js";import{_ as j}from"./RelativeTime.vue_vue_type_script_setup_true_lang-NGvUfuKC.js";import{_ as z}from"./SkeletonList.vue_vue_type_script_setup_true_lang-BmeRGmxf.js";import{_ as ie}from"./RefreshButton.vue_vue_type_script_setup_true_lang-P7VwWcRa.js";import{_ as H}from"./SelectMenu.vue_vue_type_script_setup_true_lang-BtHqT6G1.js";import{_ as de}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./Teleport-I0XiM19H.js";const ue={class:"page-head"},ce={class:"sub"},pe={key:1,class:"banner ok"},me={class:"code"},ve={class:"row"},he={class:"grid-2"},we={class:"panel"},fe={class:"phead"},ke={class:"mute",style:{"font-size":"var(--t-xs)"}},ye={key:1,class:"cards"},be={class:"name","data-label":"user"},_e={key:0,class:"badge info"},ge={"data-label":"role"},$e=["title"],Ce={key:1},Ae={class:"dim nowrap","data-label":"added"},Ue={class:"right nowrap","data-label":""},Te=["onClick"],Re={key:2,class:"hint"},Ve={class:"row wrap two-up"},xe={class:"field grow"},Ne={class:"field grow"},Se={class:"field"},Pe={class:"row"},Ie=["disabled"],De={key:4,class:"hint"},Ee={class:"panel"},Oe={class:"phead"},Le={key:1,class:"cards"},We={class:"name","data-label":"name"},Be={class:"dim nowrap","data-label":"last used"},Me={key:1,class:"mute"},Ye={class:"right nowrap","data-label":""},Fe={key:2,class:"hint"},je={class:"field"},ze={class:"row"},He=["disabled"],qe={class:"sheet",role:"dialog","aria-modal":"true","aria-label":"Change password"},Ge={class:"hint"},Je={class:"field"},Ke={class:"row"},Qe=["disabled"],q="The only admin — promote another account first.",Xe=oe({__name:"UsersView",setup(Ze){const $=p([]),N=p([]),S=p(!1),i=p(""),l=p({username:"",password:"",role:"viewer"}),w=p(""),m=p(null),b=p(""),_=p(null),G=M(()=>l.value.username.trim().length>0&&l.value.password.length>=8),J={viewer:"reads everything",developer:"deploys and tears down",maintainer:"host configuration",admin:"accounts and sign-on"},E=te.map(o=>({value:o,label:I(o),hint:J[o]})),K=M(()=>$.value.filter(o=>o.role==="admin").length);function T(o){return o.role==="admin"&&K.value===1}async function v(){const[o,e]=await Promise.all([h.get("/api/users"),h.get("/api/tokens")]);if(S.value=!0,!o.ok){i.value=y(o,"load the accounts");return}i.value="",$.value=o.body.users??[],N.value=e.ok?e.body.tokens??[]:[]}v();async function Q(){const o=await h.post("/api/users",{username:l.value.username.trim(),password:l.value.password,role:l.value.role});if(!o.ok){i.value=y(o,"create this account");return}g("ok",`Created ${o.body.user.username} as a ${o.body.user.role}.`),l.value={username:"",password:"",role:"viewer"},v()}async function X(o){const e=await h.del(`/api/users/${o.id}`);if(!e.ok){i.value=y(e,`delete ${o.username}`);return}g("ok",`Deleted ${o.username}.`),v()}async function Z(o,e){var d;if(e===o.role)return;const a=await h.patch(`/api/users/${o.id}`,{role:e});if(!a.ok){i.value=y(a,`change the role for ${o.username}`);return}i.value="",o.id===((d=k.user)==null?void 0:d.id)?(await le(),g("ok",`You are now a ${e}. What this app offers you changed with it.`)):g("ok",`${o.username} is now a ${e}.`),v()}async function ee(){var a;const o=m.value;if(!o)return;const e=await h.put(`/api/users/${o.id}/password`,{password:b.value});if(!e.ok){i.value=y(e,`change the password for ${o.username}`);return}m.value=null,b.value="",g("ok",o.id===((a=k.user)==null?void 0:a.id)?"Password changed. You have been signed out everywhere — sign in again.":`Password changed. ${o.username} has been signed out everywhere.`),v()}async function se(){const o=await h.post("/api/tokens",{name:w.value.trim()});if(!o.ok){i.value=y(o,"create this token");return}_.value={what:`Personal token “${w.value.trim()}”`,value:o.body.token,note:"Send it as a bearer token. The server stores only a hash, so this is the only time it is shown."},w.value="",v()}async function ae(o){const e=await h.del(`/api/tokens/${o.id}`);if(!e.ok){i.value=y(e,`revoke ${o.name}`);return}g("ok",`Revoked ${o.name}.`),v()}return(o,e)=>(t(),n("div",null,[s("div",ue,[s("div",null,[e[10]||(e[10]=s("h1",null,"Users & access",-1)),s("div",ce,[e[9]||(e[9]=C(" Who can sign in, and the tokens they use from scripts ",-1)),u(L,{label:"how access works here"},{default:A(()=>[...e[8]||(e[8]=[C(" Three kinds of caller. The host token from the environment is the root credential CI holds. An account signs in with a password and gets a browser session. A personal token belongs to one account and is what a script uses — it can do anything that account can. ",-1)])]),_:1})])]),e[11]||(e[11]=s("span",{class:"grow"},null,-1)),u(ie,{run:v})]),i.value?(t(),U(re,{key:0,text:i.value,title:"Something went wrong."},null,8,["text"])):f("",!0),_.value?(t(),n("div",pe,[s("b",null,c(_.value.what)+" — copy it now.",1),s("p",null,c(_.value.note),1),s("pre",me,c(_.value.value),1),s("div",ve,[s("button",{onClick:e[0]||(e[0]=a=>_.value=null)},"I have stored it")])])):f("",!0),s("div",he,[s("section",we,[s("div",fe,[e[12]||(e[12]=s("h2",{class:"section"},"Accounts",-1)),e[13]||(e[13]=s("span",{class:"grow"},null,-1)),s("span",ke,c($.value.length),1)]),S.value?$.value.length?(t(),n("table",ye,[e[15]||(e[15]=s("thead",null,[s("tr",null,[s("th",null,"User"),s("th",null,"Role"),s("th",null,"Added"),s("th",{"aria-label":"Actions"})])],-1)),s("tbody",null,[(t(!0),n(W,null,B($.value,a=>{var d,O;return t(),n("tr",{key:a.id},[s("td",be,[s("b",null,c(a.username),1),a.id===((d=r(k).user)==null?void 0:d.id)?(t(),n("span",_e,"you")):f("",!0)]),s("td",ge,[r(R)("admin")?(t(),n("span",{key:0,class:"role-pick",title:T(a)?q:void 0},[u(H,{"model-value":a.role,label:`Role for ${a.username}`,options:r(E),disabled:T(a),placeholder:r(I)(a.role),"onUpdate:modelValue":P=>Z(a,P)},null,8,["model-value","label","options","disabled","placeholder","onUpdate:modelValue"])],8,$e)):(t(),n("span",Ce,c(r(I)(a.role)),1))]),s("td",Ae,[u(j,{at:a.createdAt},null,8,["at"])]),s("td",Ue,[a.id===((O=r(k).user)==null?void 0:O.id)||r(R)("admin")?(t(),n("button",{key:0,class:"ghost sm",onClick:P=>{m.value=a,b.value=""}}," Change password ",8,Te)):f("",!0),r(R)("admin")?(t(),U(Y,{key:1,class:"danger sm",confirm:`Delete ${a.username}?`,disabled:T(a),title:T(a)?q:void 0,onRun:P=>X(a)},{default:A(()=>[...e[14]||(e[14]=[C("Delete",-1)])]),_:1},8,["confirm","disabled","title","onRun"])):f("",!0)])])}),128))])])):(t(),n("p",Re,"No accounts yet.")):(t(),U(z,{key:0,rows:3})),r(R)("admin")?(t(),n("form",{key:3,class:"stack-form",onSubmit:D(Q,["prevent"])},[e[20]||(e[20]=s("h3",null,"Add an account",-1)),s("div",Ve,[s("label",xe,[e[16]||(e[16]=s("span",null,"Username",-1)),V(s("input",{"onUpdate:modelValue":e[1]||(e[1]=a=>l.value.username=a),type:"text",autocomplete:"off"},null,512),[[x,l.value.username]])]),s("label",Ne,[e[17]||(e[17]=s("span",null,"Password",-1)),V(s("input",{"onUpdate:modelValue":e[2]||(e[2]=a=>l.value.password=a),type:"password",autocomplete:"new-password"},null,512),[[x,l.value.password]])])]),s("div",Se,[e[18]||(e[18]=s("label",{for:"new-role"},"Role",-1)),u(H,{id:"new-role","model-value":l.value.role,label:"Role for the new account",options:r(E),"onUpdate:modelValue":e[3]||(e[3]=a=>l.value.role=a)},null,8,["model-value","options"])]),e[21]||(e[21]=s("p",{class:"hint"},"At least 8 characters. A new account starts as a viewer unless you say otherwise.",-1)),s("div",Pe,[s("button",{class:"primary",type:"submit",disabled:!G.value},"Add account",8,Ie),e[19]||(e[19]=s("span",{class:"grow"},null,-1))]),u(F,{what:"this account creation",method:"POST",path:"/api/users",body:{username:l.value.username||"alice",password:"…",role:l.value.role}},null,8,["body"])],32)):(t(),n("p",De," Only an admin can add an account or change a role. Ask one of the admins above. "))]),s("section",Ee,[s("div",Oe,[e[23]||(e[23]=s("h2",{class:"section"},"Your API tokens",-1)),u(L,{label:"when to use one"},{default:A(()=>[...e[22]||(e[22]=[C(" A script or a CI job signing in as you. It carries whatever you can do, so give each one a name you will recognise later and revoke the ones you stop using. ",-1)])]),_:1})]),S.value?N.value.length?(t(),n("table",Le,[e[25]||(e[25]=s("thead",null,[s("tr",null,[s("th",null,"Name"),s("th",null,"Last used"),s("th",{"aria-label":"Actions"})])],-1)),s("tbody",null,[(t(!0),n(W,null,B(N.value,a=>(t(),n("tr",{key:a.id},[s("td",We,[s("b",null,c(a.name),1)]),s("td",Be,[a.lastUsedAt?(t(),U(j,{key:0,at:a.lastUsedAt},null,8,["at"])):(t(),n("span",Me,"never"))]),s("td",Ye,[u(Y,{class:"danger sm",confirm:`Revoke ${a.name}?`,onRun:d=>ae(a)},{default:A(()=>[...e[24]||(e[24]=[C("Revoke",-1)])]),_:1},8,["confirm","onRun"])])]))),128))])])):(t(),n("p",Fe,c(r(k).root?"The host token is not an account, so it has no personal tokens.":"No tokens yet."),1)):(t(),U(z,{key:0,rows:2})),r(k).root?f("",!0):(t(),n("form",{key:3,class:"stack-form",onSubmit:D(se,["prevent"])},[e[27]||(e[27]=s("h3",null,"New token",-1)),s("label",je,[e[26]||(e[26]=s("span",null,"What is it for",-1)),V(s("input",{"onUpdate:modelValue":e[4]||(e[4]=a=>w.value=a),type:"text",placeholder:"ci-deploy",autocomplete:"off"},null,512),[[x,w.value]])]),s("div",ze,[s("button",{class:"primary",type:"submit",disabled:!w.value.trim()},"Create token",8,He)]),u(F,{what:"this token creation",method:"POST",path:"/api/tokens",body:{name:w.value||"ci-deploy"}},null,8,["body"])],32))])]),u(ne,{name:"fade"},{default:A(()=>{var a;return[m.value?(t(),n("div",{key:0,class:"scrim",onClick:e[7]||(e[7]=D(d=>m.value=null,["self"]))},[s("div",qe,[s("h3",null,"Change password for "+c(m.value.username),1),s("p",Ge," This signs "+c(m.value.id===((a=r(k).user)==null?void 0:a.id)?"you":"them")+" out everywhere — every session and personal token is revoked. ",1),s("label",Je,[e[28]||(e[28]=s("span",null,"New password",-1)),V(s("input",{"onUpdate:modelValue":e[5]||(e[5]=d=>b.value=d),type:"password",autocomplete:"new-password"},null,512),[[x,b.value]])]),s("div",Ke,[s("button",{class:"primary",disabled:b.value.length<8,onClick:ee}," Change password ",8,Qe),s("button",{class:"ghost",onClick:e[6]||(e[6]=d=>m.value=null)},"Cancel")])])])):f("",!0)]}),_:1})]))}}),us=de(Xe,[["__scopeId","data-v-fb77a882"]]);export{us as default};
|
|
2
|
-
//# sourceMappingURL=UsersView-
|
|
1
|
+
import{d as oe,a6 as te,M as I,c as n,a as s,f as C,e as u,w as A,_ as L,z as U,g as f,t as c,F as W,r as B,u as r,a7 as R,h as D,i as V,v as x,b as k,T as ne,j as p,k as M,p as h,C as y,o as t,U as g,s as le}from"./index-DB2WhG8N.js";import{_ as Y}from"./ActionButton.vue_vue_type_script_setup_true_lang-AGS1FKpY.js";import{E as F}from"./EquivalentCommand-D0dyw0Wd.js";import{_ as re}from"./ErrorNote.vue_vue_type_script_setup_true_lang-BrBUwK6j.js";import{_ as j}from"./RelativeTime.vue_vue_type_script_setup_true_lang-eoX10cnp.js";import{_ as z}from"./SkeletonList.vue_vue_type_script_setup_true_lang-CvoOnzDO.js";import{_ as ie}from"./RefreshButton.vue_vue_type_script_setup_true_lang-8Tme6z_i.js";import{_ as H}from"./SelectMenu.vue_vue_type_script_setup_true_lang-Bjd8KlYw.js";import{_ as de}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./Teleport-Bg1yDCl9.js";const ue={class:"page-head"},ce={class:"sub"},pe={key:1,class:"banner ok"},me={class:"code"},ve={class:"row"},he={class:"grid-2"},we={class:"panel"},fe={class:"phead"},ke={class:"mute",style:{"font-size":"var(--t-xs)"}},ye={key:1,class:"cards"},be={class:"name","data-label":"user"},_e={key:0,class:"badge info"},ge={"data-label":"role"},$e=["title"],Ce={key:1},Ae={class:"dim nowrap","data-label":"added"},Ue={class:"right nowrap","data-label":""},Te=["onClick"],Re={key:2,class:"hint"},Ve={class:"row wrap two-up"},xe={class:"field grow"},Ne={class:"field grow"},Se={class:"field"},Pe={class:"row"},Ie=["disabled"],De={key:4,class:"hint"},Ee={class:"panel"},Oe={class:"phead"},Le={key:1,class:"cards"},We={class:"name","data-label":"name"},Be={class:"dim nowrap","data-label":"last used"},Me={key:1,class:"mute"},Ye={class:"right nowrap","data-label":""},Fe={key:2,class:"hint"},je={class:"field"},ze={class:"row"},He=["disabled"],qe={class:"sheet",role:"dialog","aria-modal":"true","aria-label":"Change password"},Ge={class:"hint"},Je={class:"field"},Ke={class:"row"},Qe=["disabled"],q="The only admin — promote another account first.",Xe=oe({__name:"UsersView",setup(Ze){const $=p([]),N=p([]),S=p(!1),i=p(""),l=p({username:"",password:"",role:"viewer"}),w=p(""),m=p(null),b=p(""),_=p(null),G=M(()=>l.value.username.trim().length>0&&l.value.password.length>=8),J={viewer:"reads everything",developer:"deploys and tears down",maintainer:"host configuration",admin:"accounts and sign-on"},E=te.map(o=>({value:o,label:I(o),hint:J[o]})),K=M(()=>$.value.filter(o=>o.role==="admin").length);function T(o){return o.role==="admin"&&K.value===1}async function v(){const[o,e]=await Promise.all([h.get("/api/users"),h.get("/api/tokens")]);if(S.value=!0,!o.ok){i.value=y(o,"load the accounts");return}i.value="",$.value=o.body.users??[],N.value=e.ok?e.body.tokens??[]:[]}v();async function Q(){const o=await h.post("/api/users",{username:l.value.username.trim(),password:l.value.password,role:l.value.role});if(!o.ok){i.value=y(o,"create this account");return}g("ok",`Created ${o.body.user.username} as a ${o.body.user.role}.`),l.value={username:"",password:"",role:"viewer"},v()}async function X(o){const e=await h.del(`/api/users/${o.id}`);if(!e.ok){i.value=y(e,`delete ${o.username}`);return}g("ok",`Deleted ${o.username}.`),v()}async function Z(o,e){var d;if(e===o.role)return;const a=await h.patch(`/api/users/${o.id}`,{role:e});if(!a.ok){i.value=y(a,`change the role for ${o.username}`);return}i.value="",o.id===((d=k.user)==null?void 0:d.id)?(await le(),g("ok",`You are now a ${e}. What this app offers you changed with it.`)):g("ok",`${o.username} is now a ${e}.`),v()}async function ee(){var a;const o=m.value;if(!o)return;const e=await h.put(`/api/users/${o.id}/password`,{password:b.value});if(!e.ok){i.value=y(e,`change the password for ${o.username}`);return}m.value=null,b.value="",g("ok",o.id===((a=k.user)==null?void 0:a.id)?"Password changed. You have been signed out everywhere — sign in again.":`Password changed. ${o.username} has been signed out everywhere.`),v()}async function se(){const o=await h.post("/api/tokens",{name:w.value.trim()});if(!o.ok){i.value=y(o,"create this token");return}_.value={what:`Personal token “${w.value.trim()}”`,value:o.body.token,note:"Send it as a bearer token. The server stores only a hash, so this is the only time it is shown."},w.value="",v()}async function ae(o){const e=await h.del(`/api/tokens/${o.id}`);if(!e.ok){i.value=y(e,`revoke ${o.name}`);return}g("ok",`Revoked ${o.name}.`),v()}return(o,e)=>(t(),n("div",null,[s("div",ue,[s("div",null,[e[10]||(e[10]=s("h1",null,"Users & access",-1)),s("div",ce,[e[9]||(e[9]=C(" Who can sign in, and the tokens they use from scripts ",-1)),u(L,{label:"how access works here"},{default:A(()=>[...e[8]||(e[8]=[C(" Three kinds of caller. The host token from the environment is the root credential CI holds. An account signs in with a password and gets a browser session. A personal token belongs to one account and is what a script uses — it can do anything that account can. ",-1)])]),_:1})])]),e[11]||(e[11]=s("span",{class:"grow"},null,-1)),u(ie,{run:v})]),i.value?(t(),U(re,{key:0,text:i.value,title:"Something went wrong."},null,8,["text"])):f("",!0),_.value?(t(),n("div",pe,[s("b",null,c(_.value.what)+" — copy it now.",1),s("p",null,c(_.value.note),1),s("pre",me,c(_.value.value),1),s("div",ve,[s("button",{onClick:e[0]||(e[0]=a=>_.value=null)},"I have stored it")])])):f("",!0),s("div",he,[s("section",we,[s("div",fe,[e[12]||(e[12]=s("h2",{class:"section"},"Accounts",-1)),e[13]||(e[13]=s("span",{class:"grow"},null,-1)),s("span",ke,c($.value.length),1)]),S.value?$.value.length?(t(),n("table",ye,[e[15]||(e[15]=s("thead",null,[s("tr",null,[s("th",null,"User"),s("th",null,"Role"),s("th",null,"Added"),s("th",{"aria-label":"Actions"})])],-1)),s("tbody",null,[(t(!0),n(W,null,B($.value,a=>{var d,O;return t(),n("tr",{key:a.id},[s("td",be,[s("b",null,c(a.username),1),a.id===((d=r(k).user)==null?void 0:d.id)?(t(),n("span",_e,"you")):f("",!0)]),s("td",ge,[r(R)("admin")?(t(),n("span",{key:0,class:"role-pick",title:T(a)?q:void 0},[u(H,{"model-value":a.role,label:`Role for ${a.username}`,options:r(E),disabled:T(a),placeholder:r(I)(a.role),"onUpdate:modelValue":P=>Z(a,P)},null,8,["model-value","label","options","disabled","placeholder","onUpdate:modelValue"])],8,$e)):(t(),n("span",Ce,c(r(I)(a.role)),1))]),s("td",Ae,[u(j,{at:a.createdAt},null,8,["at"])]),s("td",Ue,[a.id===((O=r(k).user)==null?void 0:O.id)||r(R)("admin")?(t(),n("button",{key:0,class:"ghost sm",onClick:P=>{m.value=a,b.value=""}}," Change password ",8,Te)):f("",!0),r(R)("admin")?(t(),U(Y,{key:1,class:"danger sm",confirm:`Delete ${a.username}?`,disabled:T(a),title:T(a)?q:void 0,onRun:P=>X(a)},{default:A(()=>[...e[14]||(e[14]=[C("Delete",-1)])]),_:1},8,["confirm","disabled","title","onRun"])):f("",!0)])])}),128))])])):(t(),n("p",Re,"No accounts yet.")):(t(),U(z,{key:0,rows:3})),r(R)("admin")?(t(),n("form",{key:3,class:"stack-form",onSubmit:D(Q,["prevent"])},[e[20]||(e[20]=s("h3",null,"Add an account",-1)),s("div",Ve,[s("label",xe,[e[16]||(e[16]=s("span",null,"Username",-1)),V(s("input",{"onUpdate:modelValue":e[1]||(e[1]=a=>l.value.username=a),type:"text",autocomplete:"off"},null,512),[[x,l.value.username]])]),s("label",Ne,[e[17]||(e[17]=s("span",null,"Password",-1)),V(s("input",{"onUpdate:modelValue":e[2]||(e[2]=a=>l.value.password=a),type:"password",autocomplete:"new-password"},null,512),[[x,l.value.password]])])]),s("div",Se,[e[18]||(e[18]=s("label",{for:"new-role"},"Role",-1)),u(H,{id:"new-role","model-value":l.value.role,label:"Role for the new account",options:r(E),"onUpdate:modelValue":e[3]||(e[3]=a=>l.value.role=a)},null,8,["model-value","options"])]),e[21]||(e[21]=s("p",{class:"hint"},"At least 8 characters. A new account starts as a viewer unless you say otherwise.",-1)),s("div",Pe,[s("button",{class:"primary",type:"submit",disabled:!G.value},"Add account",8,Ie),e[19]||(e[19]=s("span",{class:"grow"},null,-1))]),u(F,{what:"this account creation",method:"POST",path:"/api/users",body:{username:l.value.username||"alice",password:"…",role:l.value.role}},null,8,["body"])],32)):(t(),n("p",De," Only an admin can add an account or change a role. Ask one of the admins above. "))]),s("section",Ee,[s("div",Oe,[e[23]||(e[23]=s("h2",{class:"section"},"Your API tokens",-1)),u(L,{label:"when to use one"},{default:A(()=>[...e[22]||(e[22]=[C(" A script or a CI job signing in as you. It carries whatever you can do, so give each one a name you will recognise later and revoke the ones you stop using. ",-1)])]),_:1})]),S.value?N.value.length?(t(),n("table",Le,[e[25]||(e[25]=s("thead",null,[s("tr",null,[s("th",null,"Name"),s("th",null,"Last used"),s("th",{"aria-label":"Actions"})])],-1)),s("tbody",null,[(t(!0),n(W,null,B(N.value,a=>(t(),n("tr",{key:a.id},[s("td",We,[s("b",null,c(a.name),1)]),s("td",Be,[a.lastUsedAt?(t(),U(j,{key:0,at:a.lastUsedAt},null,8,["at"])):(t(),n("span",Me,"never"))]),s("td",Ye,[u(Y,{class:"danger sm",confirm:`Revoke ${a.name}?`,onRun:d=>ae(a)},{default:A(()=>[...e[24]||(e[24]=[C("Revoke",-1)])]),_:1},8,["confirm","onRun"])])]))),128))])])):(t(),n("p",Fe,c(r(k).root?"The host token is not an account, so it has no personal tokens.":"No tokens yet."),1)):(t(),U(z,{key:0,rows:2})),r(k).root?f("",!0):(t(),n("form",{key:3,class:"stack-form",onSubmit:D(se,["prevent"])},[e[27]||(e[27]=s("h3",null,"New token",-1)),s("label",je,[e[26]||(e[26]=s("span",null,"What is it for",-1)),V(s("input",{"onUpdate:modelValue":e[4]||(e[4]=a=>w.value=a),type:"text",placeholder:"ci-deploy",autocomplete:"off"},null,512),[[x,w.value]])]),s("div",ze,[s("button",{class:"primary",type:"submit",disabled:!w.value.trim()},"Create token",8,He)]),u(F,{what:"this token creation",method:"POST",path:"/api/tokens",body:{name:w.value||"ci-deploy"}},null,8,["body"])],32))])]),u(ne,{name:"fade"},{default:A(()=>{var a;return[m.value?(t(),n("div",{key:0,class:"scrim",onClick:e[7]||(e[7]=D(d=>m.value=null,["self"]))},[s("div",qe,[s("h3",null,"Change password for "+c(m.value.username),1),s("p",Ge," This signs "+c(m.value.id===((a=r(k).user)==null?void 0:a.id)?"you":"them")+" out everywhere — every session and personal token is revoked. ",1),s("label",Je,[e[28]||(e[28]=s("span",null,"New password",-1)),V(s("input",{"onUpdate:modelValue":e[5]||(e[5]=d=>b.value=d),type:"password",autocomplete:"new-password"},null,512),[[x,b.value]])]),s("div",Ke,[s("button",{class:"primary",disabled:b.value.length<8,onClick:ee}," Change password ",8,Qe),s("button",{class:"ghost",onClick:e[6]||(e[6]=d=>m.value=null)},"Cancel")])])])):f("",!0)]}),_:1})]))}}),us=de(Xe,[["__scopeId","data-v-fb77a882"]]);export{us as default};
|
|
2
|
+
//# sourceMappingURL=UsersView-DcjfdY6Q.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsersView-BrZbuuOg.js","sources":["../../src/views/UsersView.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Accounts and personal API tokens.\n *\n * Accounts landed in 0.10.0 with no UI at all, so the only way to add a second operator was a curl\n * call — which is exactly the thing a control plane exists to spare people.\n *\n * TWO AUDIENCES, TWO SECTIONS, and the split is deliberate. **Accounts** are about other people and\n * are shared state; **tokens** are yours alone (the API scopes them to the caller and cannot show\n * anyone else's). Mixing them into one table would imply an admin can manage another person's\n * tokens, which is not true and would be a bad idea if it were.\n *\n * SECRETS ARE SHOWN ONCE, and the page says so in the same breath as showing them. Same discipline\n * as a notifier signing secret and a registry credential: there is no read path on the server, so\n * this is not a policy that could be relaxed later — the value genuinely stops existing.\n *\n * ── ROLES ────────────────────────────────────────────────────────────────────────────────────────\n *\n * The roster is ordinary team information, so ANY signed-in account reads this page. Changing it —\n * adding an account, setting a role, deleting one, setting someone ELSE's password — is admin's,\n * and those controls are simply not rendered for anyone else. Your OWN password stays yours at\n * every role, so that one button is there for everybody, on their own row only.\n *\n * Hiding is UX. `can('admin')` decides what to DRAW; the server's permission table decides what is\n * allowed, and a hidden control that is somehow reached still comes back 403 — which lands in\n * `listError` and says which role the route wanted. That path is not a fallback, it is the actual\n * enforcement, so it stays.\n *\n * THE LAST ADMIN is the one rule the server has that the UI can see coming: it refuses to delete or\n * demote the final admin account. A request that can only fail is worse than a control that says\n * why it cannot be pressed, so that row's role picker and Delete arrive already disabled, carrying\n * the same remedy the server would have answered with — promote another account first.\n */\nimport { computed, ref } from 'vue';\nimport { api, problem } from '../api/client';\nimport { ROLES, type Role, type User, type UsersResponse } from '../api/types';\nimport { authState, can, checkAuth } from '../composables/useAuth';\nimport { sentence } from '../composables/useFormat';\nimport { toast } from '../composables/useToasts';\nimport ActionButton from '../components/ActionButton.vue';\nimport EquivalentCommand from '../components/EquivalentCommand.vue';\nimport ErrorNote from '../components/ErrorNote.vue';\nimport InfoHint from '../components/InfoHint.vue';\nimport RelativeTime from '../components/RelativeTime.vue';\nimport SkeletonList from '../components/SkeletonList.vue';\nimport RefreshButton from '../components/RefreshButton.vue';\nimport SelectMenu from '../components/SelectMenu.vue';\n\ntype Token = { id: number; name: string; createdAt: number; lastUsedAt: number | null };\n\nconst users = ref<User[]>([]);\nconst tokens = ref<Token[]>([]);\nconst loaded = ref(false);\nconst listError = ref('');\n\nconst newUser = ref<{ username: string; password: string; role: Role }>({\n username: '',\n password: '',\n role: 'viewer',\n});\nconst newToken = ref('');\nconst pwFor = ref<User | null>(null);\nconst pwValue = ref('');\n\n/** Held only until dismissed — there is no way to show either of these again. */\nconst revealed = ref<{ what: string; value: string; note: string } | null>(null);\n\nconst canCreateUser = computed(\n () => newUser.value.username.trim().length > 0 && newUser.value.password.length >= 8,\n);\n\n/** One line each, in the picker itself — a role name alone does not say what it costs to grant. */\nconst ROLE_WHAT: Record<Role, string> = {\n viewer: 'reads everything',\n developer: 'deploys and tears down',\n maintainer: 'host configuration',\n admin: 'accounts and sign-on',\n};\nconst roleOptions = ROLES.map((r) => ({ value: r, label: sentence(r), hint: ROLE_WHAT[r] }));\n\nconst adminCount = computed(() => users.value.filter((u) => u.role === 'admin').length);\n/**\n * The last admin cannot be demoted or deleted — the server refuses both, and a host with no admin\n * has nobody who can add one back. Counting ROWS is the same thing the server counts: root holds\n * PSTACK_TOKEN, not an account, and may not exist as a human at all.\n */\nfunction lastAdmin(u: User): boolean {\n return u.role === 'admin' && adminCount.value === 1;\n}\nconst LAST_ADMIN_WHY = 'The only admin — promote another account first.';\n\nasync function load(): Promise<void> {\n const [u, t] = await Promise.all([\n api.get<UsersResponse>('/api/users'),\n api.get<{ tokens: Token[] }>('/api/tokens'),\n ]);\n loaded.value = true;\n if (!u.ok) {\n listError.value = problem(u, 'load the accounts');\n return;\n }\n listError.value = '';\n users.value = u.body.users ?? [];\n // Root (PSTACK_TOKEN) is not a user, so it has no personal tokens — an error here is expected.\n tokens.value = t.ok ? (t.body.tokens ?? []) : [];\n}\nvoid load();\n\nasync function createUser(): Promise<void> {\n // The role is always sent, never left to the server's default: what this form creates should be\n // whatever the form is showing. (An absent role means viewer there, which is the same answer —\n // but the day it is not, this page would be creating something other than what it said.)\n const r = await api.post<{ user: User }>('/api/users', {\n username: newUser.value.username.trim(),\n password: newUser.value.password,\n role: newUser.value.role,\n });\n if (!r.ok) {\n listError.value = problem(r, 'create this account');\n return;\n }\n toast('ok', `Created ${r.body.user.username} as a ${r.body.user.role}.`);\n newUser.value = { username: '', password: '', role: 'viewer' };\n void load();\n}\n\nasync function removeUser(u: User): Promise<void> {\n const r = await api.del(`/api/users/${u.id}`);\n // The server refuses to delete the last account. That is a rule worth surfacing verbatim rather\n // than as \"could not delete\" — it tells the operator what to do instead.\n if (!r.ok) {\n listError.value = problem(r, `delete ${u.username}`);\n return;\n }\n toast('ok', `Deleted ${u.username}.`);\n void load();\n}\n\nasync function changeRole(u: User, role: string): Promise<void> {\n if (role === u.role) return;\n const r = await api.patch(`/api/users/${u.id}`, { role });\n if (!r.ok) {\n listError.value = problem(r, `change the role for ${u.username}`);\n return;\n }\n listError.value = '';\n if (u.id === authState.user?.id) {\n // You just changed your OWN role, and this whole app — the rail, this page's controls, the\n // footer — is drawn from the role it is holding. Re-read it before anything renders again,\n // or the UI keeps offering what the server will now refuse. (The server needs no prompting:\n // every request looks the role up fresh.)\n await checkAuth();\n toast('ok', `You are now a ${role}. What this app offers you changed with it.`);\n } else {\n toast('ok', `${u.username} is now a ${role}.`);\n }\n void load();\n}\n\nasync function changePassword(): Promise<void> {\n const u = pwFor.value;\n if (!u) return;\n const r = await api.put(`/api/users/${u.id}/password`, { password: pwValue.value });\n if (!r.ok) {\n listError.value = problem(r, `change the password for ${u.username}`);\n return;\n }\n pwFor.value = null;\n pwValue.value = '';\n // Not a footnote: the change signs that user out everywhere, and if it was YOU, the next request\n // is a 401. Saying so here is the difference between an expected step and an apparent bug.\n toast(\n 'ok',\n u.id === authState.user?.id\n ? `Password changed. You have been signed out everywhere — sign in again.`\n : `Password changed. ${u.username} has been signed out everywhere.`,\n );\n void load();\n}\n\nasync function createToken(): Promise<void> {\n const r = await api.post<{ token: string; id: number }>('/api/tokens', {\n name: newToken.value.trim(),\n });\n if (!r.ok) {\n listError.value = problem(r, 'create this token');\n return;\n }\n revealed.value = {\n what: `Personal token “${newToken.value.trim()}”`,\n value: r.body.token,\n note: 'Send it as a bearer token. The server stores only a hash, so this is the only time it is shown.',\n };\n newToken.value = '';\n void load();\n}\n\nasync function removeToken(t: Token): Promise<void> {\n const r = await api.del(`/api/tokens/${t.id}`);\n if (!r.ok) {\n listError.value = problem(r, `revoke ${t.name}`);\n return;\n }\n toast('ok', `Revoked ${t.name}.`);\n void load();\n}\n</script>\n\n<template>\n <div>\n <div class=\"page-head\">\n <div>\n <h1>Users & access</h1>\n <div class=\"sub\">\n Who can sign in, and the tokens they use from scripts\n <InfoHint label=\"how access works here\">\n Three kinds of caller. The host token from the environment is the root credential CI\n holds. An account signs in with a password and gets a browser session. A personal token\n belongs to one account and is what a script uses — it can do anything that account can.\n </InfoHint>\n </div>\n </div>\n <span class=\"grow\" />\n <RefreshButton :run=\"load\" />\n </div>\n\n <ErrorNote v-if=\"listError\" :text=\"listError\" title=\"Something went wrong.\" />\n\n <div v-if=\"revealed\" class=\"banner ok\">\n <b>{{ revealed.what }} — copy it now.</b>\n <p>{{ revealed.note }}</p>\n <pre class=\"code\">{{ revealed.value }}</pre>\n <div class=\"row\">\n <button @click=\"revealed = null\">I have stored it</button>\n </div>\n </div>\n\n <div class=\"grid-2\">\n <section class=\"panel\">\n <div class=\"phead\">\n <h2 class=\"section\">Accounts</h2>\n <span class=\"grow\" />\n <span class=\"mute\" style=\"font-size: var(--t-xs)\">{{ users.length }}</span>\n </div>\n\n <SkeletonList v-if=\"!loaded\" :rows=\"3\" />\n <!-- `cards` + `data-label` per cell: below 640px the same markup renders as cards. Without\n it the row's two buttons pushed the table past the viewport and got clipped. -->\n <table v-else-if=\"users.length\" class=\"cards\">\n <thead>\n <tr>\n <th>User</th>\n <th>Role</th>\n <th>Added</th>\n <th aria-label=\"Actions\" />\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"u in users\" :key=\"u.id\">\n <td class=\"name\" data-label=\"user\">\n <b>{{ u.username }}</b>\n <span v-if=\"u.id === authState.user?.id\" class=\"badge info\">you</span>\n </td>\n <!-- An admin gets the picker in place: promotion is a one-step decision about one\n person, and a dialog for a four-option choice is a page-blocking ceremony. Anyone\n else reads the role as text — `sentence()` at render only, never on the value.\n A role this build does not know still shows: it falls through to `placeholder`. -->\n <td data-label=\"role\">\n <span\n v-if=\"can('admin')\"\n class=\"role-pick\"\n :title=\"lastAdmin(u) ? LAST_ADMIN_WHY : undefined\"\n >\n <SelectMenu\n :model-value=\"u.role\"\n :label=\"`Role for ${u.username}`\"\n :options=\"roleOptions\"\n :disabled=\"lastAdmin(u)\"\n :placeholder=\"sentence(u.role)\"\n @update:model-value=\"(v) => changeRole(u, v)\"\n />\n </span>\n <span v-else>{{ sentence(u.role) }}</span>\n </td>\n <td class=\"dim nowrap\" data-label=\"added\"><RelativeTime :at=\"u.createdAt\" /></td>\n <td class=\"right nowrap\" data-label=\"\">\n <!-- Your own password is yours at any role; someone else's is an admin operation. -->\n <button\n v-if=\"u.id === authState.user?.id || can('admin')\"\n class=\"ghost sm\"\n @click=\"pwFor = u; pwValue = ''\"\n >\n Change password\n </button>\n <ActionButton\n v-if=\"can('admin')\"\n class=\"danger sm\"\n :confirm=\"`Delete ${u.username}?`\"\n :disabled=\"lastAdmin(u)\"\n :title=\"lastAdmin(u) ? LAST_ADMIN_WHY : undefined\"\n @run=\"removeUser(u)\"\n >Delete</ActionButton\n >\n </td>\n </tr>\n </tbody>\n </table>\n <p v-else class=\"hint\">No accounts yet.</p>\n\n <form v-if=\"can('admin')\" class=\"stack-form\" @submit.prevent=\"createUser\">\n <h3>Add an account</h3>\n <div class=\"row wrap two-up\">\n <label class=\"field grow\">\n <span>Username</span>\n <input v-model=\"newUser.username\" type=\"text\" autocomplete=\"off\" />\n </label>\n <label class=\"field grow\">\n <span>Password</span>\n <input v-model=\"newUser.password\" type=\"password\" autocomplete=\"new-password\" />\n </label>\n </div>\n <div class=\"field\">\n <label for=\"new-role\">Role</label>\n <SelectMenu\n id=\"new-role\"\n :model-value=\"newUser.role\"\n label=\"Role for the new account\"\n :options=\"roleOptions\"\n @update:model-value=\"(v) => (newUser.role = v as Role)\"\n />\n </div>\n <p class=\"hint\">At least 8 characters. A new account starts as a viewer unless you say otherwise.</p>\n <div class=\"row\">\n <button class=\"primary\" type=\"submit\" :disabled=\"!canCreateUser\">Add account</button>\n <span class=\"grow\" />\n </div>\n <EquivalentCommand\n what=\"this account creation\"\n method=\"POST\"\n path=\"/api/users\"\n :body=\"{ username: newUser.username || 'alice', password: '…', role: newUser.role }\"\n />\n </form>\n <!-- Not an apology for a missing button: it says who to ask, which is the thing the reader\n actually needs. Reading the roster is every account's; changing it is admin's. -->\n <p v-else class=\"hint\">\n Only an admin can add an account or change a role. Ask one of the admins above.\n </p>\n </section>\n\n <section class=\"panel\">\n <div class=\"phead\">\n <h2 class=\"section\">Your API tokens</h2>\n <InfoHint label=\"when to use one\">\n A script or a CI job signing in as you. It carries whatever you can do, so give each one\n a name you will recognise later and revoke the ones you stop using.\n </InfoHint>\n </div>\n\n <SkeletonList v-if=\"!loaded\" :rows=\"2\" />\n <table v-else-if=\"tokens.length\" class=\"cards\">\n <thead>\n <tr>\n <th>Name</th>\n <th>Last used</th>\n <th aria-label=\"Actions\" />\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"t in tokens\" :key=\"t.id\">\n <td class=\"name\" data-label=\"name\"><b>{{ t.name }}</b></td>\n <td class=\"dim nowrap\" data-label=\"last used\">\n <RelativeTime v-if=\"t.lastUsedAt\" :at=\"t.lastUsedAt\" />\n <span v-else class=\"mute\">never</span>\n </td>\n <td class=\"right nowrap\" data-label=\"\">\n <ActionButton\n class=\"danger sm\"\n :confirm=\"`Revoke ${t.name}?`\"\n @run=\"removeToken(t)\"\n >Revoke</ActionButton\n >\n </td>\n </tr>\n </tbody>\n </table>\n <p v-else class=\"hint\">\n {{ authState.root ? 'The host token is not an account, so it has no personal tokens.' : 'No tokens yet.' }}\n </p>\n\n <form v-if=\"!authState.root\" class=\"stack-form\" @submit.prevent=\"createToken\">\n <h3>New token</h3>\n <label class=\"field\">\n <span>What is it for</span>\n <input v-model=\"newToken\" type=\"text\" placeholder=\"ci-deploy\" autocomplete=\"off\" />\n </label>\n <div class=\"row\">\n <button class=\"primary\" type=\"submit\" :disabled=\"!newToken.trim()\">Create token</button>\n </div>\n <EquivalentCommand\n what=\"this token creation\"\n method=\"POST\"\n path=\"/api/tokens\"\n :body=\"{ name: newToken || 'ci-deploy' }\"\n />\n </form>\n </section>\n </div>\n\n <!-- Password change: a dialog, because it is a distinct decision about one row. -->\n <Transition name=\"fade\">\n <div v-if=\"pwFor\" class=\"scrim\" @click.self=\"pwFor = null\">\n <div class=\"sheet\" role=\"dialog\" aria-modal=\"true\" aria-label=\"Change password\">\n <h3>Change password for {{ pwFor.username }}</h3>\n <p class=\"hint\">\n This signs {{ pwFor.id === authState.user?.id ? 'you' : 'them' }} out everywhere —\n every session and personal token is revoked.\n </p>\n <label class=\"field\">\n <span>New password</span>\n <input v-model=\"pwValue\" type=\"password\" autocomplete=\"new-password\" />\n </label>\n <div class=\"row\">\n <button class=\"primary\" :disabled=\"pwValue.length < 8\" @click=\"changePassword\">\n Change password\n </button>\n <button class=\"ghost\" @click=\"pwFor = null\">Cancel</button>\n </div>\n </div>\n </div>\n </Transition>\n </div>\n</template>\n\n<style scoped>\n.stack-form {\n margin-top: var(--s5);\n padding-top: var(--s4);\n border-top: 1px solid var(--line-soft);\n display: flex;\n flex-direction: column;\n gap: var(--s3);\n}\n.stack-form h3 {\n font-size: var(--t-sm);\n color: var(--fg-dim);\n}\ntd.right {\n text-align: end;\n}\n/* Two fields share a line where there is room and stack where there is not — at 390px a pair of\n * half-width inputs is two inputs nobody can type into. */\n.two-up > .field {\n flex: 1 1 200px;\n}\ntd.right button {\n margin-inline-start: var(--s2);\n}\n/* The picker sits in a row, not a form: it takes the width its longest label needs and no more,\n * so the Role column does not eat the table. The wrapper exists to carry `title` when the control\n * inside it is disabled — a disabled button does not reliably show one of its own. */\n.role-pick {\n display: inline-block;\n}\n.role-pick :deep(.selm-trigger) {\n width: auto;\n min-width: 150px;\n}\n</style>\n"],"names":["LAST_ADMIN_WHY","users","ref","tokens","loaded","listError","newUser","newToken","pwFor","pwValue","revealed","canCreateUser","computed","ROLE_WHAT","roleOptions","ROLES","r","sentence","adminCount","u","lastAdmin","load","t","api","problem","createUser","toast","removeUser","changeRole","role","_a","authState","checkAuth","changePassword","createToken","removeToken","_createElementBlock","_createElementVNode","_hoisted_1","_cache","_hoisted_2","_createVNode","InfoHint","RefreshButton","_createBlock","ErrorNote","_openBlock","_hoisted_3","_toDisplayString","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_Fragment","_renderList","_hoisted_11","_unref","_hoisted_12","_hoisted_13","can","SelectMenu","v","_hoisted_15","_hoisted_16","RelativeTime","_hoisted_17","$event","_hoisted_18","ActionButton","_hoisted_19","SkeletonList","_hoisted_20","_hoisted_21","_vModelText","_hoisted_22","_hoisted_23","_hoisted_24","_hoisted_25","EquivalentCommand","_hoisted_26","_hoisted_27","_hoisted_28","_hoisted_29","_hoisted_30","_hoisted_31","_hoisted_32","_hoisted_33","_hoisted_34","_hoisted_35","_hoisted_36","_hoisted_37","_Transition","_hoisted_38","_hoisted_39","_hoisted_40","_hoisted_41","_hoisted_42"],"mappings":"06DAyFMA,EAAiB,sFAvCvB,MAAMC,EAAQC,EAAY,EAAE,EACtBC,EAASD,EAAa,EAAE,EACxBE,EAASF,EAAI,EAAK,EAClBG,EAAYH,EAAI,EAAE,EAElBI,EAAUJ,EAAwD,CACtE,SAAU,GACV,SAAU,GACV,KAAM,QAAA,CACP,EACKK,EAAWL,EAAI,EAAE,EACjBM,EAAQN,EAAiB,IAAI,EAC7BO,EAAUP,EAAI,EAAE,EAGhBQ,EAAWR,EAA0D,IAAI,EAEzES,EAAgBC,EACpB,IAAMN,EAAQ,MAAM,SAAS,KAAA,EAAO,OAAS,GAAKA,EAAQ,MAAM,SAAS,QAAU,CAAA,EAI/E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A,IAAAA,EAAA,EAAA,EAAAF,EAAyB,YAAnB,eAAY,EAAA,KAClBA,EAAuE,QAAA,sCAAvD5B,EAAO,MAAA4D,GAAE,KAAK,WAAW,aAAa,cAAA,gBAAtC5D,EAAA,KAAO,CAAA,KAEzB4B,EAKM,MALN6D,GAKM,CAJJ7D,EAES,SAAA,CAFD,MAAM,UAAW,SAAU5B,EAAA,MAAQ,OAAM,EAAO,QAAOwB,EAAA,EAAgB,oBAE/E,EAAAkE,EAAA,EACA9D,EAA2D,SAAA,CAAnD,MAAM,QAAS,uBAAO7B,EAAA,MAAK,KAAA,EAAS,QAAM,CAAA"}
|
|
1
|
+
{"version":3,"file":"UsersView-DcjfdY6Q.js","sources":["../../src/views/UsersView.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Accounts and personal API tokens.\n *\n * Accounts landed in 0.10.0 with no UI at all, so the only way to add a second operator was a curl\n * call — which is exactly the thing a control plane exists to spare people.\n *\n * TWO AUDIENCES, TWO SECTIONS, and the split is deliberate. **Accounts** are about other people and\n * are shared state; **tokens** are yours alone (the API scopes them to the caller and cannot show\n * anyone else's). Mixing them into one table would imply an admin can manage another person's\n * tokens, which is not true and would be a bad idea if it were.\n *\n * SECRETS ARE SHOWN ONCE, and the page says so in the same breath as showing them. Same discipline\n * as a notifier signing secret and a registry credential: there is no read path on the server, so\n * this is not a policy that could be relaxed later — the value genuinely stops existing.\n *\n * ── ROLES ────────────────────────────────────────────────────────────────────────────────────────\n *\n * The roster is ordinary team information, so ANY signed-in account reads this page. Changing it —\n * adding an account, setting a role, deleting one, setting someone ELSE's password — is admin's,\n * and those controls are simply not rendered for anyone else. Your OWN password stays yours at\n * every role, so that one button is there for everybody, on their own row only.\n *\n * Hiding is UX. `can('admin')` decides what to DRAW; the server's permission table decides what is\n * allowed, and a hidden control that is somehow reached still comes back 403 — which lands in\n * `listError` and says which role the route wanted. That path is not a fallback, it is the actual\n * enforcement, so it stays.\n *\n * THE LAST ADMIN is the one rule the server has that the UI can see coming: it refuses to delete or\n * demote the final admin account. A request that can only fail is worse than a control that says\n * why it cannot be pressed, so that row's role picker and Delete arrive already disabled, carrying\n * the same remedy the server would have answered with — promote another account first.\n */\nimport { computed, ref } from 'vue';\nimport { api, problem } from '../api/client';\nimport { ROLES, type Role, type User, type UsersResponse } from '../api/types';\nimport { authState, can, checkAuth } from '../composables/useAuth';\nimport { sentence } from '../composables/useFormat';\nimport { toast } from '../composables/useToasts';\nimport ActionButton from '../components/ActionButton.vue';\nimport EquivalentCommand from '../components/EquivalentCommand.vue';\nimport ErrorNote from '../components/ErrorNote.vue';\nimport InfoHint from '../components/InfoHint.vue';\nimport RelativeTime from '../components/RelativeTime.vue';\nimport SkeletonList from '../components/SkeletonList.vue';\nimport RefreshButton from '../components/RefreshButton.vue';\nimport SelectMenu from '../components/SelectMenu.vue';\n\ntype Token = { id: number; name: string; createdAt: number; lastUsedAt: number | null };\n\nconst users = ref<User[]>([]);\nconst tokens = ref<Token[]>([]);\nconst loaded = ref(false);\nconst listError = ref('');\n\nconst newUser = ref<{ username: string; password: string; role: Role }>({\n username: '',\n password: '',\n role: 'viewer',\n});\nconst newToken = ref('');\nconst pwFor = ref<User | null>(null);\nconst pwValue = ref('');\n\n/** Held only until dismissed — there is no way to show either of these again. */\nconst revealed = ref<{ what: string; value: string; note: string } | null>(null);\n\nconst canCreateUser = computed(\n () => newUser.value.username.trim().length > 0 && newUser.value.password.length >= 8,\n);\n\n/** One line each, in the picker itself — a role name alone does not say what it costs to grant. */\nconst ROLE_WHAT: Record<Role, string> = {\n viewer: 'reads everything',\n developer: 'deploys and tears down',\n maintainer: 'host configuration',\n admin: 'accounts and sign-on',\n};\nconst roleOptions = ROLES.map((r) => ({ value: r, label: sentence(r), hint: ROLE_WHAT[r] }));\n\nconst adminCount = computed(() => users.value.filter((u) => u.role === 'admin').length);\n/**\n * The last admin cannot be demoted or deleted — the server refuses both, and a host with no admin\n * has nobody who can add one back. Counting ROWS is the same thing the server counts: root holds\n * PSTACK_TOKEN, not an account, and may not exist as a human at all.\n */\nfunction lastAdmin(u: User): boolean {\n return u.role === 'admin' && adminCount.value === 1;\n}\nconst LAST_ADMIN_WHY = 'The only admin — promote another account first.';\n\nasync function load(): Promise<void> {\n const [u, t] = await Promise.all([\n api.get<UsersResponse>('/api/users'),\n api.get<{ tokens: Token[] }>('/api/tokens'),\n ]);\n loaded.value = true;\n if (!u.ok) {\n listError.value = problem(u, 'load the accounts');\n return;\n }\n listError.value = '';\n users.value = u.body.users ?? [];\n // Root (PSTACK_TOKEN) is not a user, so it has no personal tokens — an error here is expected.\n tokens.value = t.ok ? (t.body.tokens ?? []) : [];\n}\nvoid load();\n\nasync function createUser(): Promise<void> {\n // The role is always sent, never left to the server's default: what this form creates should be\n // whatever the form is showing. (An absent role means viewer there, which is the same answer —\n // but the day it is not, this page would be creating something other than what it said.)\n const r = await api.post<{ user: User }>('/api/users', {\n username: newUser.value.username.trim(),\n password: newUser.value.password,\n role: newUser.value.role,\n });\n if (!r.ok) {\n listError.value = problem(r, 'create this account');\n return;\n }\n toast('ok', `Created ${r.body.user.username} as a ${r.body.user.role}.`);\n newUser.value = { username: '', password: '', role: 'viewer' };\n void load();\n}\n\nasync function removeUser(u: User): Promise<void> {\n const r = await api.del(`/api/users/${u.id}`);\n // The server refuses to delete the last account. That is a rule worth surfacing verbatim rather\n // than as \"could not delete\" — it tells the operator what to do instead.\n if (!r.ok) {\n listError.value = problem(r, `delete ${u.username}`);\n return;\n }\n toast('ok', `Deleted ${u.username}.`);\n void load();\n}\n\nasync function changeRole(u: User, role: string): Promise<void> {\n if (role === u.role) return;\n const r = await api.patch(`/api/users/${u.id}`, { role });\n if (!r.ok) {\n listError.value = problem(r, `change the role for ${u.username}`);\n return;\n }\n listError.value = '';\n if (u.id === authState.user?.id) {\n // You just changed your OWN role, and this whole app — the rail, this page's controls, the\n // footer — is drawn from the role it is holding. Re-read it before anything renders again,\n // or the UI keeps offering what the server will now refuse. (The server needs no prompting:\n // every request looks the role up fresh.)\n await checkAuth();\n toast('ok', `You are now a ${role}. What this app offers you changed with it.`);\n } else {\n toast('ok', `${u.username} is now a ${role}.`);\n }\n void load();\n}\n\nasync function changePassword(): Promise<void> {\n const u = pwFor.value;\n if (!u) return;\n const r = await api.put(`/api/users/${u.id}/password`, { password: pwValue.value });\n if (!r.ok) {\n listError.value = problem(r, `change the password for ${u.username}`);\n return;\n }\n pwFor.value = null;\n pwValue.value = '';\n // Not a footnote: the change signs that user out everywhere, and if it was YOU, the next request\n // is a 401. Saying so here is the difference between an expected step and an apparent bug.\n toast(\n 'ok',\n u.id === authState.user?.id\n ? `Password changed. You have been signed out everywhere — sign in again.`\n : `Password changed. ${u.username} has been signed out everywhere.`,\n );\n void load();\n}\n\nasync function createToken(): Promise<void> {\n const r = await api.post<{ token: string; id: number }>('/api/tokens', {\n name: newToken.value.trim(),\n });\n if (!r.ok) {\n listError.value = problem(r, 'create this token');\n return;\n }\n revealed.value = {\n what: `Personal token “${newToken.value.trim()}”`,\n value: r.body.token,\n note: 'Send it as a bearer token. The server stores only a hash, so this is the only time it is shown.',\n };\n newToken.value = '';\n void load();\n}\n\nasync function removeToken(t: Token): Promise<void> {\n const r = await api.del(`/api/tokens/${t.id}`);\n if (!r.ok) {\n listError.value = problem(r, `revoke ${t.name}`);\n return;\n }\n toast('ok', `Revoked ${t.name}.`);\n void load();\n}\n</script>\n\n<template>\n <div>\n <div class=\"page-head\">\n <div>\n <h1>Users & access</h1>\n <div class=\"sub\">\n Who can sign in, and the tokens they use from scripts\n <InfoHint label=\"how access works here\">\n Three kinds of caller. The host token from the environment is the root credential CI\n holds. An account signs in with a password and gets a browser session. A personal token\n belongs to one account and is what a script uses — it can do anything that account can.\n </InfoHint>\n </div>\n </div>\n <span class=\"grow\" />\n <RefreshButton :run=\"load\" />\n </div>\n\n <ErrorNote v-if=\"listError\" :text=\"listError\" title=\"Something went wrong.\" />\n\n <div v-if=\"revealed\" class=\"banner ok\">\n <b>{{ revealed.what }} — copy it now.</b>\n <p>{{ revealed.note }}</p>\n <pre class=\"code\">{{ revealed.value }}</pre>\n <div class=\"row\">\n <button @click=\"revealed = null\">I have stored it</button>\n </div>\n </div>\n\n <div class=\"grid-2\">\n <section class=\"panel\">\n <div class=\"phead\">\n <h2 class=\"section\">Accounts</h2>\n <span class=\"grow\" />\n <span class=\"mute\" style=\"font-size: var(--t-xs)\">{{ users.length }}</span>\n </div>\n\n <SkeletonList v-if=\"!loaded\" :rows=\"3\" />\n <!-- `cards` + `data-label` per cell: below 640px the same markup renders as cards. Without\n it the row's two buttons pushed the table past the viewport and got clipped. -->\n <table v-else-if=\"users.length\" class=\"cards\">\n <thead>\n <tr>\n <th>User</th>\n <th>Role</th>\n <th>Added</th>\n <th aria-label=\"Actions\" />\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"u in users\" :key=\"u.id\">\n <td class=\"name\" data-label=\"user\">\n <b>{{ u.username }}</b>\n <span v-if=\"u.id === authState.user?.id\" class=\"badge info\">you</span>\n </td>\n <!-- An admin gets the picker in place: promotion is a one-step decision about one\n person, and a dialog for a four-option choice is a page-blocking ceremony. Anyone\n else reads the role as text — `sentence()` at render only, never on the value.\n A role this build does not know still shows: it falls through to `placeholder`. -->\n <td data-label=\"role\">\n <span\n v-if=\"can('admin')\"\n class=\"role-pick\"\n :title=\"lastAdmin(u) ? LAST_ADMIN_WHY : undefined\"\n >\n <SelectMenu\n :model-value=\"u.role\"\n :label=\"`Role for ${u.username}`\"\n :options=\"roleOptions\"\n :disabled=\"lastAdmin(u)\"\n :placeholder=\"sentence(u.role)\"\n @update:model-value=\"(v) => changeRole(u, v)\"\n />\n </span>\n <span v-else>{{ sentence(u.role) }}</span>\n </td>\n <td class=\"dim nowrap\" data-label=\"added\"><RelativeTime :at=\"u.createdAt\" /></td>\n <td class=\"right nowrap\" data-label=\"\">\n <!-- Your own password is yours at any role; someone else's is an admin operation. -->\n <button\n v-if=\"u.id === authState.user?.id || can('admin')\"\n class=\"ghost sm\"\n @click=\"pwFor = u; pwValue = ''\"\n >\n Change password\n </button>\n <ActionButton\n v-if=\"can('admin')\"\n class=\"danger sm\"\n :confirm=\"`Delete ${u.username}?`\"\n :disabled=\"lastAdmin(u)\"\n :title=\"lastAdmin(u) ? LAST_ADMIN_WHY : undefined\"\n @run=\"removeUser(u)\"\n >Delete</ActionButton\n >\n </td>\n </tr>\n </tbody>\n </table>\n <p v-else class=\"hint\">No accounts yet.</p>\n\n <form v-if=\"can('admin')\" class=\"stack-form\" @submit.prevent=\"createUser\">\n <h3>Add an account</h3>\n <div class=\"row wrap two-up\">\n <label class=\"field grow\">\n <span>Username</span>\n <input v-model=\"newUser.username\" type=\"text\" autocomplete=\"off\" />\n </label>\n <label class=\"field grow\">\n <span>Password</span>\n <input v-model=\"newUser.password\" type=\"password\" autocomplete=\"new-password\" />\n </label>\n </div>\n <div class=\"field\">\n <label for=\"new-role\">Role</label>\n <SelectMenu\n id=\"new-role\"\n :model-value=\"newUser.role\"\n label=\"Role for the new account\"\n :options=\"roleOptions\"\n @update:model-value=\"(v) => (newUser.role = v as Role)\"\n />\n </div>\n <p class=\"hint\">At least 8 characters. A new account starts as a viewer unless you say otherwise.</p>\n <div class=\"row\">\n <button class=\"primary\" type=\"submit\" :disabled=\"!canCreateUser\">Add account</button>\n <span class=\"grow\" />\n </div>\n <EquivalentCommand\n what=\"this account creation\"\n method=\"POST\"\n path=\"/api/users\"\n :body=\"{ username: newUser.username || 'alice', password: '…', role: newUser.role }\"\n />\n </form>\n <!-- Not an apology for a missing button: it says who to ask, which is the thing the reader\n actually needs. Reading the roster is every account's; changing it is admin's. -->\n <p v-else class=\"hint\">\n Only an admin can add an account or change a role. Ask one of the admins above.\n </p>\n </section>\n\n <section class=\"panel\">\n <div class=\"phead\">\n <h2 class=\"section\">Your API tokens</h2>\n <InfoHint label=\"when to use one\">\n A script or a CI job signing in as you. It carries whatever you can do, so give each one\n a name you will recognise later and revoke the ones you stop using.\n </InfoHint>\n </div>\n\n <SkeletonList v-if=\"!loaded\" :rows=\"2\" />\n <table v-else-if=\"tokens.length\" class=\"cards\">\n <thead>\n <tr>\n <th>Name</th>\n <th>Last used</th>\n <th aria-label=\"Actions\" />\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"t in tokens\" :key=\"t.id\">\n <td class=\"name\" data-label=\"name\"><b>{{ t.name }}</b></td>\n <td class=\"dim nowrap\" data-label=\"last used\">\n <RelativeTime v-if=\"t.lastUsedAt\" :at=\"t.lastUsedAt\" />\n <span v-else class=\"mute\">never</span>\n </td>\n <td class=\"right nowrap\" data-label=\"\">\n <ActionButton\n class=\"danger sm\"\n :confirm=\"`Revoke ${t.name}?`\"\n @run=\"removeToken(t)\"\n >Revoke</ActionButton\n >\n </td>\n </tr>\n </tbody>\n </table>\n <p v-else class=\"hint\">\n {{ authState.root ? 'The host token is not an account, so it has no personal tokens.' : 'No tokens yet.' }}\n </p>\n\n <form v-if=\"!authState.root\" class=\"stack-form\" @submit.prevent=\"createToken\">\n <h3>New token</h3>\n <label class=\"field\">\n <span>What is it for</span>\n <input v-model=\"newToken\" type=\"text\" placeholder=\"ci-deploy\" autocomplete=\"off\" />\n </label>\n <div class=\"row\">\n <button class=\"primary\" type=\"submit\" :disabled=\"!newToken.trim()\">Create token</button>\n </div>\n <EquivalentCommand\n what=\"this token creation\"\n method=\"POST\"\n path=\"/api/tokens\"\n :body=\"{ name: newToken || 'ci-deploy' }\"\n />\n </form>\n </section>\n </div>\n\n <!-- Password change: a dialog, because it is a distinct decision about one row. -->\n <Transition name=\"fade\">\n <div v-if=\"pwFor\" class=\"scrim\" @click.self=\"pwFor = null\">\n <div class=\"sheet\" role=\"dialog\" aria-modal=\"true\" aria-label=\"Change password\">\n <h3>Change password for {{ pwFor.username }}</h3>\n <p class=\"hint\">\n This signs {{ pwFor.id === authState.user?.id ? 'you' : 'them' }} out everywhere —\n every session and personal token is revoked.\n </p>\n <label class=\"field\">\n <span>New password</span>\n <input v-model=\"pwValue\" type=\"password\" autocomplete=\"new-password\" />\n </label>\n <div class=\"row\">\n <button class=\"primary\" :disabled=\"pwValue.length < 8\" @click=\"changePassword\">\n Change password\n </button>\n <button class=\"ghost\" @click=\"pwFor = null\">Cancel</button>\n </div>\n </div>\n </div>\n </Transition>\n </div>\n</template>\n\n<style scoped>\n.stack-form {\n margin-top: var(--s5);\n padding-top: var(--s4);\n border-top: 1px solid var(--line-soft);\n display: flex;\n flex-direction: column;\n gap: var(--s3);\n}\n.stack-form h3 {\n font-size: var(--t-sm);\n color: var(--fg-dim);\n}\ntd.right {\n text-align: end;\n}\n/* Two fields share a line where there is room and stack where there is not — at 390px a pair of\n * half-width inputs is two inputs nobody can type into. */\n.two-up > .field {\n flex: 1 1 200px;\n}\ntd.right button {\n margin-inline-start: var(--s2);\n}\n/* The picker sits in a row, not a form: it takes the width its longest label needs and no more,\n * so the Role column does not eat the table. The wrapper exists to carry `title` when the control\n * inside it is disabled — a disabled button does not reliably show one of its own. */\n.role-pick {\n display: inline-block;\n}\n.role-pick :deep(.selm-trigger) {\n width: auto;\n min-width: 150px;\n}\n</style>\n"],"names":["LAST_ADMIN_WHY","users","ref","tokens","loaded","listError","newUser","newToken","pwFor","pwValue","revealed","canCreateUser","computed","ROLE_WHAT","roleOptions","ROLES","r","sentence","adminCount","u","lastAdmin","load","t","api","problem","createUser","toast","removeUser","changeRole","role","_a","authState","checkAuth","changePassword","createToken","removeToken","_createElementBlock","_createElementVNode","_hoisted_1","_cache","_hoisted_2","_createVNode","InfoHint","RefreshButton","_createBlock","ErrorNote","_openBlock","_hoisted_3","_toDisplayString","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_Fragment","_renderList","_hoisted_11","_unref","_hoisted_12","_hoisted_13","can","SelectMenu","v","_hoisted_15","_hoisted_16","RelativeTime","_hoisted_17","$event","_hoisted_18","ActionButton","_hoisted_19","SkeletonList","_hoisted_20","_hoisted_21","_vModelText","_hoisted_22","_hoisted_23","_hoisted_24","_hoisted_25","EquivalentCommand","_hoisted_26","_hoisted_27","_hoisted_28","_hoisted_29","_hoisted_30","_hoisted_31","_hoisted_32","_hoisted_33","_hoisted_34","_hoisted_35","_hoisted_36","_hoisted_37","_Transition","_hoisted_38","_hoisted_39","_hoisted_40","_hoisted_41","_hoisted_42"],"mappings":"06DAyFMA,EAAiB,sFAvCvB,MAAMC,EAAQC,EAAY,EAAE,EACtBC,EAASD,EAAa,EAAE,EACxBE,EAASF,EAAI,EAAK,EAClBG,EAAYH,EAAI,EAAE,EAElBI,EAAUJ,EAAwD,CACtE,SAAU,GACV,SAAU,GACV,KAAM,QAAA,CACP,EACKK,EAAWL,EAAI,EAAE,EACjBM,EAAQN,EAAiB,IAAI,EAC7BO,EAAUP,EAAI,EAAE,EAGhBQ,EAAWR,EAA0D,IAAI,EAEzES,EAAgBC,EACpB,IAAMN,EAAQ,MAAM,SAAS,KAAA,EAAO,OAAS,GAAKA,EAAQ,MAAM,SAAS,QAAU,CAAA,EAI/EO,EAAkC,CACtC,OAAQ,mBACR,UAAW,yBACX,WAAY,qBACZ,MAAO,sBAAA,EAEHC,EAAcC,GAAM,IAAKC,IAAO,CAAE,MAAOA,EAAG,MAAOC,EAASD,CAAC,EAAG,KAAMH,EAAUG,CAAC,GAAI,EAErFE,EAAaN,EAAS,IAAMX,EAAM,MAAM,OAAQkB,GAAMA,EAAE,OAAS,OAAO,EAAE,MAAM,EAMtF,SAASC,EAAUD,EAAkB,CACnC,OAAOA,EAAE,OAAS,SAAWD,EAAW,QAAU,CACpD,CAGA,eAAeG,GAAsB,CACnC,KAAM,CAACF,EAAGG,CAAC,EAAI,MAAM,QAAQ,IAAI,CAC/BC,EAAI,IAAmB,YAAY,EACnCA,EAAI,IAAyB,aAAa,CAAA,CAC3C,EAED,GADAnB,EAAO,MAAQ,GACX,CAACe,EAAE,GAAI,CACTd,EAAU,MAAQmB,EAAQL,EAAG,mBAAmB,EAChD,MACF,CACAd,EAAU,MAAQ,GAClBJ,EAAM,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Q,CAAG9B,EAAA,MAAS,KAAA,CAAI,EAAI,eAAY,EAAAsF,EAAA,CAAA,GAEjFpD,EAKEwC,EAAA,CAJA,KAAK,sBACL,OAAO,OACP,KAAK,cACJ,WAAc1E,EAAA,OAAQ,WAAA,CAAA,6BAO/BkC,EAoBaqD,GAAA,CApBD,KAAK,QAAM,WACrB,IAAA,OAkBM,OAlBKtF,EAAA,WAAX4B,EAkBM,MAAA,OAlBY,MAAM,QAAS,yBAAY5B,EAAA,MAAK,KAAA,CAAA,MAAA,CAAA,EAAA,GAChD6B,EAgBM,MAhBN0D,GAgBM,CAfJ1D,EAAiD,KAAA,KAA7C,uBAAoBW,EAAGxC,EAAA,MAAM,QAAQ,EAAA,CAAA,EACzC6B,EAGI,IAHJ2D,GAAgB,iBACAxF,EAAA,MAAM,OAAOmD,EAAAA,KAAU,OAAVA,YAAAA,EAAgB,kBAAsB,kEAEnE,CAAA,EACAtB,EAGQ,QAHR4D,GAGQ,CAFN1D,EAAA,EAAA,IAAAA,EAAA,EAAA,EAAAF,EAAyB,YAAnB,eAAY,EAAA,KAClBA,EAAuE,QAAA,sCAAvD5B,EAAO,MAAA4D,GAAE,KAAK,WAAW,aAAa,cAAA,gBAAtC5D,EAAA,KAAO,CAAA,KAEzB4B,EAKM,MALN6D,GAKM,CAJJ7D,EAES,SAAA,CAFD,MAAM,UAAW,SAAU5B,EAAA,MAAQ,OAAM,EAAO,QAAOwB,EAAA,EAAgB,oBAE/E,EAAAkE,EAAA,EACA9D,EAA2D,SAAA,CAAnD,MAAM,QAAS,uBAAO7B,EAAA,MAAK,KAAA,EAAS,QAAM,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{V as f,m as k}from"./VarIO-
|
|
2
|
-
//# sourceMappingURL=VarEditor.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import{V as f,m as k}from"./VarIO-gtGLr9Br.js";import{d as b,c as p,a as l,F as g,r as x,e as w,w as y,o as c,f as m}from"./index-DB2WhG8N.js";const _=["value","aria-label","onInput"],I=["value","aria-label","onInput"],C=["aria-label","onClick"],N=b({__name:"VarEditor",props:{modelValue:{}},emits:["update:modelValue","change"],setup(r,{emit:i}){const u=r,t=i;function d(o,a){const n=u.modelValue.map((e,s)=>s===o?{...e,...a}:e);t("update:modelValue",n),t("change")}function v(){t("update:modelValue",[...u.modelValue,{k:"",v:""}]),t("change")}function h(o,a){const n=a==="replace"?o:k(u.modelValue,o);t("update:modelValue",n.length?n:[{k:"",v:""}]),t("change")}function V(o){const a=u.modelValue.filter((n,e)=>e!==o);t("update:modelValue",a.length?a:[{k:"",v:""}]),t("change")}return(o,a)=>(c(),p("div",null,[a[1]||(a[1]=l("div",{class:"kv head"},[l("span",null,"name"),l("span",null,"value"),l("span")],-1)),(c(!0),p(g,null,x(r.modelValue,(n,e)=>(c(),p("div",{key:e,class:"kv"},[l("input",{type:"text",value:n.k,"aria-label":`variable name ${e+1}`,placeholder:"PR",spellcheck:"false",autocomplete:"off",onInput:s=>d(e,{k:s.target.value.trim()})},null,40,_),l("input",{type:"text",value:n.v,"aria-label":`variable value ${e+1}`,placeholder:"7",spellcheck:"false",autocomplete:"off",onInput:s=>d(e,{v:s.target.value})},null,40,I),l("button",{class:"sm ghost","aria-label":`remove variable ${e+1}`,onClick:s=>V(e)},"−",8,C)]))),128)),l("button",{class:"sm",onClick:v},"+ variable"),w(f,{pairs:r.modelValue,replace:"",onApply:h},{default:y(()=>[...a[0]||(a[0]=[l("p",{class:"hint",style:{"margin-top":"0"}},[l("b",null,"Replace all"),m(" uses exactly what was pasted. "),l("b",null,"Merge"),m(" overwrites the names it finds, keeps the rest, and adds what is new. ")],-1)])]),_:1},8,["pairs"])]))}});export{N as _};
|
|
2
|
+
//# sourceMappingURL=VarEditor.vue_vue_type_script_setup_true_lang-gohbG3IW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VarEditor.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
{"version":3,"file":"VarEditor.vue_vue_type_script_setup_true_lang-gohbG3IW.js","sources":["../../src/components/VarEditor.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * The free-form variable editor, shared by the Config tab and Submit.\n *\n * Free-form on purpose: the spec's `env:` block lists what it DECLARES, which is not the same as\n * what it NEEDS — `stack: pr-${PR}` consumes `PR` without declaring it anywhere. The authoritative\n * list of what is missing is the server's 400 text, not this form.\n *\n * The rows are the editor; `VarIO` under them is the same list as `.env`, CSV or TSV. Typing a\n * dozen variables one input at a time is how they end up mistyped, and the list an operator\n * already has is almost always one of those three formats.\n */\nimport type { VarPair } from '../api/types';\nimport { mergeVars } from '../composables/useVarFormats';\nimport VarIO from './VarIO.vue';\n\nconst props = defineProps<{ modelValue: VarPair[] }>();\nconst emit = defineEmits<{ 'update:modelValue': [VarPair[]]; change: [] }>();\n\nfunction set(i: number, patch: Partial<VarPair>): void {\n const next = props.modelValue.map((e, n) => (n === i ? { ...e, ...patch } : e));\n emit('update:modelValue', next);\n emit('change');\n}\n\nfunction add(): void {\n emit('update:modelValue', [...props.modelValue, { k: '', v: '' }]);\n emit('change');\n}\n\n/**\n * Both modes are honest here — this editor owns its whole list, so replacing it is a thing the\n * operator can mean. A replace that parsed to nothing still leaves one blank row: an editor with no\n * rows looks broken.\n */\nfunction applyImport(pairs: VarPair[], mode: 'replace' | 'merge'): void {\n const next = mode === 'replace' ? pairs : mergeVars(props.modelValue, pairs);\n emit('update:modelValue', next.length ? next : [{ k: '', v: '' }]);\n emit('change');\n}\n\nfunction remove(i: number): void {\n const next = props.modelValue.filter((_, n) => n !== i);\n // Never leave the editor with no rows: an empty list looks like a broken control.\n emit('update:modelValue', next.length ? next : [{ k: '', v: '' }]);\n emit('change');\n}\n</script>\n\n<template>\n <div>\n <div class=\"kv head\"><span>name</span><span>value</span><span /></div>\n <div v-for=\"(e, i) in modelValue\" :key=\"i\" class=\"kv\">\n <input\n type=\"text\"\n :value=\"e.k\"\n :aria-label=\"`variable name ${i + 1}`\"\n placeholder=\"PR\"\n spellcheck=\"false\"\n autocomplete=\"off\"\n @input=\"set(i, { k: ($event.target as HTMLInputElement).value.trim() })\"\n />\n <input\n type=\"text\"\n :value=\"e.v\"\n :aria-label=\"`variable value ${i + 1}`\"\n placeholder=\"7\"\n spellcheck=\"false\"\n autocomplete=\"off\"\n @input=\"set(i, { v: ($event.target as HTMLInputElement).value })\"\n />\n <button class=\"sm ghost\" :aria-label=\"`remove variable ${i + 1}`\" @click=\"remove(i)\">−</button>\n </div>\n <button class=\"sm\" @click=\"add\">+ variable</button>\n\n <VarIO :pairs=\"modelValue\" replace @apply=\"applyImport\">\n <p class=\"hint\" style=\"margin-top: 0\">\n <b>Replace all</b> uses exactly what was pasted. <b>Merge</b> overwrites the names it finds,\n keeps the rest, and adds what is new.\n </p>\n </VarIO>\n </div>\n</template>\n"],"names":["props","__props","emit","__emit","set","i","patch","next","n","add","applyImport","pairs","mode","mergeVars","remove","_","_createElementBlock","_createElementVNode","_openBlock","_Fragment","_renderList","e","$event","_hoisted_3","_createVNode","VarIO","_cache"],"mappings":"2VAgBA,MAAMA,EAAQC,EACRC,EAAOC,EAEb,SAASC,EAAIC,EAAWC,EAA+B,CACrD,MAAMC,EAAOP,EAAM,WAAW,IAAI,CAAC,EAAGQ,IAAOA,IAAMH,EAAI,CAAE,GAAG,EAAG,GAAGC,CAAA,EAAU,CAAE,EAC9EJ,EAAK,oBAAqBK,CAAI,EAC9BL,EAAK,QAAQ,CACf,CAEA,SAASO,GAAY,CACnBP,EAAK,oBAAqB,CAAC,GAAGF,EAAM,WAAY,CAAE,EAAG,GAAI,EAAG,EAAA,CAAI,CAAC,EACjEE,EAAK,QAAQ,CACf,CAOA,SAASQ,EAAYC,EAAkBC,EAAiC,CACtE,MAAML,EAAOK,IAAS,UAAYD,EAAQE,EAAUb,EAAM,WAAYW,CAAK,EAC3ET,EAAK,oBAAqBK,EAAK,OAASA,EAAO,CAAC,CAAE,EAAG,GAAI,EAAG,EAAA,CAAI,CA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AAA,EAAA,CAAA,EAAA,CAHJT,EAGI,IAAA,CAHD,MAAM,OAAO,MAAA,CAAA,aAAA,GAAA,CAAA,GACdA,EAAkB,SAAf,aAAW,IAAI,iCAA+B,EAAAA,EAAY,SAAT,OAAK,IAAI,wEAE/D,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as P,c as h,a as c,F as $,r as S,u as C,t as b,g as w,a4 as Z,i as Q,v as U,e as W,f as M,E as q,j as V,k as A,o as m,U as N}from"./index-
|
|
1
|
+
import{d as P,c as h,a as c,F as $,r as S,u as C,t as b,g as w,a4 as Z,i as Q,v as U,e as W,f as M,E as q,j as V,k as A,o as m,U as N}from"./index-DB2WhG8N.js";import{_ as H}from"./SelectMenu.vue_vue_type_script_setup_true_lang-Bjd8KlYw.js";import{_ as G}from"./_plugin-vue_export-helper-DlAUqK2U.js";const T=["env","csv","tsv"],x={env:".env",csv:"CSV",tsv:"TSV"},D=/^[A-Za-z_][A-Za-z0-9_]*$/,J=/^[A-Za-z0-9_@%+=:,./-]+$/,F={csv:",",tsv:" "},K=new Set(["name","key","variable","var"]),X=new Set(["value","val"]);function Y(e,s,t){const a=e.filter(l=>l.k);if(s==="env")return[...t?t.split(`
|
|
2
2
|
`).map(o=>`# ${o}`):[],...a.map(o=>`${o.k}=${ee(o.v)}`)].join(`
|
|
3
3
|
`)+`
|
|
4
4
|
`;const n=F[s];return[["name","value"],...a.map(l=>[l.k,l.v])].map(l=>l.map(o=>te(o??"",n)).join(n)).join(`
|
|
@@ -12,4 +12,4 @@ import{d as P,c as h,a as c,F as $,r as S,u as C,t as b,g as w,a4 as Z,i as Q,v
|
|
|
12
12
|
REGION=eu-central
|
|
13
13
|
|
|
14
14
|
…or two columns of CSV or TSV`},null,512),[[U,l.value]]),c("div",he,[W(H,{modelValue:o.value,"onUpdate:modelValue":r[3]||(r[3]=u=>o.value=u),label:"how to read the paste",options:k},null,8,["modelValue"]),i.value?(m(),h("span",me," read as "+b(C(x)[i.value.format]),1)):w("",!0)]),i.value?(m(),h($,{key:0},[c("p",be,[c("b",null,b(d.value.length),1),M(" variable"+b(d.value.length===1?"":"s")+" read. ",1),y.value.length?(m(),h($,{key:0},[M(b(y.value.length)+" ("+b(y.value.map(u=>u.k).join(", "))+") had no value and will be skipped — a value stored here is never blank. ",1)],64)):w("",!0)]),d.value.length?(m(),h("ul",ge,[(m(!0),h($,null,S(d.value.slice(0,R),u=>(m(),h("li",{key:u.k},[c("span",ye,[c("code",null,b(u.k),1)]),c("span",ke,b(u.v),1)]))),128)),d.value.length>R?(m(),h("li",we," and "+b(d.value.length-R)+" more ",1)):w("",!0)])):w("",!0),i.value.problems.length?(m(),h("div",_e,[c("b",null,b(i.value.problems.length)+" line"+b(i.value.problems.length===1?"":"s")+" could not be read ",1),c("ul",$e,[(m(!0),h($,null,S(i.value.problems,u=>(m(),h("li",{key:u.line},[c("span",xe,"line "+b(u.line),1),c("code",null,b(u.text),1),c("span",Ee,b(u.reason),1)]))),128))]),r[10]||(r[10]=c("p",null," They are not imported. Fix them and paste again, or apply what parsed and add the rest by hand. ",-1))])):w("",!0),c("div",Ce,[e.replace?(m(),h("button",{key:0,type:"button",class:"primary",disabled:!d.value.length||e.busy,title:d.value.length?"Discard the current list and use exactly what was pasted":"Nothing parsed to apply",onClick:r[4]||(r[4]=u=>_("replace"))}," Replace all ",8,Ve)):w("",!0),c("button",{type:"button",class:q(e.replace?"":"primary"),disabled:!d.value.length||e.busy,title:d.value.length?"Overwrite matching names, keep the rest, add what is new":"Nothing parsed to apply",onClick:r[5]||(r[5]=u=>_("merge"))}," Merge ",10,Ae),c("button",{type:"button",class:"ghost",onClick:r[6]||(r[6]=u=>n.value=!1)},"Cancel")])],64)):w("",!0)])):w("",!0)]))}}),Oe=G(Se,[["__scopeId","data-v-0ae3954c"]]);export{Oe as V,Le as m};
|
|
15
|
-
//# sourceMappingURL=VarIO-
|
|
15
|
+
//# sourceMappingURL=VarIO-gtGLr9Br.js.map
|