1import{c as N,r as c,e0 as k,j as e,X as $,L as A,e1 as P,e2 as M}from"./index-Bbt7XrBV.js";import{P as m,s as t}from"./PageHeader-D-hO8mCj.js";import{C as S}from"./check-CZZcmJ5H.js";function _(a,s){return a.replace(/\{([^}]+)\}/g,(u,n)=>(s==null?void 0:s[n])??`{${n}}`)}const T={pending:"Waiting for approval",approved:"Approved and run",rejected:"Rejected",expired:"Expired without a decision",failed:"Approved, but it failed"};function R(a){const s=a.label||a.prefix||"an agent";return a.kind==="oauth-grant"?`${s} (connected app)`:`${s} (agent key)`}function j(a){return JSON.stringify(a,null,2)}function q(){var b,g;const{id:a}=N(),[s,u]=c.useState(null),[n,f]=c.useState(null),[d,h]=c.useState(null),[x,y]=c.useState(!1);c.useEffect(()=>{k(a).then(u).catch(l=>{var i;return h(((i=l==null?void 0:l.body)==null?void 0:i.error)||"This change could not be loaded.")})},[a]);const v=async l=>{var i;y(!0),h(null);try{const r=l?await P(a):await M(a);u(r.approval),f(r.response)}catch(r){h(((i=r==null?void 0:r.body)==null?void 0:i.error)||"Something went wrong. Reload and try again.")}finally{y(!1)}};if(!s)return e.jsxs(e.Fragment,{children:[e.jsx(m,{title:"Proposed change",status:d?"error":"loading"}),d&&e.jsx("div",{className:t.card,role:"alert",style:{padding:16,color:"#ef4444"},children:d})]});const o=s.operation,p=s.status==="pending";return e.jsxs(e.Fragment,{children:[e.jsx(m,{title:"Proposed change",status:"live",subtitle:`${s.environment} · requested by ${R(s.requested_by)}`}),e.jsx("div",{className:t.stack,children:e.jsxs("div",{className:t.card,children:[e.jsxs("div",{className:t.cardHeader,children:[e.jsxs("div",{children:[e.jsx("div",{className:t.cardTitle,children:o.summary||o.name}),e.jsx("div",{className:t.cardSubtitle,children:e.jsxs("code",{children:[o.method," ",_(o.path,s.path_params)]})})]}),e.jsx("span",{className:t.tableMuted,role:"status",children:T[s.status]||s.status})]}),e.jsxs("div",{className:t.cardContent,style:{display:"grid",gap:12,fontSize:13},children:[Object.keys(s.query||{}).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:t.tableMuted,children:"Query"}),e.jsx("pre",{className:t.codeBlock,children:j(s.query)})]}),p?e.jsxs("div",{children:[e.jsx("div",{className:t.tableMuted,children:"Body"}),e.jsx("pre",{className:t.codeBlock,children:j(s.body)})]}):e.jsxs("div",{className:t.tableMuted,children:["Body fields: ",(s.body_keys||[]).join(", ")||"none"," (values are dropped once a change is decided)"]}),e.jsxs("div",{className:t.tableMuted,children:["Proposed ",s.created_at,p?`, expires ${s.expires_at}`:"",s.decided_by?`. Decided by ${s.decided_by} ${s.decided_at}`:"",(b=s.result)!=null&&b.status?`. Result: HTTP ${s.result.status}`:"",(g=s.result)!=null&&g.error?` (${s.result.error})`:""]}),n&&e.jsxs("div",{children:[e.jsx("div",{className:t.tableMuted,children:"Response"}),e.jsx("pre",{className:t.codeBlock,children:j(n.body)})]}),d&&e.jsx("div",{role:"alert",style:{color:"#ef4444"},children:d}),p&&e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{type:"button",className:`${t.btn} ${t.btnPrimary}`,disabled:x,onClick:()=>v(!0),children:[e.jsx(S,{size:14}),x?"Runningâ¦":"Approve and run"]}),e.jsxs("button",{type:"button",className:`${t.btn} ${t.btnDanger}`,disabled:x,onClick:()=>v(!1),children:[e.jsx($,{size:14}),"Reject"]})]}),p&&e.jsx("div",{className:t.tableMuted,children:"Approving runs this in production now, as you. The agent's key is recorded as the operator in the audit log."}),e.jsx(A,{to:"/app/settings?tab=API%20keys",children:"All pending changes"})]})]})})]})}export{q as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.