refactor(q1): src/api 全量清零 any + types/monitor 扩展输入 DTO
ROADMAP Q1 推进(前端类型安全治理 in_progress): - src/api/ 整个目录 any 清零(含 monitor/ deploy/ 子目录 12+ 文件) create/update 入参 any -> Record<string, unknown> / object mock 桩 trace/grafana 对接 types/ 标准类型(Trace/GrafanaDashboard) 典型接口 LdapFormData/ProbeForm 等强类型表单用 object 接收 - types/monitor.ts 扩展 ~150 行接口: ZabbixDatasource / AlertSilence / 7 个输入 DTO Trace / TraceSpan / TraceServiceMetrics / GrafanaDashboard / DashboardPanel HealthProbeInput 验证: - 整个 src/api/ 目录 any=0 - ESLint no-explicit-any: 995 -> 937 (本项目此轮贡献 -58) - tsc -b 零错误, npm run build ✓ (17.06s) - API 回归 8/8 核心端点通过, Docker 部署 healthy
This commit is contained in:
1 parent
480e677042
commit
b553c7956d
436 files changed
+410
-1198
No files matched your search
@@ -0,0 +1 @@
|
||||
import{i as Ne,r as o,f as ve,j as e,L as M,v as ae,B as a,V as D,O as fe,X as pe,Y as we,u as be,t as c}from"./index-o4rKtKfJ.js";import{C as g,a as N}from"./card-6Ae5ROGi.js";import{I as h}from"./input-BfBi0wR2.js";import{B as x}from"./badge-CDGsL4jH.js";import{S as v,a as f,b as w,c as b,d as r}from"./select-DuV0kIrj.js";import{L as i}from"./label-DrX9VaVC.js";import{p as Se}from"./pipeline-CDjAR1sy.js";import{d as m}from"./config-CDJQFc9v.js";import{P as le}from"./plus-BXcAPnTg.js";import{S as ne}from"./save-CtHT3jpw.js";import{T as ke}from"./trash-2-C2Niwqae.js";import{U as de}from"./user-plus-DR6J1R-V.js";import"./index-BeCACrpC.js";import"./chevron-up-CZcf1jNw.js";const Ie=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],re=Ne("regex",Ie);function Oe(){const[l,me]=o.useState([]),[xe,T]=o.useState(!0),[S,A]=o.useState(!1),[y,ie]=o.useState([]),[n,k]=o.useState(null),[F,ye]=o.useState([]),[I,_]=o.useState([]),[p,he]=o.useState(""),[j,q]=o.useState(""),[G,H]=o.useState(!1),[J,z]=o.useState(!1),[P,O]=o.useState(""),[E,X]=o.useState(""),[C,Y]=o.useState(""),[K,Q]=o.useState("editor"),[W,Z]=o.useState(""),[Ce,U]=o.useState(null),[L,ee]=o.useState(""),[se,te]=o.useState(""),Re=ve(),R=async()=>{T(!0);try{const[s,t,d]=await Promise.all([m.getItemRoles(),Se.getPipelines({page_size:200}),be.getUsers({page_size:500})]);me(Array.isArray(s)?s:s?.list||s?.data||[]),ie(Array.isArray(t)?t:t?.list||t?.data||[]);const u=Array.isArray(d)?d:d?.list||d?.data||[];ye(u)}catch{}finally{T(!1)}};o.useEffect(()=>{R()},[]);const $=async()=>{if(!p){_([]);return}try{const s=await m.getUserItemRoles(Number(p));_(Array.isArray(s)?s:s?.data||s?.list||[])}catch{_([])}};o.useEffect(()=>{$()},[p]);const B=o.useMemo(()=>{const s={};return l.forEach(t=>{try{const d=new RegExp(t.pattern);s[t.id]=y.filter(u=>d.test(u.code)).map(u=>u.code)}catch{s[t.id]=[]}}),s},[l,y]),oe=(n?l.find(s=>s.id===n):null)?B[n]||[]:[],ue=async()=>{if(!P.trim()||!E.trim()||!C.trim()){c.error("名称、代码、正则表达式不能为空");return}A(!0);try{await m.createItemRole({name:P.trim(),code:E.trim(),pattern:C.trim(),role:K,description:W}),c.success("已创建"),z(!1),O(""),X(""),Y(""),Q("editor"),Z(""),R()}catch(s){c.error(s?.message||"创建失败")}finally{A(!1)}},Ae=async s=>{if(!L.trim()){c.error("正则不能为空");return}A(!0);try{await m.updateItemRole(s,{pattern:L,role:se}),c.success("已更新"),U(null),R()}catch(t){c.error(t?.message||"更新失败")}finally{A(!1)}},je=async s=>{if(await Re({title:"删除角色",description:`确定删除「${s.name}」?匹配 ${B[s.id]?.length||0} 条流水线`,variant:"destructive"}))try{await m.deleteItemRole(s.id),c.success("已删除"),R()}catch{c.error("删除失败")}},Be=async s=>{try{await m.updateItemRole(s.id,{status:s.status?0:1}),c.success(s.status?"已禁用":"已启用"),R()}catch{c.error("操作失败")}},De=async()=>{if(!p||!j){c.error("请选择用户和角色");return}H(!0);try{await m.assignItemRole(Number(p),{user_id:Number(p),item_role_id:Number(j)}),c.success("已分配"),q(""),$()}catch(s){c.error(s?.message||"分配失败")}finally{H(!1)}},ge=async s=>{try{await m.removeItemRole(Number(p),s),c.success("已撤销"),$()}catch{c.error("撤销失败")}},ce=s=>s==="owner"?"bg-amber-500/20 text-amber-400 border-amber-500/30":s==="editor"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",V=F.find(s=>String(s.id)===p);return xe?e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:167:23",className:"flex items-center justify-center py-20",children:e.jsx(M,{"code-path":"src/components/deploy/DeployRBAC.tsx:167:79",className:"w-6 h-6 animate-spin"})}):e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:170:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:172:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:173:9",children:[e.jsxs("h1",{"code-path":"src/components/deploy/DeployRBAC.tsx:174:11",className:"text-xl font-bold flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(ae,{"code-path":"src/components/deploy/DeployRBAC.tsx:175:13",className:"w-5 h-5 text-purple-500"}),"发布权限"]}),e.jsx("p",{"code-path":"src/components/deploy/DeployRBAC.tsx:177:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"Jenkins-style Role Strategy — 按流水线 code 正则匹配分配角色"})]}),e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:181:9",onClick:()=>z(!0),disabled:J,children:[e.jsx(le,{"code-path":"src/components/deploy/DeployRBAC.tsx:182:11",className:"w-4 h-4 mr-1"}),"新建角色"]})]}),e.jsx(g,{"code-path":"src/components/deploy/DeployRBAC.tsx:187:7",className:"bg-[var(-Line truncated
|
||||
Reference in new issue
Block a user