@samanhappy/mcphub 1.0.30 → 1.0.31
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/dist/clients/openapi.js +13 -0
- package/dist/clients/openapi.js.map +1 -1
- package/dist/config/configManager.js +2 -1
- package/dist/config/configManager.js.map +1 -1
- package/dist/config/index.js +2 -1
- package/dist/config/index.js.map +1 -1
- package/dist/controllers/oauthServerController.js +76 -1
- package/dist/controllers/oauthServerController.js.map +1 -1
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -1
- package/dist/services/mcpService.js +3 -2
- package/dist/services/mcpService.js.map +1 -1
- package/dist/services/sseService.js +14 -4
- package/dist/services/sseService.js.map +1 -1
- package/dist/utils/abortIsolatingFetch.js +31 -0
- package/dist/utils/abortIsolatingFetch.js.map +1 -0
- package/dist/utils/basePath.js +13 -0
- package/dist/utils/basePath.js.map +1 -0
- package/dist/utils/frontendShell.js +88 -0
- package/dist/utils/frontendShell.js.map +1 -0
- package/dist/utils/oauthConsentResource.js +45 -0
- package/dist/utils/oauthConsentResource.js.map +1 -0
- package/frontend/dist/assets/{ActivityPage-U9om5C9X.js → ActivityPage-Dx53zxEM.js} +2 -2
- package/frontend/dist/assets/{ActivityPage-U9om5C9X.js.map → ActivityPage-Dx53zxEM.js.map} +1 -1
- package/frontend/dist/assets/{Dashboard-DGqpU4bd.js → Dashboard-ZYVsSvOw.js} +2 -2
- package/frontend/dist/assets/{Dashboard-DGqpU4bd.js.map → Dashboard-ZYVsSvOw.js.map} +1 -1
- package/frontend/dist/assets/{EndpointCopy-DuGmhiMq.js → EndpointCopy-ngxLPeDF.js} +2 -2
- package/frontend/dist/assets/{EndpointCopy-DuGmhiMq.js.map → EndpointCopy-ngxLPeDF.js.map} +1 -1
- package/frontend/dist/assets/{GroupsPage-Dhqy02FY.js → GroupsPage-JPtupGpI.js} +3 -3
- package/frontend/dist/assets/{GroupsPage-Dhqy02FY.js.map → GroupsPage-JPtupGpI.js.map} +1 -1
- package/frontend/dist/assets/{LoginPage-BXRn47pC.js → LoginPage-B6rU3Ugr.js} +2 -2
- package/frontend/dist/assets/LoginPage-B6rU3Ugr.js.map +1 -0
- package/frontend/dist/assets/{LogsPage-CiO6LZEJ.js → LogsPage-CXq382fb.js} +2 -2
- package/frontend/dist/assets/{LogsPage-CiO6LZEJ.js.map → LogsPage-CXq382fb.js.map} +1 -1
- package/frontend/dist/assets/{MarketPage-BEdWfj0u.js → MarketPage-BGnQQyXK.js} +2 -2
- package/frontend/dist/assets/{MarketPage-BEdWfj0u.js.map → MarketPage-BGnQQyXK.js.map} +1 -1
- package/frontend/dist/assets/OAuthConsentPage-C-n6tv3-.js +2 -0
- package/frontend/dist/assets/OAuthConsentPage-C-n6tv3-.js.map +1 -0
- package/frontend/dist/assets/{PromptsPage-BG6oWgAk.js → PromptsPage-BLpy76K4.js} +2 -2
- package/frontend/dist/assets/{PromptsPage-BG6oWgAk.js.map → PromptsPage-BLpy76K4.js.map} +1 -1
- package/frontend/dist/assets/{ResourcesPage-BqJUKqnV.js → ResourcesPage-C5nynRqE.js} +2 -2
- package/frontend/dist/assets/{ResourcesPage-BqJUKqnV.js.map → ResourcesPage-C5nynRqE.js.map} +1 -1
- package/frontend/dist/assets/{ServersPage-CHbXHEcG.js → ServersPage-Ca5W9cPW.js} +4 -4
- package/frontend/dist/assets/{ServersPage-CHbXHEcG.js.map → ServersPage-Ca5W9cPW.js.map} +1 -1
- package/frontend/dist/assets/{SettingsPage-B6yl-U9T.js → SettingsPage-DgFBjp_O.js} +2 -2
- package/frontend/dist/assets/{SettingsPage-B6yl-U9T.js.map → SettingsPage-DgFBjp_O.js.map} +1 -1
- package/frontend/dist/assets/{StatusDot-Bz7sBh0t.js → StatusDot-CmSkukx0.js} +2 -2
- package/frontend/dist/assets/{StatusDot-Bz7sBh0t.js.map → StatusDot-CmSkukx0.js.map} +1 -1
- package/frontend/dist/assets/{ToggleGroup-60voS_0U.js → ToggleGroup-sG_2LQom.js} +2 -2
- package/frontend/dist/assets/{ToggleGroup-60voS_0U.js.map → ToggleGroup-sG_2LQom.js.map} +1 -1
- package/frontend/dist/assets/{UsersPage-Dzzo9CC-.js → UsersPage-PHkFXLL8.js} +2 -2
- package/frontend/dist/assets/{UsersPage-Dzzo9CC-.js.map → UsersPage-PHkFXLL8.js.map} +1 -1
- package/frontend/dist/assets/{contextCost-CIOdvJNu.js → contextCost-D_iNNbhX.js} +2 -2
- package/frontend/dist/assets/{contextCost-CIOdvJNu.js.map → contextCost-D_iNNbhX.js.map} +1 -1
- package/frontend/dist/assets/{icons-vendor-hw0ScL8G.js → icons-vendor-BFl4A9fq.js} +64 -59
- package/frontend/dist/assets/icons-vendor-BFl4A9fq.js.map +1 -0
- package/frontend/dist/assets/index-CLugsCsy.js +3 -0
- package/frontend/dist/assets/index-CLugsCsy.js.map +1 -0
- package/frontend/dist/assets/{resourceService-DIIsi_li.js → resourceService-33rS8QGJ.js} +2 -2
- package/frontend/dist/assets/{resourceService-DIIsi_li.js.map → resourceService-33rS8QGJ.js.map} +1 -1
- package/frontend/dist/assets/useSettingsData-fK2bv9oN.js +2 -0
- package/frontend/dist/assets/{useSettingsData-C84qj7ge.js.map → useSettingsData-fK2bv9oN.js.map} +1 -1
- package/frontend/dist/assets/{variableDetection-Y9ymMI80.js → variableDetection-ByJ_cnxa.js} +2 -2
- package/frontend/dist/assets/{variableDetection-Y9ymMI80.js.map → variableDetection-ByJ_cnxa.js.map} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/LoginPage-BXRn47pC.js.map +0 -1
- package/frontend/dist/assets/icons-vendor-hw0ScL8G.js.map +0 -1
- package/frontend/dist/assets/index-Ca9HKIrV.js +0 -3
- package/frontend/dist/assets/index-Ca9HKIrV.js.map +0 -1
- package/frontend/dist/assets/useSettingsData-C84qj7ge.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as u,j as e}from"./framework-vendor-I9Y6AgD5.js";import{b as p,T as x,L as m}from"./index-CLugsCsy.js";import{u as v}from"./i18n-vendor-y9bLzIeh.js";import{l as g,E as f}from"./icons-vendor-BFl4A9fq.js";const w=()=>{const{t:l}=v(),r=u.useMemo(()=>window.__OAUTH_CONSENT_CONTEXT__??null,[]),i=`${p()}/oauth/authorize`,a=n=>r?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"hidden",name:"client_id",value:r.clientId}),e.jsx("input",{type:"hidden",name:"redirect_uri",value:r.redirectUri}),e.jsx("input",{type:"hidden",name:"response_type",value:r.responseType}),e.jsx("input",{type:"hidden",name:"scope",value:r.scope}),r.resource?e.jsx("input",{type:"hidden",name:"resource",value:r.resource.raw}):null,r.state?e.jsx("input",{type:"hidden",name:"state",value:r.state}):null,r.codeChallenge?e.jsx("input",{type:"hidden",name:"code_challenge",value:r.codeChallenge}):null,r.codeChallengeMethod?e.jsx("input",{type:"hidden",name:"code_challenge_method",value:r.codeChallengeMethod}):null,r.token?e.jsx("input",{type:"hidden",name:"token",value:r.token}):null,e.jsx("input",{type:"hidden",name:"allow",value:n})]}):null,o=n=>{switch(n.kind){case"all":return l("oauthServer.resourceAll");case"smart":return l("oauthServer.resourceSmart");case"server":return l("oauthServer.resourceServer",{name:n.name??""});case"group":return l("oauthServer.resourceGroup",{name:n.name??""});default:return n.name||n.raw}},t=(n,h)=>n?e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:11.5,color:"var(--hub-ink-2)",textDecoration:"none",borderBottom:"1px solid var(--hub-line)",paddingBottom:1,maxWidth:220},title:n,children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h}),e.jsx(f,{size:10,className:"flex-shrink-0"})]}):null;if(!r)return e.jsx("div",{className:"relative min-h-screen w-full overflow-hidden",style:{background:"var(--hub-bg)",color:"var(--hub-ink)"},children:e.jsx("div",{className:"relative mx-auto flex min-h-screen w-full max-w-lg items-center justify-center px-6",children:e.jsxs("div",{className:"hub-card w-full",style:{padding:"22px"},children:[e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--hub-err)"},children:[e.jsx(g,{size:16,className:"flex-shrink-0"}),e.jsx("h1",{className:"hub-h1",style:{fontSize:15},children:l("oauthServer.requestInvalidTitle")})]}),e.jsx("p",{className:"hub-sub",style:{marginTop:8},children:l("oauthServer.requestInvalid")})]})})});const c=`${r.clientId.slice(0,8)}…`,s=r.client,d=!!(s!=null&&s.policyUri||s!=null&&s.tosUri||s!=null&&s.clientUri);return e.jsxs("div",{className:"relative min-h-screen w-full overflow-hidden",style:{background:"var(--hub-bg)",color:"var(--hub-ink)"},children:[e.jsxs("div",{className:"absolute top-3 right-4 z-20 flex items-center gap-1",children:[e.jsx(x,{}),e.jsx(m,{})]}),e.jsx("div",{className:"relative mx-auto flex min-h-screen w-full max-w-lg items-center justify-center px-6",children:e.jsxs("div",{className:"w-full space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"relative grid place-items-center",style:{width:44,height:44,borderRadius:10,background:"var(--hub-ink)",color:"var(--hub-bg)"},children:e.jsx("span",{className:"hub-mono font-semibold",style:{fontSize:18},children:"M"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{style:{fontSize:20,fontWeight:600,letterSpacing:"-0.02em",color:"var(--hub-ink)"},children:l("oauthServer.authorizeTitle")}),e.jsx("p",{className:"hub-sub",style:{marginTop:4},children:l("oauthServer.authorizeSubtitle")})]})]}),e.jsxs("div",{className:"hub-card",style:{padding:"22px 22px 20px"},children:[r.resource?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"12px 14px",borderRadius:10,background:"var(--hub-accent-soft)",border:"1px solid var(--hub-line)",marginBottom:14},children:[e.jsx("span",{className:"hub-sect",children:l("oauthServer.grantingAccessTo")}),e.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--hub-ink)"},children:o(r.resource)}),e.jsx("span",{className:"hub-mono",style:{fontSize:11.5,color:"var(--hub-ink-2)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.resource.raw})]}):null,e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"12px 14px",borderRadius:10,background:"var(--hub-bg-2)",border:"1px solid var(--hub-line)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[s!=null&&s.logoUri?e.jsx("img",{src:s.logoUri,alt:"",width:20,height:20,style:{borderRadius:4,flexShrink:0,objectFit:"contain"},referrerPolicy:"no-referrer"}):null,e.jsx("span",{style:{fontWeight:600,fontSize:15,color:"var(--hub-ink)"},children:r.clientName})]}),e.jsxs("span",{className:"hub-sect",children:[l("oauthServer.clientId"),": ",e.jsx("span",{className:"hub-mono",children:c})]}),e.jsxs("span",{style:{fontSize:11.5,color:"var(--hub-ink-2)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:r.redirectUri,children:[l("oauthServer.willRedirectTo")," ",r.redirectUri]}),d?e.jsxs("div",{style:{display:"flex",gap:12,marginTop:6,flexWrap:"wrap"},children:[t(s==null?void 0:s.policyUri,l("oauthServer.policy")),t(s==null?void 0:s.tosUri,l("oauthServer.terms")),t(s==null?void 0:s.clientUri,l("oauthServer.homepage"))]}):null]}),e.jsxs("div",{style:{marginTop:18},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:4},children:l("oauthServer.scopesTitle")}),r.scopes.length===0?e.jsx("p",{className:"hub-sub",style:{marginTop:8},children:l("oauthServer.noScopes")}):e.jsx("div",{className:"hub-divider",children:r.scopes.map(n=>e.jsxs("div",{style:{padding:"10px 0"},children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--hub-ink)"},children:e.jsx("span",{className:"hub-mono",children:n.name})}),e.jsx("div",{style:{fontSize:12.5,color:"var(--hub-ink-2)",marginTop:2},children:n.description})]},n.name))})]}),e.jsxs("div",{style:{marginTop:22,display:"flex",gap:10},children:[e.jsxs("form",{method:"POST",action:i,style:{flex:1},children:[a("true"),e.jsx("button",{type:"submit",className:"hub-btn primary w-full justify-center",style:{height:"auto",minHeight:40,padding:"8px 12px",flexDirection:"column",gap:1},children:e.jsx("span",{style:{lineHeight:1.3},children:l("oauthServer.buttons.approve")})})]}),e.jsxs("form",{method:"POST",action:i,style:{flex:1},children:[a("false"),e.jsx("button",{type:"submit",className:"hub-btn danger w-full justify-center",style:{height:"auto",minHeight:40,padding:"8px 12px",flexDirection:"column",gap:1},children:e.jsx("span",{style:{lineHeight:1.3},children:l("oauthServer.buttons.deny")})})]})]})]})]})})]})};export{w as default};
|
|
2
|
+
//# sourceMappingURL=OAuthConsentPage-C-n6tv3-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthConsentPage-C-n6tv3-.js","sources":["../../src/pages/OAuthConsentPage.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { AlertCircle, ExternalLink } from 'lucide-react';\nimport { getBasePath } from '../utils/runtime';\nimport ThemeSwitch from '@/components/ui/ThemeSwitch';\nimport LanguageSwitch from '@/components/ui/LanguageSwitch';\nimport type { OAuthConsentContext, ResourceTarget } from '../types/runtime';\n\n/**\n * OAuth consent screen, booted inside the dashboard SPA by the shell the\n * backend serves at GET /oauth/authorize (context injected into\n * window.__OAUTH_CONSENT_CONTEXT__). The server has already validated the\n * request and resolved the user, so this page only renders the payload and\n * POSTs the decision back to /oauth/authorize.\n */\nconst OAuthConsentPage: React.FC = () => {\n const { t } = useTranslation();\n\n const context = useMemo<OAuthConsentContext | null>(\n () => window.__OAUTH_CONSENT_CONTEXT__ ?? null,\n [],\n );\n\n const postUrl = `${getBasePath()}/oauth/authorize`;\n\n const hiddenInputs = (allow: string): React.ReactNode => {\n if (!context) return null;\n return (\n <>\n <input type=\"hidden\" name=\"client_id\" value={context.clientId} />\n <input type=\"hidden\" name=\"redirect_uri\" value={context.redirectUri} />\n <input type=\"hidden\" name=\"response_type\" value={context.responseType} />\n <input type=\"hidden\" name=\"scope\" value={context.scope} />\n {context.resource ? (\n <input type=\"hidden\" name=\"resource\" value={context.resource.raw} />\n ) : null}\n {context.state ? <input type=\"hidden\" name=\"state\" value={context.state} /> : null}\n {context.codeChallenge ? (\n <input type=\"hidden\" name=\"code_challenge\" value={context.codeChallenge} />\n ) : null}\n {context.codeChallengeMethod ? (\n <input type=\"hidden\" name=\"code_challenge_method\" value={context.codeChallengeMethod} />\n ) : null}\n {context.token ? <input type=\"hidden\" name=\"token\" value={context.token} /> : null}\n <input type=\"hidden\" name=\"allow\" value={allow} />\n </>\n );\n };\n\n const resourceLabel = (resource: ResourceTarget): string => {\n switch (resource.kind) {\n case 'all':\n return t('oauthServer.resourceAll');\n case 'smart':\n return t('oauthServer.resourceSmart');\n case 'server':\n return t('oauthServer.resourceServer', { name: resource.name ?? '' });\n case 'group':\n return t('oauthServer.resourceGroup', { name: resource.name ?? '' });\n default:\n return resource.name || resource.raw;\n }\n };\n\n const link = (href: string | undefined, label: string): React.ReactNode => {\n if (!href) return null;\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n gap: 3,\n fontSize: 11.5,\n color: 'var(--hub-ink-2)',\n textDecoration: 'none',\n borderBottom: '1px solid var(--hub-line)',\n paddingBottom: 1,\n maxWidth: 220,\n }}\n title={href}\n >\n <span\n style={{\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {label}\n </span>\n <ExternalLink size={10} className=\"flex-shrink-0\" />\n </a>\n );\n };\n\n if (!context) {\n return (\n <div\n className=\"relative min-h-screen w-full overflow-hidden\"\n style={{ background: 'var(--hub-bg)', color: 'var(--hub-ink)' }}\n >\n <div className=\"relative mx-auto flex min-h-screen w-full max-w-lg items-center justify-center px-6\">\n <div className=\"hub-card w-full\" style={{ padding: '22px' }}>\n <div className=\"flex items-center gap-2\" style={{ color: 'var(--hub-err)' }}>\n <AlertCircle size={16} className=\"flex-shrink-0\" />\n <h1 className=\"hub-h1\" style={{ fontSize: 15 }}>\n {t('oauthServer.requestInvalidTitle')}\n </h1>\n </div>\n <p className=\"hub-sub\" style={{ marginTop: 8 }}>\n {t('oauthServer.requestInvalid')}\n </p>\n </div>\n </div>\n </div>\n );\n }\n\n const clientIdFingerprint = `${context.clientId.slice(0, 8)}…`;\n const client = context.client;\n const hasLinks = Boolean(client?.policyUri || client?.tosUri || client?.clientUri);\n\n return (\n <div\n className=\"relative min-h-screen w-full overflow-hidden\"\n style={{ background: 'var(--hub-bg)', color: 'var(--hub-ink)' }}\n >\n {/* Top-right controls, matching the login screen */}\n <div className=\"absolute top-3 right-4 z-20 flex items-center gap-1\">\n <ThemeSwitch />\n <LanguageSwitch />\n </div>\n\n <div className=\"relative mx-auto flex min-h-screen w-full max-w-lg items-center justify-center px-6\">\n <div className=\"w-full space-y-6\">\n {/* Brand */}\n <div className=\"flex flex-col items-center gap-3\">\n <div\n className=\"relative grid place-items-center\"\n style={{\n width: 44,\n height: 44,\n borderRadius: 10,\n background: 'var(--hub-ink)',\n color: 'var(--hub-bg)',\n }}\n >\n <span className=\"hub-mono font-semibold\" style={{ fontSize: 18 }}>\n M\n </span>\n </div>\n <div className=\"text-center\">\n <h1\n style={{\n fontSize: 20,\n fontWeight: 600,\n letterSpacing: '-0.02em',\n color: 'var(--hub-ink)',\n }}\n >\n {t('oauthServer.authorizeTitle')}\n </h1>\n <p className=\"hub-sub\" style={{ marginTop: 4 }}>\n {t('oauthServer.authorizeSubtitle')}\n </p>\n </div>\n </div>\n\n {/* Consent card */}\n <div className=\"hub-card\" style={{ padding: '22px 22px 20px' }}>\n {/* Resource target (RFC 8707) */}\n {context.resource ? (\n <div\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: 4,\n padding: '12px 14px',\n borderRadius: 10,\n background: 'var(--hub-accent-soft)',\n border: '1px solid var(--hub-line)',\n marginBottom: 14,\n }}\n >\n <span className=\"hub-sect\">{t('oauthServer.grantingAccessTo')}</span>\n <span style={{ fontWeight: 600, fontSize: 14, color: 'var(--hub-ink)' }}>\n {resourceLabel(context.resource)}\n </span>\n <span\n className=\"hub-mono\"\n style={{\n fontSize: 11.5,\n color: 'var(--hub-ink-2)',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {context.resource.raw}\n </span>\n </div>\n ) : null}\n\n {/* Client box */}\n <div\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: 4,\n padding: '12px 14px',\n borderRadius: 10,\n background: 'var(--hub-bg-2)',\n border: '1px solid var(--hub-line)',\n }}\n >\n <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n {client?.logoUri ? (\n <img\n src={client.logoUri}\n alt=\"\"\n width={20}\n height={20}\n style={{ borderRadius: 4, flexShrink: 0, objectFit: 'contain' }}\n referrerPolicy=\"no-referrer\"\n />\n ) : null}\n <span style={{ fontWeight: 600, fontSize: 15, color: 'var(--hub-ink)' }}>\n {context.clientName}\n </span>\n </div>\n <span className=\"hub-sect\">\n {t('oauthServer.clientId')}: <span className=\"hub-mono\">{clientIdFingerprint}</span>\n </span>\n <span\n style={{\n fontSize: 11.5,\n color: 'var(--hub-ink-2)',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n title={context.redirectUri}\n >\n {t('oauthServer.willRedirectTo')} {context.redirectUri}\n </span>\n {hasLinks ? (\n <div style={{ display: 'flex', gap: 12, marginTop: 6, flexWrap: 'wrap' }}>\n {link(client?.policyUri, t('oauthServer.policy'))}\n {link(client?.tosUri, t('oauthServer.terms'))}\n {link(client?.clientUri, t('oauthServer.homepage'))}\n </div>\n ) : null}\n </div>\n\n {/* Scopes */}\n <div style={{ marginTop: 18 }}>\n <div className=\"hub-sect\" style={{ marginBottom: 4 }}>\n {t('oauthServer.scopesTitle')}\n </div>\n {context.scopes.length === 0 ? (\n <p className=\"hub-sub\" style={{ marginTop: 8 }}>\n {t('oauthServer.noScopes')}\n </p>\n ) : (\n <div className=\"hub-divider\">\n {context.scopes.map((scope) => (\n <div key={scope.name} style={{ padding: '10px 0' }}>\n <div style={{ fontWeight: 600, fontSize: 13, color: 'var(--hub-ink)' }}>\n <span className=\"hub-mono\">{scope.name}</span>\n </div>\n <div style={{ fontSize: 12.5, color: 'var(--hub-ink-2)', marginTop: 2 }}>\n {scope.description}\n </div>\n </div>\n ))}\n </div>\n )}\n </div>\n\n {/* Approve / deny */}\n <div style={{ marginTop: 22, display: 'flex', gap: 10 }}>\n <form method=\"POST\" action={postUrl} style={{ flex: 1 }}>\n {hiddenInputs('true')}\n <button\n type=\"submit\"\n className=\"hub-btn primary w-full justify-center\"\n style={{\n height: 'auto',\n minHeight: 40,\n padding: '8px 12px',\n flexDirection: 'column',\n gap: 1,\n }}\n >\n <span style={{ lineHeight: 1.3 }}>{t('oauthServer.buttons.approve')}</span>\n </button>\n </form>\n <form method=\"POST\" action={postUrl} style={{ flex: 1 }}>\n {hiddenInputs('false')}\n <button\n type=\"submit\"\n className=\"hub-btn danger w-full justify-center\"\n style={{\n height: 'auto',\n minHeight: 40,\n padding: '8px 12px',\n flexDirection: 'column',\n gap: 1,\n }}\n >\n <span style={{ lineHeight: 1.3 }}>{t('oauthServer.buttons.deny')}</span>\n </button>\n </form>\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport default OAuthConsentPage;\n"],"names":["OAuthConsentPage","t","useTranslation","context","useMemo","postUrl","getBasePath","hiddenInputs","allow","jsxs","Fragment","jsx","resourceLabel","resource","link","href","label","ExternalLink","AlertCircle","clientIdFingerprint","client","hasLinks","ThemeSwitch","LanguageSwitch","scope"],"mappings":"oNAeA,MAAMA,EAA6B,IAAM,CACvC,KAAM,CAAE,EAAAC,CAAA,EAAMC,EAAA,EAERC,EAAUC,EAAAA,QACd,IAAM,OAAO,2BAA6B,KAC1C,CAAA,CAAC,EAGGC,EAAU,G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SAAA,CACC,KAAK,SACL,UAAU,wCACV,MAAO,CACL,OAAQ,OACR,UAAW,GACX,QAAS,WACT,cAAe,SACf,IAAK,CAAA,EAGP,SAAAA,EAAAA,IAAC,QAAK,MAAO,CAAE,WAAY,KAAQ,SAAAV,EAAE,6BAA6B,CAAA,CAAE,CAAA,CAAA,CACtE,EACF,EACAQ,EAAAA,KAAC,OAAA,CAAK,OAAO,OAAO,OAAQJ,EAAS,MAAO,CAAE,KAAM,CAAA,EACjD,SAAA,CAAAE,EAAa,OAAO,EACrBI,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAU,uCACV,MAAO,CACL,OAAQ,OACR,UAAW,GACX,QAAS,WACT,cAAe,SACf,IAAK,CAAA,EAGP,SAAAA,EAAAA,IAAC,QAAK,MAAO,CAAE,WAAY,KAAQ,SAAAV,EAAE,0BAA0B,CAAA,CAAE,CAAA,CAAA,CACnE,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CAAA,CAGN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as o,j as e}from"./framework-vendor-I9Y6AgD5.js";import{j as B,f as T,h as I,e as K,u as L}from"./index-Ca9HKIrV.js";import{u as A}from"./i18n-vendor-y9bLzIeh.js";import{C as X}from"./ConfirmDialog-CYfXEuyU.js";import{a as $}from"./StatusDot-Bz7sBh0t.js";import{P as R,X as D,g as G,u as H,r as M,a2 as O}from"./icons-vendor-hw0ScL8G.js";const W=async()=>{const t=await B("/prompts");if(!t.success)throw new Error(t.message||"Failed to fetch built-in prompts");return t.data||[]},_=async t=>{const u=await K("/prompts",t);if(!u.success)throw new Error(u.message||"Failed to create built-in prompt");return u.data},J=async(t,u)=>{const b=await I(`/prompts/${t}`,u);if(!b.success)throw new Error(b.message||"Failed to update built-in prompt");return b.data},Q=async t=>{const u=await T(`/prompts/${t}`);if(!u.success)throw new Error(u.message||"Failed to delete built-in prompt")},U=()=>{const{t}=A(),[u,b]=o.useState([]),[r,f]=o.useState(!0),[p,n]=o.useState(null),[P,N]=o.useState(0),w=o.useCallback(async()=>{try{f(!0);const l=await W();b(l),n(null)}catch(l){console.error("Error fetching built-in prompts:",l),n(l instanceof Error?l.message:t("builtinPrompts.fetchError")),b([])}finally{f(!1)}},[t]),x=o.useCallback(()=>{N(l=>l+1)},[]),y=async l=>{try{const m=await _(l);return x(),{success:!0,data:m}}catch(m){const c=m instanceof Error?m.message:t("builtinPrompts.createError");return n(c),{success:!1,message:c}}},j=async(l,m)=>{try{const c=await J(l,m);return x(),{success:!0,data:c}}catch(c){const v=c instanceof Error?c.message:t("builtinPrompts.updateError");return n(v),{success:!1,message:v}}},g=async l=>{try{return await Q(l),x(),{success:!0}}catch(m){const c=m instanceof Error?m.message:t("builtinPrompts.deleteError");return n(c),{success:!1,message:c}}};return o.useEffect(()=>{w()},[w,P]),{prompts:u,loading:r,error:p,setError:n,triggerRefresh:x,addPrompt:y,editPrompt:j,removePrompt:g}},F=({prompt:t,onSave:u,onCancel:b})=>{const{t:r}=A(),[f,p]=o.useState(null),[n,P]=o.useState(!1),[N,w]=o.useState((t==null?void 0:t.name)||""),[x,y]=o.useState((t==null?void 0:t.title)||""),[j,g]=o.useState((t==null?void 0:t.description)||""),[l,m]=o.useState((t==null?void 0:t.template)||""),[c,v]=o.useState((t==null?void 0:t.enabled)!==!1),[k,C]=o.useState((t==null?void 0:t.arguments)||[]),E=()=>{C([...k,{name:"",description:"",required:!1}])},z=s=>{C(k.filter((i,d)=>d!==s))},S=(s,i,d)=>{C(k.map((h,q)=>q===s?{...h,[i]:d}:h))},a=async s=>{if(s.preventDefault(),p(null),!N.trim()){p(r("builtinPrompts.nameRequired"));return}if(!l.trim()){p(r("builtinPrompts.templateRequired"));return}P(!0);try{const i=await u({name:N.trim(),title:x.trim()||void 0,description:j.trim()||void 0,template:l,arguments:k.length>0?k.filter(d=>d.name.trim()):void 0,enabled:c});i.success||p(i.message||r("builtinPrompts.saveError"))}catch(i){p(i instanceof Error?i.message:r("builtinPrompts.saveError"))}finally{P(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto",children:e.jsxs("form",{onSubmit:a,children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6",children:r(t?"builtinPrompts.edit":"builtinPrompts.addNew")}),f&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md",children:e.jsx("p",{className:"text-sm font-medium",children:f})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinPrompts.name")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:N,onChange:s=>w(s.target.value),placeholder:r("builtinPrompts.namePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",required:!0,disabled:n})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinPrompts.title")}),e.jsx("input",{type:"text",value:x,onChange:s=>y(s.target.value),placeholder:r("builtinPrompts.titlePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:n})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinPrompts.description")}),e.jsx("input",{type:"text",value:j,onChange:s=>g(s.target.value),placeholder:r("builtinPrompts.descriptionPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:n})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinPrompts.template")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:l,onChange:s=>m(s.target.value),placeholder:r("builtinPrompts.templatePlaceholder"),rows:6,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:n}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("builtinPrompts.templateHint")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:r("builtinPrompts.arguments")}),e.jsxs("button",{type:"button",onClick:E,className:"text-blue-600 hover:text-blue-800 text-sm flex items-center",disabled:n,children:[e.jsx(R,{size:14,className:"mr-1"}),r("builtinPrompts.addArgument")]})]}),k.map((s,i)=>e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("input",{type:"text",value:s.name,onChange:d=>S(i,"name",d.target.value),placeholder:r("builtinPrompts.argName"),className:"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:n}),e.jsx("input",{type:"text",value:s.description||"",onChange:d=>S(i,"description",d.target.value),placeholder:r("builtinPrompts.argDescription"),className:"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:n}),e.jsxs("label",{className:"flex items-center text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:s.required||!1,onChange:d=>S(i,"required",d.target.checked),className:"mr-1",disabled:n}),r("builtinPrompts.argRequired")]}),e.jsx("button",{type:"button",onClick:()=>z(i),className:"text-red-500 hover:text-red-700 p-1",disabled:n,children:e.jsx(D,{size:16})})]},i))]}),e.jsxs("div",{className:"flex items-center pt-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:c,onChange:s=>v(s.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",disabled:n}),e.jsx("label",{htmlFor:"enabled",className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:r("builtinPrompts.enabled")})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[e.jsx("button",{type:"button",onClick:b,className:"hub-btn",disabled:n,children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:n,className:"hub-btn primary",children:r(n?"common.saving":"common.save")})]})]})})})},re=()=>{var S;const{t}=A(),{auth:u}=L(),{prompts:b,loading:r,error:f,setError:p,addPrompt:n,editPrompt:P,removePrompt:N}=U(),[w,x]=o.useState(!1),[y,j]=o.useState(null),[g,l]=o.useState(null),[m,c]=o.useState(new Set),v=(S=u.user)==null?void 0:S.isAdmin,k=a=>{c(s=>{const i=new Set(s);return i.has(a)?i.delete(a):i.add(a),i})},C=async a=>{const s=await n(a);return s.success&&x(!1),s},E=async a=>{if(!y)return{success:!1,message:"No prompt selected"};const s=await P(y.id,a);return s.success&&j(null),s},z=async()=>{g&&(await N(g.id),l(null))};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:t("pages.prompts.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:b.length})," ",t("nav.prompts").toLowerCase()]})]}),v&&e.jsxs("button",{onClick:()=>x(!0),className:"hub-btn primary",children:[e.jsx(R,{size:13})," ",t("builtinPrompts.add")]})]}),f&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(D,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:f})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>p(null),children:e.jsx(D,{size:13})})]}),r?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:t("app.loading")}):b.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"grid place-items-center",style:{width:40,height:40,borderRadius:10,border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:e.jsx(G,{size:18})}),e.jsx("div",{className:"font-medium",style:{color:"var(--hub-ink-2)",fontSize:13},children:t("builtinPrompts.noPrompts")}),v&&e.jsx("button",{onClick:()=>x(!0),className:"hub-btn ghost sm",style:{color:"var(--hub-accent)"},children:t("builtinPrompts.addFirst")})]})}):e.jsx("div",{className:"hub-card overflow-hidden",children:b.map((a,s)=>{const i=m.has(a.id),d=a.enabled!==!1;return e.jsxs("div",{style:{borderTop:s===0?0:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]",style:{padding:"12px 16px"},onClick:()=>k(a.id),children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[e.jsx(H,{size:12,style:{color:"var(--hub-ink-3)",transform:i?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",style:{fontSize:13.5,color:d?"var(--hub-ink)":"var(--hub-ink-3)"},children:a.title||a.name}),e.jsx("span",{className:"hub-mono",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:a.name}),e.jsx($,{kind:d?"ok":"muted",label:t(d?"builtinPrompts.active":"builtinPrompts.inactive")})]}),a.description&&e.jsx("div",{className:"truncate mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:a.description})]})]}),v&&e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsx("button",{onClick:h=>{h.stopPropagation(),j(a)},className:"hub-icon-btn sm",title:t("builtinPrompts.edit"),children:e.jsx(M,{size:13})}),e.jsx("button",{onClick:h=>{h.stopPropagation(),l(a)},className:"hub-icon-btn sm",title:t("builtinPrompts.delete"),style:{color:"var(--hub-err)"},children:e.jsx(O,{size:13})})]})]}),i&&e.jsxs("div",{style:{padding:"12px 16px 14px 38px",background:"var(--hub-bg-2)",borderTop:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:t("builtinPrompts.template")}),e.jsx("pre",{className:"hub-mono",style:{fontSize:12,color:"var(--hub-ink-2)",background:"var(--hub-surface)",border:"1px solid var(--hub-line)",borderRadius:7,padding:10,overflowX:"auto",whiteSpace:"pre-wrap",margin:0},children:a.template})]}),a.arguments&&a.arguments.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:t("builtinPrompts.arguments")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.arguments.map((h,q)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[e.jsx("code",{className:"hub-mono hub-tag accent",style:{fontSize:11},children:"{{"+h.name+"}}"}),h.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:11},children:"*"}),h.description&&e.jsxs("span",{style:{color:"var(--hub-ink-3)"},children:["— ",h.description]})]},q))})]})]})]},a.id)})}),w&&e.jsx(F,{onSave:C,onCancel:()=>x(!1)}),y&&e.jsx(F,{prompt:y,onSave:E,onCancel:()=>j(null)}),e.jsx(X,{isOpen:!!g,onClose:()=>l(null),onConfirm:z,title:t("builtinPrompts.confirmDelete"),message:t("builtinPrompts.deleteWarning",{name:(g==null?void 0:g.name)||""}),variant:"danger"})]})};export{re as default};
|
|
2
|
-
//# sourceMappingURL=PromptsPage-
|
|
1
|
+
import{r as o,j as e}from"./framework-vendor-I9Y6AgD5.js";import{j as B,f as T,h as I,e as K,u as L}from"./index-CLugsCsy.js";import{u as A}from"./i18n-vendor-y9bLzIeh.js";import{C as X}from"./ConfirmDialog-CYfXEuyU.js";import{a as $}from"./StatusDot-CmSkukx0.js";import{P as R,X as D,g as G,u as H,r as M,a3 as O}from"./icons-vendor-BFl4A9fq.js";const W=async()=>{const t=await B("/prompts");if(!t.success)throw new Error(t.message||"Failed to fetch built-in prompts");return t.data||[]},_=async t=>{const u=await K("/prompts",t);if(!u.success)throw new Error(u.message||"Failed to create built-in prompt");return u.data},J=async(t,u)=>{const b=await I(`/prompts/${t}`,u);if(!b.success)throw new Error(b.message||"Failed to update built-in prompt");return b.data},Q=async t=>{const u=await T(`/prompts/${t}`);if(!u.success)throw new Error(u.message||"Failed to delete built-in prompt")},U=()=>{const{t}=A(),[u,b]=o.useState([]),[r,f]=o.useState(!0),[p,n]=o.useState(null),[P,N]=o.useState(0),w=o.useCallback(async()=>{try{f(!0);const l=await W();b(l),n(null)}catch(l){console.error("Error fetching built-in prompts:",l),n(l instanceof Error?l.message:t("builtinPrompts.fetchError")),b([])}finally{f(!1)}},[t]),x=o.useCallback(()=>{N(l=>l+1)},[]),y=async l=>{try{const m=await _(l);return x(),{success:!0,data:m}}catch(m){const c=m instanceof Error?m.message:t("builtinPrompts.createError");return n(c),{success:!1,message:c}}},j=async(l,m)=>{try{const c=await J(l,m);return x(),{success:!0,data:c}}catch(c){const v=c instanceof Error?c.message:t("builtinPrompts.updateError");return n(v),{success:!1,message:v}}},g=async l=>{try{return await Q(l),x(),{success:!0}}catch(m){const c=m instanceof Error?m.message:t("builtinPrompts.deleteError");return n(c),{success:!1,message:c}}};return o.useEffect(()=>{w()},[w,P]),{prompts:u,loading:r,error:p,setError:n,triggerRefresh:x,addPrompt:y,editPrompt:j,removePrompt:g}},F=({prompt:t,onSave:u,onCancel:b})=>{const{t:r}=A(),[f,p]=o.useState(null),[n,P]=o.useState(!1),[N,w]=o.useState((t==null?void 0:t.name)||""),[x,y]=o.useState((t==null?void 0:t.title)||""),[j,g]=o.useState((t==null?void 0:t.description)||""),[l,m]=o.useState((t==null?void 0:t.template)||""),[c,v]=o.useState((t==null?void 0:t.enabled)!==!1),[k,C]=o.useState((t==null?void 0:t.arguments)||[]),E=()=>{C([...k,{name:"",description:"",required:!1}])},z=s=>{C(k.filter((i,d)=>d!==s))},S=(s,i,d)=>{C(k.map((h,q)=>q===s?{...h,[i]:d}:h))},a=async s=>{if(s.preventDefault(),p(null),!N.trim()){p(r("builtinPrompts.nameRequired"));return}if(!l.trim()){p(r("builtinPrompts.templateRequired"));return}P(!0);try{const i=await u({name:N.trim(),title:x.trim()||void 0,description:j.trim()||void 0,template:l,arguments:k.length>0?k.filter(d=>d.name.trim()):void 0,enabled:c});i.success||p(i.message||r("builtinPrompts.saveError"))}catch(i){p(i instanceof Error?i.message:r("builtinPrompts.saveError"))}finally{P(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto",children:e.jsxs("form",{onSubmit:a,children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6",children:r(t?"builtinPrompts.edit":"builtinPrompts.addNew")}),f&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md",children:e.jsx("p",{className:"text-sm font-medium",children:f})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinPrompts.name")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:N,onChange:s=>w(s.target.value),placeholder:r("builtinPrompts.namePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",required:!0,disabled:n})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinPrompts.title")}),e.jsx("input",{type:"text",value:x,onChange:s=>y(s.target.value),placeholder:r("builtinPrompts.titlePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:n})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinPrompts.description")}),e.jsx("input",{type:"text",value:j,onChange:s=>g(s.target.value),placeholder:r("builtinPrompts.descriptionPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:n})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinPrompts.template")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:l,onChange:s=>m(s.target.value),placeholder:r("builtinPrompts.templatePlaceholder"),rows:6,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:n}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("builtinPrompts.templateHint")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:r("builtinPrompts.arguments")}),e.jsxs("button",{type:"button",onClick:E,className:"text-blue-600 hover:text-blue-800 text-sm flex items-center",disabled:n,children:[e.jsx(R,{size:14,className:"mr-1"}),r("builtinPrompts.addArgument")]})]}),k.map((s,i)=>e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("input",{type:"text",value:s.name,onChange:d=>S(i,"name",d.target.value),placeholder:r("builtinPrompts.argName"),className:"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:n}),e.jsx("input",{type:"text",value:s.description||"",onChange:d=>S(i,"description",d.target.value),placeholder:r("builtinPrompts.argDescription"),className:"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:n}),e.jsxs("label",{className:"flex items-center text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:s.required||!1,onChange:d=>S(i,"required",d.target.checked),className:"mr-1",disabled:n}),r("builtinPrompts.argRequired")]}),e.jsx("button",{type:"button",onClick:()=>z(i),className:"text-red-500 hover:text-red-700 p-1",disabled:n,children:e.jsx(D,{size:16})})]},i))]}),e.jsxs("div",{className:"flex items-center pt-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:c,onChange:s=>v(s.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",disabled:n}),e.jsx("label",{htmlFor:"enabled",className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:r("builtinPrompts.enabled")})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[e.jsx("button",{type:"button",onClick:b,className:"hub-btn",disabled:n,children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:n,className:"hub-btn primary",children:r(n?"common.saving":"common.save")})]})]})})})},re=()=>{var S;const{t}=A(),{auth:u}=L(),{prompts:b,loading:r,error:f,setError:p,addPrompt:n,editPrompt:P,removePrompt:N}=U(),[w,x]=o.useState(!1),[y,j]=o.useState(null),[g,l]=o.useState(null),[m,c]=o.useState(new Set),v=(S=u.user)==null?void 0:S.isAdmin,k=a=>{c(s=>{const i=new Set(s);return i.has(a)?i.delete(a):i.add(a),i})},C=async a=>{const s=await n(a);return s.success&&x(!1),s},E=async a=>{if(!y)return{success:!1,message:"No prompt selected"};const s=await P(y.id,a);return s.success&&j(null),s},z=async()=>{g&&(await N(g.id),l(null))};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:t("pages.prompts.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:b.length})," ",t("nav.prompts").toLowerCase()]})]}),v&&e.jsxs("button",{onClick:()=>x(!0),className:"hub-btn primary",children:[e.jsx(R,{size:13})," ",t("builtinPrompts.add")]})]}),f&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(D,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:f})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>p(null),children:e.jsx(D,{size:13})})]}),r?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:t("app.loading")}):b.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"grid place-items-center",style:{width:40,height:40,borderRadius:10,border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:e.jsx(G,{size:18})}),e.jsx("div",{className:"font-medium",style:{color:"var(--hub-ink-2)",fontSize:13},children:t("builtinPrompts.noPrompts")}),v&&e.jsx("button",{onClick:()=>x(!0),className:"hub-btn ghost sm",style:{color:"var(--hub-accent)"},children:t("builtinPrompts.addFirst")})]})}):e.jsx("div",{className:"hub-card overflow-hidden",children:b.map((a,s)=>{const i=m.has(a.id),d=a.enabled!==!1;return e.jsxs("div",{style:{borderTop:s===0?0:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]",style:{padding:"12px 16px"},onClick:()=>k(a.id),children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[e.jsx(H,{size:12,style:{color:"var(--hub-ink-3)",transform:i?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",style:{fontSize:13.5,color:d?"var(--hub-ink)":"var(--hub-ink-3)"},children:a.title||a.name}),e.jsx("span",{className:"hub-mono",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:a.name}),e.jsx($,{kind:d?"ok":"muted",label:t(d?"builtinPrompts.active":"builtinPrompts.inactive")})]}),a.description&&e.jsx("div",{className:"truncate mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:a.description})]})]}),v&&e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsx("button",{onClick:h=>{h.stopPropagation(),j(a)},className:"hub-icon-btn sm",title:t("builtinPrompts.edit"),children:e.jsx(M,{size:13})}),e.jsx("button",{onClick:h=>{h.stopPropagation(),l(a)},className:"hub-icon-btn sm",title:t("builtinPrompts.delete"),style:{color:"var(--hub-err)"},children:e.jsx(O,{size:13})})]})]}),i&&e.jsxs("div",{style:{padding:"12px 16px 14px 38px",background:"var(--hub-bg-2)",borderTop:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:t("builtinPrompts.template")}),e.jsx("pre",{className:"hub-mono",style:{fontSize:12,color:"var(--hub-ink-2)",background:"var(--hub-surface)",border:"1px solid var(--hub-line)",borderRadius:7,padding:10,overflowX:"auto",whiteSpace:"pre-wrap",margin:0},children:a.template})]}),a.arguments&&a.arguments.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:t("builtinPrompts.arguments")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.arguments.map((h,q)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[e.jsx("code",{className:"hub-mono hub-tag accent",style:{fontSize:11},children:"{{"+h.name+"}}"}),h.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:11},children:"*"}),h.description&&e.jsxs("span",{style:{color:"var(--hub-ink-3)"},children:["— ",h.description]})]},q))})]})]})]},a.id)})}),w&&e.jsx(F,{onSave:C,onCancel:()=>x(!1)}),y&&e.jsx(F,{prompt:y,onSave:E,onCancel:()=>j(null)}),e.jsx(X,{isOpen:!!g,onClose:()=>l(null),onConfirm:z,title:t("builtinPrompts.confirmDelete"),message:t("builtinPrompts.deleteWarning",{name:(g==null?void 0:g.name)||""}),variant:"danger"})]})};export{re as default};
|
|
2
|
+
//# sourceMappingURL=PromptsPage-BLpy76K4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptsPage-BG6oWgAk.js","sources":["../../src/services/builtinPromptService.ts","../../src/hooks/useBuiltinPromptData.ts","../../src/pages/PromptsPage.tsx"],"sourcesContent":["import { BuiltinPrompt, ApiResponse } from '@/types';\nimport { apiGet, apiPost, apiPut, apiDelete } from '../utils/fetchInterceptor';\n\n/**\n * Get all built-in prompts\n */\nexport const getBuiltinPrompts = async (): Promise<BuiltinPrompt[]> => {\n const response: ApiResponse<BuiltinPrompt[]> = await apiGet('/prompts');\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in prompts');\n }\n return response.data || [];\n};\n\n/**\n * Get a single built-in prompt by ID\n */\nexport const getBuiltinPromptById = async (id: string): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiGet(`/prompts/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Create a new built-in prompt\n */\nexport const createBuiltinPrompt = async (\n prompt: Omit<BuiltinPrompt, 'id'>,\n): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiPost('/prompts', prompt);\n if (!response.success) {\n throw new Error(response.message || 'Failed to create built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Update an existing built-in prompt\n */\nexport const updateBuiltinPrompt = async (\n id: string,\n prompt: Partial<BuiltinPrompt>,\n): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiPut(`/prompts/${id}`, prompt);\n if (!response.success) {\n throw new Error(response.message || 'Failed to update built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Delete a built-in prompt\n */\nexport const deleteBuiltinPrompt = async (id: string): Promise<void> => {\n const response: ApiResponse = await apiDelete(`/prompts/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to delete built-in prompt');\n }\n};\n","import { useState, useEffect, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinPrompt } from '@/types';\nimport {\n getBuiltinPrompts,\n createBuiltinPrompt,\n updateBuiltinPrompt,\n deleteBuiltinPrompt,\n} from '@/services/builtinPromptService';\n\nexport const useBuiltinPromptData = () => {\n const { t } = useTranslation();\n const [prompts, setPrompts] = useState<BuiltinPrompt[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [refreshKey, setRefreshKey] = useState(0);\n\n const fetchPrompts = useCallback(async () => {\n try {\n setLoading(true);\n const data = await getBuiltinPrompts();\n setPrompts(data);\n setError(null);\n } catch (err) {\n console.error('Error fetching built-in prompts:', err);\n setError(err instanceof Error ? err.message : t('builtinPrompts.fetchError'));\n setPrompts([]);\n } finally {\n setLoading(false);\n }\n }, [t]);\n\n const triggerRefresh = useCallback(() => {\n setRefreshKey((prev) => prev + 1);\n }, []);\n\n const addPrompt = async (prompt: Omit<BuiltinPrompt, 'id'>) => {\n try {\n const result = await createBuiltinPrompt(prompt);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.createError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const editPrompt = async (id: string, prompt: Partial<BuiltinPrompt>) => {\n try {\n const result = await updateBuiltinPrompt(id, prompt);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.updateError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const removePrompt = async (id: string) => {\n try {\n await deleteBuiltinPrompt(id);\n triggerRefresh();\n return { success: true };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.deleteError');\n setError(message);\n return { success: false, message };\n }\n };\n\n useEffect(() => {\n fetchPrompts();\n }, [fetchPrompts, refreshKey]);\n\n return {\n prompts,\n loading,\n error,\n setError,\n triggerRefresh,\n addPrompt,\n editPrompt,\n removePrompt,\n };\n};\n","import React, { useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinPrompt, PromptArgument } from '@/types';\nimport { useBuiltinPromptData } from '@/hooks/useBuiltinPromptData';\nimport { useAuth } from '@/contexts/AuthContext';\nimport { Edit, Trash, Plus, MessageSquare, X, ChevronDown } from 'lucide-react';\nimport ConfirmDialog from '@/components/ui/ConfirmDialog';\nimport { StatusDot } from '@/components/ui/StatusDot';\n\n// Form dialog for creating/editing a built-in prompt\ninterface PromptFormDialogProps {\n prompt?: BuiltinPrompt | null;\n onSave: (data: Omit<BuiltinPrompt, 'id'>) => Promise<{ success: boolean; message?: string }>;\n onCancel: () => void;\n}\n\nconst PromptFormDialog: React.FC<PromptFormDialogProps> = ({ prompt, onSave, onCancel }) => {\n const { t } = useTranslation();\n const [error, setError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const [name, setName] = useState(prompt?.name || '');\n const [title, setTitle] = useState(prompt?.title || '');\n const [description, setDescription] = useState(prompt?.description || '');\n const [template, setTemplate] = useState(prompt?.template || '');\n const [enabled, setEnabled] = useState(prompt?.enabled !== false);\n const [args, setArgs] = useState<PromptArgument[]>(prompt?.arguments || []);\n\n const handleAddArg = () => {\n setArgs([...args, { name: '', description: '', required: false }]);\n };\n\n const handleRemoveArg = (index: number) => {\n setArgs(args.filter((_, i) => i !== index));\n };\n\n const handleArgChange = (index: number, field: keyof PromptArgument, value: string | boolean) => {\n setArgs(args.map((a, i) => (i === index ? { ...a, [field]: value } : a)));\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setError(null);\n\n if (!name.trim()) {\n setError(t('builtinPrompts.nameRequired'));\n return;\n }\n if (!template.trim()) {\n setError(t('builtinPrompts.templateRequired'));\n return;\n }\n\n setIsSubmitting(true);\n try {\n const result = await onSave({\n name: name.trim(),\n title: title.trim() || undefined,\n description: description.trim() || undefined,\n template,\n arguments: args.length > 0 ? args.filter((a) => a.name.trim()) : undefined,\n enabled,\n });\n if (!result.success) {\n setError(result.message || t('builtinPrompts.saveError'));\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : t('builtinPrompts.saveError'));\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n <div className=\"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4\">\n <div className=\"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto\">\n <form onSubmit={handleSubmit}>\n <h2 className=\"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6\">\n {prompt ? t('builtinPrompts.edit') : t('builtinPrompts.addNew')}\n </h2>\n\n {error && (\n <div className=\"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md\">\n <p className=\"text-sm font-medium\">{error}</p>\n </div>\n )}\n\n <div className=\"space-y-5\">\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.name')} <span className=\"text-red-500\">*</span>\n </label>\n <input\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={t('builtinPrompts.namePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.title')}\n </label>\n <input\n type=\"text\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n placeholder={t('builtinPrompts.titlePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.description')}\n </label>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder={t('builtinPrompts.descriptionPlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.template')} <span className=\"text-red-500\">*</span>\n </label>\n <textarea\n value={template}\n onChange={(e) => setTemplate(e.target.value)}\n placeholder={t('builtinPrompts.templatePlaceholder')}\n rows={6}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n <p className=\"mt-1 text-xs text-gray-500 dark:text-gray-400\">\n {t('builtinPrompts.templateHint')}\n </p>\n </div>\n\n {/* Arguments */}\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300\">\n {t('builtinPrompts.arguments')}\n </label>\n <button\n type=\"button\"\n onClick={handleAddArg}\n className=\"text-blue-600 hover:text-blue-800 text-sm flex items-center\"\n disabled={isSubmitting}\n >\n <Plus size={14} className=\"mr-1\" />\n {t('builtinPrompts.addArgument')}\n </button>\n </div>\n {args.map((arg, index) => (\n <div key={index} className=\"flex items-start gap-2 mb-2\">\n <input\n type=\"text\"\n value={arg.name}\n onChange={(e) => handleArgChange(index, 'name', e.target.value)}\n placeholder={t('builtinPrompts.argName')}\n className=\"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <input\n type=\"text\"\n value={arg.description || ''}\n onChange={(e) => handleArgChange(index, 'description', e.target.value)}\n placeholder={t('builtinPrompts.argDescription')}\n className=\"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label className=\"flex items-center text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap\">\n <input\n type=\"checkbox\"\n checked={arg.required || false}\n onChange={(e) => handleArgChange(index, 'required', e.target.checked)}\n className=\"mr-1\"\n disabled={isSubmitting}\n />\n {t('builtinPrompts.argRequired')}\n </label>\n <button\n type=\"button\"\n onClick={() => handleRemoveArg(index)}\n className=\"text-red-500 hover:text-red-700 p-1\"\n disabled={isSubmitting}\n >\n <X size={16} />\n </button>\n </div>\n ))}\n </div>\n\n <div className=\"flex items-center pt-2\">\n <input\n type=\"checkbox\"\n id=\"enabled\"\n checked={enabled}\n onChange={(e) => setEnabled(e.target.checked)}\n className=\"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label htmlFor=\"enabled\" className=\"ml-2 block text-sm text-gray-700 dark:text-gray-300\">\n {t('builtinPrompts.enabled')}\n </label>\n </div>\n </div>\n\n <div className=\"flex justify-end space-x-2 mt-6\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"hub-btn\"\n disabled={isSubmitting}\n >\n {t('common.cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={isSubmitting}\n className=\"hub-btn primary\"\n >\n {isSubmitting ? t('common.saving') : t('common.save')}\n </button>\n </div>\n </form>\n </div>\n </div>\n );\n};\n\nconst PromptsPage: React.FC = () => {\n const { t } = useTranslation();\n const { auth } = useAuth();\n const {\n prompts,\n loading,\n error,\n setError,\n addPrompt,\n editPrompt,\n removePrompt,\n } = useBuiltinPromptData();\n\n const [showForm, setShowForm] = useState(false);\n const [editingPrompt, setEditingPrompt] = useState<BuiltinPrompt | null>(null);\n const [promptToDelete, setPromptToDelete] = useState<BuiltinPrompt | null>(null);\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());\n\n const isAdmin = auth.user?.isAdmin;\n\n const toggleExpand = (id: string) => {\n setExpandedIds((prev) => {\n const next = new Set(prev);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n return next;\n });\n };\n\n const handleCreate = async (data: Omit<BuiltinPrompt, 'id'>) => {\n const result = await addPrompt(data);\n if (result.success) {\n setShowForm(false);\n }\n return result;\n };\n\n const handleEdit = async (data: Omit<BuiltinPrompt, 'id'>) => {\n if (!editingPrompt) return { success: false, message: 'No prompt selected' };\n const result = await editPrompt(editingPrompt.id, data);\n if (result.success) {\n setEditingPrompt(null);\n }\n return result;\n };\n\n const handleConfirmDelete = async () => {\n if (promptToDelete) {\n await removePrompt(promptToDelete.id);\n setPromptToDelete(null);\n }\n };\n\n return (\n <div>\n <div className=\"flex items-end justify-between gap-4 mb-6\">\n <div>\n <h1 className=\"hub-h1\">{t('pages.prompts.title')}</h1>\n <p className=\"hub-sub\">\n <span className=\"hub-num\">{prompts.length}</span> {t('nav.prompts').toLowerCase()}\n </p>\n </div>\n {isAdmin && (\n <button onClick={() => setShowForm(true)} className=\"hub-btn primary\">\n <Plus size={13} /> {t('builtinPrompts.add')}\n </button>\n )}\n </div>\n\n {error && (\n <div\n className=\"hub-card flex items-center justify-between gap-3 mb-4\"\n style={{\n padding: '10px 14px',\n borderColor: 'oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n }}\n >\n <div className=\"flex items-center gap-2 min-w-0\">\n <X size={14} className=\"flex-shrink-0\" />\n <span className=\"truncate text-[13px]\">{error}</span>\n </div>\n <button className=\"hub-icon-btn sm\" onClick={() => setError(null)}>\n <X size={13} />\n </button>\n </div>\n )}\n\n {loading ? (\n <div className=\"hub-card p-10 text-center\" style={{ color: 'var(--hub-ink-3)' }}>\n {t('app.loading')}\n </div>\n ) : prompts.length === 0 ? (\n <div className=\"hub-card p-10 text-center\" style={{ color: 'var(--hub-ink-3)' }}>\n <div className=\"flex flex-col items-center gap-3\">\n <div\n className=\"grid place-items-center\"\n style={{\n width: 40,\n height: 40,\n borderRadius: 10,\n border: '1px solid var(--hub-line)',\n background: 'var(--hub-bg-2)',\n }}\n >\n <MessageSquare size={18} />\n </div>\n <div className=\"font-medium\" style={{ color: 'var(--hub-ink-2)', fontSize: 13 }}>\n {t('builtinPrompts.noPrompts')}\n </div>\n {isAdmin && (\n <button\n onClick={() => setShowForm(true)}\n className=\"hub-btn ghost sm\"\n style={{ color: 'var(--hub-accent)' }}\n >\n {t('builtinPrompts.addFirst')}\n </button>\n )}\n </div>\n </div>\n ) : (\n <div className=\"hub-card overflow-hidden\">\n {prompts.map((prompt, idx) => {\n const isExpanded = expandedIds.has(prompt.id);\n const enabled = prompt.enabled !== false;\n return (\n <div\n key={prompt.id}\n style={{ borderTop: idx === 0 ? 0 : '1px solid var(--hub-line-2)' }}\n >\n <div\n className=\"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]\"\n style={{ padding: '12px 16px' }}\n onClick={() => toggleExpand(prompt.id)}\n >\n <div className=\"flex items-center gap-2.5 flex-1 min-w-0\">\n <ChevronDown\n size={12}\n style={{\n color: 'var(--hub-ink-3)',\n transform: isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)',\n transition: 'transform 0.15s',\n flexShrink: 0,\n }}\n />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span\n className=\"font-medium truncate\"\n style={{\n fontSize: 13.5,\n color: enabled ? 'var(--hub-ink)' : 'var(--hub-ink-3)',\n }}\n >\n {prompt.title || prompt.name}\n </span>\n <span\n className=\"hub-mono\"\n style={{ fontSize: 11.5, color: 'var(--hub-ink-3)' }}\n >\n {prompt.name}\n </span>\n <StatusDot\n kind={enabled ? 'ok' : 'muted'}\n label={\n enabled\n ? t('builtinPrompts.active')\n : t('builtinPrompts.inactive')\n }\n />\n </div>\n {prompt.description && (\n <div\n className=\"truncate mt-0.5\"\n style={{ fontSize: 12, color: 'var(--hub-ink-3)' }}\n >\n {prompt.description}\n </div>\n )}\n </div>\n </div>\n {isAdmin && (\n <div className=\"flex items-center gap-1 ml-3\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n setEditingPrompt(prompt);\n }}\n className=\"hub-icon-btn sm\"\n title={t('builtinPrompts.edit')}\n >\n <Edit size={13} />\n </button>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setPromptToDelete(prompt);\n }}\n className=\"hub-icon-btn sm\"\n title={t('builtinPrompts.delete')}\n style={{ color: 'var(--hub-err)' }}\n >\n <Trash size={13} />\n </button>\n </div>\n )}\n </div>\n {isExpanded && (\n <div\n style={{\n padding: '12px 16px 14px 38px',\n background: 'var(--hub-bg-2)',\n borderTop: '1px solid var(--hub-line-2)',\n }}\n >\n <div>\n <div className=\"hub-sect\" style={{ marginBottom: 5 }}>\n {t('builtinPrompts.template')}\n </div>\n <pre\n className=\"hub-mono\"\n style={{\n fontSize: 12,\n color: 'var(--hub-ink-2)',\n background: 'var(--hub-surface)',\n border: '1px solid var(--hub-line)',\n borderRadius: 7,\n padding: 10,\n overflowX: 'auto',\n whiteSpace: 'pre-wrap',\n margin: 0,\n }}\n >\n {prompt.template}\n </pre>\n </div>\n {prompt.arguments && prompt.arguments.length > 0 && (\n <div className=\"mt-3\">\n <div className=\"hub-sect\" style={{ marginBottom: 5 }}>\n {t('builtinPrompts.arguments')}\n </div>\n <div className=\"flex flex-wrap gap-1.5\">\n {prompt.arguments.map((arg, i) => (\n <div key={i} className=\"flex items-center gap-1.5 text-[12px]\">\n <code className=\"hub-mono hub-tag accent\" style={{ fontSize: 11 }}>\n {'{{' + arg.name + '}}'}\n </code>\n {arg.required && (\n <span style={{ color: 'var(--hub-err)', fontSize: 11 }}>*</span>\n )}\n {arg.description && (\n <span style={{ color: 'var(--hub-ink-3)' }}>\n — {arg.description}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n\n {/* Add form dialog */}\n {showForm && (\n <PromptFormDialog onSave={handleCreate} onCancel={() => setShowForm(false)} />\n )}\n\n {/* Edit form dialog */}\n {editingPrompt && (\n <PromptFormDialog\n prompt={editingPrompt}\n onSave={handleEdit}\n onCancel={() => setEditingPrompt(null)}\n />\n )}\n\n {/* Delete confirmation */}\n <ConfirmDialog\n isOpen={!!promptToDelete}\n onClose={() => setPromptToDelete(null)}\n onConfirm={handleConfirmDelete}\n title={t('builtinPrompts.confirmDelete')}\n message={t('builtinPrompts.deleteWarning', { name: promptToDelete?.name || '' })}\n variant=\"danger\"\n />\n </div>\n );\n};\n\nexport default PromptsPage;\n"],"names":["getBuiltinPrompts","response","apiGet","createBuiltinPrompt","prompt","apiPost","updateBuiltinPrompt","id","apiPut","deleteBuiltinPrompt","apiDelete","useBuiltinPromptData","useTranslation","prompts","setPrompts","useState","loading","setLoading","error","setError","refreshKey","setRefreshKey","fetchPrompts","useCallback","data","err","triggerRefresh","prev","addPrompt","result","message","editPrompt","removePrompt","useEffect","PromptFormDialog","onSave","onCancel","t","isSubmitting","setIsSubmitting","name","setName","title","setTitle","description","setDescription","template","setTemplate","enabled","setEnabled","args","setArgs","handleAddArg","handleRemoveArg","index","_","i","handleArgChange","field","value","a","handleSubmit","e","jsx","jsxs","Plus","arg","X","PromptsPage","auth","useAuth","showForm","setShowForm","editingPrompt","setEditingPrompt","promptToDelete","setPromptToDelete","expandedIds","setExpandedIds","isAdmin","_a","toggleExpand","next","handleCreate","handleEdit","handleConfirmDelete","MessageSquare","idx","isExpanded","ChevronDown","StatusDot","Edit","Trash","ConfirmDialog"],"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T,CAAA,CAAA,EAVMV,CAYV,CACD,CAAA,CACH,CAAA,CAAA,CACF,CAAA,CAAA,CAAA,CAEJ,CAAA,EArIGpD,EAAO,EAAA,CAyIlB,CAAC,CAAA,CACH,EAIDmE,SACErC,EAAA,CAAiB,OAAQiD,EAAc,SAAU,IAAMX,EAAY,EAAK,EAAG,EAI7EC,GACCV,EAAAA,IAAC7B,EAAA,CACC,OAAQuC,EACR,OAAQW,EACR,SAAU,IAAMV,EAAiB,IAAI,CAAA,CAAA,EAKzCX,EAAAA,IAAC8B,EAAA,CACC,OAAQ,CAAC,CAAClB,EACV,QAAS,IAAMC,EAAkB,IAAI,EACrC,UAAWS,EACX,MAAO,EAAE,8BAA8B,EACvC,QAAS,EAAE,+BAAgC,CAAE,MAAMV,GAAA,YAAAA,EAAgB,OAAQ,GAAI,EAC/E,QAAQ,QAAA,CAAA,CACV,EACF,CAEJ"}
|
|
1
|
+
{"version":3,"file":"PromptsPage-BLpy76K4.js","sources":["../../src/services/builtinPromptService.ts","../../src/hooks/useBuiltinPromptData.ts","../../src/pages/PromptsPage.tsx"],"sourcesContent":["import { BuiltinPrompt, ApiResponse } from '@/types';\nimport { apiGet, apiPost, apiPut, apiDelete } from '../utils/fetchInterceptor';\n\n/**\n * Get all built-in prompts\n */\nexport const getBuiltinPrompts = async (): Promise<BuiltinPrompt[]> => {\n const response: ApiResponse<BuiltinPrompt[]> = await apiGet('/prompts');\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in prompts');\n }\n return response.data || [];\n};\n\n/**\n * Get a single built-in prompt by ID\n */\nexport const getBuiltinPromptById = async (id: string): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiGet(`/prompts/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Create a new built-in prompt\n */\nexport const createBuiltinPrompt = async (\n prompt: Omit<BuiltinPrompt, 'id'>,\n): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiPost('/prompts', prompt);\n if (!response.success) {\n throw new Error(response.message || 'Failed to create built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Update an existing built-in prompt\n */\nexport const updateBuiltinPrompt = async (\n id: string,\n prompt: Partial<BuiltinPrompt>,\n): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiPut(`/prompts/${id}`, prompt);\n if (!response.success) {\n throw new Error(response.message || 'Failed to update built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Delete a built-in prompt\n */\nexport const deleteBuiltinPrompt = async (id: string): Promise<void> => {\n const response: ApiResponse = await apiDelete(`/prompts/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to delete built-in prompt');\n }\n};\n","import { useState, useEffect, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinPrompt } from '@/types';\nimport {\n getBuiltinPrompts,\n createBuiltinPrompt,\n updateBuiltinPrompt,\n deleteBuiltinPrompt,\n} from '@/services/builtinPromptService';\n\nexport const useBuiltinPromptData = () => {\n const { t } = useTranslation();\n const [prompts, setPrompts] = useState<BuiltinPrompt[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [refreshKey, setRefreshKey] = useState(0);\n\n const fetchPrompts = useCallback(async () => {\n try {\n setLoading(true);\n const data = await getBuiltinPrompts();\n setPrompts(data);\n setError(null);\n } catch (err) {\n console.error('Error fetching built-in prompts:', err);\n setError(err instanceof Error ? err.message : t('builtinPrompts.fetchError'));\n setPrompts([]);\n } finally {\n setLoading(false);\n }\n }, [t]);\n\n const triggerRefresh = useCallback(() => {\n setRefreshKey((prev) => prev + 1);\n }, []);\n\n const addPrompt = async (prompt: Omit<BuiltinPrompt, 'id'>) => {\n try {\n const result = await createBuiltinPrompt(prompt);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.createError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const editPrompt = async (id: string, prompt: Partial<BuiltinPrompt>) => {\n try {\n const result = await updateBuiltinPrompt(id, prompt);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.updateError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const removePrompt = async (id: string) => {\n try {\n await deleteBuiltinPrompt(id);\n triggerRefresh();\n return { success: true };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.deleteError');\n setError(message);\n return { success: false, message };\n }\n };\n\n useEffect(() => {\n fetchPrompts();\n }, [fetchPrompts, refreshKey]);\n\n return {\n prompts,\n loading,\n error,\n setError,\n triggerRefresh,\n addPrompt,\n editPrompt,\n removePrompt,\n };\n};\n","import React, { useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinPrompt, PromptArgument } from '@/types';\nimport { useBuiltinPromptData } from '@/hooks/useBuiltinPromptData';\nimport { useAuth } from '@/contexts/AuthContext';\nimport { Edit, Trash, Plus, MessageSquare, X, ChevronDown } from 'lucide-react';\nimport ConfirmDialog from '@/components/ui/ConfirmDialog';\nimport { StatusDot } from '@/components/ui/StatusDot';\n\n// Form dialog for creating/editing a built-in prompt\ninterface PromptFormDialogProps {\n prompt?: BuiltinPrompt | null;\n onSave: (data: Omit<BuiltinPrompt, 'id'>) => Promise<{ success: boolean; message?: string }>;\n onCancel: () => void;\n}\n\nconst PromptFormDialog: React.FC<PromptFormDialogProps> = ({ prompt, onSave, onCancel }) => {\n const { t } = useTranslation();\n const [error, setError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const [name, setName] = useState(prompt?.name || '');\n const [title, setTitle] = useState(prompt?.title || '');\n const [description, setDescription] = useState(prompt?.description || '');\n const [template, setTemplate] = useState(prompt?.template || '');\n const [enabled, setEnabled] = useState(prompt?.enabled !== false);\n const [args, setArgs] = useState<PromptArgument[]>(prompt?.arguments || []);\n\n const handleAddArg = () => {\n setArgs([...args, { name: '', description: '', required: false }]);\n };\n\n const handleRemoveArg = (index: number) => {\n setArgs(args.filter((_, i) => i !== index));\n };\n\n const handleArgChange = (index: number, field: keyof PromptArgument, value: string | boolean) => {\n setArgs(args.map((a, i) => (i === index ? { ...a, [field]: value } : a)));\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setError(null);\n\n if (!name.trim()) {\n setError(t('builtinPrompts.nameRequired'));\n return;\n }\n if (!template.trim()) {\n setError(t('builtinPrompts.templateRequired'));\n return;\n }\n\n setIsSubmitting(true);\n try {\n const result = await onSave({\n name: name.trim(),\n title: title.trim() || undefined,\n description: description.trim() || undefined,\n template,\n arguments: args.length > 0 ? args.filter((a) => a.name.trim()) : undefined,\n enabled,\n });\n if (!result.success) {\n setError(result.message || t('builtinPrompts.saveError'));\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : t('builtinPrompts.saveError'));\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n <div className=\"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4\">\n <div className=\"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto\">\n <form onSubmit={handleSubmit}>\n <h2 className=\"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6\">\n {prompt ? t('builtinPrompts.edit') : t('builtinPrompts.addNew')}\n </h2>\n\n {error && (\n <div className=\"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md\">\n <p className=\"text-sm font-medium\">{error}</p>\n </div>\n )}\n\n <div className=\"space-y-5\">\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.name')} <span className=\"text-red-500\">*</span>\n </label>\n <input\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={t('builtinPrompts.namePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.title')}\n </label>\n <input\n type=\"text\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n placeholder={t('builtinPrompts.titlePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.description')}\n </label>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder={t('builtinPrompts.descriptionPlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.template')} <span className=\"text-red-500\">*</span>\n </label>\n <textarea\n value={template}\n onChange={(e) => setTemplate(e.target.value)}\n placeholder={t('builtinPrompts.templatePlaceholder')}\n rows={6}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n <p className=\"mt-1 text-xs text-gray-500 dark:text-gray-400\">\n {t('builtinPrompts.templateHint')}\n </p>\n </div>\n\n {/* Arguments */}\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300\">\n {t('builtinPrompts.arguments')}\n </label>\n <button\n type=\"button\"\n onClick={handleAddArg}\n className=\"text-blue-600 hover:text-blue-800 text-sm flex items-center\"\n disabled={isSubmitting}\n >\n <Plus size={14} className=\"mr-1\" />\n {t('builtinPrompts.addArgument')}\n </button>\n </div>\n {args.map((arg, index) => (\n <div key={index} className=\"flex items-start gap-2 mb-2\">\n <input\n type=\"text\"\n value={arg.name}\n onChange={(e) => handleArgChange(index, 'name', e.target.value)}\n placeholder={t('builtinPrompts.argName')}\n className=\"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <input\n type=\"text\"\n value={arg.description || ''}\n onChange={(e) => handleArgChange(index, 'description', e.target.value)}\n placeholder={t('builtinPrompts.argDescription')}\n className=\"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label className=\"flex items-center text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap\">\n <input\n type=\"checkbox\"\n checked={arg.required || false}\n onChange={(e) => handleArgChange(index, 'required', e.target.checked)}\n className=\"mr-1\"\n disabled={isSubmitting}\n />\n {t('builtinPrompts.argRequired')}\n </label>\n <button\n type=\"button\"\n onClick={() => handleRemoveArg(index)}\n className=\"text-red-500 hover:text-red-700 p-1\"\n disabled={isSubmitting}\n >\n <X size={16} />\n </button>\n </div>\n ))}\n </div>\n\n <div className=\"flex items-center pt-2\">\n <input\n type=\"checkbox\"\n id=\"enabled\"\n checked={enabled}\n onChange={(e) => setEnabled(e.target.checked)}\n className=\"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label htmlFor=\"enabled\" className=\"ml-2 block text-sm text-gray-700 dark:text-gray-300\">\n {t('builtinPrompts.enabled')}\n </label>\n </div>\n </div>\n\n <div className=\"flex justify-end space-x-2 mt-6\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"hub-btn\"\n disabled={isSubmitting}\n >\n {t('common.cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={isSubmitting}\n className=\"hub-btn primary\"\n >\n {isSubmitting ? t('common.saving') : t('common.save')}\n </button>\n </div>\n </form>\n </div>\n </div>\n );\n};\n\nconst PromptsPage: React.FC = () => {\n const { t } = useTranslation();\n const { auth } = useAuth();\n const {\n prompts,\n loading,\n error,\n setError,\n addPrompt,\n editPrompt,\n removePrompt,\n } = useBuiltinPromptData();\n\n const [showForm, setShowForm] = useState(false);\n const [editingPrompt, setEditingPrompt] = useState<BuiltinPrompt | null>(null);\n const [promptToDelete, setPromptToDelete] = useState<BuiltinPrompt | null>(null);\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());\n\n const isAdmin = auth.user?.isAdmin;\n\n const toggleExpand = (id: string) => {\n setExpandedIds((prev) => {\n const next = new Set(prev);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n return next;\n });\n };\n\n const handleCreate = async (data: Omit<BuiltinPrompt, 'id'>) => {\n const result = await addPrompt(data);\n if (result.success) {\n setShowForm(false);\n }\n return result;\n };\n\n const handleEdit = async (data: Omit<BuiltinPrompt, 'id'>) => {\n if (!editingPrompt) return { success: false, message: 'No prompt selected' };\n const result = await editPrompt(editingPrompt.id, data);\n if (result.success) {\n setEditingPrompt(null);\n }\n return result;\n };\n\n const handleConfirmDelete = async () => {\n if (promptToDelete) {\n await removePrompt(promptToDelete.id);\n setPromptToDelete(null);\n }\n };\n\n return (\n <div>\n <div className=\"flex items-end justify-between gap-4 mb-6\">\n <div>\n <h1 className=\"hub-h1\">{t('pages.prompts.title')}</h1>\n <p className=\"hub-sub\">\n <span className=\"hub-num\">{prompts.length}</span> {t('nav.prompts').toLowerCase()}\n </p>\n </div>\n {isAdmin && (\n <button onClick={() => setShowForm(true)} className=\"hub-btn primary\">\n <Plus size={13} /> {t('builtinPrompts.add')}\n </button>\n )}\n </div>\n\n {error && (\n <div\n className=\"hub-card flex items-center justify-between gap-3 mb-4\"\n style={{\n padding: '10px 14px',\n borderColor: 'oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n }}\n >\n <div className=\"flex items-center gap-2 min-w-0\">\n <X size={14} className=\"flex-shrink-0\" />\n <span className=\"truncate text-[13px]\">{error}</span>\n </div>\n <button className=\"hub-icon-btn sm\" onClick={() => setError(null)}>\n <X size={13} />\n </button>\n </div>\n )}\n\n {loading ? (\n <div className=\"hub-card p-10 text-center\" style={{ color: 'var(--hub-ink-3)' }}>\n {t('app.loading')}\n </div>\n ) : prompts.length === 0 ? (\n <div className=\"hub-card p-10 text-center\" style={{ color: 'var(--hub-ink-3)' }}>\n <div className=\"flex flex-col items-center gap-3\">\n <div\n className=\"grid place-items-center\"\n style={{\n width: 40,\n height: 40,\n borderRadius: 10,\n border: '1px solid var(--hub-line)',\n background: 'var(--hub-bg-2)',\n }}\n >\n <MessageSquare size={18} />\n </div>\n <div className=\"font-medium\" style={{ color: 'var(--hub-ink-2)', fontSize: 13 }}>\n {t('builtinPrompts.noPrompts')}\n </div>\n {isAdmin && (\n <button\n onClick={() => setShowForm(true)}\n className=\"hub-btn ghost sm\"\n style={{ color: 'var(--hub-accent)' }}\n >\n {t('builtinPrompts.addFirst')}\n </button>\n )}\n </div>\n </div>\n ) : (\n <div className=\"hub-card overflow-hidden\">\n {prompts.map((prompt, idx) => {\n const isExpanded = expandedIds.has(prompt.id);\n const enabled = prompt.enabled !== false;\n return (\n <div\n key={prompt.id}\n style={{ borderTop: idx === 0 ? 0 : '1px solid var(--hub-line-2)' }}\n >\n <div\n className=\"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]\"\n style={{ padding: '12px 16px' }}\n onClick={() => toggleExpand(prompt.id)}\n >\n <div className=\"flex items-center gap-2.5 flex-1 min-w-0\">\n <ChevronDown\n size={12}\n style={{\n color: 'var(--hub-ink-3)',\n transform: isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)',\n transition: 'transform 0.15s',\n flexShrink: 0,\n }}\n />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span\n className=\"font-medium truncate\"\n style={{\n fontSize: 13.5,\n color: enabled ? 'var(--hub-ink)' : 'var(--hub-ink-3)',\n }}\n >\n {prompt.title || prompt.name}\n </span>\n <span\n className=\"hub-mono\"\n style={{ fontSize: 11.5, color: 'var(--hub-ink-3)' }}\n >\n {prompt.name}\n </span>\n <StatusDot\n kind={enabled ? 'ok' : 'muted'}\n label={\n enabled\n ? t('builtinPrompts.active')\n : t('builtinPrompts.inactive')\n }\n />\n </div>\n {prompt.description && (\n <div\n className=\"truncate mt-0.5\"\n style={{ fontSize: 12, color: 'var(--hub-ink-3)' }}\n >\n {prompt.description}\n </div>\n )}\n </div>\n </div>\n {isAdmin && (\n <div className=\"flex items-center gap-1 ml-3\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n setEditingPrompt(prompt);\n }}\n className=\"hub-icon-btn sm\"\n title={t('builtinPrompts.edit')}\n >\n <Edit size={13} />\n </button>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setPromptToDelete(prompt);\n }}\n className=\"hub-icon-btn sm\"\n title={t('builtinPrompts.delete')}\n style={{ color: 'var(--hub-err)' }}\n >\n <Trash size={13} />\n </button>\n </div>\n )}\n </div>\n {isExpanded && (\n <div\n style={{\n padding: '12px 16px 14px 38px',\n background: 'var(--hub-bg-2)',\n borderTop: '1px solid var(--hub-line-2)',\n }}\n >\n <div>\n <div className=\"hub-sect\" style={{ marginBottom: 5 }}>\n {t('builtinPrompts.template')}\n </div>\n <pre\n className=\"hub-mono\"\n style={{\n fontSize: 12,\n color: 'var(--hub-ink-2)',\n background: 'var(--hub-surface)',\n border: '1px solid var(--hub-line)',\n borderRadius: 7,\n padding: 10,\n overflowX: 'auto',\n whiteSpace: 'pre-wrap',\n margin: 0,\n }}\n >\n {prompt.template}\n </pre>\n </div>\n {prompt.arguments && prompt.arguments.length > 0 && (\n <div className=\"mt-3\">\n <div className=\"hub-sect\" style={{ marginBottom: 5 }}>\n {t('builtinPrompts.arguments')}\n </div>\n <div className=\"flex flex-wrap gap-1.5\">\n {prompt.arguments.map((arg, i) => (\n <div key={i} className=\"flex items-center gap-1.5 text-[12px]\">\n <code className=\"hub-mono hub-tag accent\" style={{ fontSize: 11 }}>\n {'{{' + arg.name + '}}'}\n </code>\n {arg.required && (\n <span style={{ color: 'var(--hub-err)', fontSize: 11 }}>*</span>\n )}\n {arg.description && (\n <span style={{ color: 'var(--hub-ink-3)' }}>\n — {arg.description}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n\n {/* Add form dialog */}\n {showForm && (\n <PromptFormDialog onSave={handleCreate} onCancel={() => setShowForm(false)} />\n )}\n\n {/* Edit form dialog */}\n {editingPrompt && (\n <PromptFormDialog\n prompt={editingPrompt}\n onSave={handleEdit}\n onCancel={() => setEditingPrompt(null)}\n />\n )}\n\n {/* Delete confirmation */}\n <ConfirmDialog\n isOpen={!!promptToDelete}\n onClose={() => setPromptToDelete(null)}\n onConfirm={handleConfirmDelete}\n title={t('builtinPrompts.confirmDelete')}\n message={t('builtinPrompts.deleteWarning', { name: promptToDelete?.name || '' })}\n variant=\"danger\"\n />\n </div>\n );\n};\n\nexport default PromptsPage;\n"],"names":["getBuiltinPrompts","response","apiGet","createBuiltinPrompt","prompt","apiPost","updateBuiltinPrompt","id","apiPut","deleteBuiltinPrompt","apiDelete","useBuiltinPromptData","useTranslation","prompts","setPrompts","useState","loading","setLoading","error","setError","refreshKey","setRefreshKey","fetchPrompts","useCallback","data","err","triggerRefresh","prev","addPrompt","result","message","editPrompt","removePrompt","useEffect","PromptFormDialog","onSave","onCancel","t","isSubmitting","setIsSubmitting","name","setName","title","setTitle","description","setDescription","template","setTemplate","enabled","setEnabled","args","setArgs","handleAddArg","handleRemoveArg","index","_","i","handleArgChange","field","value","a","handleSubmit","e","jsx","jsxs","Plus","arg","X","PromptsPage","auth","useAuth","showForm","setShowForm","editingPrompt","setEditingPrompt","promptToDelete","setPromptToDelete","expandedIds","setExpandedIds","isAdmin","_a","toggleExpand","next","handleCreate","handleEdit","handleConfirmDelete","MessageSquare","idx","isExpanded","ChevronDown","StatusDot","Edit","Trash","ConfirmDialog"],"mappings":"2VAMO,MAAMA,EAAoB,SAAsC,CACrE,MAAMC,EAAyC,MAAMC,EAAO,UAAU,EACtE,GAAI,CAACD,EAAS,QACZ,MAAM,IAAI,MAAMA,EAAS,SAAW,kCAAkC,EAExE,OAAOA,EAAS,MAAQ,CAAA,CAC1B,EAgBaE,EAAsB,MACjCC,GAC2B,CAC3B,MAAMH,EAAuC,MAAMI,EAAQ,WAAYD,CAAM,EAC7E,GAAI,CAACH,EAAS,QACZ,MAAM,IAAI,MAAMA,EAAS,SAAW,kCAAkC,EAExE,OAAOA,EAAS,IAClB,EAKaK,EAAsB,MACjCC,EACAH,IAC2B,CAC3B,MAAMH,EAAuC,MAAMO,EAAO,YAAYD,CAAE,GAAIH,CAAM,EAClF,GAAI,CAACH,EAAS,QACZ,MAAM,IAAI,MAAMA,EAAS,SAAW,kCAAkC,EAExE,OAAOA,EAAS,IAClB,EAKaQ,EAAsB,MAAOF,GAA8B,CACtE,MAAMN,EAAwB,MAAMS,EAAU,YAAYH,CAAE,EAAE,EAC9D,GAAI,CAACN,EAAS,QACZ,MAAM,IAAI,MAAMA,EAAS,SAAW,kCAAkC,CAE1E,EClDaU,EAAuB,IAAM,CACxC,KAAM,CAAE,CAAA,EAAMC,EAAA,EACR,CAACC,EAASC,CAAU,EA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,UAAU,yBACZ,SAAA3D,EAAO,UAAU,IAAI,CAAC8D,EAAKV,IAC1BQ,OAAC,MAAA,CAAY,UAAU,wCACrB,SAAA,CAAAD,EAAAA,IAAC,OAAA,CAAK,UAAU,0BAA0B,MAAO,CAAE,SAAU,EAAA,EAC1D,SAAA,KAAOG,EAAI,KAAO,IAAA,CACrB,EACCA,EAAI,UACHH,EAAAA,IAAC,OAAA,CAAK,MAAO,CAAE,MAAO,iBAAkB,SAAU,EAAA,EAAM,SAAA,GAAA,CAAC,EAE1DG,EAAI,aACHF,EAAAA,KAAC,OAAA,CAAK,MAAO,CAAE,MAAO,oBAAsB,SAAA,CAAA,KACvCE,EAAI,WAAA,CAAA,CACT,CAAA,CAAA,EAVMV,CAYV,CACD,CAAA,CACH,CAAA,CAAA,CACF,CAAA,CAAA,CAAA,CAEJ,CAAA,EArIGpD,EAAO,EAAA,CAyIlB,CAAC,CAAA,CACH,EAIDmE,SACErC,EAAA,CAAiB,OAAQiD,EAAc,SAAU,IAAMX,EAAY,EAAK,EAAG,EAI7EC,GACCV,EAAAA,IAAC7B,EAAA,CACC,OAAQuC,EACR,OAAQW,EACR,SAAU,IAAMV,EAAiB,IAAI,CAAA,CAAA,EAKzCX,EAAAA,IAAC8B,EAAA,CACC,OAAQ,CAAC,CAAClB,EACV,QAAS,IAAMC,EAAkB,IAAI,EACrC,UAAWS,EACX,MAAO,EAAE,8BAA8B,EACvC,QAAS,EAAE,+BAAgC,CAAE,MAAMV,GAAA,YAAAA,EAAgB,OAAQ,GAAI,EAC/E,QAAQ,QAAA,CAAA,CACV,EACF,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as n,j as e}from"./framework-vendor-I9Y6AgD5.js";import{j as D,f as B,h as q,e as A,u as I}from"./index-Ca9HKIrV.js";import{u as P}from"./i18n-vendor-y9bLzIeh.js";import{C as K}from"./ConfirmDialog-CYfXEuyU.js";import{a as L}from"./StatusDot-Bz7sBh0t.js";import{P as X,X as F,F as $,u as G,r as H,a2 as M}from"./icons-vendor-hw0ScL8G.js";const O=async()=>{const s=await D("/resources");if(!s.success)throw new Error(s.message||"Failed to fetch built-in resources");return s.data||[]},U=async s=>{const c=await A("/resources",s);if(!c.success)throw new Error(c.message||"Failed to create built-in resource");return c.data},W=async(s,c)=>{const m=await q(`/resources/${s}`,c);if(!m.success)throw new Error(m.message||"Failed to update built-in resource");return m.data},Y=async s=>{const c=await B(`/resources/${s}`);if(!c.success)throw new Error(c.message||"Failed to delete built-in resource")},J=()=>{const{t:s}=P(),[c,m]=n.useState([]),[t,g]=n.useState(!0),[x,i]=n.useState(null),[w,j]=n.useState(0),N=n.useCallback(async()=>{try{g(!0);const a=await O();m(a),i(null)}catch(a){console.error("Error fetching built-in resources:",a),i(a instanceof Error?a.message:s("builtinResources.fetchError")),m([])}finally{g(!1)}},[s]),b=n.useCallback(()=>{j(a=>a+1)},[]),p=async a=>{try{const u=await U(a);return b(),{success:!0,data:u}}catch(u){const l=u instanceof Error?u.message:s("builtinResources.createError");return i(l),{success:!1,message:l}}},f=async(a,u)=>{try{const l=await W(a,u);return b(),{success:!0,data:l}}catch(l){const y=l instanceof Error?l.message:s("builtinResources.updateError");return i(y),{success:!1,message:y}}},d=async a=>{try{return await Y(a),b(),{success:!0}}catch(u){const l=u instanceof Error?u.message:s("builtinResources.deleteError");return i(l),{success:!1,message:l}}};return n.useEffect(()=>{N()},[N,w]),{resources:c,loading:t,error:x,setError:i,triggerRefresh:b,addResource:p,editResource:f,removeResource:d}},T=({resource:s,onSave:c,onCancel:m})=>{const{t}=P(),[g,x]=n.useState(null),[i,w]=n.useState(!1),[j,N]=n.useState((s==null?void 0:s.uri)||""),[b,p]=n.useState((s==null?void 0:s.name)||""),[f,d]=n.useState((s==null?void 0:s.description)||""),[a,u]=n.useState((s==null?void 0:s.mimeType)||"text/plain"),[l,y]=n.useState((s==null?void 0:s.content)||""),[R,S]=n.useState((s==null?void 0:s.enabled)!==!1),E=async o=>{if(o.preventDefault(),x(null),!j.trim()){x(t("builtinResources.uriRequired"));return}if(!l.trim()){x(t("builtinResources.contentRequired"));return}w(!0);try{const v=await c({uri:j.trim(),name:b.trim()||void 0,description:f.trim()||void 0,mimeType:a.trim()||"text/plain",content:l,enabled:R});v.success||x(v.message||t("builtinResources.saveError"))}catch(v){x(v instanceof Error?v.message:t("builtinResources.saveError"))}finally{w(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto",children:e.jsxs("form",{onSubmit:E,children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6",children:t(s?"builtinResources.edit":"builtinResources.addNew")}),g&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md",children:e.jsx("p",{className:"text-sm font-medium",children:g})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("builtinResources.uri")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:j,onChange:o=>N(o.target.value),placeholder:t("builtinResources.uriPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.name")}),e.jsx("input",{type:"text",value:b,onChange:o=>p(o.target.value),placeholder:t("builtinResources.namePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.description")}),e.jsx("input",{type:"text",value:f,onChange:o=>d(o.target.value),placeholder:t("builtinResources.descriptionPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.mimeType")}),e.jsx("input",{type:"text",value:a,onChange:o=>u(o.target.value),placeholder:"text/plain",className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("builtinResources.content")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:l,onChange:o=>y(o.target.value),placeholder:t("builtinResources.contentPlaceholder"),rows:8,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:i})]}),e.jsxs("div",{className:"flex items-center pt-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:R,onChange:o=>S(o.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",disabled:i}),e.jsx("label",{htmlFor:"enabled",className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:t("builtinResources.enabled")})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[e.jsx("button",{type:"button",onClick:m,className:"hub-btn",disabled:i,children:t("common.cancel")}),e.jsx("button",{type:"submit",disabled:i,className:"hub-btn primary",children:t(i?"common.saving":"common.save")})]})]})})})},te=()=>{var v;const{t:s}=P(),{auth:c}=I(),{resources:m,loading:t,error:g,setError:x,addResource:i,editResource:w,removeResource:j}=J(),[N,b]=n.useState(!1),[p,f]=n.useState(null),[d,a]=n.useState(null),[u,l]=n.useState(new Set),y=(v=c.user)==null?void 0:v.isAdmin,R=r=>{l(h=>{const k=new Set(h);return k.has(r)?k.delete(r):k.add(r),k})},S=async r=>{const h=await i(r);return h.success&&b(!1),h},E=async r=>{if(!p)return{success:!1,message:"No resource selected"};const h=await w(p.id,r);return h.success&&f(null),h},o=async()=>{d&&(await j(d.id),a(null))};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:s("pages.resources.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:m.length})," ",s("nav.resources").toLowerCase()]})]}),y&&e.jsxs("button",{onClick:()=>b(!0),className:"hub-btn primary",children:[e.jsx(X,{size:13})," ",s("builtinResources.add")]})]}),g&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(F,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:g})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>x(null),children:e.jsx(F,{size:13})})]}),t?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:s("app.loading")}):m.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"grid place-items-center",style:{width:40,height:40,borderRadius:10,border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:e.jsx($,{size:18})}),e.jsx("div",{className:"font-medium",style:{color:"var(--hub-ink-2)",fontSize:13},children:s("builtinResources.noResources")}),y&&e.jsx("button",{onClick:()=>b(!0),className:"hub-btn ghost sm",style:{color:"var(--hub-accent)"},children:s("builtinResources.addFirst")})]})}):e.jsx("div",{className:"hub-card overflow-hidden",children:m.map((r,h)=>{const k=u.has(r.id),C=r.enabled!==!1;return e.jsxs("div",{style:{borderTop:h===0?0:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]",style:{padding:"12px 16px"},onClick:()=>R(r.id),children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[e.jsx(G,{size:12,style:{color:"var(--hub-ink-3)",transform:k?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",style:{fontSize:13.5,color:C?"var(--hub-ink)":"var(--hub-ink-3)"},children:r.name||r.uri}),r.name&&e.jsx("span",{className:"hub-mono truncate",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:r.uri}),e.jsx(L,{kind:C?"ok":"muted",label:s(C?"builtinResources.active":"builtinResources.inactive")}),r.mimeType&&e.jsx("span",{className:"hub-tag accent",style:{fontSize:10},children:r.mimeType})]}),r.description&&e.jsx("div",{className:"truncate mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:r.description})]})]}),y&&e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsx("button",{onClick:z=>{z.stopPropagation(),f(r)},className:"hub-icon-btn sm",title:s("builtinResources.edit"),children:e.jsx(H,{size:13})}),e.jsx("button",{onClick:z=>{z.stopPropagation(),a(r)},className:"hub-icon-btn sm",title:s("builtinResources.delete"),style:{color:"var(--hub-err)"},children:e.jsx(M,{size:13})})]})]}),k&&e.jsxs("div",{style:{padding:"12px 16px 14px 38px",background:"var(--hub-bg-2)",borderTop:"1px solid var(--hub-line-2)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:s("builtinResources.content")}),e.jsx("pre",{className:"hub-mono",style:{fontSize:12,color:"var(--hub-ink-2)",background:"var(--hub-surface)",border:"1px solid var(--hub-line)",borderRadius:7,padding:10,overflowX:"auto",overflowY:"auto",whiteSpace:"pre-wrap",maxHeight:260,margin:0},children:r.content})]})]},r.id)})}),N&&e.jsx(T,{onSave:S,onCancel:()=>b(!1)}),p&&e.jsx(T,{resource:p,onSave:E,onCancel:()=>f(null)}),e.jsx(K,{isOpen:!!d,onClose:()=>a(null),onConfirm:o,title:s("builtinResources.confirmDelete"),message:s("builtinResources.deleteWarning",{name:(d==null?void 0:d.name)||(d==null?void 0:d.uri)||""}),variant:"danger"})]})};export{te as default};
|
|
2
|
-
//# sourceMappingURL=ResourcesPage-
|
|
1
|
+
import{r as n,j as e}from"./framework-vendor-I9Y6AgD5.js";import{j as D,f as B,h as q,e as A,u as I}from"./index-CLugsCsy.js";import{u as P}from"./i18n-vendor-y9bLzIeh.js";import{C as K}from"./ConfirmDialog-CYfXEuyU.js";import{a as L}from"./StatusDot-CmSkukx0.js";import{P as X,X as F,F as $,u as G,r as H,a3 as M}from"./icons-vendor-BFl4A9fq.js";const O=async()=>{const s=await D("/resources");if(!s.success)throw new Error(s.message||"Failed to fetch built-in resources");return s.data||[]},U=async s=>{const c=await A("/resources",s);if(!c.success)throw new Error(c.message||"Failed to create built-in resource");return c.data},W=async(s,c)=>{const m=await q(`/resources/${s}`,c);if(!m.success)throw new Error(m.message||"Failed to update built-in resource");return m.data},Y=async s=>{const c=await B(`/resources/${s}`);if(!c.success)throw new Error(c.message||"Failed to delete built-in resource")},J=()=>{const{t:s}=P(),[c,m]=n.useState([]),[t,g]=n.useState(!0),[x,i]=n.useState(null),[w,j]=n.useState(0),N=n.useCallback(async()=>{try{g(!0);const a=await O();m(a),i(null)}catch(a){console.error("Error fetching built-in resources:",a),i(a instanceof Error?a.message:s("builtinResources.fetchError")),m([])}finally{g(!1)}},[s]),b=n.useCallback(()=>{j(a=>a+1)},[]),p=async a=>{try{const u=await U(a);return b(),{success:!0,data:u}}catch(u){const l=u instanceof Error?u.message:s("builtinResources.createError");return i(l),{success:!1,message:l}}},f=async(a,u)=>{try{const l=await W(a,u);return b(),{success:!0,data:l}}catch(l){const y=l instanceof Error?l.message:s("builtinResources.updateError");return i(y),{success:!1,message:y}}},d=async a=>{try{return await Y(a),b(),{success:!0}}catch(u){const l=u instanceof Error?u.message:s("builtinResources.deleteError");return i(l),{success:!1,message:l}}};return n.useEffect(()=>{N()},[N,w]),{resources:c,loading:t,error:x,setError:i,triggerRefresh:b,addResource:p,editResource:f,removeResource:d}},T=({resource:s,onSave:c,onCancel:m})=>{const{t}=P(),[g,x]=n.useState(null),[i,w]=n.useState(!1),[j,N]=n.useState((s==null?void 0:s.uri)||""),[b,p]=n.useState((s==null?void 0:s.name)||""),[f,d]=n.useState((s==null?void 0:s.description)||""),[a,u]=n.useState((s==null?void 0:s.mimeType)||"text/plain"),[l,y]=n.useState((s==null?void 0:s.content)||""),[R,S]=n.useState((s==null?void 0:s.enabled)!==!1),E=async o=>{if(o.preventDefault(),x(null),!j.trim()){x(t("builtinResources.uriRequired"));return}if(!l.trim()){x(t("builtinResources.contentRequired"));return}w(!0);try{const v=await c({uri:j.trim(),name:b.trim()||void 0,description:f.trim()||void 0,mimeType:a.trim()||"text/plain",content:l,enabled:R});v.success||x(v.message||t("builtinResources.saveError"))}catch(v){x(v instanceof Error?v.message:t("builtinResources.saveError"))}finally{w(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto",children:e.jsxs("form",{onSubmit:E,children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6",children:t(s?"builtinResources.edit":"builtinResources.addNew")}),g&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md",children:e.jsx("p",{className:"text-sm font-medium",children:g})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("builtinResources.uri")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:j,onChange:o=>N(o.target.value),placeholder:t("builtinResources.uriPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.name")}),e.jsx("input",{type:"text",value:b,onChange:o=>p(o.target.value),placeholder:t("builtinResources.namePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.description")}),e.jsx("input",{type:"text",value:f,onChange:o=>d(o.target.value),placeholder:t("builtinResources.descriptionPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.mimeType")}),e.jsx("input",{type:"text",value:a,onChange:o=>u(o.target.value),placeholder:"text/plain",className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("builtinResources.content")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:l,onChange:o=>y(o.target.value),placeholder:t("builtinResources.contentPlaceholder"),rows:8,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:i})]}),e.jsxs("div",{className:"flex items-center pt-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:R,onChange:o=>S(o.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",disabled:i}),e.jsx("label",{htmlFor:"enabled",className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:t("builtinResources.enabled")})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[e.jsx("button",{type:"button",onClick:m,className:"hub-btn",disabled:i,children:t("common.cancel")}),e.jsx("button",{type:"submit",disabled:i,className:"hub-btn primary",children:t(i?"common.saving":"common.save")})]})]})})})},te=()=>{var v;const{t:s}=P(),{auth:c}=I(),{resources:m,loading:t,error:g,setError:x,addResource:i,editResource:w,removeResource:j}=J(),[N,b]=n.useState(!1),[p,f]=n.useState(null),[d,a]=n.useState(null),[u,l]=n.useState(new Set),y=(v=c.user)==null?void 0:v.isAdmin,R=r=>{l(h=>{const k=new Set(h);return k.has(r)?k.delete(r):k.add(r),k})},S=async r=>{const h=await i(r);return h.success&&b(!1),h},E=async r=>{if(!p)return{success:!1,message:"No resource selected"};const h=await w(p.id,r);return h.success&&f(null),h},o=async()=>{d&&(await j(d.id),a(null))};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:s("pages.resources.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:m.length})," ",s("nav.resources").toLowerCase()]})]}),y&&e.jsxs("button",{onClick:()=>b(!0),className:"hub-btn primary",children:[e.jsx(X,{size:13})," ",s("builtinResources.add")]})]}),g&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(F,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:g})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>x(null),children:e.jsx(F,{size:13})})]}),t?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:s("app.loading")}):m.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"grid place-items-center",style:{width:40,height:40,borderRadius:10,border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:e.jsx($,{size:18})}),e.jsx("div",{className:"font-medium",style:{color:"var(--hub-ink-2)",fontSize:13},children:s("builtinResources.noResources")}),y&&e.jsx("button",{onClick:()=>b(!0),className:"hub-btn ghost sm",style:{color:"var(--hub-accent)"},children:s("builtinResources.addFirst")})]})}):e.jsx("div",{className:"hub-card overflow-hidden",children:m.map((r,h)=>{const k=u.has(r.id),C=r.enabled!==!1;return e.jsxs("div",{style:{borderTop:h===0?0:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]",style:{padding:"12px 16px"},onClick:()=>R(r.id),children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[e.jsx(G,{size:12,style:{color:"var(--hub-ink-3)",transform:k?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",style:{fontSize:13.5,color:C?"var(--hub-ink)":"var(--hub-ink-3)"},children:r.name||r.uri}),r.name&&e.jsx("span",{className:"hub-mono truncate",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:r.uri}),e.jsx(L,{kind:C?"ok":"muted",label:s(C?"builtinResources.active":"builtinResources.inactive")}),r.mimeType&&e.jsx("span",{className:"hub-tag accent",style:{fontSize:10},children:r.mimeType})]}),r.description&&e.jsx("div",{className:"truncate mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:r.description})]})]}),y&&e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsx("button",{onClick:z=>{z.stopPropagation(),f(r)},className:"hub-icon-btn sm",title:s("builtinResources.edit"),children:e.jsx(H,{size:13})}),e.jsx("button",{onClick:z=>{z.stopPropagation(),a(r)},className:"hub-icon-btn sm",title:s("builtinResources.delete"),style:{color:"var(--hub-err)"},children:e.jsx(M,{size:13})})]})]}),k&&e.jsxs("div",{style:{padding:"12px 16px 14px 38px",background:"var(--hub-bg-2)",borderTop:"1px solid var(--hub-line-2)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:s("builtinResources.content")}),e.jsx("pre",{className:"hub-mono",style:{fontSize:12,color:"var(--hub-ink-2)",background:"var(--hub-surface)",border:"1px solid var(--hub-line)",borderRadius:7,padding:10,overflowX:"auto",overflowY:"auto",whiteSpace:"pre-wrap",maxHeight:260,margin:0},children:r.content})]})]},r.id)})}),N&&e.jsx(T,{onSave:S,onCancel:()=>b(!1)}),p&&e.jsx(T,{resource:p,onSave:E,onCancel:()=>f(null)}),e.jsx(K,{isOpen:!!d,onClose:()=>a(null),onConfirm:o,title:s("builtinResources.confirmDelete"),message:s("builtinResources.deleteWarning",{name:(d==null?void 0:d.name)||(d==null?void 0:d.uri)||""}),variant:"danger"})]})};export{te as default};
|
|
2
|
+
//# sourceMappingURL=ResourcesPage-C5nynRqE.js.map
|