P1: - utils/storage.ts、theme.ts、validate.ts + index 统一出口 - request/store/useTheme 接入 storage;清零 confirm/alert - PipelineManager、TerminalAuditTab 拆分子模块(<700行红线) P2: - api/monitor、api/deploy 子目录化 - hooks/api 扩展:servers/pipelines/alerts/audit/sessionCommands - PipelineManager、AuditOperationsTab 接入 TanStack Query
2 lines
9.3 KiB
JavaScript
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-HuRw9UhJ.js";import{I as u}from"./input-C9Xfv8um.js";import{B as $}from"./badge-CeS-g-Od.js";import{L as y}from"./label-DvRDtaMA.js";import{d as n}from"./config-J-uY34Cv.js";import{R as q}from"./refresh-cw-CSycAyA2.js";import{P as K}from"./plus-BVwIGPvl.js";import{P as X}from"./pencil-BZ7zX3m0.js";import{T as Y}from"./trash-2-Cf9-88KL.js";import{U as J}from"./user-plus-DK2M0PwG.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};
|