decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 4.23 kB
JavaScript
import{c as V,b as q,r as z,a as O,i as Y,e as $,j as t,n as L,K as J,t as Q,o as W,B as G,p as H}from"./index-ztdGKvBm.js";import{C as X}from"./collection-table-wrapper-Ds5dhGJx.js";import{E as D}from"./empty-state-I_cTbW85.js";import{S as Z}from"./search-input-BQ8Dp8aD.js";import{B as I}from"./badge-DcUertOZ.js";import{u as ee}from"./use-debounced-value-DO5dvp6c.js";import{a as K}from"./admin-fetch-BhTJlAsX.js";import"./table-C3AdbrSy.js";import"./ArrowUp-D5DDc3Cp.js";import"./SearchMd-BD2qldmS.js";function pe(){const e=V.c(58),s=q(),[r,M]=z.useState("");let N;e[0]!==r?(N=r.trim(),e[0]=r,e[1]=N):N=e[1];const i=ee(N,300),{data:R}=O.useSession(),k=R?.user?.id;let n;e[2]!==i?(n=J.deploymentAdminUsers(i),e[2]=i,e[3]=n):n=e[3];let l;e[4]!==i?(l=()=>{const a=new URLSearchParams({limit:"100"});return i&&a.set("searchValue",i),K(`/api/_admin/users?${a}`)},e[4]=i,e[5]=l):l=e[5];let C;e[6]!==n||e[7]!==l?(C={queryKey:n,queryFn:l},e[6]=n,e[7]=l,e[8]=C):C=e[8];const{data:P,isLoading:_,isError:A}=Y(C);let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=te,e[9]=w):w=e[9];let y;e[10]!==s?(y={mutationFn:ae,onSuccess:w,onError:a=>{Q.error(a instanceof Error?a.message:s("admin.users.failedToImpersonate"))}},e[10]=s,e[11]=y):y=e[11];const E=$(y);let b;e[12]!==P?.users?(b=P?.users??[],e[12]=P?.users,e[13]=b):b=e[13];const B=b;let o;e[14]!==s?(o=s("admin.users.columnUser"),e[14]=s,e[15]=o):o=e[15];let m;e[16]!==s?(m=a=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(W,{url:a.image??void 0,fallback:a.name??"?",shape:"circle",size:"sm"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:a.name||s("admin.users.unknown")}),t.jsx("div",{className:"text-sm text-muted-foreground truncate",children:a.email})]})]}),e[16]=s,e[17]=m):m=e[17];let d;e[18]!==o||e[19]!==m?(d={id:"user",header:o,render:m,cellClassName:"flex-1 min-w-0"},e[18]=o,e[19]=m,e[20]=d):d=e[20];let c;e[21]!==s?(c=s("admin.users.columnEmail"),e[21]=s,e[22]=c):c=e[22];let u;e[23]!==s?(u=a=>a.emailVerified?t.jsx(I,{variant:"outline",className:"text-success border-success/20",children:s("admin.users.verified")}):t.jsx(I,{variant:"outline",className:"text-muted-foreground",children:s("admin.users.unverified")}),e[23]=s,e[24]=u):u=e[24];let f;e[25]!==c||e[26]!==u?(f={id:"verified",header:c,render:u,cellClassName:"w-28 shrink-0"},e[25]=c,e[26]=u,e[27]=f):f=e[27];let p;e[28]!==s?(p=s("admin.users.columnCreated"),e[28]=s,e[29]=p):p=e[29];let h;e[30]!==p?(h={id:"created",header:p,render:se,cellClassName:"w-48 shrink-0"},e[30]=p,e[31]=h):h=e[31];let x;e[32]!==k||e[33]!==E||e[34]!==s?(x={id:"actions",header:"",render:a=>t.jsx(G,{variant:"outline",size:"sm",disabled:a.id===k||E.isPending,onClick:()=>E.mutate(a.id),children:s("admin.users.impersonate")}),cellClassName:"w-32 shrink-0"},e[32]=k,e[33]=E,e[34]=s,e[35]=x):x=e[35];let T;e[36]!==f||e[37]!==h||e[38]!==x||e[39]!==d?(T=[d,f,h,x],e[36]=f,e[37]=h,e[38]=x,e[39]=d,e[40]=T):T=e[40];const F=T;let j;e[41]!==s?(j=s("admin.users.searchPlaceholder"),e[41]=s,e[42]=j):j=e[42];let g;e[43]!==r||e[44]!==j?(g=t.jsx(Z,{value:r,onChange:M,placeholder:j,className:"w-full md:w-[375px]"}),e[43]=r,e[44]=j,e[45]=g):g=e[45];let S;e[46]!==i||e[47]!==A||e[48]!==s?(S=A?t.jsx(D,{title:s("admin.users.failedToLoadTitle"),description:s("admin.users.failedToLoadDescription")}):t.jsx(D,{title:s("admin.users.noUsersFoundTitle"),description:i?s("admin.users.noUsersMatchSearch",{search:i}):s("admin.users.noUsersYet")}),e[46]=i,e[47]=A,e[48]=s,e[49]=S):S=e[49];let v;e[50]!==F||e[51]!==_||e[52]!==S||e[53]!==B?(v=t.jsx(X,{columns:F,data:B,isLoading:_,emptyState:S}),e[50]=F,e[51]=_,e[52]=S,e[53]=B,e[54]=v):v=e[54];let U;return e[55]!==g||e[56]!==v?(U=t.jsx(L,{children:t.jsx(L.Content,{children:t.jsx(L.Container,{children:t.jsxs("div",{className:"flex flex-col gap-6",children:[g,v]})})})}),e[55]=g,e[56]=v,e[57]=U):U=e[57],U}function se(e){return t.jsx("span",{className:"text-sm text-foreground",children:H(e.createdAt)})}function te(){window.location.href="/"}function ae(e){return K("/api/_admin/impersonate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e})})}export{pe as default};