@promptowl/contextnest-community 1.24.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +109 -6
- package/CONFIGURATION.md +7 -2
- package/README.md +1 -1
- package/STEWARDSHIP.md +24 -0
- package/dist/{chunk-2TPQTN4Y.js → chunk-2KHM5C7V.js} +37 -3
- package/dist/{chunk-XUIWAWDO.js → chunk-32SZCH36.js} +4 -4
- package/dist/{chunk-KIAAEHWL.js → chunk-7FROMOZM.js} +23 -5
- package/dist/{chunk-5EZOPA47.js → chunk-DTLMBF4W.js} +10 -8
- package/dist/{chunk-LA3VTQ22.js → chunk-JDAOA5KP.js} +43 -1
- package/dist/{chunk-I3CSD6CK.js → chunk-KPGNZLZL.js} +2 -2
- package/dist/{chunk-YVMSM7LS.js → chunk-LHWOJPFE.js} +7 -0
- package/dist/{chunk-ZTT4U4NE.js → chunk-TI7HMP64.js} +99 -12
- package/dist/{client-KEY4PYJH.js → client-D44ZHDTJ.js} +1 -1
- package/dist/{engine-S3QBQ7LH.js → engine-TER6FDBP.js} +3 -3
- package/dist/{external-edit-service-6FNFPOJJ.js → external-edit-service-CAGENHDJ.js} +4 -4
- package/dist/{grants-service-UT3EQ3R7.js → grants-service-2OTFS7EH.js} +3 -3
- package/dist/index.js +863 -355
- package/dist/{migrations.postgres-AIQ7WSU7.js → migrations.postgres-23VJJJJX.js} +12 -2
- package/dist/{review-service-HHGOTO6P.js → review-service-4G2XUFS6.js} +7 -7
- package/dist/{stewardship-service-4DHNRULG.js → stewardship-service-S22V2JKG.js} +6 -4
- package/dist/{version-service-KIOQME6U.js → version-service-X4FAG2OZ.js} +4 -4
- package/dist/web3/assets/ActivityTracePage-D2iIbEph.js +1 -0
- package/dist/web3/assets/{AgentDocsPage-CIiaBqMy.js → AgentDocsPage-Dkhgb1hk.js} +1 -1
- package/dist/web3/assets/CollaboratorManager-Bo81D--Q.js +1 -0
- package/dist/web3/assets/CollaboratorsTab-DRCitQuX.js +1 -0
- package/dist/web3/assets/DocumentEditor-DV2WHYbj.js +36 -0
- package/dist/web3/assets/{DocumentsTab-Vba-AzBv.js → DocumentsTab-BUxBCN8o.js} +2 -2
- package/dist/web3/assets/{ExternalEditsTab-BSzAQIGM.js → ExternalEditsTab-kIBimZyE.js} +1 -1
- package/dist/web3/assets/MarkdownEditor-CsVusP2d.css +1 -0
- package/dist/web3/assets/MarkdownEditor-Dfk5uIE5.js +648 -0
- package/dist/web3/assets/{NestPageHeader-CoLUV1Oz.js → NestPageHeader-yOK-OIYZ.js} +1 -1
- package/dist/web3/assets/NestView-DwIagxwJ.js +68 -0
- package/dist/web3/assets/{OverviewTab-Dxi-Hu-N.js → OverviewTab-DFOFMVyE.js} +1 -1
- package/dist/web3/assets/{PersonCombobox-CPOlNs6G.js → PersonCombobox-D350WlrJ.js} +1 -1
- package/dist/web3/assets/{ReasonDialog-DgLxfRWv.js → ReasonDialog-CN3ECAnQ.js} +1 -1
- package/dist/web3/assets/{ReviewActions-OfOdqzCn.js → ReviewActions-BXDTDPp1.js} +1 -1
- package/dist/web3/assets/{ReviewTab-CyX8yxd3.js → ReviewTab-CZewAYiz.js} +1 -1
- package/dist/web3/assets/StewardsTab-AagNWcWS.js +1 -0
- package/dist/web3/assets/{SubmitForReviewModal-Ci2DdWs0.js → SubmitForReviewModal-BOZJxwRN.js} +1 -1
- package/dist/web3/assets/{alert-dialog-DTozKlmV.js → alert-dialog-4SiLKlz8.js} +1 -1
- package/dist/web3/assets/{arrow-left-BCKt4CwQ.js → arrow-left-BAgIocLn.js} +1 -1
- package/dist/web3/assets/backlinks-Cb8Uf8mw.js +24 -0
- package/dist/web3/assets/{card-XG2dP5Xf.js → card-UDyMRcps.js} +1 -1
- package/dist/web3/assets/{chevron-left-BPwUT9DS.js → chevron-left-XR4ReJ9Z.js} +1 -1
- package/dist/web3/assets/{circle-check-DI8IBGeo.js → circle-check-CSkZUEFK.js} +1 -1
- package/dist/web3/assets/{circle-x-VKVhC88W.js → circle-x-in2o3aHU.js} +1 -1
- package/dist/web3/assets/client-attribution-BraarYaP.js +1 -0
- package/dist/web3/assets/{code-xml-CMabYZvH.js → code-xml-pPQgdctI.js} +1 -1
- package/dist/web3/assets/{corner-down-right-BGxwK6wH.js → corner-down-right-CuxZWscX.js} +1 -1
- package/dist/web3/assets/{count-skeleton-DMbdpscX.js → count-skeleton-DBWCDhRy.js} +1 -1
- package/dist/web3/assets/{earth-BEp1EKTo.js → earth-CXOcThqn.js} +1 -1
- package/dist/web3/assets/{file-exclamation-point-r8qZGIjP.js → file-exclamation-point-CSphs1VD.js} +1 -1
- package/dist/web3/assets/{folder-input-Cmtx1Jhk.js → folder-input-BAwK9tFL.js} +1 -1
- package/dist/web3/assets/{index-C1wTSjfP.js → index-A0_ymcqL.js} +1 -1
- package/dist/web3/assets/index-B5hLclEq.js +389 -0
- package/dist/web3/assets/index-DrUAtoQM.css +1 -0
- package/dist/web3/assets/page-BHD4beun.js +1 -0
- package/dist/web3/assets/{page-CPjWQNKx.js → page-BSYUXYmO.js} +1 -1
- package/dist/web3/assets/page-BYc2DIux.js +45 -0
- package/dist/web3/assets/{page-Bicf02Cz.js → page-BfibLg8e.js} +1 -1
- package/dist/web3/assets/page-CGe8MtUu.js +9 -0
- package/dist/web3/assets/{page-CQt3ZGbf.js → page-CIgPJmG6.js} +1 -1
- package/dist/web3/assets/{page-CHb0F5hV.js → page-CUjuSs5Q.js} +1 -1
- package/dist/web3/assets/{page-BYUFhYWZ.js → page-Ck31nx9b.js} +1 -1
- package/dist/web3/assets/{page-BExMvttJ.js → page-Cpdj_11Y.js} +1 -1
- package/dist/web3/assets/{page-CtaW65El.js → page-D0sN3GO6.js} +1 -1
- package/dist/web3/assets/page-DEpH91X2.js +1 -0
- package/dist/web3/assets/{page-CC0NJi8v.js → page-l8-B7CGt.js} +1 -1
- package/dist/web3/assets/{page-DGOL9l8i.js → page-mnSHmk6A.js} +1 -1
- package/dist/web3/assets/{page-title-ClvvBsIo.js → page-title-BkqlUA0j.js} +1 -1
- package/dist/web3/assets/{page-ByyVLDVo.js → page-xzYqkBUP.js} +5 -5
- package/dist/web3/assets/{play-C5YNKpAH.js → play-B8xE9j5f.js} +1 -1
- package/dist/web3/assets/{refresh-cw-BhHzSH9m.js → refresh-cw-CsCtmWwX.js} +1 -1
- package/dist/web3/assets/{scroll-area-hz-xtayP.js → scroll-area-CbcH6yrZ.js} +1 -1
- package/dist/web3/assets/{select-DBFTrUmI.js → select-DrL0mpRN.js} +2 -2
- package/dist/web3/assets/{send-0CHvmluT.js → send-CvAgOUPG.js} +1 -1
- package/dist/web3/assets/{settings-CeeF4LEb.js → settings-EY4A_DYv.js} +1 -1
- package/dist/web3/assets/{share-2-CMnOlOt-.js → share-2-vGmZUl90.js} +1 -1
- package/dist/web3/assets/{tag-DQ_6J5Gv.js → tag-Br_y1f00.js} +1 -1
- package/dist/web3/assets/{trash-2-HBi-Pslz.js → trash-2-B4hRXo-p.js} +1 -1
- package/dist/web3/assets/{triangle-alert-CDy8-7sv.js → triangle-alert-CsYGyfGZ.js} +1 -1
- package/dist/web3/assets/{user-plus-CvBNcpn4.js → user-plus-4CTYEkd3.js} +1 -1
- package/dist/web3/assets/{x-By7piikG.js → x-qxt1WrUi.js} +1 -1
- package/dist/web3/assets/zap-BcsKR0ef.js +16 -0
- package/dist/web3/index.html +2 -2
- package/package.json +2 -2
- package/dist/web3/assets/ActivityTracePage-BOZHgJ8S.js +0 -1
- package/dist/web3/assets/CollaboratorManager-By91wrIr.js +0 -1
- package/dist/web3/assets/CollaboratorsTab-D1EE64Fs.js +0 -1
- package/dist/web3/assets/DocumentEditor-DrQfrW3d.js +0 -36
- package/dist/web3/assets/MarkdownEditor-74N_naNQ.css +0 -1
- package/dist/web3/assets/MarkdownEditor-C9zqZjC5.js +0 -643
- package/dist/web3/assets/NestView-CTZ55tXD.js +0 -63
- package/dist/web3/assets/StewardsTab-DBEEfAQI.js +0 -1
- package/dist/web3/assets/backlinks-CYd4xENL.js +0 -24
- package/dist/web3/assets/index-BM-h3DwI.css +0 -1
- package/dist/web3/assets/index-EaX2yql0.js +0 -389
- package/dist/web3/assets/page-B3yvQvHy.js +0 -1
- package/dist/web3/assets/page-BUOADv2X.js +0 -1
- package/dist/web3/assets/page-BsPMDm5d.js +0 -45
- package/dist/web3/assets/page-Cj1NetQ-.js +0 -1
- package/dist/web3/assets/zap-C2T8riBp.js +0 -11
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{r as l,j as e,B as b,ao as se,at as te,e as Se,O as Ae,d9 as Be,da as Fe,f as E,u as Ge,bs as X,L as O,T as He,P as qe,Q as Ke,R as P,U as We,V as y,c8 as Ve,C as Ye,cn as Qe,aP as Je,ag as Xe,D as ve,x as ye,y as be,z as je,G as _e,J as q,I as M,H as we,i as ke,c9 as Ze,E as es,db as Ne,dc as ss,dd as ts,de as ns}from"./index-B5hLclEq.js";import{P as as}from"./page-title-BkqlUA0j.js";import{C as m,a as u,c as p,b as x,d as g}from"./card-UDyMRcps.js";import{T as rs}from"./triangle-alert-CsYGyfGZ.js";import{M as is,r as os}from"./index-A0_ymcqL.js";import{E as ls}from"./earth-CXOcThqn.js";import{T as cs}from"./trash-2-B4hRXo-p.js";function Te(n){return`${n.replace(/["'`\\$;|&<>(){}\s]/g,"").replace(/\/+$/,"")}/mcp`}function S(...n){return n.filter(r=>r!==null).join(`
|
|
2
|
+
`)}const K="<your ContextNest API key>",I="CONTEXTNEST_API_KEY";function ds(n,r,t,d){return[`**Not connectable yet.** ${t}`,"",n.openMode?`This server needs no credential at all, but ${r} still wants an OAuth client to authorize against, and this server runs no authorization server to offer it. There is no header field to fall back to either.`:`This server authenticates with API keys and does not run an OAuth authorization server, so ${r} has nothing to complete its consent flow against. There is no header field to fall back to.`,"",`The endpoint it would point at is \`${d}\`, so nothing here changes once an authorization server ships.`,"","Until then, the workable routes are:","","- Use one of the other harnesses in this panel.","- Or drive the nest through the REST API directly."].join(`
|
|
3
|
+
`)}const W=[{id:"claude-desktop",name:"Claude (claude.ai and Claude Desktop)",kind:"chat",where:"Customize → Connectors → Add custom connector",open:"https://claude.ai/customize/connectors",docs:"https://claude.com/docs/connectors/custom/remote-mcp",support:"header",body:(n,r)=>S("1. Open **Customize → Connectors** and click **Add custom connector**. On Team and Enterprise plans an Owner adds it once under **Organization settings → Connectors → Add → Custom → Web**; members then find it under **Customize → Connectors** and click **Connect**.",`2. Set the MCP server URL to \`${r}\`.`,n.openMode?"3. For **Authentication**, choose **No sign-in** — this server needs no credential.":`3. For **Authentication**, choose **No sign-in**, then open **Request headers**, pick the \`authorization\` header and enter \`Bearer ${K}\` as its value. Enter the value only — Claude adds the header name itself and sends the value exactly as typed, so the \`Bearer \` prefix and its trailing space have to be there.`,"4. Click **Add**. Authentication settings can't be changed afterwards; changing them means removing the connector and adding it again.",n.openMode?null:"",n.openMode?null:"> **Request headers are in beta, and the credential is organization-wide.** If the dialog has no **Request headers** section, your organization doesn't have access yet. Everyone on the connector shares the one credential, so on this surface they all reach this server as the key's owner and see that person's nests. Per-user visibility here needs OAuth, which this server doesn't run yet — for per-user nests today, use one of the command-line harnesses.","","> The MCP client runs on Anthropic's servers, not the user's machine, so this URL must resolve on the public internet and present a valid TLS certificate. A `localhost` or internal-DNS address will not work here.")},{id:"chatgpt",name:"ChatGPT",kind:"chat",where:"Settings → Security and login → Developer mode",docs:"https://developers.openai.com/plugins/deploy/connect-chatgpt",support:"header",body:(n,r)=>S("1. Open **Settings → Security and login** and turn on **Developer mode**.","2. Go to the **Plugins** page and click the **+** button.","3. Give it a name and description you'll recognise in the tools menu later.",`4. Under **Connection**, paste the MCP server URL \`${r}\` — including the \`/mcp\` path.`,"5. Create the connection, then add it from the **tools menu** in a new conversation.","","Developer mode is available on Plus, Pro, Business, Enterprise and Edu — not on the free tier. Public HTTPS is required.",n.openMode?null:"",n.openMode?null:"> **This surface may not connect yet.** The connection step takes a URL and discovers the server's own authentication; OpenAI documents no field for a fixed API key or `Authorization` header. If the connection fails asking you to sign in, this server has no OAuth authorization server to offer it — use one of the command-line harnesses instead.","","> ChatGPT renamed this surface in July 2026. Older guides point at **Settings → Connectors → Advanced**, which no longer exists.")},{id:"grok",name:"Grok",kind:"chat",where:"grok.com/connectors → New Connector → Custom",open:"https://grok.com/connectors",docs:"https://docs.x.ai/grok/connectors",support:"header",body:(n,r)=>S("1. Go to **grok.com/connectors** and choose **New Connector → Custom**.",`2. Enter the MCP server URL \`${r}\`.`,n.openMode?"3. Leave authentication empty.":`3. Complete any authentication the form asks for, supplying \`Bearer ${K}\` where it wants a credential.`,"4. Grok discovers the exposed tools and offers them alongside its built-in connectors.","","The server must be reachable over the public internet; Grok has no tunnel of its own.",n.openMode?null:"",n.openMode?null:"> xAI documents the connector form but not which credentials it accepts, so the authentication step isn't verified here. If it only offers OAuth, this server has none to offer yet — use a command-line harness instead.")},{id:"perplexity",name:"Perplexity",kind:"chat",where:"All settings → Connectors (perplexity.ai/account/connectors)",open:"https://www.perplexity.ai/account/connectors",docs:"https://www.perplexity.ai/help-center/en/articles/13915507-adding-custom-remote-connectors",support:"oauth-only",body:(n,r)=>ds(n,"Perplexity","Under **All settings → Connectors**, Perplexity's custom-connector form asks for an OAuth client ID under **Advanced**, over Streamable HTTP, on a Pro, Max or Enterprise plan.",r)},{id:"claude-code",name:"Claude Code",kind:"cli",where:"one command in any terminal",docs:"https://code.claude.com/docs/en/mcp-quickstart",support:"header",body:(n,r)=>S("```bash",n.openMode?`claude mcp add --transport http contextnest ${r}`:`claude mcp add --transport http contextnest ${r} \\
|
|
4
|
+
--header "Authorization: Bearer $${I}"`,"```","",n.openMode?"By default this registers at `local` scope — only you, only this project. Add `--scope user` for every project, or `--scope project` to write `.mcp.json` in the repo; that file is safe to commit.":`By default this registers at \`local\` scope — only you, only this project. Add \`--scope user\` for every project, or \`--scope project\` to write \`.mcp.json\` in the repo — that file is safe to commit because it can reference \`\${${I}}\` rather than the value.`,"","A session started before the server was added must be restarted; a fresh session picks it up automatically.")},{id:"codex",name:"OpenAI Codex CLI",kind:"cli",where:"codex mcp add, or ~/.codex/config.toml",docs:"https://learn.chatgpt.com/docs/extend/mcp?surface=cli",support:"header",body:(n,r)=>S("```bash",n.openMode?`codex mcp add contextnest --url ${r}`:`codex mcp add contextnest --url ${r} --bearer-token-env-var ${I}`,"```","","Or write it into `~/.codex/config.toml` directly:","","```toml","[mcp_servers.contextnest]",`url = "${r}"`,n.openMode?null:`bearer_token_env_var = "${I}"`,"```","",n.openMode?null:"Codex reads the token from the environment and sends it as an `Authorization: Bearer` header, so the value never lands in the config file.")},{id:"hermes",name:"Hermes (Nous Research)",kind:"cli",where:"~/.hermes/config.yaml",docs:"https://hermes-agent.nousresearch.com/docs/reference/mcp-config-reference",support:"header",body:(n,r)=>S("```yaml","mcp_servers:"," contextnest:",` url: "${r}"`,n.openMode?null:" headers:",n.openMode?null:` Authorization: "Bearer \${env:${I}}"`," enabled: true","```","",n.openMode?null:`Values support \`\${env:VAR}\` interpolation against \`~/.hermes/.env\`, so put the key in that file as \`${I}\` and keep it out of the YAML.`,n.openMode?null:"",'A `url` entry speaks Streamable HTTP — set `transport: "sse"` only if you need the older one.')},{id:"gemini-cli",name:"Gemini CLI",kind:"cli",where:"~/.gemini/settings.json",docs:"https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md",support:"header",body:(n,r)=>S("```json","{",' "mcpServers": {',' "contextnest": {',` "httpUrl": "${r}"${n.openMode?"":","}`,n.openMode?null:` "headers": { "Authorization": "Bearer ${K}" }`," }"," }","}","```","","Gemini CLI picks the transport from the property name: `httpUrl` is Streamable HTTP, `url` would be SSE, `command` would be stdio. Use `httpUrl` here.")},{id:"cursor",name:"Cursor",kind:"editor",where:"~/.cursor/mcp.json (or .cursor/mcp.json in a project)",docs:"https://cursor.com/docs/mcp",support:"header",body:(n,r)=>S("```json","{",' "mcpServers": {',' "contextnest": {',` "url": "${r}"${n.openMode?"":","}`,n.openMode?null:` "headers": { "Authorization": "Bearer ${K}" }`," }"," }","}","```","","Cursor expands variables inside `url` and `headers`, so the key can come from the environment rather than the file.")}],Ce=W[0];function hs(n){return W.find(r=>r.id===n)}function Oe(n,r){const t=[n.open?`[Open the settings page](${n.open})`:null,`[${n.name} docs](${n.docs})`].filter(d=>d!==null).join(" · ");return`${n.body(r,Te(r.serverUrl))}
|
|
5
|
+
|
|
6
|
+
${t}`}const ms=[{kind:"chat",heading:"# Chat"},{kind:"cli",heading:"# Command line"},{kind:"editor",heading:"# Editors"}];function us(n){const t=[`**Connect once.** All of these point at the same endpoint — \`${Te(n.serverUrl)}\` — and that one connection reads across every nest the caller can see: the public ones, plus whatever private nests they have been given access to. There is no per-nest setup, and nothing to redo when someone is added to another nest.`,"","What comes back is decided by who the caller authenticates as, not by which tool they are running.","",n.openMode?"This deployment runs in open mode, so no credential is involved and every caller is the same anonymous user.":["Two things to get right about the credential:","","- **Use a user-level key, not a nest-scoped one.** A key scoped to a single nest narrows this endpoint back down to that nest, which looks exactly like the connect-once promise being broken. Mint a user-level key in the Connect dialog.","- **Each person uses their own key.** A key shared across a team makes all of them the same user to this server, so they would all see the key owner's nests instead of their own."].join(`
|
|
7
|
+
`),""];for(const{kind:d,heading:f}of ms){const h=W.filter(c=>c.kind===d);if(h.length!==0){t.push(f,"");for(const c of h)t.push(`## ${c.name}`,"",`*${c.where}*`,"",Oe(c,n),"")}}return t.join(`
|
|
8
|
+
`).trimEnd()+`
|
|
9
|
+
`}const ps={chat:"Chat",cli:"Command line",editor:"Editors"},xs=["chat","cli","editor"];function gs({publicBaseUrl:n,openMode:r}){const[t,d]=l.useState(Ce.id),f=n.trim(),h=f||window.location.origin,c=l.useMemo(()=>({serverUrl:h,openMode:r}),[h,r]),j=hs(t)??Ce,L=l.useMemo(()=>Oe(j,c),[j,c]);return e.jsxs(m,{children:[e.jsx(u,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-base",children:"Connecting agents"}),e.jsxs(x,{children:["Setup steps for each AI tool your people are likely to use. Every one of them connects ",e.jsx("strong",{children:"once"}),", to the same server-level MCP endpoint, and that single connection reads across every nest the caller can see — the public ones plus whatever private nests they have access to. There is no per-nest setup, and nothing to redo when someone is added to another nest."]})]}),e.jsxs(b,{size:"sm",variant:"outline",onClick:()=>te(us(c),"All connection instructions copied"),children:[e.jsx(se,{className:"h-4 w-4 mr-1.5"}),"Copy all"]})]})}),e.jsxs(g,{className:"space-y-4",children:[!f&&e.jsxs("div",{role:"alert",className:"flex gap-2 rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx(rs,{className:"h-4 w-4 shrink-0 mt-0.5 text-amber-600"}),e.jsxs("span",{children:["No public base URL is set, so these steps use"," ",e.jsx("code",{children:h})," — the address of"," ",e.jsx("em",{children:"this browser's"})," connection. Most of these tools run the MCP client on the vendor's servers, not the user's machine, so a private or proxied address will fail for them. Set the public base URL on the ",e.jsx("strong",{children:"General"})," tab."]})]}),!r&&e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Use a user-level key, not a nest-scoped one."})," A key scoped to a single nest narrows this endpoint back down to that nest, which looks exactly like the connect-once promise being broken."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Each person uses their own key."})," A key shared across a team makes all of them the same user to this server, so they would all see the key owner's nests instead of their own."]})]}),xs.map(C=>{const U=W.filter(N=>N.kind===C);return U.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:ps[C]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.map(N=>e.jsxs(b,{size:"sm",variant:N.id===t?"default":"outline","aria-pressed":N.id===t,onClick:()=>d(N.id),children:[N.name,N.support==="oauth-only"&&e.jsx(Se,{variant:"secondary",className:"ml-1.5",children:"OAuth"})]},N.id))})]},C)}),e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:j.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:j.where})]}),e.jsxs(b,{size:"sm",variant:"ghost",onClick:()=>te(L,`${j.name} steps copied`),children:[e.jsx(se,{className:"h-4 w-4 mr-1.5"}),"Copy"]})]}),e.jsx("article",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.jsx(is,{remarkPlugins:[os],components:{a:({...C})=>e.jsx("a",{...C,target:"_blank",rel:"noopener noreferrer"})},children:L})})]})]})]})}const fs=[{value:"open",label:"Everyone",hint:"Anyone can sign in with PromptOwl."},{value:"admin-only",label:"Admins only",hint:"Only the server admin can use PromptOwl sign-in."},{value:"disabled",label:"Off",hint:"Hide PromptOwl sign-in."}],vs=[{value:"open",label:"Everyone",hint:"Anyone can sign in and create their own account."},{value:"invite-only",label:"Invite only",hint:"Invited users sign in and set a password; no self sign-up."},{value:"disabled",label:"Off",hint:"No email & password sign-in — PromptOwl only."}],Z=[{id:"general",label:"General",keys:["promptowl_sign_in_gate","manual_sign_in","public_base_url","logo_url","anthropic_api_key","people_suggest_all_users","shared_deployment"]},{id:"sso",label:"Single sign-on",keys:["oidc_enabled","oidc_issuer","oidc_client_id","oidc_client_secret","oidc_allowed_domains","oidc_auto_provision","oidc_department_tagging","sso_token_exchange_enabled","mcp_signing_secret","mcp_token_ttl_seconds","ms_token_exchange_enabled","ms_client_id","ms_tenant_id","google_token_exchange_enabled","google_client_id"]},{id:"notifications",label:"Notifications",keys:["slack_webhook_url","msteams_webhook_url","smtp_url","notify_email_from","notify_email_to"]},{id:"community-sites",label:"Community sites",keys:[]},{id:"agents",label:"Connecting agents",keys:[]},{id:"advanced",label:"Advanced",keys:["telemetry_enabled","posthog_key","posthog_host","max_body_bytes","trace_retention_days","type_artifact_enabled","type_table_enabled","workflow_plane_enabled","promptowl_teams_enabled","subagent_runs_enabled","subagent_max_depth","subagent_max_children"]}],V=n=>({autoComplete:n==="password"?"new-password":"off","data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"});function v({value:n,placeholder:r,onChange:t,type:d="text"}){const f=d==="password",[h,c]=l.useState(!1);return e.jsxs("div",{className:"relative flex-1",children:[e.jsx(M,{value:n,type:f&&h?"text":d,placeholder:r,onChange:j=>t(j.target.value),className:f?"flex-1 pr-9":"flex-1",...V(d)}),f&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>c(j=>!j),className:"absolute inset-y-0 right-0 flex items-center px-2.5 text-muted-foreground hover:text-foreground",title:h?"Hide":"Show","aria-label":h?"Hide value":"Show value",children:h?e.jsx(Ze,{className:"h-4 w-4"}):e.jsx(es,{className:"h-4 w-4"})})]})}function ys({bytes:n,onChange:r}){const[t,d]=l.useState(String(Math.round(n/1048576)));return l.useEffect(()=>d(String(Math.round(n/(1024*1024)))),[n]),e.jsxs("div",{className:"flex items-center gap-2 max-w-xs",children:[e.jsx(M,{type:"number",value:t,onChange:f=>{d(f.target.value);const h=Number(f.target.value);Number.isFinite(h)&&h>0&&r(Math.floor(h*1024*1024))},...V("number")}),e.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"MB"})]})}function ee({value:n,onChange:r,min:t,max:d}){const[f,h]=l.useState(String(n));return l.useEffect(()=>h(String(n)),[n]),e.jsx(M,{type:"number",min:t,max:d,value:f,className:"max-w-[7rem]",onChange:c=>{h(c.target.value);const j=Number(c.target.value);Number.isInteger(j)&&r(j)},...V("number")})}function bs({settings:n,onUpdate:r}){var xe,ge;const[t,d]=l.useState(n),[f,h]=l.useState(!1),c=Ge(),{authMode:j}=Ae(),[L,C]=l.useState(null),[U,N]=l.useState("general"),[ne,ae]=l.useState(!1);l.useEffect(()=>{n&&d(n)},[n]);const[Y,Pe]=l.useState(null),[re,ie]=l.useState(null),z=async()=>{try{await c.invalidateQueries({queryKey:ke.communitySites().queryKey});const s=await c.fetchQuery(ke.communitySites());Pe(s.community_sites),ie(null)}catch(s){ie(s.message)}};l.useEffect(()=>{z()},[]);const[_,D]=l.useState(null),[w,A]=l.useState({name:"",url:"",secret:"",is_active:!0}),[oe,le]=l.useState(!1),[ce,B]=l.useState(null),[T,F]=l.useState(null),[de,he]=l.useState(!1),Ie=()=>{A({name:"",url:"",secret:"",is_active:!0}),B(null),D({mode:"add"})},Ee=s=>{A({name:s.name,url:s.url,secret:"",is_active:s.is_active}),B(null),D({mode:"edit",site:s})},Me=async()=>{if(_){le(!0),B(null);try{if(_.mode==="add")await ss({name:w.name.trim(),url:w.url.trim(),secret:w.secret.trim(),is_active:w.is_active});else{const s={name:w.name.trim(),url:w.url.trim(),is_active:w.is_active};w.secret.trim()&&(s.secret=w.secret.trim()),await Ne(_.site.id,s)}D(null),await z()}catch(s){B(s.message)}finally{le(!1)}}},Le=async s=>{try{await Ne(s.id,{is_active:!s.is_active}),await z()}catch(a){E.error(a.message)}},De=async()=>{if(T){he(!0);try{await ts(T.id),F(null),await z()}catch(s){E.error(s.message)}finally{he(!1)}}},i=s=>{d(a=>a&&{...a,...s}),C(null)},R=l.useMemo(()=>{if(!t||!n)return[];const s=n;return Object.keys(t).filter(a=>{if(a==="anthropic_api_key"||a==="oidc_client_secret"||a==="mcp_signing_secret"){const o=t[a];return typeof o=="string"&&o.trim()!==""||o===null}return(t[a]??"")!==(s[a]??"")})},[t,n]),G=R.length>0,Re=s=>s.some(a=>R.includes(a)),$e=async()=>{var a;if(!t||!G)return;const s={};for(const o of R)s[o]=t[o];h(!0),C(null);try{await r(s)}catch(o){C((o==null?void 0:o.message)||"Failed to save settings");const k=((a=o==null?void 0:o.body)==null?void 0:a.fieldErrors)??{},$=Object.keys(k),H=Q=>$.some(J=>Q.keys.includes(J)),fe=$.length?Z.find(H):Z.find(Q=>Q.keys.some(J=>R.includes(J)));fe&&N(fe.id)}finally{h(!1)}},Ue=()=>{n&&d(n),C(null)},[me,ue]=l.useState(null),ze=async s=>{ue(s);try{await ns(s),E.success(`Test ${s==="slack"?"Slack":"Teams"} notification sent — check the channel.`)}catch(a){E.error((a==null?void 0:a.message)||"Test notification failed.")}finally{ue(null)}},pe=(s,a)=>e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsxs(b,{type:"button",variant:"outline",size:"sm",disabled:me===s||!(n!=null&&n[a]),onClick:()=>ze(s),children:[me===s&&e.jsx(O,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Send test"]}),R.includes(a)&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Save first — the test uses the saved URL."})]});return e.jsxs("div",{children:[e.jsx(as,{icon:X,title:"Server settings",description:"Server-wide options. Changes apply on Save and persist across restarts.",className:"mb-6",actions:n&&e.jsxs(e.Fragment,{children:[G&&e.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Unsaved changes"}),e.jsx(b,{variant:"ghost",size:"sm",onClick:Ue,disabled:!G||f,children:"Discard"}),e.jsxs(b,{size:"sm",onClick:$e,disabled:!G||f,children:[f&&e.jsx(O,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Save changes"]})]})}),L&&e.jsxs("div",{role:"alert",className:"mb-4 rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:"Couldn't save settings"}),e.jsx("div",{className:"mt-0.5 text-destructive/90",children:L})]}),t?e.jsxs(He,{value:U,onValueChange:N,children:[e.jsx(qe,{children:Z.map(s=>e.jsxs(Ke,{value:s.id,className:"gap-1.5",children:[s.label,Re(s.keys)&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary","aria-label":"unsaved changes"})]},s.id))}),e.jsxs(P,{value:"general",className:"space-y-4",children:[e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsxs(p,{className:"flex items-center gap-2 text-base",children:[e.jsx(X,{className:"h-4 w-4 text-muted-foreground"}),"PromptOwl sign-in"]}),e.jsx(x,{children:"Who can sign in to this server using their PromptOwl account."})]}),e.jsx(g,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:fs.map(s=>{const a=t.promptowl_sign_in_gate===s.value,o=s.value==="disabled"&&t.manual_sign_in==="disabled";return e.jsxs("button",{type:"button",disabled:o,onClick:()=>!a&&!o&&i({promptowl_sign_in_gate:s.value}),className:`text-left rounded-lg border p-3 transition-colors ${a?"border-primary bg-primary/5 ring-1 ring-primary":o?"opacity-50 cursor-not-allowed":"hover:bg-muted/50"}`,"aria-pressed":a,children:[e.jsx("div",{className:"text-sm font-medium",children:s.label}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.hint})]},s.value)})})})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsxs(p,{className:"flex items-center gap-2 text-base",children:[e.jsx(X,{className:"h-4 w-4 text-muted-foreground"}),"Manual sign-in"]}),e.jsx(x,{children:"Email & password sign-in. Independent of PromptOwl — you can't turn this fully off while PromptOwl sign-in is also off."})]}),e.jsx(g,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:vs.map(s=>{const a=t.manual_sign_in===s.value,o=s.value==="disabled"&&t.promptowl_sign_in_gate==="disabled";return e.jsxs("button",{type:"button",disabled:o,onClick:()=>!a&&!o&&i({manual_sign_in:s.value}),className:`text-left rounded-lg border p-3 transition-colors ${a?"border-primary bg-primary/5 ring-1 ring-primary":o?"opacity-50 cursor-not-allowed":"hover:bg-muted/50"}`,"aria-pressed":a,children:[e.jsx("div",{className:"text-sm font-medium",children:s.label}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.hint})]},s.value)})})})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Public base URL"}),e.jsx(x,{children:"This server's public address — used for share links and SSO redirects. Leave empty if unsure."})]}),e.jsx(g,{children:e.jsx(v,{value:t.public_base_url??"",placeholder:"https://nest.yourcompany.com",onChange:s=>i({public_base_url:s})})})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Logo"}),e.jsx(x,{children:"URL of the logo shown in the header. Leave empty for the default."})]}),e.jsx(g,{children:e.jsx(v,{value:t.logo_url??"",placeholder:"https://example.com/logo.svg",onChange:s=>i({logo_url:s})})})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Anthropic API key"}),e.jsx(x,{children:"The server-wide model key. Runners pick it up automatically (every nest, unless a nest overrides it in its Tool environment). No key, no LLM calls. Stored server-side; shown masked."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:t.anthropic_api_key===null?"Will be cleared when you save.":n!=null&&n.anthropic_api_key_masked?`Current: ${n.anthropic_api_key_masked}`:"Not set — runs can't execute until a key exists here or in a nest's Tool environment."}),e.jsx(v,{type:"password",value:typeof t.anthropic_api_key=="string"?t.anthropic_api_key:"",placeholder:"sk-ant-… (paste to set or replace)",onChange:s=>i({anthropic_api_key:s})}),(n==null?void 0:n.anthropic_api_key_masked)&&t.anthropic_api_key!==null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-destructive hover:underline",onClick:()=>i({anthropic_api_key:null}),children:"Clear key"}),t.anthropic_api_key===null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-muted-foreground hover:underline",onClick:()=>i({anthropic_api_key:void 0}),children:"Keep current key"})]})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsxs(p,{className:"flex items-center gap-2 text-base",children:[e.jsx(We,{className:"h-4 w-4 text-muted-foreground"}),"People directory"]}),e.jsx(x,{children:'What the "add a person" fields suggest when inviting someone to a nest, a team, or a stewardship role.'})]}),e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"pr-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"Suggest everyone on this server"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Off, the pickers only suggest people the inviter already shares a nest or team with. On, they suggest every registered account — right when this server is one organisation, wrong when it hosts several, because it shows them each other's email addresses. Either way anyone can still be invited by typing their address."})]}),e.jsx(y,{checked:t.people_suggest_all_users,onCheckedChange:s=>i({people_suggest_all_users:s})})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4 pt-4 border-t",children:[e.jsxs("div",{className:"pr-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"This server hosts several organizations"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"A nest's Organization tier is readable by every account on this server. Off, that is one company and the tier applies in one click. On — the PromptOwl-hosted service, or any install shared by unrelated customers — opening a nest to Organization asks for the same acknowledgement as Public (enforced by the server, not only the UI), and the visibility picker says who the tier really reaches."})]}),e.jsx(y,{checked:t.shared_deployment,onCheckedChange:s=>i({shared_deployment:s}),"data-testid":"settings-shared-deployment"})]})]})]})]}),e.jsxs(P,{value:"sso",className:"space-y-4",children:[e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsxs(p,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ve,{className:"h-4 w-4 text-muted-foreground"}),"Single sign-on (OIDC)"]}),e.jsx(x,{children:"Let teammates sign in with your identity provider — Microsoft Entra ID, Google, or any OpenID Connect issuer. Fill in the issuer and app credentials below, then turn it on."})]}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:[t.oidc_enabled?"On":"Off",!t.oidc_enabled&&!(t.oidc_issuer&&t.oidc_client_id)&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· configure the issuer and app credentials first"]})]}),e.jsx(y,{checked:t.oidc_enabled,onCheckedChange:s=>i({oidc_enabled:s})})]}),(()=>{var o,k;const s=t.oidc_client_secret===null?!1:typeof t.oidc_client_secret=="string"&&t.oidc_client_secret.trim()!==""?!0:!!(n!=null&&n.oidc_client_secret_set),a=t.oidc_enabled&&!!((o=t.oidc_issuer)!=null&&o.trim())&&!!((k=t.oidc_client_id)!=null&&k.trim())&&s;return!t.oidc_enabled||a?null:e.jsx("div",{role:"alert",className:"rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-400",children:"Enabled but not configured — the SSO sign-in button stays hidden until the issuer, client ID, and client secret are all set."})})(),(()=>{var o;const s=((o=t.oidc_issuer)==null?void 0:o.trim())??"",a=/^https:\/\/login\.microsoftonline\.com\/[^/]+\/v2\.0$/.test(s)?"entra":s==="https://accounts.google.com"?"google":null;return e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Issuer URL"}),e.jsxs("div",{className:"flex gap-2 mb-2",role:"group","aria-label":"Identity provider preset",children:[e.jsx(b,{type:"button",variant:a==="entra"?"default":"outline",size:"sm","aria-pressed":a==="entra",onClick:()=>{const k=window.prompt("Microsoft Entra tenant ID (Directory ID) — find it on your app registration's Overview page:");k&&k.trim()&&i({oidc_issuer:`https://login.microsoftonline.com/${k.trim()}/v2.0`})},children:"Microsoft Entra ID"}),e.jsx(b,{type:"button",variant:a==="google"?"default":"outline",size:"sm","aria-pressed":a==="google",onClick:()=>i({oidc_issuer:"https://accounts.google.com"}),children:"Google"}),a===null&&s!==""&&e.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Custom issuer"})]}),e.jsx(v,{value:t.oidc_issuer??"",placeholder:"https://login.microsoftonline.com/{tenant}/v2.0",onChange:k=>i({oidc_issuer:k})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"https:// only. Must serve /.well-known/openid-configuration."})]})})(),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Client ID"}),e.jsx(v,{value:t.oidc_client_id??"",placeholder:"Application (client) ID from your IdP app registration",onChange:s=>i({oidc_client_id:s})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Client secret"}),e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:t.oidc_client_secret===null?"Will be cleared when you save.":n!=null&&n.oidc_client_secret_set?"A client secret is set. Paste a new one to replace it.":"Not set."}),e.jsx(v,{type:"password",value:typeof t.oidc_client_secret=="string"?t.oidc_client_secret:"",placeholder:"Paste to set or replace",onChange:s=>i({oidc_client_secret:s})}),(n==null?void 0:n.oidc_client_secret_set)&&t.oidc_client_secret!==null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-destructive hover:underline",onClick:()=>i({oidc_client_secret:null}),children:"Clear secret"}),t.oidc_client_secret===null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-muted-foreground hover:underline",onClick:()=>i({oidc_client_secret:void 0}),children:"Keep current secret"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Redirect URI"}),(()=>{const a=`${(t.public_base_url||window.location.origin).replace(/\/$/,"")}/auth/oidc/callback`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 bg-muted/40 border rounded px-2 py-1.5 text-xs font-mono break-all",children:a}),e.jsxs(b,{type:"button",variant:"outline",size:"sm",onClick:async()=>{await te(a)&&(ae(!0),setTimeout(()=>ae(!1),1500))},children:[ne?e.jsx(Ye,{className:"h-3.5 w-3.5"}):e.jsx(se,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1.5",children:ne?"Copied":"Copy"})]})]})})(),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Register this exact URI in your IdP's app registration (Entra: Authentication → Web redirect URIs; Google: Authorized redirect URIs)."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Allowed email domains"}),e.jsx(v,{value:t.oidc_allowed_domains??"",placeholder:"acme.com, contractors.acme.com — empty allows any",onChange:s=>i({oidc_allowed_domains:s})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Only accounts whose email domain is listed may sign in. Leave empty to allow any domain your IdP asserts."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Auto-provision new users"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create an account on first SSO sign-in. Turn off to allow only users you've already invited."})]}),e.jsx(y,{checked:t.oidc_auto_provision,onCheckedChange:s=>i({oidc_auto_provision:s})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Department auto-tagging"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Tag new documents with the creator's directory department (requires the department claim from your IdP)."})]}),e.jsx(y,{checked:t.oidc_department_tagging,onCheckedChange:s=>i({oidc_department_tagging:s})})]}),t.oidc_enabled&&t.oidc_auto_provision&&!((xe=t.oidc_allowed_domains)!=null&&xe.trim())&&e.jsx("div",{role:"alert",className:"rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-400",children:"Anyone your issuer can authenticate will get an account on first sign-in — with a consumer or multi-tenant issuer (e.g. Google), that's any account on the internet, and it applies even when manual sign-in is invite-only. Set allowed email domains above, or turn auto-provision off."})]})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{children:"Agent SSO — token exchange"}),e.jsx(x,{children:"Let an external agent, acting for a user your IdP already authenticated (Microsoft Entra / Google), exchange that IdP's ID token for a short-lived MCP bearer — no second login. Uses the domain allowlist and auto-provision settings above."})]}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:t.sso_token_exchange_enabled?"On":"Off"}),e.jsx(y,{checked:t.sso_token_exchange_enabled,onCheckedChange:s=>i({sso_token_exchange_enabled:s})})]}),(t.ms_token_exchange_enabled||t.google_token_exchange_enabled)&&t.oidc_auto_provision&&!((ge=t.oidc_allowed_domains)!=null&&ge.trim())&&e.jsx("div",{role:"alert",className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:"Blocked: with auto-provision on and no allowed email domains, anyone with an account at that provider could sign themselves up and mint a token. Set allowed email domains above, or turn auto-provision off."}),(()=>{var k,$,H;const s=t.mcp_signing_secret===null?!1:typeof t.mcp_signing_secret=="string"&&t.mcp_signing_secret.trim()!==""?!0:!!(n!=null&&n.mcp_signing_secret_set),a=t.ms_token_exchange_enabled&&!!((k=t.ms_client_id)!=null&&k.trim())&&!!(($=t.ms_tenant_id)!=null&&$.trim()),o=t.google_token_exchange_enabled&&!!((H=t.google_client_id)!=null&&H.trim());return!t.sso_token_exchange_enabled||s&&(a||o)?null:e.jsx("div",{role:"alert",className:"rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-400",children:"Enabled but not ready — the endpoint needs a signing secret and at least one provider turned on with its client ID filled in (plus the tenant ID for Microsoft)."})})(),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"MCP signing secret"}),e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:t.mcp_signing_secret===null?"Will be cleared when you save.":n!=null&&n.mcp_signing_secret_set?"A signing secret is set. Paste a new one to replace it.":"Not set. Use a long random string — this signs the MCP tokens the exchange mints."}),e.jsx(v,{type:"password",value:typeof t.mcp_signing_secret=="string"?t.mcp_signing_secret:"",placeholder:"Paste to set or replace (16+ characters)",onChange:s=>i({mcp_signing_secret:s})}),(n==null?void 0:n.mcp_signing_secret_set)&&t.mcp_signing_secret!==null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-destructive hover:underline",onClick:()=>i({mcp_signing_secret:null}),children:"Clear secret"}),t.mcp_signing_secret===null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-muted-foreground hover:underline",onClick:()=>i({mcp_signing_secret:void 0}),children:"Keep current secret"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Token lifetime (seconds)"}),e.jsx(v,{type:"number",value:String(t.mcp_token_ttl_seconds??300),placeholder:"300",onChange:s=>i({mcp_token_ttl_seconds:s.trim()===""?300:Number(s)})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"30–3600. Short by design — a minted token expires quickly."})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Microsoft Entra"}),e.jsx(y,{checked:t.ms_token_exchange_enabled,onCheckedChange:s=>i({ms_token_exchange_enabled:s})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Client (application) ID"}),e.jsx(v,{value:t.ms_client_id??"",placeholder:"Entra app (client) ID — the token audience",onChange:s=>i({ms_client_id:s})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Tenant ID"}),e.jsx(v,{value:t.ms_tenant_id??"",placeholder:"Directory (tenant) ID — builds the issuer",onChange:s=>i({ms_tenant_id:s})})]})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Google"}),e.jsx(y,{checked:t.google_token_exchange_enabled,onCheckedChange:s=>i({google_token_exchange_enabled:s})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"OAuth client ID"}),e.jsx(v,{value:t.google_client_id??"",placeholder:"Google OAuth client ID — the token audience",onChange:s=>i({google_client_id:s})})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:["Your agent calls"," ",e.jsx("code",{className:"text-[11px]",children:"POST /auth/token-exchange"})," ","with the IdP ID token and receives a short-lived MCP bearer for"," ",e.jsx("code",{className:"text-[11px]",children:"/mcp"})," and"," ",e.jsx("code",{className:"text-[11px]",children:"/index"}),". The token is verified by signature, issuer, audience (the client id above) and expiry. Security-critical — keep it off until reviewed. For a public IdP like Google, set the allowed email domains above so only your organization can exchange."]})]})]})]}),e.jsxs(P,{value:"notifications",className:"space-y-4",children:[e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Slack notifications"}),e.jsx(x,{children:"Post governance events (review requested, approved, rejected, nest shared) to a Slack channel via an incoming-webhook URL. Leave empty to turn the connector off. The URL contains a secret — treat it like a password."})]}),e.jsxs(g,{children:[e.jsx(v,{type:"password",value:t.slack_webhook_url??"",placeholder:"https://hooks.slack.com/services/…",onChange:s=>i({slack_webhook_url:s})}),pe("slack","slack_webhook_url")]})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Microsoft Teams notifications"}),e.jsx(x,{children:'Post the same governance events to a Microsoft Teams channel as Adaptive Cards via an incoming-webhook URL (create one in Teams with the Workflows app: "Post to a channel when a webhook request is received"). Leave empty to turn the connector off. The URL contains a secret — treat it like a password.'})]}),e.jsxs(g,{children:[e.jsx(v,{type:"password",value:t.msteams_webhook_url??"",placeholder:"https://….logic.azure.com/workflows/…",onChange:s=>i({msteams_webhook_url:s})}),pe("teams","msteams_webhook_url")]})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Email notifications"}),e.jsx(x,{children:"Send the same governance events over SMTP. Set the connection URL (smtp:// or smtps://, credentials inline), a From address, and one or more recipients (comma-separated). Leave the URL empty to turn the connector off."})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx(v,{type:"password",value:t.smtp_url??"",placeholder:"smtps://user:pass@smtp.example.com:465",onChange:s=>i({smtp_url:s})}),e.jsx(v,{value:t.notify_email_from??"",placeholder:"From — nest@yourcompany.com",onChange:s=>i({notify_email_from:s})}),e.jsx(v,{value:t.notify_email_to??"",placeholder:"To — team@yourcompany.com, ops@yourcompany.com",onChange:s=>i({notify_email_to:s})})]})]})]}),e.jsxs(P,{value:"advanced",className:"space-y-4",children:[e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Usage telemetry"}),e.jsx(x,{children:"Send anonymous usage counts to PromptOwl. Turn off to keep all usage data on this server."})]}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:t.telemetry_enabled?"On":"Off"}),e.jsx(y,{checked:t.telemetry_enabled,onCheckedChange:s=>i({telemetry_enabled:s})})]})})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Product analytics"}),e.jsx(x,{children:"Send usage events to your own PostHog project. Leave the key empty to keep analytics off. Also off whenever usage telemetry above is off."})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx(v,{value:t.posthog_key??"",placeholder:"Project API key — phc_...",onChange:s=>i({posthog_key:s})}),e.jsx(v,{value:t.posthog_host??"",placeholder:"Host — https://us.i.posthog.com",onChange:s=>i({posthog_host:s})})]})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Max upload size"}),e.jsx(x,{children:"Largest request/file accepted, in megabytes. Raise this if big HTML artifacts (decks, dashboards) get rejected."})]}),e.jsx(g,{children:e.jsx(ys,{bytes:t.max_body_bytes,onChange:s=>i({max_body_bytes:s})})})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Activity trace retention"}),e.jsx(x,{children:"How many days of activity-trace rows (API requests and MCP tool calls) to keep. Older rows are pruned opportunistically. Set 0 to keep activity forever."})]}),e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{value:t.trace_retention_days,min:0,max:3650,onChange:s=>i({trace_retention_days:s})}),e.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"days"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"0–3650 — 0 disables pruning entirely."})]})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Content types"}),e.jsx(x,{children:"Which node types can be created on this server. Turning one off hides it from the editor and refuses new creations — existing nodes of that type stay readable and versioned. Runnable types (agent, skill, tool) are governed by the workflow plane below."})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:["Artifacts (hosted HTML) —"," ",t.type_artifact_enabled?"On":"Off"]}),e.jsx(y,{checked:t.type_artifact_enabled,onCheckedChange:s=>i({type_artifact_enabled:s})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:["Tables (CSV fact stores) —"," ",t.type_table_enabled?"On":"Off"]}),e.jsx(y,{checked:t.type_table_enabled,onCheckedChange:s=>i({type_table_enabled:s})})]})]})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsxs(p,{className:"text-base",children:["Workflow plane ",e.jsx(Qe,{className:"ml-1 align-middle"})]}),e.jsx(x,{children:"Typed edges, an edge-type registry, and governed runs — the automation layer. Optional; off by default. Turning it on adds API surface and UI views but changes nothing until someone creates an edge."})]}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:t.workflow_plane_enabled?"On":"Off"}),e.jsx(y,{checked:t.workflow_plane_enabled,onCheckedChange:s=>i({workflow_plane_enabled:s,...s?{}:{subagent_runs_enabled:!1}})})]})})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Import teams from PromptOwl"}),e.jsx(x,{children:"Lets users who signed in with PromptOwl pull their PromptOwl teams in as local teams. Off by default. When off, the PromptOwl Teams panel is hidden and the import API is unavailable."})]}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:t.promptowl_teams_enabled?"On":"Off"}),e.jsx(y,{checked:t.promptowl_teams_enabled,onCheckedChange:s=>i({promptowl_teams_enabled:s})})]})})]}),e.jsxs(m,{children:[e.jsxs(u,{children:[e.jsx(p,{className:"text-base",children:"Sub-agent runs (recursion)"}),e.jsx(x,{children:"Lets a run spawn nested sub-agent runs (a call tree). Bounded by depth, fan-out and re-entrancy caps so the tree stays finite. This opens a recursion surface — enable it only after reviewing the caps for your deployment. Requires the workflow plane."})]}),e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:[t.subagent_runs_enabled?"On":"Off",!t.workflow_plane_enabled&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· enable the workflow plane first"]})]}),e.jsx(y,{checked:t.subagent_runs_enabled,disabled:!t.workflow_plane_enabled,onCheckedChange:s=>i({subagent_runs_enabled:s})})]}),t.subagent_runs_enabled&&e.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Max depth"}),e.jsx(ee,{value:t.subagent_max_depth,min:1,max:32,onChange:s=>i({subagent_max_depth:s})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"1–32 — how deep the sub-agent call tree may nest."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Max sub-agents per run"}),e.jsx(ee,{value:t.subagent_max_children,min:1,max:128,onChange:s=>i({subagent_max_children:s})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"1–128 — fan-out a single run may spawn."})]})]})]})]})]}),e.jsx(P,{value:"community-sites",className:"space-y-4",children:e.jsxs(m,{children:[e.jsx(u,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs(p,{className:"flex items-center gap-2 text-base",children:[e.jsx(ls,{className:"h-4 w-4 text-muted-foreground"}),"Official community sites"]}),e.jsx(x,{children:"Sites trusted for one-click SSO auto-login. A visitor arriving with a ticket signed by one of these sites' secrets is signed in automatically — the ticket's audience is also checked against this server's own base URL, so a ticket minted for a different deployment can't be replayed here."})]}),e.jsxs(b,{size:"sm",onClick:Ie,children:[e.jsx(Je,{className:"h-4 w-4 mr-1.5"}),"Add site"]})]})}),e.jsxs(g,{children:[re&&e.jsx("div",{role:"alert",className:"mb-4 rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:re}),Y?Y.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-6",children:"No community sites configured yet. Add one to enable SSO auto-login from it."}):e.jsx("div",{className:"divide-y",children:Y.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(Se,{variant:"outline",className:s.is_active?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-muted-foreground/20 text-muted-foreground",children:s.is_active?"Enabled":"Disabled"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[s.url," · secret ",s.secret_set?"set":"not set"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(y,{checked:s.is_active,onCheckedChange:()=>Le(s),"aria-label":`Enable ${s.name}`,title:"Enabled sites can sign visitors in with an SSO ticket. This is the admin switch, not a reachability check."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>Ee(s),title:"Edit this community site",children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsx(b,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>F(s),title:"Remove this community site",children:e.jsx(cs,{className:"h-4 w-4"})})]})]},s.id))}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[e.jsx(O,{className:"h-4 w-4 animate-spin"})," Loading community sites…"]})]})]})}),e.jsx(P,{value:"agents",className:"space-y-4",children:e.jsx(gs,{publicBaseUrl:t.public_base_url,openMode:j==="open"})})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-10",children:[e.jsx(O,{className:"h-4 w-4 animate-spin"})," Loading settings…"]}),e.jsx(ve,{open:!!_,onOpenChange:s=>!s&&D(null),children:e.jsxs(ye,{children:[e.jsxs(be,{children:[e.jsx(je,{children:(_==null?void 0:_.mode)==="edit"?"Edit community site":"Add community site"}),e.jsx(_e,{children:"The secret is write-only — leave it blank when editing to keep the current one."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(q,{htmlFor:"site-name",children:"Name"}),e.jsx(M,{id:"site-name",value:w.name,onChange:s=>A(a=>({...a,name:s.target.value})),placeholder:"Main community site"})]}),e.jsxs("div",{children:[e.jsx(q,{htmlFor:"site-url",children:"Site URL"}),e.jsx(M,{id:"site-url",value:w.url,onChange:s=>A(a=>({...a,url:s.target.value})),placeholder:"https://community.example.com"})]}),e.jsxs("div",{children:[e.jsx(q,{htmlFor:"site-secret",children:"Secret key"}),e.jsx(M,{id:"site-secret",type:"password",value:w.secret,onChange:s=>A(a=>({...a,secret:s.target.value})),placeholder:(_==null?void 0:_.mode)==="edit"?"Leave blank to keep the current secret":"Shared secret (16+ characters)",...V("password")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(q,{htmlFor:"site-active",children:"Auto-login enabled"}),e.jsx(y,{id:"site-active",checked:w.is_active,onCheckedChange:s=>A(a=>({...a,is_active:s}))})]}),ce&&e.jsx("div",{role:"alert",className:"text-sm text-destructive",children:ce})]}),e.jsxs(we,{children:[e.jsx(b,{variant:"outline",onClick:()=>D(null),children:"Cancel"}),e.jsxs(b,{onClick:Me,disabled:oe,children:[oe&&e.jsx(O,{className:"h-4 w-4 mr-1.5 animate-spin"}),(_==null?void 0:_.mode)==="edit"?"Save changes":"Add site"]})]})]})}),e.jsx(ve,{open:!!T,onOpenChange:s=>!s&&F(null),children:e.jsxs(ye,{children:[e.jsxs(be,{children:[e.jsxs(je,{children:["Remove ",T==null?void 0:T.name,"?"]}),e.jsx(_e,{children:"Visitors arriving from this site will no longer be auto-signed-in. This can't be undone from here — you'll need to re-add the site and its secret to restore it."})]}),e.jsxs(we,{children:[e.jsx(b,{variant:"outline",onClick:()=>F(null),children:"Cancel"}),e.jsxs(b,{variant:"destructive",onClick:De,disabled:de,children:[de&&e.jsx(O,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Remove"]})]})]})})]})}function As(){const{isAdmin:n,refreshHealth:r}=Ae(),[t,d]=l.useState(null);l.useEffect(()=>{n&&Be().then(d).catch(()=>{})},[n]);const f=l.useCallback(async h=>{try{const c=await Fe(h);d(c.settings),await r(),E.success("Settings saved")}catch(c){throw E.error((c==null?void 0:c.message)||"Failed to save settings"),c}},[r]);return e.jsx(bs,{settings:t,onUpdate:f})}export{As as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as n,u as G,i as z,f as l,aI as U,_ as V,j as e,B as C,L as M,
|
|
1
|
+
import{r as n,u as G,i as z,f as l,aI as U,_ as V,j as e,B as C,L as M,ag as W,aP as J,aU as X,aV as Y,aT as Z}from"./index-B5hLclEq.js";import{N as I}from"./NestPageHeader-yOK-OIYZ.js";import{T as ee}from"./trash-2-B4hRXo-p.js";import{T as te}from"./triangle-alert-CsYGyfGZ.js";import"./arrow-left-BAgIocLn.js";function se({nestId:a,nestName:B,isArchived:T,onBack:H}){var K;const[h,Q]=n.useState([]),p=G(),[S,D]=n.useState(!0),[d,E]=n.useState(!1),[g,P]=n.useState(!1),[i,_]=n.useState(null),[o,j]=n.useState(""),[c,w]=n.useState(""),[A,b]=n.useState(""),x=n.useCallback(async()=>{D(!0);try{const{definitions:t}=await p.fetchQuery(z.definitions(a));Q(t)}catch(t){l.error((t==null?void 0:t.message)||"Failed to load definitions")}finally{D(!1)}},[a]);n.useEffect(()=>{let t=!1;return p.fetchQuery(z.nest(a)).then(s=>{if(t)return;const q=U({roles:(s==null?void 0:s.roles)??[],permission:(s==null?void 0:s.permission)??null,myStewards:(s==null?void 0:s.myStewards)??[],isOwner:(s==null?void 0:s.permission)==="owner",isAdmin:(s==null?void 0:s.permission)==="admin",isArchived:T||V(s==null?void 0:s.nest)});E(q.canManage||q.collabCanWrite)}).catch(()=>{t||E(!1)}),()=>{t=!0}},[a,p,T]),n.useEffect(()=>{x()},[x]);const N=()=>{_(null),j(""),w(""),b("")},y=t=>{var s;_(t.id),j(t.term),w(t.definition),b(((s=t.linked_tag)==null?void 0:s.replace(/^#/,""))??"")},L=o.trim().toLowerCase(),r=L?h.find(t=>t.term.toLowerCase()===L&&t.id!==i)??null:null,F=async()=>{if(!o.trim()||!c.trim())return l.error("Term and definition are both required."),!1;P(!0);try{const t=A.trim();return await X(a,{term:o.trim(),definition:c.trim(),...t||i?{linked_tag:t||null}:{},...i?{editing_id:i}:{}}),l.success(i?"Definition updated":r?`Replaced the definition of "${r.term}"`:"Term defined"),N(),await x(),!0}catch(t){return l.error((t==null?void 0:t.message)||"Save failed"),!1}finally{P(!1)}},O=async t=>{try{await Y(a,t.id),l.success(`Removed "${t.term}"`),await x()}catch(s){l.error((s==null?void 0:s.message)||"Delete failed")}},[u,m]=n.useState(!1),f=i??(u?"new":null),$=()=>{N(),m(!1)},v=t=>{t.key==="Escape"?(t.preventDefault(),$()):t.key==="Enter"&&(t.ctrlKey||t.metaKey||!(t.target instanceof HTMLTextAreaElement))&&(t.preventDefault(),F().then(s=>s&&m(!1)))},k="w-full rounded-md border border-input bg-background px-2 py-1 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",R=e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"align-top",children:e.jsx("input",{autoFocus:!0,value:o,onChange:t=>j(t.target.value),onKeyDown:v,placeholder:"Term","aria-label":"Term",className:k,"data-testid":"definitions-term"})}),e.jsx("td",{className:"align-top",children:e.jsx("textarea",{value:c,onChange:t=>w(t.target.value),onKeyDown:v,placeholder:"What this term means here — formula or source if quantitative. Ctrl+Enter saves.","aria-label":"Definition",rows:Math.min(8,Math.max(2,c.split(`
|
|
2
2
|
`).length+1)),className:`${k} min-h-[2.25rem] resize-y`,"data-testid":"definitions-definition"})}),e.jsx("td",{className:"align-top",children:e.jsx("input",{value:A,onChange:t=>b(t.target.value),onKeyDown:v,placeholder:"tag","aria-label":"Linked tag",className:`${k} w-28`,"data-testid":"definitions-tag"})}),e.jsx("td",{className:"align-top text-xs text-muted-foreground whitespace-nowrap pt-2",children:i?(K=h.find(t=>t.id===i))==null?void 0:K.defined_by:"you"}),e.jsx("td",{className:"align-top whitespace-nowrap text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(C,{variant:"ghost",size:"sm",className:"h-7",onClick:$,disabled:g,children:"Cancel"}),e.jsx(C,{size:"sm",className:"h-7",onClick:()=>void F().then(t=>t&&m(!1)),disabled:g||!o.trim()||!c.trim(),"data-testid":"definitions-save",children:g?e.jsx(M,{className:"h-3.5 w-3.5 animate-spin"}):r&&!i?"Replace":"Save"})]})})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(I,{nestName:B,onBack:H,title:e.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:"Definitions"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The nest's shared vocabulary — what each term means here, written down once so everyone (and every agent reading this nest) uses it the same way. Click a row to edit it."}),e.jsx("div",{className:"border border-border rounded-lg overflow-x-auto","data-testid":"definitions-table",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-muted-foreground text-xs",children:e.jsxs("tr",{className:"[&>th]:px-3 [&>th]:py-2 [&>th]:text-left [&>th]:font-medium",children:[e.jsx("th",{className:"w-[18%]",children:"Term"}),e.jsx("th",{children:"Definition"}),e.jsx("th",{className:"w-28",children:"Tag"}),e.jsx("th",{className:"w-36",children:"Defined by"}),e.jsx("th",{className:"w-28"})]})}),e.jsxs("tbody",{children:[S&&e.jsx("tr",{children:e.jsxs("td",{colSpan:5,className:"px-3 py-8 text-center text-muted-foreground",children:[e.jsx(M,{className:"h-4 w-4 animate-spin inline mr-2"}),"Loading…"]})}),!S&&h.length===0&&!u&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-3 py-8 text-center text-muted-foreground",children:d?"No terms defined yet. Add the first one below.":"No terms defined yet."})}),h.map(t=>f===t.id?e.jsx("tr",{className:"border-t border-border bg-muted/20 [&>td]:px-2 [&>td]:py-1.5","data-testid":"definitions-row-editing",children:R},t.id):e.jsxs("tr",{onClick:d&&f===null?()=>y(t):void 0,className:`group border-t border-border align-top [&>td]:px-3 [&>td]:py-2${d&&f===null?" cursor-text hover:bg-muted/30":""}`,"data-testid":"definitions-row",children:[e.jsx("td",{className:"font-medium whitespace-nowrap",children:t.term}),e.jsx("td",{className:"max-w-[520px]",children:e.jsx("span",{className:"whitespace-pre-wrap",children:t.definition})}),e.jsx("td",{className:"whitespace-nowrap",children:t.linked_tag?e.jsx("span",{className:"rounded bg-amber-50 text-amber-700 px-1.5 py-0.5 text-xs",children:t.linked_tag}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx("td",{className:"text-xs text-muted-foreground whitespace-nowrap",children:t.defined_by}),e.jsx("td",{className:"whitespace-nowrap text-right",children:d&&e.jsxs("span",{className:"opacity-0 group-hover:opacity-100 focus-within:opacity-100",children:[e.jsx("button",{type:"button","aria-label":`Edit ${t.term}`,onClick:s=>{s.stopPropagation(),y(t)},className:"p-1 rounded hover:bg-accent mr-1",children:e.jsx(W,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","aria-label":`Delete ${t.term}`,onClick:s=>{s.stopPropagation(),O(t)},className:"p-1 rounded hover:bg-accent text-red-600",children:e.jsx(ee,{className:"h-3.5 w-3.5"})})]})})]},t.id)),f!==null&&r&&e.jsx("tr",{className:"bg-amber-50/60",children:e.jsx("td",{colSpan:5,className:"px-3 py-2 text-xs text-amber-800",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("b",{children:r.term})," ",i?e.jsxs(e.Fragment,{children:["is already defined by another row (",r.defined_by,") — this rename will be rejected."]}):e.jsxs(e.Fragment,{children:["is already defined by ",r.defined_by,". Saving replaces that definition."]})]}),!i&&e.jsxs(C,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>{m(!1),y(r)},children:[e.jsx(W,{className:"h-3.5 w-3.5 mr-1"})," Edit it instead"]})]})})}),d&&u&&i===null&&e.jsx("tr",{className:"border-t border-border bg-muted/20 [&>td]:px-2 [&>td]:py-1.5","data-testid":"definitions-row-new",children:R}),d&&!u&&e.jsx("tr",{className:"border-t border-border",children:e.jsx("td",{colSpan:5,className:"p-0",children:e.jsxs("button",{type:"button",onClick:()=>{N(),m(!0)},className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-sm text-muted-foreground hover:bg-muted/40 hover:text-foreground","data-testid":"definitions-add",children:[e.jsx(J,{className:"h-3.5 w-3.5"})," New term"]})})})]})]})}),e.jsxs("details",{className:"rounded-md border bg-muted/30 px-3 py-2 text-xs",children:[e.jsx("summary",{className:"cursor-pointer font-medium text-muted-foreground",children:"For developers — fetch a definition over HTTP"}),e.jsxs("div",{className:"mt-2 space-y-1.5 text-muted-foreground",children:[e.jsx("p",{children:"Agents and analysis jobs read these live, so a definition edited here changes what they answer with on the next call."}),e.jsxs("pre",{className:"overflow-x-auto rounded border bg-background p-2 font-mono text-[10.5px] leading-relaxed",children:["GET /nests/",a,"/definitions?term=<term>"]}),e.jsx("p",{children:"Omit the query to get the whole glossary."})]})]})]})}function le(){const a=Z();return e.jsx(se,{nestId:a.nestId,nestName:a.nestName,isArchived:a.isArchived,onBack:a.leaveNest})}export{le as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as ue,r as A,aW as Qe,j as u,U as Oe,B as Pe,L as Ue,aX as Ve,C as Je,
|
|
1
|
+
import{c as ue,r as A,aW as Qe,j as u,U as Oe,B as Pe,L as Ue,aX as Ve,C as Je,ao as Ke,at as qe,aT as et}from"./index-B5hLclEq.js";import{N as tt}from"./NestPageHeader-yOK-OIYZ.js";import{L as nt,T as rt}from"./tag-Br_y1f00.js";import{T as st}from"./triangle-alert-CsYGyfGZ.js";import"./arrow-left-BAgIocLn.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ch as he,O as ue,r as h,u as pe,i as U,cl as F,j as t,cm as xe,cn as q,C as fe,f as x,s as ge,L as ve,B as u,bx as K,co as be,cp as je,cq as ye,bO as ke,bP as Ne,aC as _e,at as we}from"./index-EaX2yql0.js";import{f as Ce,r as Q}from"./dates-BCxbm4_q.js";import{P as Re}from"./page-title-ClvvBsIo.js";import{A as Se,a as $e,R as Ae}from"./ReviewActions-OfOdqzCn.js";import{f as V}from"./scroll-area-hz-xtayP.js";import"./select-DBFTrUmI.js";import"./card-XG2dP5Xf.js";import{R as J}from"./ReasonDialog-DgLxfRWv.js";import{C as We}from"./circle-check-DI8IBGeo.js";import{T as qe}from"./trash-2-HBi-Pslz.js";import{C as Te}from"./circle-x-VKVhC88W.js";import{C as De}from"./chevron-left-BPwUT9DS.js";const Y=8;function ze(f,j,g=Y){return j?f:f.slice(0,g)}function X(f,j){return f.filter(g=>g.id!==j)}function Je(){var I,E;const{openNest:f,openReview:j}=he(),{adminStatus:g}=ue(),G=((I=g==null?void 0:g.me)==null?void 0:I.email)??null,[n,m]=h.useState({items:[],waiting:[]}),[H,Z]=h.useState(!0),[T,D]=h.useState(!1),[l,S]=h.useState(null),[y,z]=h.useState("delete"),[d,v]=h.useState(new Set),[p,N]=h.useState(null),[$,ee]=h.useState(!1),M=pe(),w=async e=>{D(!0);try{const s=await M.fetchQuery(U.myWork({offset:e}));m(a=>({items:s.items,waiting:s.waiting,notifications:s.notifications??a.notifications,pagination:s.pagination}));const i=new Set(s.items.map(a=>`${a.nest_id}:${a.node_id}`));v(a=>new Set([...a].filter(k=>i.has(k))))}catch(s){console.error("[Dashboard] goToWorkPage failed",s)}finally{D(!1)}};h.useEffect(()=>{M.fetchQuery(U.myWork()).then(m).catch(()=>m({items:[],waiting:[],notifications:[]})).finally(()=>Z(!1))},[G]);const te=async(e,s)=>{await be(e.nest_id,e.node_id,s),R(e)},se=async(e,s)=>{await je(e.nest_id,e.node_id,s),R(e)},b=n.items.filter(e=>e.type==="review"),A=e=>`${e.nest_id}:${e.node_id}`,C=(()=>{const e=new Map;for(const i of b)d.has(A(i))&&e.set(i.nest_id,(e.get(i.nest_id)??0)+1);const s=Math.max(0,...e.values());return Math.max(0,s-F)})(),ie=async(e,s)=>{var B;const i=b.filter(o=>d.has(A(o)));if(i.length===0){x.info("Nothing selected on this page"),v(new Set),N(null);return}const a=new Map;for(const o of i)a.set(o.nest_id,[...a.get(o.nest_id)??[],o.node_id]);const k=await Promise.all([...a].map(([o,r])=>ye(o,e,r,s||void 0).then(_=>({nestId:o,..._})).catch(_=>({nestId:o,succeeded:0,failed:r.length,results:r.map(me=>({nodeId:me,ok:!1,error:(_==null?void 0:_.message)||"Request failed"}))})))),W=k.reduce((o,r)=>o+r.succeeded,0),L=k.reduce((o,r)=>o+r.failed,0),ce=new Set(k.flatMap(o=>o.results.filter(r=>!r.ok).map(r=>`${o.nestId}:${r.nodeId}`))),O=e==="approve"?"approved":"rejected";if(L===0)x.success(`${W} document${W===1?"":"s"} ${O}`);else{const o=[...new Set(k.flatMap(r=>r.results).filter(r=>!r.ok).map(r=>r.error||"Unknown reason"))];x.warning(`${W} ${O}, ${L} could not be`,{description:o.join(" "),duration:1e4})}v(ce),N(null),w(((B=n.pagination)==null?void 0:B.offset)??0)},c=e=>e.target_type==="nest_archive",ne=e=>e.type!=="deletion"?"Review":c(e)?"Archive":"Deletion",ae=async()=>{const e=l;await ke(e.nest_id,e.request_id),R(e)},oe=async e=>{const s=l;await Ne(s.nest_id,s.request_id,e),R(s)},re=async e=>{await _e(e.nest_id,e.request_id),m(s=>({...s,waiting:s.waiting.filter(i=>!(i.nest_id===e.nest_id&&i.node_id===e.node_id))}))},de=async e=>{await we(e.nest_id,e.node_id),m(s=>({...s,waiting:s.waiting.filter(i=>!(i.nest_id===e.nest_id&&i.node_id===e.node_id))}))},P=e=>{if(e.type==="deletion"&&e.target_type&&e.target_type!=="document"){f(e.nest_id,e.nest_name,!1,!1);return}j(e.nest_id,e.nest_name,e.node_id)},le=e=>{q([e.id]).catch(()=>{}),m(s=>({...s,notifications:X(s.notifications??[],e.id)})),e.node_id?j(e.nest_id,e.nest_name,e.node_id):f(e.nest_id,e.nest_name,!1,!1)},R=e=>{var s;m(i=>({...i,items:i.items.filter(a=>!(a.nest_id===e.nest_id&&a.node_id===e.node_id))})),v(i=>{const a=new Set(i);return a.delete(`${e.nest_id}:${e.node_id}`),a}),w(((s=n.pagination)==null?void 0:s.offset)??0)};return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Re,{icon:xe,title:"My Work",description:"Reviews and requests waiting on you, and what you handed off.",className:"mb-0"}),t.jsx("div",{children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{children:[(((E=n.notifications)==null?void 0:E.length)??0)>0&&t.jsxs("div",{className:"mb-3 rounded-lg border border-amber-300/50 bg-amber-500/5",children:[t.jsxs("div",{className:"px-4 py-2 flex items-center gap-2 text-sm font-medium",children:["🔔 Notifications",t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",n.notifications.length,")"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:async()=>{await q("all"),m(e=>({...e,notifications:[]}))},children:"Mark all read"})]}),t.jsx("div",{className:ge("divide-y border-t",$&&"max-h-80 overflow-y-auto"),children:ze(n.notifications,$).map(e=>t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs hover:bg-amber-500/10",children:[t.jsxs("button",{type:"button",onClick:()=>le(e),className:"flex-1 flex items-center gap-2 text-left",children:[t.jsx("span",{className:"flex-1",children:e.message}),t.jsx("span",{className:"text-muted-foreground shrink-0",children:Ce(e.created_at)})]}),t.jsx("button",{type:"button",title:"Mark as read","aria-label":"Mark as read",className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-amber-500/20 hover:text-foreground",onClick:async()=>{try{await q([e.id]),m(s=>({...s,notifications:X(s.notifications??[],e.id)}))}catch(s){x.error((s==null?void 0:s.message)||"Failed to mark as read")}},children:t.jsx(fe,{className:"h-3.5 w-3.5"})})]},e.id))}),n.notifications.length>Y&&t.jsx("div",{className:"border-t px-4 py-1.5 text-center",children:t.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>ee(e=>!e),children:$?"Show less":`Show all (${n.notifications.length})`})})]}),H?t.jsxs("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(ve,{className:"h-4 w-4 animate-spin"}),"Loading your work…"]}):n.items.length===0?t.jsx("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 text-center text-sm text-muted-foreground",children:"You're all caught up — nothing waiting on you."}):t.jsxs("div",{className:"rounded-lg border divide-y overflow-hidden",children:[b.length>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 bg-muted/40 px-4 py-2 text-sm",children:[t.jsx(V,{checked:d.size===0?!1:d.size===b.length?!0:"indeterminate",onCheckedChange:e=>v(e===!0?new Set(b.map(A)):new Set),"aria-label":"Select every review waiting on you","data-testid":"work-select-all"}),t.jsx("span",{className:"text-muted-foreground",children:d.size>0?`${d.size} selected`:`Select all ${b.length} reviews`}),C>0&&t.jsxs("span",{className:"text-destructive",children:["Up to ",F," per nest — deselect"," ",C,"."]}),d.size>0&&t.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[t.jsxs(u,{size:"sm",disabled:C>0,onClick:()=>N("approve"),"data-testid":"work-bulk-approve",children:["Approve ",d.size]}),t.jsxs(u,{size:"sm",variant:"outline",disabled:C>0,onClick:()=>N("reject"),"data-testid":"work-bulk-reject",children:["Reject ",d.size]}),t.jsx(u,{size:"sm",variant:"ghost",onClick:()=>v(new Set),children:"Clear"})]})]}),n.items.map(e=>{const s=`${e.nest_id}:${e.node_id}`;return t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-muted/40 group",children:[b.length>1&&t.jsx(V,{checked:d.has(s),disabled:e.type!=="review",onCheckedChange:()=>v(i=>{const a=new Set(i);return a.has(s)?a.delete(s):a.add(s),a}),"aria-label":`Select ${e.title}`,className:e.type==="review"?"":"invisible"}),t.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide shrink-0 ${e.type==="deletion"&&!c(e)?"bg-red-100 text-red-800 dark:bg-red-950/40 dark:text-red-300":"bg-amber-100 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300"}`,children:ne(e)}),t.jsxs("button",{onClick:()=>P(e),className:"flex items-center gap-2 min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"font-medium truncate",children:e.title}),t.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["in ",e.nest_name," · ",e.requested_by," · ",Q(e.requested_at),e.reason?` · "${e.reason}"`:""]})]}),t.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.type==="deletion"?t.jsxs(t.Fragment,{children:[t.jsxs(u,{variant:"outline",className:c(e)?Se:"text-destructive hover:text-destructive",onClick:()=>{z("delete"),S(e)},children:[c(e)?t.jsx(We,{className:"h-4 w-4 mr-2"}):t.jsx(qe,{className:"h-4 w-4 mr-2"}),c(e)?"Approve":"Delete"]}),t.jsxs(u,{variant:"outline",className:$e,onClick:()=>{z("decline"),S(e)},children:[t.jsx(Te,{className:"h-4 w-4 mr-2"})," Reject"]})]}):t.jsx(Ae,{documentTitle:e.title,version:1,onApprove:i=>te(e,i),onReject:i=>se(e,i)})})]},s)})]})]}),n.waiting.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Waiting on others"}),t.jsx("span",{className:"rounded-full bg-muted text-muted-foreground text-xs font-semibold px-2 py-0.5",children:n.waiting.length})]}),t.jsx("div",{className:"rounded-lg border divide-y overflow-hidden",children:n.waiting.map(e=>t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 hover:bg-muted/40 group text-sm",children:[t.jsxs("button",{onClick:()=>P(e),className:"flex items-center gap-3 flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"font-medium truncate",children:e.title}),t.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:["in ",e.nest_name," ·"," ",e.type==="deletion"?"requested":"submitted"," ",Q(e.requested_at)]}),t.jsx("span",{className:"flex-1"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:e.type!=="deletion"?"Pending Review":c(e)?"Archive Requested":"Deletion Requested"})]}),e.type==="deletion"&&e.request_id&&t.jsx(u,{size:"sm",variant:"ghost",className:"shrink-0 text-muted-foreground h-7 px-2",onClick:async s=>{s.stopPropagation();try{await re(e),x.success(c(e)?"Archive request withdrawn":"Deletion request withdrawn")}catch(i){x.error((i==null?void 0:i.message)||"Failed to withdraw deletion request")}},title:"Withdraw this deletion request",children:"Withdraw"}),e.type==="review"&&t.jsx(u,{size:"sm",variant:"ghost",className:"shrink-0 text-muted-foreground h-7 px-2",onClick:async s=>{s.stopPropagation();try{await de(e),x.success("Submission withdrawn — back to Draft")}catch(i){x.error((i==null?void 0:i.message)||"Failed to withdraw submission")}},title:"Withdraw this submission and return the document to Draft",children:"Withdraw"}),t.jsx(K,{className:"h-4 w-4 text-muted-foreground group-hover:translate-x-0.5 transition-transform shrink-0"})]},`${e.nest_id}:${e.node_id}`))})]}),n.pagination&&n.pagination.total>n.pagination.limit&&t.jsxs("div",{className:"flex items-center justify-center gap-3 pt-1 text-sm text-muted-foreground",children:[t.jsxs(u,{variant:"outline",size:"sm",disabled:T||n.pagination.offset===0,onClick:()=>w(Math.max(0,n.pagination.offset-n.pagination.limit)),children:[t.jsx(De,{className:"h-3.5 w-3.5 mr-1"}),"Prev"]}),t.jsxs("span",{children:["Page ",Math.floor(n.pagination.offset/n.pagination.limit)+1," of"," ",Math.max(1,Math.ceil(n.pagination.total/n.pagination.limit))]}),t.jsxs(u,{variant:"outline",size:"sm",disabled:T||!n.pagination.has_more,onClick:()=>w(n.pagination.offset+n.pagination.limit),children:["Next",t.jsx(K,{className:"h-3.5 w-3.5 ml-1"})]})]})]})}),p&&t.jsx(J,{open:!0,onOpenChange:e=>!e&&N(null),title:p==="approve"?`Approve ${d.size} document${d.size===1?"":"s"}?`:`Reject ${d.size} document${d.size===1?"":"s"}?`,description:p==="approve"?"Approving publishes each one. Anything that changed since this inbox loaded is reported back and left alone.":"Each author gets the same reason and the work goes back to them.",label:p==="reject"?"Why?":"Comment (optional)",optionalReason:p==="approve",placeholder:"Shared with every author in this batch",confirmLabel:p==="approve"?"Approve all":"Reject all",destructive:p==="reject",onConfirm:e=>ie(p,e)}),l&&t.jsx(J,{open:!0,onOpenChange:e=>!e&&S(null),title:y!=="delete"?`Reject this ${c(l)?"archive":"deletion"} request`:c(l)?`Archive "${l.title}"?`:`Delete "${l.title}"?`,description:`${l.requested_by} asked for this: "${l.reason??""}". ${y!=="delete"?c(l)?"The nest stays where it is; your note is the record, and the requester is notified.":"The document stays; your note is the record, and the requester is notified.":c(l)?"The nest goes read-only and leaves the dashboard; nothing is deleted and you can restore it.":"Deleting removes the document, its history, comments and annotations. It cannot be undone."}`,label:y==="decline"?"Why are you rejecting?":void 0,placeholder:"e.g. still referenced by onboarding",confirmLabel:y!=="delete"?"Reject":c(l)?"Archive nest":"Delete document",destructive:y==="delete"&&!c(l),onConfirm:y==="delete"?ae:oe})]})}export{Je as default};
|
|
1
|
+
import{ck as he,O as ue,r as h,u as pe,i as U,co as F,j as t,cp as xe,cq as q,C as fe,f as x,s as ge,L as ve,B as u,bx as K,cr as be,cs as je,ct as ye,bO as ke,bP as Ne,as as _e,ax as we}from"./index-B5hLclEq.js";import{f as Ce,r as Q}from"./dates-BCxbm4_q.js";import{P as Re}from"./page-title-BkqlUA0j.js";import{A as Se,a as $e,R as Ae}from"./ReviewActions-BXDTDPp1.js";import{f as V}from"./scroll-area-CbcH6yrZ.js";import"./select-DrL0mpRN.js";import"./card-UDyMRcps.js";import{R as J}from"./ReasonDialog-CN3ECAnQ.js";import{C as We}from"./circle-check-CSkZUEFK.js";import{T as qe}from"./trash-2-B4hRXo-p.js";import{C as Te}from"./circle-x-in2o3aHU.js";import{C as De}from"./chevron-left-XR4ReJ9Z.js";const Y=8;function ze(f,j,g=Y){return j?f:f.slice(0,g)}function X(f,j){return f.filter(g=>g.id!==j)}function Je(){var I,E;const{openNest:f,openReview:j}=he(),{adminStatus:g}=ue(),G=((I=g==null?void 0:g.me)==null?void 0:I.email)??null,[n,m]=h.useState({items:[],waiting:[]}),[H,Z]=h.useState(!0),[T,D]=h.useState(!1),[l,S]=h.useState(null),[y,z]=h.useState("delete"),[d,v]=h.useState(new Set),[p,N]=h.useState(null),[$,ee]=h.useState(!1),M=pe(),w=async e=>{D(!0);try{const s=await M.fetchQuery(U.myWork({offset:e}));m(a=>({items:s.items,waiting:s.waiting,notifications:s.notifications??a.notifications,pagination:s.pagination}));const i=new Set(s.items.map(a=>`${a.nest_id}:${a.node_id}`));v(a=>new Set([...a].filter(k=>i.has(k))))}catch(s){console.error("[Dashboard] goToWorkPage failed",s)}finally{D(!1)}};h.useEffect(()=>{M.fetchQuery(U.myWork()).then(m).catch(()=>m({items:[],waiting:[],notifications:[]})).finally(()=>Z(!1))},[G]);const te=async(e,s)=>{await be(e.nest_id,e.node_id,s),R(e)},se=async(e,s)=>{await je(e.nest_id,e.node_id,s),R(e)},b=n.items.filter(e=>e.type==="review"),A=e=>`${e.nest_id}:${e.node_id}`,C=(()=>{const e=new Map;for(const i of b)d.has(A(i))&&e.set(i.nest_id,(e.get(i.nest_id)??0)+1);const s=Math.max(0,...e.values());return Math.max(0,s-F)})(),ie=async(e,s)=>{var B;const i=b.filter(o=>d.has(A(o)));if(i.length===0){x.info("Nothing selected on this page"),v(new Set),N(null);return}const a=new Map;for(const o of i)a.set(o.nest_id,[...a.get(o.nest_id)??[],o.node_id]);const k=await Promise.all([...a].map(([o,r])=>ye(o,e,r,s||void 0).then(_=>({nestId:o,..._})).catch(_=>({nestId:o,succeeded:0,failed:r.length,results:r.map(me=>({nodeId:me,ok:!1,error:(_==null?void 0:_.message)||"Request failed"}))})))),W=k.reduce((o,r)=>o+r.succeeded,0),L=k.reduce((o,r)=>o+r.failed,0),ce=new Set(k.flatMap(o=>o.results.filter(r=>!r.ok).map(r=>`${o.nestId}:${r.nodeId}`))),O=e==="approve"?"approved":"rejected";if(L===0)x.success(`${W} document${W===1?"":"s"} ${O}`);else{const o=[...new Set(k.flatMap(r=>r.results).filter(r=>!r.ok).map(r=>r.error||"Unknown reason"))];x.warning(`${W} ${O}, ${L} could not be`,{description:o.join(" "),duration:1e4})}v(ce),N(null),w(((B=n.pagination)==null?void 0:B.offset)??0)},c=e=>e.target_type==="nest_archive",ne=e=>e.type!=="deletion"?"Review":c(e)?"Archive":"Deletion",ae=async()=>{const e=l;await ke(e.nest_id,e.request_id),R(e)},oe=async e=>{const s=l;await Ne(s.nest_id,s.request_id,e),R(s)},re=async e=>{await _e(e.nest_id,e.request_id),m(s=>({...s,waiting:s.waiting.filter(i=>!(i.nest_id===e.nest_id&&i.node_id===e.node_id))}))},de=async e=>{await we(e.nest_id,e.node_id),m(s=>({...s,waiting:s.waiting.filter(i=>!(i.nest_id===e.nest_id&&i.node_id===e.node_id))}))},P=e=>{if(e.type==="deletion"&&e.target_type&&e.target_type!=="document"){f(e.nest_id,e.nest_name,!1,!1);return}j(e.nest_id,e.nest_name,e.node_id)},le=e=>{q([e.id]).catch(()=>{}),m(s=>({...s,notifications:X(s.notifications??[],e.id)})),e.node_id?j(e.nest_id,e.nest_name,e.node_id):f(e.nest_id,e.nest_name,!1,!1)},R=e=>{var s;m(i=>({...i,items:i.items.filter(a=>!(a.nest_id===e.nest_id&&a.node_id===e.node_id))})),v(i=>{const a=new Set(i);return a.delete(`${e.nest_id}:${e.node_id}`),a}),w(((s=n.pagination)==null?void 0:s.offset)??0)};return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Re,{icon:xe,title:"My Work",description:"Reviews and requests waiting on you, and what you handed off.",className:"mb-0"}),t.jsx("div",{children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{children:[(((E=n.notifications)==null?void 0:E.length)??0)>0&&t.jsxs("div",{className:"mb-3 rounded-lg border border-amber-300/50 bg-amber-500/5",children:[t.jsxs("div",{className:"px-4 py-2 flex items-center gap-2 text-sm font-medium",children:["🔔 Notifications",t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",n.notifications.length,")"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:async()=>{await q("all"),m(e=>({...e,notifications:[]}))},children:"Mark all read"})]}),t.jsx("div",{className:ge("divide-y border-t",$&&"max-h-80 overflow-y-auto"),children:ze(n.notifications,$).map(e=>t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs hover:bg-amber-500/10",children:[t.jsxs("button",{type:"button",onClick:()=>le(e),className:"flex-1 flex items-center gap-2 text-left",children:[t.jsx("span",{className:"flex-1",children:e.message}),t.jsx("span",{className:"text-muted-foreground shrink-0",children:Ce(e.created_at)})]}),t.jsx("button",{type:"button",title:"Mark as read","aria-label":"Mark as read",className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-amber-500/20 hover:text-foreground",onClick:async()=>{try{await q([e.id]),m(s=>({...s,notifications:X(s.notifications??[],e.id)}))}catch(s){x.error((s==null?void 0:s.message)||"Failed to mark as read")}},children:t.jsx(fe,{className:"h-3.5 w-3.5"})})]},e.id))}),n.notifications.length>Y&&t.jsx("div",{className:"border-t px-4 py-1.5 text-center",children:t.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>ee(e=>!e),children:$?"Show less":`Show all (${n.notifications.length})`})})]}),H?t.jsxs("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(ve,{className:"h-4 w-4 animate-spin"}),"Loading your work…"]}):n.items.length===0?t.jsx("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 text-center text-sm text-muted-foreground",children:"You're all caught up — nothing waiting on you."}):t.jsxs("div",{className:"rounded-lg border divide-y overflow-hidden",children:[b.length>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 bg-muted/40 px-4 py-2 text-sm",children:[t.jsx(V,{checked:d.size===0?!1:d.size===b.length?!0:"indeterminate",onCheckedChange:e=>v(e===!0?new Set(b.map(A)):new Set),"aria-label":"Select every review waiting on you","data-testid":"work-select-all"}),t.jsx("span",{className:"text-muted-foreground",children:d.size>0?`${d.size} selected`:`Select all ${b.length} reviews`}),C>0&&t.jsxs("span",{className:"text-destructive",children:["Up to ",F," per nest — deselect"," ",C,"."]}),d.size>0&&t.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[t.jsxs(u,{size:"sm",disabled:C>0,onClick:()=>N("approve"),"data-testid":"work-bulk-approve",children:["Approve ",d.size]}),t.jsxs(u,{size:"sm",variant:"outline",disabled:C>0,onClick:()=>N("reject"),"data-testid":"work-bulk-reject",children:["Reject ",d.size]}),t.jsx(u,{size:"sm",variant:"ghost",onClick:()=>v(new Set),children:"Clear"})]})]}),n.items.map(e=>{const s=`${e.nest_id}:${e.node_id}`;return t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-muted/40 group",children:[b.length>1&&t.jsx(V,{checked:d.has(s),disabled:e.type!=="review",onCheckedChange:()=>v(i=>{const a=new Set(i);return a.has(s)?a.delete(s):a.add(s),a}),"aria-label":`Select ${e.title}`,className:e.type==="review"?"":"invisible"}),t.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide shrink-0 ${e.type==="deletion"&&!c(e)?"bg-red-100 text-red-800 dark:bg-red-950/40 dark:text-red-300":"bg-amber-100 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300"}`,children:ne(e)}),t.jsxs("button",{onClick:()=>P(e),className:"flex items-center gap-2 min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"font-medium truncate",children:e.title}),t.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["in ",e.nest_name," · ",e.requested_by," · ",Q(e.requested_at),e.reason?` · "${e.reason}"`:""]})]}),t.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.type==="deletion"?t.jsxs(t.Fragment,{children:[t.jsxs(u,{variant:"outline",className:c(e)?Se:"text-destructive hover:text-destructive",onClick:()=>{z("delete"),S(e)},children:[c(e)?t.jsx(We,{className:"h-4 w-4 mr-2"}):t.jsx(qe,{className:"h-4 w-4 mr-2"}),c(e)?"Approve":"Delete"]}),t.jsxs(u,{variant:"outline",className:$e,onClick:()=>{z("decline"),S(e)},children:[t.jsx(Te,{className:"h-4 w-4 mr-2"})," Reject"]})]}):t.jsx(Ae,{documentTitle:e.title,version:1,onApprove:i=>te(e,i),onReject:i=>se(e,i)})})]},s)})]})]}),n.waiting.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Waiting on others"}),t.jsx("span",{className:"rounded-full bg-muted text-muted-foreground text-xs font-semibold px-2 py-0.5",children:n.waiting.length})]}),t.jsx("div",{className:"rounded-lg border divide-y overflow-hidden",children:n.waiting.map(e=>t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 hover:bg-muted/40 group text-sm",children:[t.jsxs("button",{onClick:()=>P(e),className:"flex items-center gap-3 flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"font-medium truncate",children:e.title}),t.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:["in ",e.nest_name," ·"," ",e.type==="deletion"?"requested":"submitted"," ",Q(e.requested_at)]}),t.jsx("span",{className:"flex-1"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:e.type!=="deletion"?"Pending Review":c(e)?"Archive Requested":"Deletion Requested"})]}),e.type==="deletion"&&e.request_id&&t.jsx(u,{size:"sm",variant:"ghost",className:"shrink-0 text-muted-foreground h-7 px-2",onClick:async s=>{s.stopPropagation();try{await re(e),x.success(c(e)?"Archive request withdrawn":"Deletion request withdrawn")}catch(i){x.error((i==null?void 0:i.message)||"Failed to withdraw deletion request")}},title:"Withdraw this deletion request",children:"Withdraw"}),e.type==="review"&&t.jsx(u,{size:"sm",variant:"ghost",className:"shrink-0 text-muted-foreground h-7 px-2",onClick:async s=>{s.stopPropagation();try{await de(e),x.success("Submission withdrawn — back to Draft")}catch(i){x.error((i==null?void 0:i.message)||"Failed to withdraw submission")}},title:"Withdraw this submission and return the document to Draft",children:"Withdraw"}),t.jsx(K,{className:"h-4 w-4 text-muted-foreground group-hover:translate-x-0.5 transition-transform shrink-0"})]},`${e.nest_id}:${e.node_id}`))})]}),n.pagination&&n.pagination.total>n.pagination.limit&&t.jsxs("div",{className:"flex items-center justify-center gap-3 pt-1 text-sm text-muted-foreground",children:[t.jsxs(u,{variant:"outline",size:"sm",disabled:T||n.pagination.offset===0,onClick:()=>w(Math.max(0,n.pagination.offset-n.pagination.limit)),children:[t.jsx(De,{className:"h-3.5 w-3.5 mr-1"}),"Prev"]}),t.jsxs("span",{children:["Page ",Math.floor(n.pagination.offset/n.pagination.limit)+1," of"," ",Math.max(1,Math.ceil(n.pagination.total/n.pagination.limit))]}),t.jsxs(u,{variant:"outline",size:"sm",disabled:T||!n.pagination.has_more,onClick:()=>w(n.pagination.offset+n.pagination.limit),children:["Next",t.jsx(K,{className:"h-3.5 w-3.5 ml-1"})]})]})]})}),p&&t.jsx(J,{open:!0,onOpenChange:e=>!e&&N(null),title:p==="approve"?`Approve ${d.size} document${d.size===1?"":"s"}?`:`Reject ${d.size} document${d.size===1?"":"s"}?`,description:p==="approve"?"Approving publishes each one. Anything that changed since this inbox loaded is reported back and left alone.":"Each author gets the same reason and the work goes back to them.",label:p==="reject"?"Why?":"Comment (optional)",optionalReason:p==="approve",placeholder:"Shared with every author in this batch",confirmLabel:p==="approve"?"Approve all":"Reject all",destructive:p==="reject",onConfirm:e=>ie(p,e)}),l&&t.jsx(J,{open:!0,onOpenChange:e=>!e&&S(null),title:y!=="delete"?`Reject this ${c(l)?"archive":"deletion"} request`:c(l)?`Archive "${l.title}"?`:`Delete "${l.title}"?`,description:`${l.requested_by} asked for this: "${l.reason??""}". ${y!=="delete"?c(l)?"The nest stays where it is; your note is the record, and the requester is notified.":"The document stays; your note is the record, and the requester is notified.":c(l)?"The nest goes read-only and leaves the dashboard; nothing is deleted and you can restore it.":"Deleting removes the document, its history, comments and annotations. It cannot be undone."}`,label:y==="decline"?"Why are you rejecting?":void 0,placeholder:"e.g. still referenced by onboarding",confirmLabel:y!=="delete"?"Reject":c(l)?"Archive nest":"Delete document",destructive:y==="delete"&&!c(l),onConfirm:y==="delete"?ae:oe})]})}export{Je as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ck as U,O as V,r as i,u as X,bX as G,j as e,ag as J,I as W,L as R,B as h,bA as Y,bx as Z,i as ee,aA as te,f as k,a5 as se}from"./index-B5hLclEq.js";import{r as ae}from"./dates-BCxbm4_q.js";import{P as re}from"./page-title-BkqlUA0j.js";import{f as T}from"./scroll-area-CbcH6yrZ.js";import"./select-DrL0mpRN.js";import"./card-UDyMRcps.js";import{S as ie}from"./SubmitForReviewModal-BOZJxwRN.js";import{A as ne,a as oe,b as le,c as de,d as ce,e as me,f as fe,g as ue}from"./alert-dialog-4SiLKlz8.js";import{C as E}from"./circle-check-CSkZUEFK.js";import{T as M}from"./trash-2-B4hRXo-p.js";import{C as he}from"./chevron-left-XR4ReJ9Z.js";import"./send-CvAgOUPG.js";function ke(){var z;const{openReview:F}=U(),{adminStatus:D}=V(),L=((z=D==null?void 0:D.me)==null?void 0:z.email)??null,[c,S]=i.useState([]),[a,P]=i.useState(null),[N,$]=i.useState(!0),[m,j]=i.useState(null),[C,B]=i.useState(""),[v,O]=i.useState(""),[b,Q]=i.useState("updated"),[l,x]=i.useState(new Set),[w,_]=i.useState(!1),[n,y]=i.useState(null),q=X(),u=async t=>{$(!0);try{const s=await q.fetchQuery(ee.myDrafts({offset:t,q:v||void 0,sort:b}));if(s.drafts.length===0&&t>0&&s.pagination.total>0)return void await u(0);S(s.drafts),P(s.pagination)}catch(s){console.error("[Dashboard] goToDraftsPage failed",s),S([])}finally{$(!1)}},I=async(t,s,f)=>{const r=[],d=[];for(const o of t)try{await te(o.nest_id,o.node_id,s,f),r.push(o)}catch(g){d.push(o),console.error("[Dashboard] submitForReview failed",o.node_id,g)}if(S(o=>o.filter(g=>!r.some(K=>p(K)===p(g)))),x(new Set),u((a==null?void 0:a.offset)??0),d.length){j(d);const o=r.length?`${r.length} submitted. `:"";throw new Error(`${o}Couldn't submit ${d.length}: ${d.map(g=>g.title).join(", ")}`)}r.length>1&&k.success(`${r.length} submitted for review`)},p=t=>`${t.nest_id}:${t.node_id}`;i.useEffect(()=>{const t=setTimeout(()=>O(C.trim()),250);return()=>clearTimeout(t)},[C]),i.useEffect(()=>{u(0)},[L]);const A=G.useRef(!1);i.useEffect(()=>{if(!A.current){A.current=!0;return}x(new Set),u(0)},[v,b]);const H=async t=>{if(t.length===0)return;y(null),_(!0);let s=0,f=0;const r=[];for(const d of t)try{(await se(d.nest_id,d.node_id)).deleted?f++:s++}catch(o){r.push(d.title),console.error("[Dashboard] discardDraft failed",d.node_id,o)}_(!1),x(new Set),(s||f)&&k.success([s?`${s} restored to the approved version`:"",f?`${f} deleted`:""].filter(Boolean).join(" · ")),r.length&&k.error(`Couldn't discard: ${r.join(", ")}`),u((a==null?void 0:a.offset)??0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{icon:J,title:"My Drafts",description:"Everything you started and never handed off.",className:"mb-0"}),e.jsx("div",{children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(W,{value:C,onChange:t=>B(t.target.value),placeholder:"Search drafts by title or nest…",className:"h-8 max-w-xs","aria-label":"Search your drafts","data-testid":"drafts-search"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Sort:"}),e.jsx("div",{className:"inline-flex items-center rounded-md border bg-muted/40 p-0.5",role:"group","aria-label":"Sort drafts",children:[["updated","Recently edited"],["title","Title"]].map(([t,s])=>e.jsx("button",{type:"button","aria-pressed":b===t,onClick:()=>Q(t),className:`h-6 rounded px-2 text-xs transition-colors ${b===t?"bg-background font-medium text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,"data-testid":`drafts-sort-${t}`,children:s},t))})]})]}),N?e.jsxs("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"}),"Loading your drafts…"]}):c.length===0?e.jsx("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 text-center text-sm text-muted-foreground",children:v?`No drafts match "${v}".`:"No unsubmitted drafts — everything you've written is in review or approved."}):e.jsxs("div",{className:"rounded-lg border divide-y overflow-hidden",children:[c.length>1&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 bg-muted/40 px-4 py-2 text-sm",children:[e.jsx(T,{checked:l.size===0?!1:l.size===c.length?!0:"indeterminate",onCheckedChange:t=>x(t===!0?new Set(c.map(p)):new Set),"aria-label":"Select every draft on this page","data-testid":"drafts-select-all"}),e.jsx("span",{className:"text-muted-foreground",children:l.size>0?`${l.size} selected`:`Select all ${c.length} on this page`}),l.size>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(h,{size:"sm",variant:"outline",disabled:w,onClick:()=>j(c.filter(t=>l.has(p(t)))),"data-testid":"drafts-bulk-submit",children:[e.jsx(E,{className:"h-3.5 w-3.5 mr-1"}),"Submit ",l.size," for review"]}),e.jsxs(h,{size:"sm",variant:"outline",disabled:w,onClick:()=>y(c.filter(t=>l.has(p(t)))),"data-testid":"drafts-bulk-discard",children:[w?e.jsx(R,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(M,{className:"h-3.5 w-3.5 mr-1"}),"Discard ",l.size]}),e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>x(new Set),children:"Clear"})]})]}),c.map(t=>{const s=`${t.nest_id}:${t.node_id}`;return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-muted/40 group",children:[c.length>1&&e.jsx(T,{checked:l.has(s),onCheckedChange:()=>x(f=>{const r=new Set(f);return r.has(s)?r.delete(s):r.add(s),r}),"aria-label":`Select ${t.title}`}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide shrink-0 ${t.status==="rejected"?"bg-red-100 text-red-800 dark:bg-red-950/40 dark:text-red-300":"bg-muted text-muted-foreground"}`,children:t.status==="rejected"?"Rejected":"Draft"}),e.jsxs("button",{onClick:()=>F(t.nest_id,t.nest_name,t.node_id),className:"flex flex-col min-w-0 flex-1 text-left gap-0.5",children:[e.jsx("span",{className:"font-medium truncate",children:t.title}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",title:`${t.nest_name} / ${t.node_id}`,children:[e.jsx(Y,{className:"h-3 w-3 inline mr-1 -mt-0.5"}),t.nest_name,t.folder?` / ${t.folder}`:""," · edited"," ",ae(t.updated_at)]})]}),e.jsxs(h,{size:"sm",variant:"outline",className:"shrink-0",onClick:()=>j([t]),children:[e.jsx(E,{className:"h-3.5 w-3.5 mr-1"}),"Submit for review"]}),e.jsx(h,{size:"sm",variant:"ghost",disabled:w,className:"shrink-0 text-muted-foreground hover:text-destructive",title:"Discard this draft — back to the last approved version, or delete it if there isn't one",onClick:()=>y([t]),"data-testid":"draft-discard",children:e.jsx(M,{className:"h-3.5 w-3.5"})})]},s)})]}),a&&a.total>a.limit&&e.jsxs("div",{className:"flex items-center justify-center gap-3 pt-3 text-sm text-muted-foreground",children:[e.jsxs(h,{variant:"outline",size:"sm",disabled:N||a.offset===0,onClick:()=>u(Math.max(0,a.offset-a.limit)),children:[e.jsx(he,{className:"h-3.5 w-3.5 mr-1"}),"Prev"]}),e.jsxs("span",{children:["Page ",Math.floor(a.offset/a.limit)+1," of"," ",Math.max(1,Math.ceil(a.total/a.limit))]}),e.jsxs(h,{variant:"outline",size:"sm",disabled:N||!a.has_more,onClick:()=>u(a.offset+a.limit),children:["Next",e.jsx(Z,{className:"h-3.5 w-3.5 ml-1"})]})]})]})}),m&&m.length>0&&e.jsx(ie,{isOpen:!0,onClose:()=>j(null),documentTitle:m.length===1?m[0].title:`${m.length} drafts`,currentVersion:m.length===1?m[0].version:null,onSubmit:(t,s)=>I(m,t,s)}),e.jsx(ne,{open:!!n,onOpenChange:t=>!t&&y(null),children:e.jsxs(oe,{children:[e.jsxs(le,{children:[e.jsx(de,{children:(n==null?void 0:n.length)===1?`Discard "${n[0].title}"?`:`Discard ${(n==null?void 0:n.length)??0} drafts?`}),e.jsxs(ce,{children:[(n==null?void 0:n.length)===1?"The document goes":"Each document goes"," ","back to its last approved version. A document that was never approved is deleted instead. This can't be undone."]})]}),e.jsxs(me,{children:[e.jsx(fe,{children:"Cancel"}),e.jsx(ue,{onClick:()=>void H(n??[]),"data-testid":"drafts-discard-confirm",children:"Discard"})]})]})})]})}export{ke as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as o,cX as ze,d0 as Be,dh as Ge,cM as ue,di as Ue,cY as Ye,cP as k,dj as xe,c$ as he,dk as qe,cU as Xe,dl as Ke,dm as Qe,dn as We,s as Je,u as pe,i as fe,dp as oe,A as L,K as J,a as I,L as D,B as C,dq as Ze,D as z,x as B,y as G,z as U,H as Y,C as je,e as M,dr as es,ae as ss,ds as ts,f as E,O as ns,dt as rs,U as as,aP as os,T as ls,P as is,Q as le,R as ie,du as cs,aa as ds,I as ge,dv as se,dw as ms,dx as ve,bB as us,dy as xs,dz as hs,dA as ps}from"./index-EaX2yql0.js";import{P as fs}from"./page-title-ClvvBsIo.js";import{P as js}from"./PersonCombobox-CPOlNs6G.js";import{C as q,d as X,a as ye}from"./card-XG2dP5Xf.js";import{R as gs,S as we,a as Ne,b as Ce,c as be,d as Te}from"./select-DBFTrUmI.js";import{R as Pe}from"./refresh-cw-BhHzSH9m.js";import{T as vs}from"./triangle-alert-CDy8-7sv.js";import{T as Ee}from"./trash-2-HBi-Pslz.js";import{C as Se}from"./circle-check-DI8IBGeo.js";import{C as Re}from"./circle-x-VKVhC88W.js";import{X as ys}from"./x-By7piikG.js";import{U as ws}from"./user-plus-CvBNcpn4.js";var Ns=Symbol("radix.slottable");function Cs(s){const n=({children:t})=>e.jsx(e.Fragment,{children:t});return n.displayName=`${s}.Slottable`,n.__radixId=Ns,n}var[K]=Xe("Tooltip",[xe]),Q=xe(),ke="TooltipProvider",bs=700,Z="tooltip.open",[Ts,te]=K(ke),Oe=s=>{const{__scopeTooltip:n,delayDuration:t=bs,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:m}=s,u=o.useRef(!0),p=o.useRef(!1),d=o.useRef(0);return o.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),e.jsx(Ts,{scope:n,isOpenDelayedRef:u,delayDuration:t,onOpen:o.useCallback(()=>{window.clearTimeout(d.current),u.current=!1},[]),onClose:o.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u.current=!0,a)},[a]),isPointerInTransitRef:p,onPointerInTransitChange:o.useCallback(f=>{p.current=f},[]),disableHoverableContent:r,children:m})};Oe.displayName=ke;var H="Tooltip",[Ps,F]=K(H),Ae=s=>{const{__scopeTooltip:n,children:t,open:a,defaultOpen:r,onOpenChange:m,disableHoverableContent:u,delayDuration:p}=s,d=te(H,s.__scopeTooltip),f=Q(n),[l,h]=o.useState(null),i=ze(),c=o.useRef(0),j=u??d.disableHoverableContent,g=p??d.delayDuration,v=o.useRef(!1),[y,w]=Be({prop:a,defaultProp:r??!1,onChange:b=>{b?(d.onOpen(),document.dispatchEvent(new CustomEvent(Z))):d.onClose(),m==null||m(b)},caller:H}),T=o.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),P=o.useCallback(()=>{window.clearTimeout(c.current),c.current=0,v.current=!1,w(!0)},[w]),x=o.useCallback(()=>{window.clearTimeout(c.current),c.current=0,w(!1)},[w]),S=o.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>{v.current=!0,w(!0),c.current=0},g)},[g,w]);return o.useEffect(()=>()=>{c.current&&(window.clearTimeout(c.current),c.current=0)},[]),e.jsx(Ge,{...f,children:e.jsx(Ps,{scope:n,contentId:i,open:y,stateAttribute:T,trigger:l,onTriggerChange:h,onTriggerEnter:o.useCallback(()=>{d.isOpenDelayedRef.current?S():P()},[d.isOpenDelayedRef,S,P]),onTriggerLeave:o.useCallback(()=>{j?x():(window.clearTimeout(c.current),c.current=0)},[x,j]),onOpen:P,onClose:x,disableHoverableContent:j,children:t})})};Ae.displayName=H;var ee="TooltipTrigger",De=o.forwardRef((s,n)=>{const{__scopeTooltip:t,...a}=s,r=F(ee,t),m=te(ee,t),u=Q(t),p=o.useRef(null),d=ue(n,p,r.onTriggerChange),f=o.useRef(!1),l=o.useRef(!1),h=o.useCallback(()=>f.current=!1,[]);return o.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),e.jsx(Ue,{asChild:!0,...u,children:e.jsx(Ye.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:d,onPointerMove:k(s.onPointerMove,i=>{i.pointerType!=="touch"&&!l.current&&!m.isPointerInTransitRef.current&&(r.onTriggerEnter(),l.current=!0)}),onPointerLeave:k(s.onPointerLeave,()=>{r.onTriggerLeave(),l.current=!1}),onPointerDown:k(s.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:k(s.onFocus,()=>{f.current||r.onOpen()}),onBlur:k(s.onBlur,r.onClose),onClick:k(s.onClick,r.onClose)})})});De.displayName=ee;var ne="TooltipPortal",[Es,Ss]=K(ne,{forceMount:void 0}),_e=s=>{const{__scopeTooltip:n,forceMount:t,children:a,container:r}=s,m=F(ne,n);return e.jsx(Es,{scope:n,forceMount:t,children:e.jsx(he,{present:t||m.open,children:e.jsx(qe,{asChild:!0,container:r,children:a})})})};_e.displayName=ne;var _="TooltipContent",Le=o.forwardRef((s,n)=>{const t=Ss(_,s.__scopeTooltip),{forceMount:a=t.forceMount,side:r="top",...m}=s,u=F(_,s.__scopeTooltip);return e.jsx(he,{present:a||u.open,children:u.disableHoverableContent?e.jsx(Ie,{side:r,...m,ref:n}):e.jsx(Rs,{side:r,...m,ref:n})})}),Rs=o.forwardRef((s,n)=>{const t=F(_,s.__scopeTooltip),a=te(_,s.__scopeTooltip),r=o.useRef(null),m=ue(n,r),[u,p]=o.useState(null),{trigger:d,onClose:f}=t,l=r.current,{onPointerInTransitChange:h}=a,i=o.useCallback(()=>{p(null),h(!1)},[h]),c=o.useCallback((j,g)=>{const v=j.currentTarget,y={x:j.clientX,y:j.clientY},w=_s(y,v.getBoundingClientRect()),T=Ls(y,w),P=Is(g.getBoundingClientRect()),x=Hs([...T,...P]);p(x),h(!0)},[h]);return o.useEffect(()=>()=>i(),[i]),o.useEffect(()=>{if(d&&l){const j=v=>c(v,l),g=v=>c(v,d);return d.addEventListener("pointerleave",j),l.addEventListener("pointerleave",g),()=>{d.removeEventListener("pointerleave",j),l.removeEventListener("pointerleave",g)}}},[d,l,c,i]),o.useEffect(()=>{if(u){const j=g=>{const v=g.target,y={x:g.clientX,y:g.clientY},w=(d==null?void 0:d.contains(v))||(l==null?void 0:l.contains(v)),T=!Ms(y,u);w?i():T&&(i(),f())};return document.addEventListener("pointermove",j),()=>document.removeEventListener("pointermove",j)}},[d,l,u,f,i]),e.jsx(Ie,{...s,ref:m})}),[ks,Os]=K(H,{isInside:!1}),As=Cs("TooltipContent"),Ie=o.forwardRef((s,n)=>{const{__scopeTooltip:t,children:a,"aria-label":r,onEscapeKeyDown:m,onPointerDownOutside:u,...p}=s,d=F(_,t),f=Q(t),{onClose:l}=d;return o.useEffect(()=>(document.addEventListener(Z,l),()=>document.removeEventListener(Z,l)),[l]),o.useEffect(()=>{if(d.trigger){const h=i=>{const c=i.target;c!=null&&c.contains(d.trigger)&&l()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,l]),e.jsx(Ke,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:m,onPointerDownOutside:u,onFocusOutside:h=>h.preventDefault(),onDismiss:l,children:e.jsxs(Qe,{"data-state":d.stateAttribute,...f,...p,ref:n,style:{...p.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(As,{children:a}),e.jsx(ks,{scope:t,isInside:!0,children:e.jsx(gs,{id:d.contentId,role:"tooltip",children:r||a})})]})})});Le.displayName=_;var Me="TooltipArrow",Ds=o.forwardRef((s,n)=>{const{__scopeTooltip:t,...a}=s,r=Q(t);return Os(Me,t).isInside?null:e.jsx(We,{...r,...a,ref:n})});Ds.displayName=Me;function _s(s,n){const t=Math.abs(n.top-s.y),a=Math.abs(n.bottom-s.y),r=Math.abs(n.right-s.x),m=Math.abs(n.left-s.x);switch(Math.min(t,a,r,m)){case m:return"left";case r:return"right";case t:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Ls(s,n,t=5){const a=[];switch(n){case"top":a.push({x:s.x-t,y:s.y+t},{x:s.x+t,y:s.y+t});break;case"bottom":a.push({x:s.x-t,y:s.y-t},{x:s.x+t,y:s.y-t});break;case"left":a.push({x:s.x+t,y:s.y-t},{x:s.x+t,y:s.y+t});break;case"right":a.push({x:s.x-t,y:s.y-t},{x:s.x-t,y:s.y+t});break}return a}function Is(s){const{top:n,right:t,bottom:a,left:r}=s;return[{x:r,y:n},{x:t,y:n},{x:t,y:a},{x:r,y:a}]}function Ms(s,n){const{x:t,y:a}=s;let r=!1;for(let m=0,u=n.length-1;m<n.length;u=m++){const p=n[m],d=n[u],f=p.x,l=p.y,h=d.x,i=d.y;l>a!=i>a&&t<(h-f)*(a-l)/(i-l)+f&&(r=!r)}return r}function Hs(s){const n=s.slice();return n.sort((t,a)=>t.x<a.x?-1:t.x>a.x?1:t.y<a.y?-1:t.y>a.y?1:0),$s(n)}function $s(s){if(s.length<=1)return s.slice();const n=[];for(let a=0;a<s.length;a++){const r=s[a];for(;n.length>=2;){const m=n[n.length-1],u=n[n.length-2];if((m.x-u.x)*(r.y-u.y)>=(m.y-u.y)*(r.x-u.x))n.pop();else break}n.push(r)}n.pop();const t=[];for(let a=s.length-1;a>=0;a--){const r=s[a];for(;t.length>=2;){const m=t[t.length-1],u=t[t.length-2];if((m.x-u.x)*(r.y-u.y)>=(m.y-u.y)*(r.x-u.x))t.pop();else break}t.push(r)}return t.pop(),n.length===1&&t.length===1&&n[0].x===t[0].x&&n[0].y===t[0].y?n:n.concat(t)}var Fs=Oe,Vs=Ae,zs=De,Bs=_e,He=Le;const Gs=({children:s,delayDuration:n=0})=>e.jsx(Fs,{delayDuration:n,children:s}),O=Vs,A=zs,R=o.forwardRef(({className:s,sideOffset:n=4,...t},a)=>e.jsx(Bs,{children:e.jsx(He,{ref:a,sideOffset:n,className:Je("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));R.displayName=He.displayName;const Us={Owner:"Admin",Editor:"Editor",Viewer:"Viewer",User:"Viewer"},ce=s=>Us[s]??"Viewer";function Ys({localTeams:s,onImported:n}){const[t,a]=o.useState([]),r=pe(),[m,u]=o.useState(!0),[p,d]=o.useState(null),[f,l]=o.useState(!1),[h,i]=o.useState(null),[c,j]=o.useState(null),[g,v]=o.useState(null),y=new Map(s.filter(x=>x.source==="promptowl"&&x.external_id).map(x=>[x.external_id,x]));o.useEffect(()=>{w()},[]);const w=async()=>{u(!0),d(null);try{const x=await r.fetchQuery(fe.promptowlTeams());a(x.teams)}catch(x){oe(x)?l(!0):d((x==null?void 0:x.message)||"Could not reach PromptOwl")}finally{u(!1)}},T=async x=>{var S;i(x.id),d(null);try{const b=await ts([x.id]);v(b.results[0]??null),n(),E.success((S=b.results[0])!=null&&S.created?`Imported ${x.name}`:`Synced ${x.name}`)}catch(b){oe(b)?l(!0):d((b==null?void 0:b.message)||"Sync failed")}finally{i(null),j(null)}},P=x=>{y.has(x.id)?j(x):T(x)};return f?e.jsxs(L,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(I,{children:"Your PromptOwl session has ended. Sign out and sign back in with PromptOwl to import teams."})]}):m?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(D,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-4",children:[p&&e.jsxs(L,{variant:"destructive",children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(I,{children:p})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground flex-1",children:"Your PromptOwl teams. Syncing one copies it here with its members — people without an account are invited automatically. Teams you're view-only on can't be imported, since the copy would be yours to control."}),e.jsx(C,{size:"sm",variant:"ghost",onClick:w,"aria-label":"Refresh",children:e.jsx(Pe,{className:"h-4 w-4"})})]}),g&&e.jsx(Xs,{result:g}),t.length===0?e.jsx(q,{children:e.jsx(X,{className:"py-10 text-center text-sm text-muted-foreground",children:"You're not in any teams in PromptOwl."})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:t.map(x=>e.jsx(qs,{team:x,imported:y.has(x.id),syncing:h===x.id,canImport:Ze(x),onSync:()=>P(x)},x.id))}),e.jsx(z,{open:!!c,onOpenChange:x=>!x&&j(null),children:e.jsxs(B,{className:"sm:max-w-[460px]",children:[e.jsx(G,{children:e.jsxs(U,{children:['Sync "',c==null?void 0:c.name,'" from PromptOwl?']})}),e.jsxs(L,{children:[e.jsx(vs,{className:"h-4 w-4"}),e.jsx(I,{className:"text-xs",children:"PromptOwl is the source of truth. This team's roster here will be made to match PromptOwl exactly: roles are reset, and anyone you added by hand in ContextNest is removed."})]}),e.jsxs(Y,{children:[e.jsx(C,{variant:"outline",onClick:()=>j(null),children:"Cancel"}),e.jsxs(C,{disabled:!!h,onClick:()=>c&&T(c),children:[h&&e.jsx(D,{className:"h-4 w-4 mr-1 animate-spin"}),"Sync"]})]})]})})]})}function qs({team:s,imported:n,syncing:t,canImport:a,onSync:r}){return e.jsxs(q,{className:`flex flex-col${a?"":" opacity-70"}`,children:[e.jsx(ye,{className:"space-y-1 pb-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:s.name}),e.jsx(M,{variant:"secondary",className:"shrink-0",children:s.members.length}),n&&e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsxs(M,{variant:"outline",className:"shrink-0 gap-1",children:[e.jsx(je,{className:"h-3 w-3"}),"Synced"]})}),e.jsx(R,{children:"Already imported. Syncing again updates it in place."})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["You're ",s.your_role," in PromptOwl",s.enterprise?` · ${s.enterprise.name}`:""]})]}),a?e.jsxs(C,{size:"sm",variant:n?"outline":"default",className:"shrink-0",disabled:t,onClick:r,children:[t?e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"}):n?e.jsx(Pe,{className:"h-3.5 w-3.5"}):e.jsx(es,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1",children:n?"Sync":"Import"})]}):e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 text-xs text-muted-foreground border rounded-md px-2 py-1.5",children:[e.jsx(ss,{className:"h-3 w-3"}),"View-only"]})}),e.jsx(R,{className:"max-w-xs",children:"Importing a team makes you the owner of the copy here, which is more than you can do with this team in PromptOwl. Ask an owner or editor of it to import it."})]})]})}),e.jsx(X,{className:"space-y-1.5",children:s.members.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No members."}):s.members.map(m=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"flex-1 truncate",children:m.email}),e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:ce(m.role)})}),e.jsxs(R,{children:[m.role," in PromptOwl → ",ce(m.role)," here"]})]})]},m.email))})]})}function Xs({result:s}){const n=!s.added.length&&!s.updated.length&&!s.removed.length;return e.jsxs(L,{children:[e.jsx(je,{className:"h-4 w-4"}),e.jsxs(I,{className:"text-xs space-y-0.5",children:[e.jsxs("div",{className:"font-medium",children:[s.name," — ",s.created?"imported":"synced"]}),n?e.jsx("div",{children:"Already up to date."}):e.jsxs(e.Fragment,{children:[s.added.length>0&&e.jsxs("div",{children:["Added: ",s.added.join(", ")]}),s.updated.length>0&&e.jsxs("div",{children:["Role changed: ",s.updated.join(", ")]}),s.removed.length>0&&e.jsxs("div",{children:["Removed: ",s.removed.join(", ")]})]})]})]})}const de=5,W=s=>{var n;return((n=se.find(t=>t.value===s))==null?void 0:n.label)??s},$={viewer:1,editor:2,admin:3},V=4;function me(s,n,t){if(t||s.owner_email&&s.owner_email.toLowerCase()===n)return V;const a=s.members.find(r=>(r.email||"").toLowerCase()===n);return a?$[a.role]??0:0}function mt(){var re;const{adminStatus:s,isAdmin:n,promptowlTeamsEnabled:t}=ns(),a=(((re=s==null?void 0:s.me)==null?void 0:re.email)||"").toLowerCase(),[r]=o.useState(()=>rs()),m=t&&r,[u,p]=o.useState([]),[d,f]=o.useState(!0),l=pe(),[h,i]=o.useState(null),[c,j]=o.useState(!1),[g,v]=o.useState(null),[y,w]=o.useState(null),[T,P]=o.useState(!1),x=async()=>{i(null);try{const N=await l.fetchQuery(fe.teamList());p(N.teams),v(ae=>ae?N.teams.find(Ve=>Ve.id===ae.id)??null:null)}catch(N){i((N==null?void 0:N.message)||"Failed to load teams")}finally{f(!1)}};o.useEffect(()=>{x()},[]);const S=async()=>{if(y){P(!0);try{await cs(y.id),E.success("Team deleted"),w(null),await x()}catch(N){E.error((N==null?void 0:N.message)||"Failed to delete team")}finally{P(!1)}}},b=d?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(D,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):u.length===0?e.jsx(q,{children:e.jsx(X,{className:"py-10 text-center text-sm text-muted-foreground",children:"No teams yet. Create one to share a nest with a whole group at once."})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:u.map(N=>e.jsx(Qs,{team:N,rank:me(N,a,n),onEdit:()=>v(N),onDelete:()=>w(N)},N.id))});return e.jsxs(Gs,{delayDuration:150,children:[e.jsxs("div",{className:"w-full mx-auto space-y-4",children:[e.jsx(fs,{icon:as,title:"Teams",description:e.jsxs(e.Fragment,{children:["A team is a reusable group. Give each member a role, then share the team with a nest from its ",e.jsx("strong",{children:"Share"})," dialog — every member gets their role on that nest."]}),actions:e.jsxs(C,{size:"sm",onClick:()=>j(!0),children:[e.jsx(os,{className:"h-4 w-4 mr-1"}),"New Team"]})}),h&&e.jsxs(L,{variant:"destructive",children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(I,{children:h})]}),m?e.jsxs(ls,{defaultValue:"cn",children:[e.jsxs(is,{children:[e.jsx(le,{value:"cn",children:"ContextNest Teams"}),e.jsx(le,{value:"po",children:"PromptOwl Teams"})]}),e.jsx(ie,{value:"cn",className:"mt-4",children:b}),e.jsx(ie,{value:"po",className:"mt-4",children:e.jsx(Ys,{localTeams:u,onImported:x})})]}):b]}),c&&e.jsx(Ws,{onClose:()=>j(!1),onCreated:x}),g&&e.jsx(Js,{team:g,rank:me(g,a,n),onClose:()=>v(null),onChanged:x}),e.jsx(z,{open:!!y,onOpenChange:N=>!N&&w(null),children:e.jsxs(B,{className:"sm:max-w-[420px]",children:[e.jsx(G,{children:e.jsxs(U,{children:['Delete team "',y==null?void 0:y.name,'"?']})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Members lose access to every nest this team is shared with. This can't be undone."}),e.jsxs(Y,{children:[e.jsx(C,{variant:"outline",onClick:()=>w(null),children:"Cancel"}),e.jsxs(C,{variant:"destructive",disabled:T,onClick:S,children:[T&&e.jsx(D,{className:"h-4 w-4 mr-1 animate-spin"}),"Delete"]})]})]})})]})}function $e({registered:s}){return e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsx("span",{className:"shrink-0 flex items-center",children:s?e.jsx(Se,{className:"h-3.5 w-3.5 text-green-600"}):e.jsx(Re,{className:"h-3.5 w-3.5 text-red-500"})})}),e.jsx(R,{children:s?"Registered account":"Invited — hasn't signed up yet"})]})}function Ks({member:s}){return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx($e,{registered:s.registered}),e.jsx("span",{className:"flex-1 truncate",children:s.email}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:W(s.role)})]})}function Qs({team:s,rank:n,onEdit:t,onDelete:a}){const r=s.members.slice(0,de),m=s.members.slice(de),u=n>=$.editor,p=n>=V;return e.jsxs(q,{className:"flex flex-col",children:[e.jsx(ye,{className:"space-y-1 pb-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:s.name}),e.jsx(M,{variant:"secondary",className:"shrink-0",children:s.members.length}),s.source==="promptowl"&&e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsx(M,{variant:"outline",className:"shrink-0",children:"PromptOwl"})}),e.jsx(R,{children:"Imported from PromptOwl. Re-syncing makes this roster match PromptOwl exactly."})]})]}),s.owner_email&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["Created by ",s.owner_email]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[u&&e.jsx(C,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:t,"aria-label":"Edit team",children:e.jsx(ds,{className:"h-3.5 w-3.5"})}),p&&e.jsx(C,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive",onClick:a,"aria-label":"Delete team",children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(X,{className:"space-y-1.5",children:s.members.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No members yet."}):e.jsxs(e.Fragment,{children:[r.map(d=>e.jsx(Ks,{member:d},d.userId)),m.length>0&&e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsxs("button",{className:"text-xs text-muted-foreground hover:text-foreground text-left",children:["+",m.length," more member",m.length===1?"":"s"]})}),e.jsx(R,{className:"max-w-xs",children:e.jsx("div",{className:"space-y-1",children:m.map(d=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[d.registered?e.jsx(Se,{className:"h-3 w-3 text-green-600 shrink-0"}):e.jsx(Re,{className:"h-3 w-3 text-red-500 shrink-0"}),e.jsx("span",{className:"truncate",children:d.email}),e.jsxs("span",{className:"opacity-70",children:["· ",W(d.role)]})]},d.userId))})})]})]})})]})}function Fe({onAdd:s,busy:n,maxRank:t=V,members:a=[]}){var i;const r=se.filter(c=>$[c.value]<=t),[m,u]=o.useState(""),[p,d]=o.useState(((i=r[0])==null?void 0:i.value)??"viewer"),[f,l]=o.useState(null),h=()=>{const c=m.trim();if(c){if(!us(c)){l("Enter a valid email address.");return}l(null),Promise.resolve(s(c,p)).then(()=>{var j;u(""),d(((j=r[0])==null?void 0:j.value)??"viewer")})}};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsx(js,{value:m,onChange:c=>{u(c),f&&l(null)},onSubmit:h,placeholder:"person@company.com",exclude:a,className:"flex-1",testId:"team-member-input"}),e.jsxs(we,{value:p,onValueChange:c=>d(c),children:[e.jsx(Ne,{className:"w-full sm:w-[130px] h-8",children:e.jsx(Ce,{})}),e.jsx(be,{children:r.map(c=>e.jsx(Te,{value:c.value,children:c.label},c.value))})]}),e.jsxs(C,{size:"sm",onClick:h,disabled:n||!m.trim(),children:[e.jsx(ws,{className:"h-4 w-4 mr-1"}),"Add"]})]}),f&&e.jsx("p",{className:"text-xs text-destructive",children:f})]})}function Ws({onClose:s,onCreated:n}){const[t,a]=o.useState(""),[r,m]=o.useState([]),[u,p]=o.useState(!1),d=(l,h)=>{if(r.some(i=>i.email.toLowerCase()===l.toLowerCase())){E.error("Already added");return}m(i=>[...i,{email:l,role:h}])},f=async()=>{const l=t.trim();if(l){p(!0);try{const{team:h}=await ms(l);for(const i of r)try{await ve(h.id,{email:i.email,role:i.role})}catch(c){E.error(`${i.email}: ${(c==null?void 0:c.message)||"could not add"}`)}E.success(`Team "${l}" created`),n(),s()}catch(h){E.error((h==null?void 0:h.message)||"Failed to create team")}finally{p(!1)}}};return e.jsx(z,{open:!0,onOpenChange:l=>!l&&s(),children:e.jsxs(B,{className:"sm:max-w-[480px]",children:[e.jsx(G,{children:e.jsx(U,{children:"New team"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{autoFocus:!0,placeholder:"Team name (e.g. Platform)",value:t,onChange:l=>a(l.target.value)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Members (optional)"}),r.length>0&&e.jsx("div",{className:"space-y-1.5",children:r.map(l=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"flex-1 truncate",children:l.email}),e.jsx("span",{className:"text-xs text-muted-foreground",children:W(l.role)}),e.jsx(C,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:()=>m(h=>h.filter(i=>i.email!==l.email)),"aria-label":`Remove ${l.email}`,children:e.jsx(ys,{className:"h-3.5 w-3.5"})})]},l.email))}),e.jsx(Fe,{onAdd:d,members:r.map(l=>l.email)})]})]}),e.jsxs(Y,{children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(C,{onClick:f,disabled:u||!t.trim(),children:[u&&e.jsx(D,{className:"h-4 w-4 mr-1 animate-spin"}),"Create"]})]})]})})}function Js({team:s,rank:n,onClose:t,onChanged:a}){const r=n>=$.admin,m=n>=$.editor,[u,p]=o.useState(s.name),[d,f]=o.useState(!1),l=async(i,c)=>{f(!0);try{await i(),c&&E.success(c),a()}catch(j){E.error((j==null?void 0:j.message)||"Something went wrong")}finally{f(!1)}},h=async()=>{if(!r)return;const i=u.trim();!i||i===s.name||await l(()=>xs(s.id,i),"Team renamed")};return e.jsx(z,{open:!0,onOpenChange:i=>!i&&t(),children:e.jsxs(B,{className:"sm:max-w-[480px]",children:[e.jsx(G,{children:e.jsx(U,{children:"Edit team"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(ge,{value:u,onChange:i=>p(i.target.value),onBlur:h,onKeyDown:i=>i.key==="Enter"&&h(),className:"h-9",disabled:!r})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Members"}),s.members.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No members yet."}):e.jsx("div",{className:"space-y-2",children:s.members.map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{registered:i.registered}),e.jsx("span",{className:"text-sm flex-1 truncate",children:i.email}),r?e.jsxs(we,{value:i.role,onValueChange:c=>l(()=>hs(s.id,i.userId,c),"Role updated"),children:[e.jsx(Ne,{className:"w-[120px] h-8",children:e.jsx(Ce,{})}),e.jsx(be,{children:se.map(c=>e.jsx(Te,{value:c.value,children:c.label},c.value))})]}):e.jsx(M,{variant:"secondary",className:"text-[11px]",children:W(i.role)}),r&&e.jsx(C,{size:"icon",variant:"ghost",className:"h-8 w-8",disabled:d,onClick:()=>l(()=>ps(s.id,i.userId),"Member removed"),"aria-label":`Remove ${i.email}`,children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]},i.userId))}),m&&e.jsx("div",{className:"pt-1 border-t",children:e.jsx("div",{className:"pt-2",children:e.jsx(Fe,{busy:d,maxRank:n,members:s.members.map(i=>i.email),onAdd:(i,c)=>l(()=>ve(s.id,{email:i,role:c}),"Member added")})})})]})]}),e.jsx(Y,{children:e.jsx(C,{variant:"outline",onClick:t,children:"Done"})})]})})}export{mt as default};
|
|
1
|
+
import{j as e,r as o,c_ as Ve,d3 as ze,dk as Ge,cP as ue,dl as Ue,c$ as Ye,cS as k,dm as xe,d2 as he,dn as qe,cX as Xe,dp as Ke,dq as Qe,dr as We,s as Je,u as pe,i as fe,ds as oe,A as L,K as J,a as I,L as _,B as C,dt as Ze,D as V,x as z,y as G,z as U,H as Y,C as je,e as M,bS as es,ab as ss,du as ts,f as E,O as ns,dv as rs,U as as,aP as os,T as ls,P as is,Q as le,R as ie,dw as cs,ag as ds,I as ge,dx as se,dy as ms,dz as ve,bB as us,dA as xs,dB as hs,dC as ps}from"./index-B5hLclEq.js";import{P as fs}from"./page-title-BkqlUA0j.js";import{P as js}from"./PersonCombobox-D350WlrJ.js";import{C as q,d as X,a as ye}from"./card-UDyMRcps.js";import{R as gs,S as we,a as Ne,b as Ce,c as be,d as Te}from"./select-DrL0mpRN.js";import{R as Pe}from"./refresh-cw-CsCtmWwX.js";import{T as vs}from"./triangle-alert-CsYGyfGZ.js";import{T as Ee}from"./trash-2-B4hRXo-p.js";import{C as Se}from"./circle-check-CSkZUEFK.js";import{C as Re}from"./circle-x-in2o3aHU.js";import{X as ys}from"./x-qxt1WrUi.js";import{U as ws}from"./user-plus-4CTYEkd3.js";var Ns=Symbol("radix.slottable");function Cs(s){const n=({children:t})=>e.jsx(e.Fragment,{children:t});return n.displayName=`${s}.Slottable`,n.__radixId=Ns,n}var[K]=Xe("Tooltip",[xe]),Q=xe(),ke="TooltipProvider",bs=700,Z="tooltip.open",[Ts,te]=K(ke),Oe=s=>{const{__scopeTooltip:n,delayDuration:t=bs,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:m}=s,u=o.useRef(!0),p=o.useRef(!1),d=o.useRef(0);return o.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),e.jsx(Ts,{scope:n,isOpenDelayedRef:u,delayDuration:t,onOpen:o.useCallback(()=>{window.clearTimeout(d.current),u.current=!1},[]),onClose:o.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u.current=!0,a)},[a]),isPointerInTransitRef:p,onPointerInTransitChange:o.useCallback(f=>{p.current=f},[]),disableHoverableContent:r,children:m})};Oe.displayName=ke;var H="Tooltip",[Ps,F]=K(H),Ae=s=>{const{__scopeTooltip:n,children:t,open:a,defaultOpen:r,onOpenChange:m,disableHoverableContent:u,delayDuration:p}=s,d=te(H,s.__scopeTooltip),f=Q(n),[l,h]=o.useState(null),i=Ve(),c=o.useRef(0),j=u??d.disableHoverableContent,g=p??d.delayDuration,v=o.useRef(!1),[y,w]=ze({prop:a,defaultProp:r??!1,onChange:b=>{b?(d.onOpen(),document.dispatchEvent(new CustomEvent(Z))):d.onClose(),m==null||m(b)},caller:H}),T=o.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),P=o.useCallback(()=>{window.clearTimeout(c.current),c.current=0,v.current=!1,w(!0)},[w]),x=o.useCallback(()=>{window.clearTimeout(c.current),c.current=0,w(!1)},[w]),S=o.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>{v.current=!0,w(!0),c.current=0},g)},[g,w]);return o.useEffect(()=>()=>{c.current&&(window.clearTimeout(c.current),c.current=0)},[]),e.jsx(Ge,{...f,children:e.jsx(Ps,{scope:n,contentId:i,open:y,stateAttribute:T,trigger:l,onTriggerChange:h,onTriggerEnter:o.useCallback(()=>{d.isOpenDelayedRef.current?S():P()},[d.isOpenDelayedRef,S,P]),onTriggerLeave:o.useCallback(()=>{j?x():(window.clearTimeout(c.current),c.current=0)},[x,j]),onOpen:P,onClose:x,disableHoverableContent:j,children:t})})};Ae.displayName=H;var ee="TooltipTrigger",_e=o.forwardRef((s,n)=>{const{__scopeTooltip:t,...a}=s,r=F(ee,t),m=te(ee,t),u=Q(t),p=o.useRef(null),d=ue(n,p,r.onTriggerChange),f=o.useRef(!1),l=o.useRef(!1),h=o.useCallback(()=>f.current=!1,[]);return o.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),e.jsx(Ue,{asChild:!0,...u,children:e.jsx(Ye.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:d,onPointerMove:k(s.onPointerMove,i=>{i.pointerType!=="touch"&&!l.current&&!m.isPointerInTransitRef.current&&(r.onTriggerEnter(),l.current=!0)}),onPointerLeave:k(s.onPointerLeave,()=>{r.onTriggerLeave(),l.current=!1}),onPointerDown:k(s.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:k(s.onFocus,()=>{f.current||r.onOpen()}),onBlur:k(s.onBlur,r.onClose),onClick:k(s.onClick,r.onClose)})})});_e.displayName=ee;var ne="TooltipPortal",[Es,Ss]=K(ne,{forceMount:void 0}),De=s=>{const{__scopeTooltip:n,forceMount:t,children:a,container:r}=s,m=F(ne,n);return e.jsx(Es,{scope:n,forceMount:t,children:e.jsx(he,{present:t||m.open,children:e.jsx(qe,{asChild:!0,container:r,children:a})})})};De.displayName=ne;var D="TooltipContent",Le=o.forwardRef((s,n)=>{const t=Ss(D,s.__scopeTooltip),{forceMount:a=t.forceMount,side:r="top",...m}=s,u=F(D,s.__scopeTooltip);return e.jsx(he,{present:a||u.open,children:u.disableHoverableContent?e.jsx(Ie,{side:r,...m,ref:n}):e.jsx(Rs,{side:r,...m,ref:n})})}),Rs=o.forwardRef((s,n)=>{const t=F(D,s.__scopeTooltip),a=te(D,s.__scopeTooltip),r=o.useRef(null),m=ue(n,r),[u,p]=o.useState(null),{trigger:d,onClose:f}=t,l=r.current,{onPointerInTransitChange:h}=a,i=o.useCallback(()=>{p(null),h(!1)},[h]),c=o.useCallback((j,g)=>{const v=j.currentTarget,y={x:j.clientX,y:j.clientY},w=Ds(y,v.getBoundingClientRect()),T=Ls(y,w),P=Is(g.getBoundingClientRect()),x=Hs([...T,...P]);p(x),h(!0)},[h]);return o.useEffect(()=>()=>i(),[i]),o.useEffect(()=>{if(d&&l){const j=v=>c(v,l),g=v=>c(v,d);return d.addEventListener("pointerleave",j),l.addEventListener("pointerleave",g),()=>{d.removeEventListener("pointerleave",j),l.removeEventListener("pointerleave",g)}}},[d,l,c,i]),o.useEffect(()=>{if(u){const j=g=>{const v=g.target,y={x:g.clientX,y:g.clientY},w=(d==null?void 0:d.contains(v))||(l==null?void 0:l.contains(v)),T=!Ms(y,u);w?i():T&&(i(),f())};return document.addEventListener("pointermove",j),()=>document.removeEventListener("pointermove",j)}},[d,l,u,f,i]),e.jsx(Ie,{...s,ref:m})}),[ks,Os]=K(H,{isInside:!1}),As=Cs("TooltipContent"),Ie=o.forwardRef((s,n)=>{const{__scopeTooltip:t,children:a,"aria-label":r,onEscapeKeyDown:m,onPointerDownOutside:u,...p}=s,d=F(D,t),f=Q(t),{onClose:l}=d;return o.useEffect(()=>(document.addEventListener(Z,l),()=>document.removeEventListener(Z,l)),[l]),o.useEffect(()=>{if(d.trigger){const h=i=>{const c=i.target;c!=null&&c.contains(d.trigger)&&l()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,l]),e.jsx(Ke,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:m,onPointerDownOutside:u,onFocusOutside:h=>h.preventDefault(),onDismiss:l,children:e.jsxs(Qe,{"data-state":d.stateAttribute,...f,...p,ref:n,style:{...p.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(As,{children:a}),e.jsx(ks,{scope:t,isInside:!0,children:e.jsx(gs,{id:d.contentId,role:"tooltip",children:r||a})})]})})});Le.displayName=D;var Me="TooltipArrow",_s=o.forwardRef((s,n)=>{const{__scopeTooltip:t,...a}=s,r=Q(t);return Os(Me,t).isInside?null:e.jsx(We,{...r,...a,ref:n})});_s.displayName=Me;function Ds(s,n){const t=Math.abs(n.top-s.y),a=Math.abs(n.bottom-s.y),r=Math.abs(n.right-s.x),m=Math.abs(n.left-s.x);switch(Math.min(t,a,r,m)){case m:return"left";case r:return"right";case t:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Ls(s,n,t=5){const a=[];switch(n){case"top":a.push({x:s.x-t,y:s.y+t},{x:s.x+t,y:s.y+t});break;case"bottom":a.push({x:s.x-t,y:s.y-t},{x:s.x+t,y:s.y-t});break;case"left":a.push({x:s.x+t,y:s.y-t},{x:s.x+t,y:s.y+t});break;case"right":a.push({x:s.x-t,y:s.y-t},{x:s.x-t,y:s.y+t});break}return a}function Is(s){const{top:n,right:t,bottom:a,left:r}=s;return[{x:r,y:n},{x:t,y:n},{x:t,y:a},{x:r,y:a}]}function Ms(s,n){const{x:t,y:a}=s;let r=!1;for(let m=0,u=n.length-1;m<n.length;u=m++){const p=n[m],d=n[u],f=p.x,l=p.y,h=d.x,i=d.y;l>a!=i>a&&t<(h-f)*(a-l)/(i-l)+f&&(r=!r)}return r}function Hs(s){const n=s.slice();return n.sort((t,a)=>t.x<a.x?-1:t.x>a.x?1:t.y<a.y?-1:t.y>a.y?1:0),$s(n)}function $s(s){if(s.length<=1)return s.slice();const n=[];for(let a=0;a<s.length;a++){const r=s[a];for(;n.length>=2;){const m=n[n.length-1],u=n[n.length-2];if((m.x-u.x)*(r.y-u.y)>=(m.y-u.y)*(r.x-u.x))n.pop();else break}n.push(r)}n.pop();const t=[];for(let a=s.length-1;a>=0;a--){const r=s[a];for(;t.length>=2;){const m=t[t.length-1],u=t[t.length-2];if((m.x-u.x)*(r.y-u.y)>=(m.y-u.y)*(r.x-u.x))t.pop();else break}t.push(r)}return t.pop(),n.length===1&&t.length===1&&n[0].x===t[0].x&&n[0].y===t[0].y?n:n.concat(t)}var Fs=Oe,Bs=Ae,Vs=_e,zs=De,He=Le;const Gs=({children:s,delayDuration:n=0})=>e.jsx(Fs,{delayDuration:n,children:s}),O=Bs,A=Vs,R=o.forwardRef(({className:s,sideOffset:n=4,...t},a)=>e.jsx(zs,{children:e.jsx(He,{ref:a,sideOffset:n,className:Je("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));R.displayName=He.displayName;const Us={Owner:"Admin",Editor:"Editor",Viewer:"Viewer",User:"Viewer"},ce=s=>Us[s]??"Viewer";function Ys({localTeams:s,onImported:n}){const[t,a]=o.useState([]),r=pe(),[m,u]=o.useState(!0),[p,d]=o.useState(null),[f,l]=o.useState(!1),[h,i]=o.useState(null),[c,j]=o.useState(null),[g,v]=o.useState(null),y=new Map(s.filter(x=>x.source==="promptowl"&&x.external_id).map(x=>[x.external_id,x]));o.useEffect(()=>{w()},[]);const w=async()=>{u(!0),d(null);try{const x=await r.fetchQuery(fe.promptowlTeams());a(x.teams)}catch(x){oe(x)?l(!0):d((x==null?void 0:x.message)||"Could not reach PromptOwl")}finally{u(!1)}},T=async x=>{var S;i(x.id),d(null);try{const b=await ts([x.id]);v(b.results[0]??null),n(),E.success((S=b.results[0])!=null&&S.created?`Imported ${x.name}`:`Synced ${x.name}`)}catch(b){oe(b)?l(!0):d((b==null?void 0:b.message)||"Sync failed")}finally{i(null),j(null)}},P=x=>{y.has(x.id)?j(x):T(x)};return f?e.jsxs(L,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(I,{children:"Your PromptOwl session has ended. Sign out and sign back in with PromptOwl to import teams."})]}):m?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(_,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-4",children:[p&&e.jsxs(L,{variant:"destructive",children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(I,{children:p})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground flex-1",children:"Your PromptOwl teams. Syncing one copies it here with its members — people without an account are invited automatically. Teams you're view-only on can't be imported, since the copy would be yours to control."}),e.jsx(C,{size:"sm",variant:"ghost",onClick:w,"aria-label":"Refresh",children:e.jsx(Pe,{className:"h-4 w-4"})})]}),g&&e.jsx(Xs,{result:g}),t.length===0?e.jsx(q,{children:e.jsx(X,{className:"py-10 text-center text-sm text-muted-foreground",children:"You're not in any teams in PromptOwl."})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:t.map(x=>e.jsx(qs,{team:x,imported:y.has(x.id),syncing:h===x.id,canImport:Ze(x),onSync:()=>P(x)},x.id))}),e.jsx(V,{open:!!c,onOpenChange:x=>!x&&j(null),children:e.jsxs(z,{className:"sm:max-w-[460px]",children:[e.jsx(G,{children:e.jsxs(U,{children:['Sync "',c==null?void 0:c.name,'" from PromptOwl?']})}),e.jsxs(L,{children:[e.jsx(vs,{className:"h-4 w-4"}),e.jsx(I,{className:"text-xs",children:"PromptOwl is the source of truth. This team's roster here will be made to match PromptOwl exactly: roles are reset, and anyone you added by hand in ContextNest is removed."})]}),e.jsxs(Y,{children:[e.jsx(C,{variant:"outline",onClick:()=>j(null),children:"Cancel"}),e.jsxs(C,{disabled:!!h,onClick:()=>c&&T(c),children:[h&&e.jsx(_,{className:"h-4 w-4 mr-1 animate-spin"}),"Sync"]})]})]})})]})}function qs({team:s,imported:n,syncing:t,canImport:a,onSync:r}){return e.jsxs(q,{className:`flex flex-col${a?"":" opacity-70"}`,children:[e.jsx(ye,{className:"space-y-1 pb-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:s.name}),e.jsx(M,{variant:"secondary",className:"shrink-0",children:s.members.length}),n&&e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsxs(M,{variant:"outline",className:"shrink-0 gap-1",children:[e.jsx(je,{className:"h-3 w-3"}),"Synced"]})}),e.jsx(R,{children:"Already imported. Syncing again updates it in place."})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["You're ",s.your_role," in PromptOwl",s.enterprise?` · ${s.enterprise.name}`:""]})]}),a?e.jsxs(C,{size:"sm",variant:n?"outline":"default",className:"shrink-0",disabled:t,onClick:r,children:[t?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}):n?e.jsx(Pe,{className:"h-3.5 w-3.5"}):e.jsx(es,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1",children:n?"Sync":"Import"})]}):e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 text-xs text-muted-foreground border rounded-md px-2 py-1.5",children:[e.jsx(ss,{className:"h-3 w-3"}),"View-only"]})}),e.jsx(R,{className:"max-w-xs",children:"Importing a team makes you the owner of the copy here, which is more than you can do with this team in PromptOwl. Ask an owner or editor of it to import it."})]})]})}),e.jsx(X,{className:"space-y-1.5",children:s.members.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No members."}):s.members.map(m=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"flex-1 truncate",children:m.email}),e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:ce(m.role)})}),e.jsxs(R,{children:[m.role," in PromptOwl → ",ce(m.role)," here"]})]})]},m.email))})]})}function Xs({result:s}){const n=!s.added.length&&!s.updated.length&&!s.removed.length;return e.jsxs(L,{children:[e.jsx(je,{className:"h-4 w-4"}),e.jsxs(I,{className:"text-xs space-y-0.5",children:[e.jsxs("div",{className:"font-medium",children:[s.name," — ",s.created?"imported":"synced"]}),n?e.jsx("div",{children:"Already up to date."}):e.jsxs(e.Fragment,{children:[s.added.length>0&&e.jsxs("div",{children:["Added: ",s.added.join(", ")]}),s.updated.length>0&&e.jsxs("div",{children:["Role changed: ",s.updated.join(", ")]}),s.removed.length>0&&e.jsxs("div",{children:["Removed: ",s.removed.join(", ")]})]})]})]})}const de=5,W=s=>{var n;return((n=se.find(t=>t.value===s))==null?void 0:n.label)??s},$={viewer:1,editor:2,admin:3},B=4;function me(s,n,t){if(t||s.owner_email&&s.owner_email.toLowerCase()===n)return B;const a=s.members.find(r=>(r.email||"").toLowerCase()===n);return a?$[a.role]??0:0}function mt(){var re;const{adminStatus:s,isAdmin:n,promptowlTeamsEnabled:t}=ns(),a=(((re=s==null?void 0:s.me)==null?void 0:re.email)||"").toLowerCase(),[r]=o.useState(()=>rs()),m=t&&r,[u,p]=o.useState([]),[d,f]=o.useState(!0),l=pe(),[h,i]=o.useState(null),[c,j]=o.useState(!1),[g,v]=o.useState(null),[y,w]=o.useState(null),[T,P]=o.useState(!1),x=async()=>{i(null);try{const N=await l.fetchQuery(fe.teamList());p(N.teams),v(ae=>ae?N.teams.find(Be=>Be.id===ae.id)??null:null)}catch(N){i((N==null?void 0:N.message)||"Failed to load teams")}finally{f(!1)}};o.useEffect(()=>{x()},[]);const S=async()=>{if(y){P(!0);try{await cs(y.id),E.success("Team deleted"),w(null),await x()}catch(N){E.error((N==null?void 0:N.message)||"Failed to delete team")}finally{P(!1)}}},b=d?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(_,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):u.length===0?e.jsx(q,{children:e.jsx(X,{className:"py-10 text-center text-sm text-muted-foreground",children:"No teams yet. Create one to share a nest with a whole group at once."})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:u.map(N=>e.jsx(Qs,{team:N,rank:me(N,a,n),onEdit:()=>v(N),onDelete:()=>w(N)},N.id))});return e.jsxs(Gs,{delayDuration:150,children:[e.jsxs("div",{className:"w-full mx-auto space-y-4",children:[e.jsx(fs,{icon:as,title:"Teams",description:e.jsxs(e.Fragment,{children:["A team is a reusable group. Give each member a role, then share the team with a nest from its ",e.jsx("strong",{children:"Share"})," dialog — every member gets their role on that nest."]}),actions:e.jsxs(C,{size:"sm",onClick:()=>j(!0),children:[e.jsx(os,{className:"h-4 w-4 mr-1"}),"New Team"]})}),h&&e.jsxs(L,{variant:"destructive",children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(I,{children:h})]}),m?e.jsxs(ls,{defaultValue:"cn",children:[e.jsxs(is,{children:[e.jsx(le,{value:"cn",children:"ContextNest Teams"}),e.jsx(le,{value:"po",children:"PromptOwl Teams"})]}),e.jsx(ie,{value:"cn",className:"mt-4",children:b}),e.jsx(ie,{value:"po",className:"mt-4",children:e.jsx(Ys,{localTeams:u,onImported:x})})]}):b]}),c&&e.jsx(Ws,{onClose:()=>j(!1),onCreated:x}),g&&e.jsx(Js,{team:g,rank:me(g,a,n),onClose:()=>v(null),onChanged:x}),e.jsx(V,{open:!!y,onOpenChange:N=>!N&&w(null),children:e.jsxs(z,{className:"sm:max-w-[420px]",children:[e.jsx(G,{children:e.jsxs(U,{children:['Delete team "',y==null?void 0:y.name,'"?']})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Members lose access to every nest this team is shared with. This can't be undone."}),e.jsxs(Y,{children:[e.jsx(C,{variant:"outline",onClick:()=>w(null),children:"Cancel"}),e.jsxs(C,{variant:"destructive",disabled:T,onClick:S,children:[T&&e.jsx(_,{className:"h-4 w-4 mr-1 animate-spin"}),"Delete"]})]})]})})]})}function $e({registered:s}){return e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsx("span",{className:"shrink-0 flex items-center",children:s?e.jsx(Se,{className:"h-3.5 w-3.5 text-green-600"}):e.jsx(Re,{className:"h-3.5 w-3.5 text-red-500"})})}),e.jsx(R,{children:s?"Registered account":"Invited — hasn't signed up yet"})]})}function Ks({member:s}){return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx($e,{registered:s.registered}),e.jsx("span",{className:"flex-1 truncate",children:s.email}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:W(s.role)})]})}function Qs({team:s,rank:n,onEdit:t,onDelete:a}){const r=s.members.slice(0,de),m=s.members.slice(de),u=n>=$.editor,p=n>=B;return e.jsxs(q,{className:"flex flex-col",children:[e.jsx(ye,{className:"space-y-1 pb-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:s.name}),e.jsx(M,{variant:"secondary",className:"shrink-0",children:s.members.length}),s.source==="promptowl"&&e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsx(M,{variant:"outline",className:"shrink-0",children:"PromptOwl"})}),e.jsx(R,{children:"Imported from PromptOwl. Re-syncing makes this roster match PromptOwl exactly."})]})]}),s.owner_email&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["Created by ",s.owner_email]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[u&&e.jsx(C,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:t,"aria-label":"Edit team",children:e.jsx(ds,{className:"h-3.5 w-3.5"})}),p&&e.jsx(C,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive",onClick:a,"aria-label":"Delete team",children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(X,{className:"space-y-1.5",children:s.members.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No members yet."}):e.jsxs(e.Fragment,{children:[r.map(d=>e.jsx(Ks,{member:d},d.userId)),m.length>0&&e.jsxs(O,{children:[e.jsx(A,{asChild:!0,children:e.jsxs("button",{className:"text-xs text-muted-foreground hover:text-foreground text-left",children:["+",m.length," more member",m.length===1?"":"s"]})}),e.jsx(R,{className:"max-w-xs",children:e.jsx("div",{className:"space-y-1",children:m.map(d=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[d.registered?e.jsx(Se,{className:"h-3 w-3 text-green-600 shrink-0"}):e.jsx(Re,{className:"h-3 w-3 text-red-500 shrink-0"}),e.jsx("span",{className:"truncate",children:d.email}),e.jsxs("span",{className:"opacity-70",children:["· ",W(d.role)]})]},d.userId))})})]})]})})]})}function Fe({onAdd:s,busy:n,maxRank:t=B,members:a=[]}){var i;const r=se.filter(c=>$[c.value]<=t),[m,u]=o.useState(""),[p,d]=o.useState(((i=r[0])==null?void 0:i.value)??"viewer"),[f,l]=o.useState(null),h=()=>{const c=m.trim();if(c){if(!us(c)){l("Enter a valid email address.");return}l(null),Promise.resolve(s(c,p)).then(()=>{var j;u(""),d(((j=r[0])==null?void 0:j.value)??"viewer")})}};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsx(js,{value:m,onChange:c=>{u(c),f&&l(null)},onSubmit:h,placeholder:"person@company.com",exclude:a,className:"flex-1",testId:"team-member-input"}),e.jsxs(we,{value:p,onValueChange:c=>d(c),children:[e.jsx(Ne,{className:"w-full sm:w-[130px] h-8",children:e.jsx(Ce,{})}),e.jsx(be,{children:r.map(c=>e.jsx(Te,{value:c.value,children:c.label},c.value))})]}),e.jsxs(C,{size:"sm",onClick:h,disabled:n||!m.trim(),children:[e.jsx(ws,{className:"h-4 w-4 mr-1"}),"Add"]})]}),f&&e.jsx("p",{className:"text-xs text-destructive",children:f})]})}function Ws({onClose:s,onCreated:n}){const[t,a]=o.useState(""),[r,m]=o.useState([]),[u,p]=o.useState(!1),d=(l,h)=>{if(r.some(i=>i.email.toLowerCase()===l.toLowerCase())){E.error("Already added");return}m(i=>[...i,{email:l,role:h}])},f=async()=>{const l=t.trim();if(l){p(!0);try{const{team:h}=await ms(l);for(const i of r)try{await ve(h.id,{email:i.email,role:i.role})}catch(c){E.error(`${i.email}: ${(c==null?void 0:c.message)||"could not add"}`)}E.success(`Team "${l}" created`),n(),s()}catch(h){E.error((h==null?void 0:h.message)||"Failed to create team")}finally{p(!1)}}};return e.jsx(V,{open:!0,onOpenChange:l=>!l&&s(),children:e.jsxs(z,{className:"sm:max-w-[480px]",children:[e.jsx(G,{children:e.jsx(U,{children:"New team"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ge,{autoFocus:!0,placeholder:"Team name (e.g. Platform)",value:t,onChange:l=>a(l.target.value)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Members (optional)"}),r.length>0&&e.jsx("div",{className:"space-y-1.5",children:r.map(l=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"flex-1 truncate",children:l.email}),e.jsx("span",{className:"text-xs text-muted-foreground",children:W(l.role)}),e.jsx(C,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:()=>m(h=>h.filter(i=>i.email!==l.email)),"aria-label":`Remove ${l.email}`,children:e.jsx(ys,{className:"h-3.5 w-3.5"})})]},l.email))}),e.jsx(Fe,{onAdd:d,members:r.map(l=>l.email)})]})]}),e.jsxs(Y,{children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(C,{onClick:f,disabled:u||!t.trim(),children:[u&&e.jsx(_,{className:"h-4 w-4 mr-1 animate-spin"}),"Create"]})]})]})})}function Js({team:s,rank:n,onClose:t,onChanged:a}){const r=n>=$.admin,m=n>=$.editor,[u,p]=o.useState(s.name),[d,f]=o.useState(!1),l=async(i,c)=>{f(!0);try{await i(),c&&E.success(c),a()}catch(j){E.error((j==null?void 0:j.message)||"Something went wrong")}finally{f(!1)}},h=async()=>{if(!r)return;const i=u.trim();!i||i===s.name||await l(()=>xs(s.id,i),"Team renamed")};return e.jsx(V,{open:!0,onOpenChange:i=>!i&&t(),children:e.jsxs(z,{className:"sm:max-w-[480px]",children:[e.jsx(G,{children:e.jsx(U,{children:"Edit team"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(ge,{value:u,onChange:i=>p(i.target.value),onBlur:h,onKeyDown:i=>i.key==="Enter"&&h(),className:"h-9",disabled:!r})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Members"}),s.members.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No members yet."}):e.jsx("div",{className:"space-y-2",children:s.members.map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{registered:i.registered}),e.jsx("span",{className:"text-sm flex-1 truncate",children:i.email}),r?e.jsxs(we,{value:i.role,onValueChange:c=>l(()=>hs(s.id,i.userId,c),"Role updated"),children:[e.jsx(Ne,{className:"w-[120px] h-8",children:e.jsx(Ce,{})}),e.jsx(be,{children:se.map(c=>e.jsx(Te,{value:c.value,children:c.label},c.value))})]}):e.jsx(M,{variant:"secondary",className:"text-[11px]",children:W(i.role)}),r&&e.jsx(C,{size:"icon",variant:"ghost",className:"h-8 w-8",disabled:d,onClick:()=>l(()=>ps(s.id,i.userId),"Member removed"),"aria-label":`Remove ${i.email}`,children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]},i.userId))}),m&&e.jsx("div",{className:"pt-1 border-t",children:e.jsx("div",{className:"pt-2",children:e.jsx(Fe,{busy:d,maxRank:n,members:s.members.map(i=>i.email),onAdd:(i,c)=>l(()=>ve(s.id,{email:i,role:c}),"Member added")})})})]})]}),e.jsx(Y,{children:e.jsx(C,{variant:"outline",onClick:t,children:"Done"})})]})})}export{mt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t}from"./index-B5hLclEq.js";import{ActivityTracePage as r}from"./ActivityTracePage-D2iIbEph.js";import"./page-title-BkqlUA0j.js";import"./select-DrL0mpRN.js";import"./dates-BCxbm4_q.js";import"./client-attribution-BraarYaP.js";import"./arrow-left-BAgIocLn.js";import"./refresh-cw-CsCtmWwX.js";import"./chevron-left-XR4ReJ9Z.js";function f(){return t.jsx(r,{})}export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e,D as P,x as D,y as A,z as T,
|
|
1
|
+
import{r,j as e,D as P,x as D,y as A,z as T,c8 as F,G as z,I as b,H as R,B as h,c9 as H,E as I,ca as B,f as k,O,cb as Y,cc as K,cd as U,e as G,bs as L,ce as W}from"./index-B5hLclEq.js";import{P as q}from"./page-title-BkqlUA0j.js";function S({shown:n,onToggle:c}){return e.jsx("button",{type:"button",onClick:c,tabIndex:-1,"aria-label":n?"Hide password":"Show password",title:n?"Hide password":"Show password",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:n?e.jsx(H,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})}function J({open:n,onClose:c}){const[u,l]=r.useState(""),[a,m]=r.useState(""),[t,x]=r.useState(""),[d,p]=r.useState(!1),[j,i]=r.useState(null),[N,v]=r.useState(!1),[w,g]=r.useState(!1),[f,o]=r.useState(!1),C=()=>{l(""),m(""),x(""),i(null),v(!1),g(!1),o(!1)},E=async()=>{if(i(null),a.trim().length===0){i("New password cannot be empty or only whitespace.");return}if(a.length<8){i("New password must be at least 8 characters.");return}if(a!==t){i("New passwords don't match.");return}if(a===u){i("New password must be different from the current password.");return}p(!0);try{await B(u,a),k.success("Password changed. Your other sessions were signed out."),C(),c()}catch(s){i((s==null?void 0:s.message)||"Could not change password.")}finally{p(!1)}};return e.jsx(P,{open:n,onOpenChange:s=>{!s&&!d&&(C(),c())},children:e.jsxs(D,{className:"sm:max-w-[400px]",children:[e.jsxs(A,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-4 w-4 text-muted-foreground"}),"Change password"]}),e.jsx(z,{children:"If an admin gave you a temporary password, set your own here. This signs out your other sessions."})]}),e.jsxs("div",{className:"space-y-3 py-1",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"cp-current",className:"block text-sm font-medium",children:"Current password"}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{id:"cp-current",type:N?"text":"password",placeholder:"Enter your current password",value:u,onChange:s=>l(s.target.value),autoComplete:"current-password",className:"pr-10"}),e.jsx(S,{shown:N,onToggle:()=>v(s=>!s)})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"cp-next",className:"block text-sm font-medium",children:"New password"}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{id:"cp-next",type:w?"text":"password",placeholder:"At least 8 characters",value:a,onChange:s=>m(s.target.value),autoComplete:"new-password",className:"pr-10"}),e.jsx(S,{shown:w,onToggle:()=>g(s=>!s)})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"cp-confirm",className:"block text-sm font-medium",children:"Confirm new password"}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{id:"cp-confirm",type:f?"text":"password",placeholder:"Re-enter your new password",value:t,onChange:s=>x(s.target.value),autoComplete:"new-password","aria-invalid":t.length>0&&t!==a,className:"pr-10"}),e.jsx(S,{shown:f,onToggle:()=>o(s=>!s)})]}),t.length>0&&t!==a&&e.jsx("p",{className:"text-sm text-destructive",children:"Passwords don't match."})]}),j&&e.jsx("p",{className:"text-sm text-destructive",children:j})]}),e.jsxs(R,{className:"gap-2",children:[e.jsx(h,{variant:"outline",onClick:()=>{C(),c()},disabled:d,children:"Cancel"}),e.jsx(h,{onClick:E,disabled:d||!u||!a||!t||a!==t,children:d?"Saving...":"Change password"})]})]})})}function V(){var g,f;const{adminStatus:n,isAdmin:c,refresh:u}=O(),l=(n==null?void 0:n.me)??null,[a,m]=r.useState(!1),[t,x]=r.useState(""),[d,p]=r.useState(!1),[j,i]=r.useState(!1);if(!l)return e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Sign in to see your account."});const N=((g=l.name)==null?void 0:g.trim())||l.email,v=()=>{x(l.name??""),m(!0)},w=async()=>{p(!0);try{await W(t),await u(),k.success("Name updated."),m(!1)}catch(o){k.error((o==null?void 0:o.message)||"Could not update name.")}finally{p(!1)}};return e.jsxs("div",{"data-testid":"account-page",children:[e.jsx(q,{icon:Y,title:"Your Account",description:"Who you are on this server."}),e.jsx(y,{label:"Profile photo",children:e.jsx(K,{className:"h-20 w-20",children:e.jsx(U,{className:"text-3xl",children:N.charAt(0).toUpperCase()})})}),e.jsx(y,{label:"Name",action:a?null:e.jsx(h,{variant:"outline",size:"sm",onClick:v,"data-testid":"account-edit-name",children:"Edit"}),children:a?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{value:t,"aria-label":"Name",maxLength:80,placeholder:"Your name",autoFocus:!0,onChange:o=>x(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!d&&w(),o.key==="Escape"&&m(!1)},className:"max-w-xs","data-testid":"account-name-input"}),e.jsx(h,{size:"sm",onClick:w,disabled:d||t.trim()===(l.name??"").trim(),children:d?"Saving...":"Save"}),e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>m(!1),disabled:d,children:"Cancel"})]}):e.jsx("span",{className:"text-muted-foreground",children:((f=l.name)==null?void 0:f.trim())||e.jsx("em",{children:"Not set — your email is shown instead"})})}),e.jsx(y,{label:"Email address",children:e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[l.email,c&&e.jsxs(G,{variant:"outline",className:"gap-1 border-blue-200 bg-blue-50 text-blue-700 text-[10px] px-1.5 py-0",children:[e.jsx(L,{className:"h-2.5 w-2.5"}),"Admin"]})]})}),e.jsx(y,{label:"Password",action:e.jsx(h,{variant:"outline",size:"sm",onClick:()=>i(!0),"data-testid":"account-change-password",children:"Change password"}),children:e.jsx("span",{className:"tracking-widest text-muted-foreground","aria-hidden":!0,children:"••••••••••••"})}),e.jsx(J,{open:j,onClose:()=>i(!1)})]})}function y({label:n,action:c,children:u}){return e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-border py-5",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:n}),e.jsx("div",{className:"text-sm",children:u})]}),c]})}export{V as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ie,O as Re,r as a,u as De,j as e,U as ce,B as t,A as U,K as M,a as O,L as f,I as ve,
|
|
1
|
+
import{c as Ie,O as Re,r as a,u as De,j as e,U as ce,B as t,A as U,K as M,a as O,L as f,I as ve,cc as oe,cd as de,e as Q,bs as me,cl as Ee,df as _e,C as we,ao as ye,at as Ne,D as N,x as b,y as C,z as k,G as S,H as T,dg as Le,dh as Pe,di as Fe,i as he,J as be,dj as ze}from"./index-B5hLclEq.js";import{p as Ge}from"./dates-BCxbm4_q.js";import{P as Ue}from"./page-title-BkqlUA0j.js";import{C as xe,a as ue,c as pe,b as je,d as ge}from"./card-UDyMRcps.js";import{U as fe}from"./user-plus-4CTYEkd3.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,s as l}from"./index-
|
|
1
|
+
import{j as e,s as l}from"./index-B5hLclEq.js";function x({icon:s,title:r,description:t,actions:a,className:i}){return e.jsxs("div",{className:l("mb-4",i),"data-testid":"page-title",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-semibold tracking-tight",children:[s&&e.jsx(s,{className:"h-6 w-6 shrink-0 text-muted-foreground"}),r]}),a&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:a})]}),t&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t})]})}export{x as P};
|