Files
aiops/backend/static/assets/UserGroupsManager-3Qni4Bw9.js
T
attacker b553c7956d 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
2026-06-26 03:37:56 +08:00

2 lines
9.3 KiB
JavaScript

import{i as R,f as F,r as o,j as e,B as t,L as I,Y as w,v as O,D as T,a as _,b as A,c as H,t as a}from"./index-o4rKtKfJ.js";import{I as u}from"./input-BfBi0wR2.js";import{B as $}from"./badge-CDGsL4jH.js";import{L as y}from"./label-DrX9VaVC.js";import{d as n}from"./config-CDJQFc9v.js";import{R as q}from"./refresh-cw-eQ6GkWW0.js";import{P as K}from"./plus-BXcAPnTg.js";import{P as X}from"./pencil-DNq-pnlG.js";import{T as Y}from"./trash-2-C2Niwqae.js";import{U as J}from"./user-plus-DR6J1R-V.js";const Q=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],V=R("user-x",Q);function de(){const g=F(),[G,k]=o.useState([]),[C,M]=o.useState(!0),[S,D]=o.useState({}),[z,p]=o.useState(!1),[l,U]=o.useState(null),[i,m]=o.useState(""),[x,h]=o.useState(""),[j,v]=o.useState(!1),[f,N]=o.useState({}),c=async()=>{M(!0);try{const s=await n.getGroups();k(s?.list||[])}catch{a.error("加载失败")}finally{M(!1)}};o.useEffect(()=>{c()},[]);const E=async()=>{if(!i.trim()){a.error("请输入组名");return}v(!0);try{l?await n.updateGroup(l,{name:i,description:x}):await n.createGroup({name:i,description:x}),a.success(l?"已更新":"已创建"),p(!1),c()}catch{a.error("操作失败")}finally{v(!1)}},L=async s=>{if(await g({title:"删除用户组",description:`确定删除「${s.name}」?所有成员和流水线授权将同时移除。`,variant:"destructive"}))try{await n.deleteGroup(s.id),a.success("已删除"),c()}catch{a.error("删除失败")}},b=async s=>{const r=(f[s]||"").trim();if(!r){a.error("输入用户名");return}try{await n.addGroupMember(s,{username:r}),a.success("已添加"),c(),N(d=>({...d,[s]:""}))}catch{a.error("添加失败")}},P=async(s,r,d)=>{if(await g({title:"移除成员",description:`确定从组中移除「${d}」?`}))try{await n.removeGroupMember(s,r),a.success("已移除"),c()}catch{a.error("移除失败")}},B=s=>D(r=>({...r,[s]:!r[s]}));return e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:81:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:82:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:83:9",children:[e.jsx("h2",{"code-path":"src/components/deploy/UserGroupsManager.tsx:84:11",className:"text-lg font-semibold text-[var(--dg-text-primary)]",children:"用户组管理"}),e.jsx("p",{"code-path":"src/components/deploy/UserGroupsManager.tsx:85:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"创建用户组,将组授权给流水线,组内成员自动获得流水线权限"})]}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:87:9",className:"flex items-center gap-2",children:[e.jsxs(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:88:11",variant:"outline",size:"sm",onClick:c,children:[e.jsx(q,{"code-path":"src/components/deploy/UserGroupsManager.tsx:88:68",className:"w-4 h-4 mr-1"}),"刷新"]}),e.jsxs(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:89:11",size:"sm",onClick:()=>{U(null),m(""),h(""),p(!0)},children:[e.jsx(K,{"code-path":"src/components/deploy/UserGroupsManager.tsx:90:13",className:"w-4 h-4 mr-1"}),"新建用户组"]})]})]}),C?e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:96:9",className:"flex justify-center py-12",children:e.jsx(I,{"code-path":"src/components/deploy/UserGroupsManager.tsx:96:52",className:"w-6 h-6 animate-spin text-[var(--dg-text-secondary)]"})}):G.length===0?e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:98:9",className:"text-center py-12 text-[var(--dg-text-secondary)]",children:[e.jsx(w,{"code-path":"src/components/deploy/UserGroupsManager.tsx:99:11",className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/deploy/UserGroupsManager.tsx:100:11",children:"暂无用户组,点击「新建用户组」创建"})]}):e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:103:9",className:"space-y-3",children:G.map(s=>e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:105:13",className:"border border-[var(--dg-border)] rounded-lg bg-[var(--dg-bg-secondary)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:106:15",className:"flex items-center justify-between p-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:107:17",className:"flex items-center gap-3",style:{cursor:"pointer"},onClick:()=>B(s.id),children:[e.jsx(O,{"code-path":"src/components/deploy/UserGroupsManager.tsx:108:19",className:"w-5 h-5 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:109:19",children:[e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:110:21",className:"font-medium text-[var(--dg-text-primary)]",children:s.name}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:111:21",className:"text-xs text-[var(--dg-text-secondary)]",children:[s.description||"暂无描述"," · ",(s.members||[]).length," 位成员"]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:114:17",className:"flex items-center gap-2",children:[e.jsx(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:115:19",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{U(s.id),m(s.name),h(s.description||""),p(!0)},children:e.jsx(X,{"code-path":"src/components/deploy/UserGroupsManager.tsx:116:21",className:"w-4 h-4"})}),e.jsx(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:118:19",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500",onClick:()=>L(s),children:e.jsx(Y,{"code-path":"src/components/deploy/UserGroupsManager.tsx:119:21",className:"w-4 h-4"})})]})]}),S[s.id]&&e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:125:17",className:"border-t border-[var(--dg-border)] px-4 py-3 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:127:19",className:"flex items-end gap-2",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:128:21",className:"flex-1 space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/UserGroupsManager.tsx:128:55",className:"text-xs",children:"添加用户"}),e.jsx(u,{"code-path":"src/components/deploy/UserGroupsManager.tsx:129:23",value:f[s.id]||"",onChange:r=>N(d=>({...d,[s.id]:r.target.value})),placeholder:"输入用户名",className:"h-8 text-sm",onKeyDown:r=>r.key==="Enter"&&b(s.id)})]}),e.jsxs(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:131:21",size:"sm",className:"h-8",onClick:()=>b(s.id),children:[e.jsx(J,{"code-path":"src/components/deploy/UserGroupsManager.tsx:131:93",className:"w-3.5 h-3.5 mr-1"}),"添加"]})]}),(s.members||[]).length===0?e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:135:21",className:"text-xs text-[var(--dg-text-secondary)] py-2",children:"暂无成员"}):e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:137:21",className:"flex flex-wrap gap-2",children:(s.members||[]).map(r=>e.jsxs($,{"code-path":"src/components/deploy/UserGroupsManager.tsx:139:25",variant:"secondary",className:"flex items-center gap-1 pl-2 pr-1 py-1.5",children:[e.jsx(w,{"code-path":"src/components/deploy/UserGroupsManager.tsx:140:27",className:"w-3 h-3"}),r.username,e.jsx("button",{"code-path":"src/components/deploy/UserGroupsManager.tsx:141:27",className:"ml-1 hover:text-red-400",onClick:()=>P(s.id,r.id,r.username),children:e.jsx(V,{"code-path":"src/components/deploy/UserGroupsManager.tsx:142:29",className:"w-3 h-3"})})]},r.id))})]})]},s.id))}),e.jsx(T,{"code-path":"src/components/deploy/UserGroupsManager.tsx:156:7",open:z,onOpenChange:p,children:e.jsxs(_,{"code-path":"src/components/deploy/UserGroupsManager.tsx:157:9",children:[e.jsx(A,{"code-path":"src/components/deploy/UserGroupsManager.tsx:158:11",children:e.jsx(H,{"code-path":"src/components/deploy/UserGroupsManager.tsx:158:25",children:l?"编辑用户组":"新建用户组"})}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:159:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:160:13",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/UserGroupsManager.tsx:160:40",children:"组名"}),e.jsx(u,{"code-path":"src/components/deploy/UserGroupsManager.tsx:160:57",value:i,onChange:s=>m(s.target.value),placeholder:"例如: 后端开发组"})]}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:161:13",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/UserGroupsManager.tsx:161:40",children:"描述"}),e.jsx(u,{"code-path":"src/components/deploy/UserGroupsManager.tsx:161:57",value:x,onChange:s=>h(s.target.value),placeholder:"可选"})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:163:11",className:"flex justify-end gap-2 mt-4 pt-4 border-t",children:[e.jsx(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:164:13",variant:"outline",onClick:()=>p(!1),children:"取消"}),e.jsx(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:165:13",onClick:E,disabled:j,children:j?"...":"保存"})]})]})})]})}export{de as default};