@testver/testver 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +88 -69
- package/README.md +6 -2
- package/bin/testver.js +9 -1
- package/dist/index.js +52200 -35695
- package/package.json +179 -178
- package/src/ui/static/agents/antigravity.svg +76 -0
- package/src/ui/static/agents/codex.svg +3 -0
- package/src/ui/static/agents/gemini.svg +1 -0
- package/src/ui/static/agents/opencode.svg +4 -0
- package/src/ui/static/agents/vscode.svg +17 -0
- package/src/ui/static/assets/{AIPanel-KQFq4c0Q.js → AIPanel-RWO8Cd9w.js} +32 -32
- package/src/ui/static/assets/{AIRecordPanel-CAs8fXyS.js → AIRecordPanel-DnreS585.js} +40 -40
- package/src/ui/static/assets/{AIStreamUI-p_sMTEDQ.js → AIStreamUI-C1gHJtlF.js} +9 -9
- package/src/ui/static/assets/{AITestGenPage-CHaHfmu4.js → AITestGenPage-C8bWUelu.js} +5 -5
- package/src/ui/static/assets/{APITestingPage-BSGJY_hd.js → APITestingPage-DwL67hqL.js} +19 -19
- package/src/ui/static/assets/AboutPage-CynLB95E.js +1 -0
- package/src/ui/static/assets/AccessTokensTab-BdevOmpE.js +1 -0
- package/src/ui/static/assets/AdvancedPage-BeM7aB8b.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-Lm8noJqC.js → AnalyticsPage-C5ddYfRk.js} +1 -1
- package/src/ui/static/assets/AuditLogPage-DYcUdJoj.js +1 -0
- package/src/ui/static/assets/{ChangesSummary-Cu0_4Ucf.js → ChangesSummary-BjNMwGIZ.js} +3 -3
- package/src/ui/static/assets/{CodeMapPage-uEjuo3fk.js → CodeMapPage-BQOEtv-R.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-DtotgVmI.js → ConfirmDialog-D_N9188T.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-jNkQJA1P.js → CoveragePage-8bDSphY1.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-D2fERHt9.js → CronBuilder-C7_JADb7.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BaIj_IdQ.js → Dashboard-B22yRPyV.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-DH0njYFG.js → DefectsPage-Arv4Ac-b.js} +72 -72
- package/src/ui/static/assets/{EmptyState-utxlJ0fu.js → EmptyState-BShNSbLf.js} +1 -1
- package/src/ui/static/assets/{ExportButton-ouKqn9CU.js → ExportButton-xrS_AnfS.js} +1 -1
- package/src/ui/static/assets/{FileViewer-mU3JloJ6.js → FileViewer-Bcr9T1jW.js} +18 -18
- package/src/ui/static/assets/{GitPage-TrX-RqNC.js → GitPage-DXL2Sv40.js} +12 -12
- package/src/ui/static/assets/{ImportExportPage-CIhK_raX.js → ImportExportPage-BcjzRd7T.js} +36 -36
- package/src/ui/static/assets/{JiraPushDialog-DgEZS-0u.js → JiraPushDialog-DNYU9Ce0.js} +1 -1
- package/src/ui/static/assets/{KpiTile-BHLE3HVj.js → KpiTile-BKlWqjgN.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-CaIf7Jux.js → LiveExecutionView-1LlyEDEe.js} +1 -1
- package/src/ui/static/assets/{MediaModal-DNM45Uz2.js → MediaModal-Dyy_iHl9.js} +1 -1
- package/src/ui/static/assets/MobileRunPicker-Cf5rm469.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-C4M4YJJh.js +6 -0
- package/src/ui/static/assets/{ModuleExplorer-rni7JbsL.js → ModuleExplorer-BKVbxFZK.js} +1 -1
- package/src/ui/static/assets/{OutputPage-Cn2WCpJ6.js → OutputPage-Bi-28tJi.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-BtO3iSJ4.js +1 -0
- package/src/ui/static/assets/{ProfilePage-BKNdkSnx.js → ProfilePage-BgZ4VDC-.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-5e7J8t-o.js → ProjectExplorer-BVGbmVP7.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-C1S2aclP.js → RemoteFileStrip-dzPInzgb.js} +1 -1
- package/src/ui/static/assets/{ReportCard-D4EElEe9.js → ReportCard-LOf1PXlb.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-2w2ysKRg.js → ReportFullView-Ce4OI8lf.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-9Fx-IEwV.js → ReportsPage-DFxCQ8cY.js} +48 -48
- package/src/ui/static/assets/{ResultsPage-DPkfGh-K.js → ResultsPage-DD-uj8gk.js} +115 -115
- package/src/ui/static/assets/{RunState-CRuS_bC2.js → RunState-DDwFB4tA.js} +1 -1
- package/src/ui/static/assets/{RunTargets-CPKBrefj.js → RunTargets-CkIpY3v3.js} +1 -1
- package/src/ui/static/assets/ScriptMappingPage-DQQoR6sR.js +1 -0
- package/src/ui/static/assets/{SearchableDevicePicker-DubIldKj.js → SearchableDevicePicker-CenIxD7b.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-BuZrrlW2.js → SettingsPage-DAV_0y0m.js} +83 -83
- package/src/ui/static/assets/{SharedReportView-ig5hECRk.js → SharedReportView-CqSLFKT1.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-BPkqRqkC.js → SourcesPage-BvqC9oKw.js} +14 -14
- package/src/ui/static/assets/TestExplorerPage-Bdnll77k.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-DJiWpCne.js → TestManagementPage-CCNE688A.js} +10 -10
- package/src/ui/static/assets/{TestPlansPage-G1lvK1C0.js → TestPlansPage-T6D25i6-.js} +5 -5
- package/src/ui/static/assets/{TestverCreditsRing-CEBSy3w3.js → TestverCreditsRing-CoDk5eAS.js} +1 -1
- package/src/ui/static/assets/TestverMcpPage-Dte0qSXp.js +34 -0
- package/src/ui/static/assets/{UncommittedDiffViewer-FKvUZcRi.js → UncommittedDiffViewer-BNroxCoo.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-gDGhaHE4.js → UserManagementPage-BU4MuDJZ.js} +10 -10
- package/src/ui/static/assets/{WorkflowsPage-BACdnU-1.js → WorkflowsPage-BP5k7AqE.js} +83 -83
- package/src/ui/static/assets/clipboard-BIEd7Ccc.js +1 -0
- package/src/ui/static/assets/{hiddenLlmProviders-DzwaR-b9.js → hiddenLlmProviders-BPORgy-e.js} +1 -1
- package/src/ui/static/assets/index-BlA8ntjb.js +47 -0
- package/src/ui/static/assets/index-Co4_SlGD.css +1 -0
- package/src/ui/static/assets/{reportMeta-3kxT7BIT.js → reportMeta-B9ZRW6ts.js} +1 -1
- package/src/ui/static/assets/runSelected-BoPm1sz-.js +1 -0
- package/src/ui/static/assets/{useFeatureFlags-DrhvBp0C.js → useFeatureFlags-B4Otsv-N.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-Dwj69Rfh.js → useJiraConnector--JZhbYrT.js} +1 -1
- package/src/ui/static/assets/{useOwnership-C1CmzcvJ.js → useOwnership-BhPOiYzy.js} +1 -1
- package/src/ui/static/assets/useSuites-GN_K2mHc.js +1 -0
- package/src/ui/static/assets/{useTestExplorer-CUqC18DV.js → useTestExplorer-BGhkGHKy.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-C2S_vaX2.js → useTestLifecycle-DX5ES6x8.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-DW6AW2mt.js → useTestManagement-ommXjx0q.js} +2 -2
- package/src/ui/static/assets/{useTestResults-yjH1aUy-.js → useTestResults-DWjvm8gm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-D_Dmmj8d.js → vendor-icons-Cm92aSc5.js} +1426 -1416
- package/src/ui/static/index.html +479 -479
- package/src/ui/static/assets/AboutPage-CDa24SCJ.js +0 -1
- package/src/ui/static/assets/AdvancedPage-BqXP0FLg.js +0 -3
- package/src/ui/static/assets/AuditLogPage-BvldSIik.js +0 -1
- package/src/ui/static/assets/MobileRunPicker-DFKm6_nU.js +0 -1
- package/src/ui/static/assets/MobileRunTarget-DHDoDZ_F.js +0 -6
- package/src/ui/static/assets/PipelinesPanel-D6zWcLtD.js +0 -1
- package/src/ui/static/assets/ScriptMappingPage-C3K_uyf0.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-C_jl93GR.js +0 -7
- package/src/ui/static/assets/index-D6sQYc_0.js +0 -47
- package/src/ui/static/assets/index-aInN0yoR.css +0 -1
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +0 -1
- package/src/ui/static/assets/useSuites-V0AxZYex.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,u}from"./vendor-react-DOVfxdUy.js";import{aa as d,a9 as g,ax as f,ay as h,h as x,P as b}from"./index-
|
|
1
|
+
import{j as e,u}from"./vendor-react-DOVfxdUy.js";import{aa as d,a9 as g,ax as f,ay as h,h as x,P as b}from"./index-BlA8ntjb.js";import{A as k,t as m,ab as y,bs as j}from"./vendor-icons-Cm92aSc5.js";function p(){const n=d(),{data:t}=g(n),s=(t==null?void 0:t.check)??null,i=new Map;if(s&&f(s)){for(const a of s.incoming)for(const r of a.files){const o=h(s,r.path);o&&!i.has(o)&&i.set(o,a)}for(const a of s.incomingFiles){const r=h(s,a);r&&!i.has(r)&&i.set(r,{sha:s.upstreamSha??"",shortSha:"",author:"",email:"",message:"",timestamp:"",files:[]})}}return{check:s,byPath:i}}const c=n=>n.replace(/\\/g,"/").replace(/^\.\//,"");function v({path:n,byPath:t,label:s}){return t.has(c(n))?e.jsx("span",{className:"text-[10px] font-semibold px-1 rounded bg-sky-500/15 text-sky-700 dark:text-sky-300 flex items-center flex-shrink-0",title:`Newer on ${s}`,children:e.jsx(k,{size:10})}):null}function P({filePath:n}){const t=u(),{check:s,byPath:i}=p(),a=i.get(c(n));if(!s||!a)return null;const r=x(s),o=s.projectPrefix+c(n),l=s.dirtyFiles.includes(o);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-sky-500/30 bg-sky-500/10 text-xs text-gray-700 dark:text-gray-300 flex-shrink-0",children:[e.jsx(m,{size:13,className:"text-sky-600 shrink-0"}),e.jsxs("span",{className:"flex-1 min-w-0",children:[a.author?e.jsxs(e.Fragment,{children:[a.author," changed this file on ",r," ",b(a.timestamp)," — “",a.message,"”."]}):e.jsxs(e.Fragment,{children:["This file has newer changes on ",r,"."]}),l&&" You also have uncommitted edits here."]}),e.jsxs("button",{onClick:()=>t("/git?incoming=1"),className:"px-2 py-1 text-xs rounded bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 flex items-center gap-1 shrink-0",children:[e.jsx(y,{size:12})," View change"]}),e.jsx("button",{onClick:()=>t("/git"),className:`px-2 py-1 text-xs rounded text-white flex items-center gap-1 shrink-0 ${l?"bg-amber-600 hover:bg-amber-500":"bg-emerald-600 hover:bg-emerald-500"}`,children:l?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:12})," Stash, pull & re-apply"]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{size:12})," Pull"]})})]})}function R({filePath:n}){const{check:t,byPath:s}=p();return!t||!s.has(c(n))?null:e.jsxs("span",{className:"text-[9px] font-medium text-sky-700 dark:text-sky-300 bg-sky-500/15 px-1.5 py-0.5 rounded uppercase",children:["Newer on ",x(t)]})}export{v as I,R,P as a,p as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as p,j as e,u as Fe,L as Te}from"./vendor-react-DOVfxdUy.js";import{f as X}from"./formatDate-T65-Y6Mi.js";import{T as he,a as Re,K as Me}from"./KpiTile-BHLE3HVj.js";import{R as O,P as De,m as Be,n as ze,T as H,o as K,B as ge,h as G,X as Q,Y as Z,l as me,j as Ie,L as _e}from"./vendor-charts-By5uZ93z.js";import{y as V,S as Ue,v as Oe,cy as He,a0 as B,a5 as Ke,dk as z,am as Pe,dl as pe,L as We,dm as Ye,_ as qe,ag as Xe,dd as Ge}from"./vendor-icons-D_Dmmj8d.js";import{ae as Qe,bY as Ze,a6 as ue,gN as Je,gO as Ve,gP as et,gQ as tt}from"./index-D6sQYc_0.js";function be({active:t,payload:s,label:a,clickHint:n}){return!t||!s||s.length===0?null:e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-gray-900 shadow-lg px-2.5 py-2 text-xs min-w-[120px]",children:[a!=null&&a!==""&&e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-gray-500 dark:text-gray-400 mb-1.5",children:String(a)}),e.jsx("div",{className:"space-y-1",children:s.map((r,g)=>{var N;const l=r.value,x=String(r.name??r.dataKey??""),S=r.color||((N=r.payload)==null?void 0:N.fill)||"#3B82F6";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{background:S}}),x&&x!=="value"&&e.jsx("span",{className:"text-gray-600 dark:text-gray-300 flex-1 truncate",children:x}),e.jsx("span",{className:"tabular-nums font-semibold text-gray-900 dark:text-gray-100 ml-auto",children:typeof l=="number"?Number.isInteger(l)?l.toLocaleString():l.toFixed(2):String(l??"")})]},g)})}),n&&e.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-gray-100 dark:border-white/10 text-[11px] text-blue-700 dark:text-blue-300",children:n})]})}const ye={vibrant:["#8AB4F8","#F4A0A0","#7DD3AE","#F6C66E","#B3A1EE","#F2A5C7","#7CCFC6","#F7B489","#A2ACF2","#8BCFE6"],pastel:["#93C5FD","#FCA5A5","#6EE7B7","#FCD34D","#C4B5FD","#F9A8D4","#5EEAD4","#FDBA74","#A5B4FC","#67E8F9"]},rt={status:{passed:"#7DD3AE",failed:"#F4A0A0",skipped:"#F6C66E",blocked:"#F7B489",not_run:"#C3C9D2",in_progress:"#8AB4F8"},priority:{critical:"#F4A0A0",high:"#F7B489",medium:"#F6C66E",low:"#8AB4F8"},severity:{blocker:"#EE8F8F",critical:"#F4A0A0",major:"#F6C66E",minor:"#8AB4F8",trivial:"#C3C9D2"}};function fe(t,s,a){if(Array.isArray(a)&&a.length>=t.length&&a.every(g=>typeof g=="string"))return a;const n=ye.vibrant;if(s==="status"||s==="priority"||s==="severity"){const g=rt[s];return t.map((l,x)=>g[String(l).toLowerCase().replace(/\s+/g,"_")]||n[x%n.length])}const r=s==="pastel"?ye.pastel:n;return t.map((g,l)=>r[l%r.length])}const P=t=>s=>{const a=String(s??"");return a.length>t?`${a.slice(0,t-1)}…`:a},ke=t=>(Array.isArray(t)?t:[]).map(s=>typeof s=="number"&&Number.isFinite(s)?s:Number(s)||0);function at({cell:t,height:s=260,onPick:a,clickHint:n}){var v;const r=p.useMemo(()=>{var j;const i=(Array.isArray(t.labels)?t.labels:[]).map(w=>String(w??"")),h=(Array.isArray(t.datasets)?t.datasets:[]).filter(w=>w&&typeof w=="object").map((w,$)=>({label:String(w.label??`Series ${$+1}`),data:ke(w.data)})),y=t.chartType==="pie"||t.chartType==="doughnut",k=Array.isArray(t.data)&&t.data.length>0?ke(t.data):y?(j=h[0])==null?void 0:j.data:void 0;return{...t,labels:i,data:k,datasets:y?void 0:h.length>0?h:void 0}},[t]),g=p.useMemo(()=>fe(r.labels,r.colorScheme,r.colors),[r.labels,r.colorScheme,r.colors]),l=p.useMemo(()=>fe((r.datasets||[]).map(i=>i.label),r.colorScheme,r.colors),[r.datasets,r.colorScheme,r.colors]),x=r.datasets&&r.datasets.length>0?l:g,S=p.useMemo(()=>r.datasets&&r.datasets.length>0?r.labels.map((i,h)=>{const y={label:i};for(const k of r.datasets)y[k.label]=k.data[h]??0;return y}):r.labels.map((i,h)=>{var y;return{label:i,value:((y=r.data)==null?void 0:y[h])??0}}),[r.labels,r.data,r.datasets]),N=((v=r.datasets)==null?void 0:v.map(i=>i.label))??["value"],R=r.labels.reduce((i,h)=>Math.max(i,h.length),0),C={fill:"rgb(107 114 128)",fontSize:11},L="rgba(107,114,128,0.2)",A={stroke:"rgba(107,114,128,0.4)"},M={fill:"rgba(107,114,128,0.08)"},m=p.useMemo(()=>{var w;const i=(((w=r.datasets)==null?void 0:w.flatMap($=>$.data))??r.data??[]).filter($=>Number.isFinite($));if(i.length<2)return;const h=Math.min(...i),y=Math.max(...i),k=Math.max((y-h)*.15,Math.abs(y)*.01,1);return[h>=0?Math.max(0,Math.floor(h-k)):Math.floor(h-k),Math.ceil(y+k)]},[r.data,r.datasets]),o=a?i=>{const h=i==null?void 0:i.activeTooltipIndex;typeof h=="number"&&h>=0&&a(h)}:void 0,u=a?{cursor:"pointer"}:void 0,b=e.jsx(be,{clickHint:a?n:void 0}),f=i=>e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(i??"")}),d={fontSize:11,color:"rgb(107 114 128)",maxHeight:56,overflowY:"auto"};if(r.labels.length===0||!r.datasets&&!(r.data&&r.data.length>0))return e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 p-4 text-center",children:"No data to chart."});switch(r.chartType){case"line":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(Ie,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(Q,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(Z,{tick:C,axisLine:!1,tickLine:!1,domain:m,allowDecimals:!0}),e.jsx(H,{content:b,cursor:A}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(_e,{type:"monotone",dataKey:i,stroke:x[h%x.length],strokeWidth:2,dot:{r:3,fill:x[h%x.length]},activeDot:{r:5}},i))]})});case"bar":case"stacked_bar":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(ge,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(Q,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(Z,{tick:C,axisLine:!1,tickLine:!1}),e.jsx(H,{content:b,cursor:M}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[4,4,0,0],stackId:r.chartType==="stacked_bar"?"s1":void 0},i))]})});case"horizontal_bar":return e.jsx(O,{width:"100%",height:Math.max(s,r.labels.length*28+40),children:e.jsxs(ge,{data:S,layout:"vertical",margin:{top:8,right:24,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L,horizontal:!1}),e.jsx(Q,{type:"number",tick:C,axisLine:!1,tickLine:!1}),e.jsx(Z,{type:"category",dataKey:"label",tick:C,axisLine:!1,tickLine:!1,width:Math.min(180,Math.max(60,R*6.5)),tickFormatter:P(28)}),e.jsx(H,{content:b,cursor:M}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[0,4,4,0]},i))]})});case"pie":case"doughnut":{const i=r.labels.map((k,j)=>{var w;return{name:k,value:((w=r.data)==null?void 0:w[j])??0}}),h=i.reduce((k,j)=>k+(Number(j.value)||0),0),y=(k,j)=>{var I;const w=Number((I=j==null?void 0:j.payload)==null?void 0:I.value)||0,$=h>0?Math.round(w/h*1e3)/10:0;return e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:`${P(28)(k)} · ${$}%`})};return e.jsx(O,{width:"100%",height:s,children:e.jsxs(De,{children:[e.jsx(Be,{data:i,dataKey:"value",nameKey:"name",innerRadius:r.chartType==="doughnut"?"55%":0,outerRadius:"85%",paddingAngle:2,children:i.map((k,j)=>e.jsx(ze,{fill:x[j%x.length],stroke:"transparent"},j))}),e.jsx(H,{content:e.jsx(be,{})}),e.jsx(K,{wrapperStyle:d,formatter:y})]})})}default:return e.jsxs("div",{className:"text-xs text-gray-500 p-4",children:["Unsupported chart type: ",r.chartType]})}}function st(){const t=p.useRef(null),[s,a]=p.useState(0);return p.useEffect(()=>{const n=t.current;if(!n||typeof ResizeObserver>"u")return;const r=new ResizeObserver(g=>{var l;return a(((l=g[0])==null?void 0:l.contentRect.width)??0)});return r.observe(n),a(n.getBoundingClientRect().width),()=>r.disconnect()},[]),[t,s]}function je({spec:t,links:s=!0}){const[a,n]=st(),r=n>0&&n<640,g=Array.isArray(t.cells)?t.cells:[],l=typeof t.method=="string"?t.method.trim():"";return e.jsxs("div",{ref:a,className:"flex flex-col gap-4",children:[t.summary&&e.jsx(nt,{summary:t.summary,narrow:r}),e.jsx("div",{className:"grid grid-cols-12 gap-4",children:g.map((x,S)=>e.jsx(it,{cell:x,narrow:r,links:s},S))}),l&&e.jsxs("details",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-3.5 group","data-testid":"report-method",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-semibold text-gray-800 dark:text-gray-200 list-none flex items-center gap-1.5",children:[e.jsx(V,{size:14,className:"transition-transform group-open:rotate-180","aria-hidden":!0}),"How this was calculated"]}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-gray-700 dark:text-gray-300 whitespace-pre-line",children:l})]})]})}const we={good:{sym:"✓",cls:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300"},warn:{sym:"~",cls:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300"},bad:{sym:"!",cls:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300"},info:{sym:"i",cls:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"}};function nt({summary:t,narrow:s}){const a=Array.isArray(t.findings)?t.findings:[],n=t.status&&he[t.status]?t.status:void 0;return e.jsxs("section",{className:`rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 grid gap-5 ${s||a.length===0?"grid-cols-1":"grid-cols-[minmax(220px,1fr)_minmax(0,2fr)]"}`,"aria-label":"Summary","data-testid":"report-summary",children:[e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[n&&e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${Re[n]}`,children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-current opacity-80","aria-hidden":!0}),he[n]]}),t.verdict&&e.jsx("p",{className:"text-lg leading-snug font-bold text-gray-900 dark:text-gray-100",children:t.verdict}),e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(Ue,{size:13,"aria-hidden":!0})," Summary written by the AI Assistant"]})]}),a.length>0&&e.jsx("ul",{className:"flex flex-col gap-2.5",children:a.map((r,g)=>{const l=we[r.tone]??we.info;return e.jsxs("li",{className:"flex items-start gap-2.5 text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:`mt-0.5 flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-full text-[11px] font-bold ${l.cls}`,"aria-hidden":!0,children:l.sym}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",children:r.title}),r.detail?` ${r.detail}`:""]})]},g)})})]})}function it({cell:t,narrow:s,links:a}){const n=t.type==="kpi"?3:t.type==="chart"?6:12,r=Math.max(1,Math.min(12,Math.round(Number(t.span)||n))),g=s?t.type==="kpi"?6:12:r,l={gridColumn:`span ${g} / span ${g}`};return t.type==="kpi"?e.jsx("div",{style:l,children:e.jsx(Me,{cell:t})}):t.type==="chart"?e.jsx("div",{style:l,children:e.jsx(ot,{cell:t,links:a})}):t.type==="table"?e.jsx("div",{style:l,children:e.jsx(ht,{cell:t,links:a})}):t.type==="markdown"?e.jsx("div",{style:l,children:e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4","data-testid":"report-note",children:e.jsx(gt,{content:String(t.content??"")})})}):null}function ot({cell:t,links:s}){const a=Fe(),n=s&&Array.isArray(t.runIds)&&t.runIds.some(Boolean)?t.runIds:null,r=n?g=>{const l=n[g];l&&a(`/results?runId=${encodeURIComponent(l)}`)}:void 0;return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-chart",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),(t.hint||n)&&e.jsxs("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:[t.hint,t.hint&&n?" ":"",n?"Click a bar or point to open the run.":""]}),e.jsx("div",{className:"mt-3",children:e.jsx(at,{cell:t,onPick:r,clickHint:"Click to open this run in Results"})})]})}const lt=/^(passed|pass|failed|fail|error|skipped|blocked|flaky|open|in progress|resolved|closed|fixed|rejected|never run|not run)(\s*\((?:error|fixed)\))?(?:\s*[—–-]\s+([\s\S]+))?$/i,dt={ok:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",bad:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300",warn:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300",neutral:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"},ct={passed:"ok",pass:"ok",resolved:"ok",closed:"ok",fixed:"ok",failed:"bad",fail:"bad",error:"bad",blocked:"bad",open:"bad",skipped:"warn",flaky:"warn","in progress":"warn"},Ne=/^[-+]?[\d,]+(\.\d+)?\s*(%|ms|s)?$/,xt=/^[A-Za-z0-9._-]{1,120}$/,J=10;function ve(t){const s=t.trim();return Ne.test(s)?Number(s.replace(/[,%\s]|ms|s$/g,"")):null}function ht({cell:t,links:s=!0}){const a=(Array.isArray(t.headers)?t.headers:[]).map(m=>String(m??"")),n=p.useMemo(()=>(Array.isArray(t.rows)?t.rows:[]).map(m=>(Array.isArray(m)?m:[m]).map(o=>String(o??""))),[t.rows]),[r,g]=p.useState(null),[l,x]=p.useState(""),[S,N]=p.useState(!1),R=p.useMemo(()=>a.map((m,o)=>{const u=n.map(b=>(b[o]??"").trim()).filter(Boolean);return u.length>0&&u.every(b=>Ne.test(b))}),[a,n]),C=p.useMemo(()=>{const m=s&&t.columnLinks&&typeof t.columnLinks=="object"?t.columnLinks:{},o=a.findIndex(u=>m[u]==="file");return(u,b)=>{const f=m[a[b]??""],d=(u[b]??"").trim();if(!f||!d)return null;if(f==="run"){const v=d.split(/\s+/)[0]??"";return xt.test(v)?`/results?runId=${encodeURIComponent(v)}`:null}return f==="file"?`/tests?file=${encodeURIComponent(d)}`:f==="test"&&o>=0&&u[o]?`/tests?file=${encodeURIComponent(u[o].trim())}&test=${encodeURIComponent(d)}`:null}},[s,t.columnLinks,a]),L=p.useMemo(()=>{const m=l.trim().toLowerCase();let o=m?n.filter(u=>u.some(b=>b.toLowerCase().includes(m))):n;return r&&(o=[...o].sort((u,b)=>{const f=u[r.col]??"",d=b[r.col]??"",v=ve(f),i=ve(d);return(v!=null&&i!=null?v-i:f.localeCompare(d,void 0,{numeric:!0,sensitivity:"base"}))*r.dir})),o},[n,l,r]),A=S?L:L.slice(0,J),M=m=>g(o=>{const u=R[m]?-1:1;return!o||o.col!==m?{col:m,dir:u}:o.dir===u?{col:m,dir:u===1?-1:1}:null});return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-table",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),t.hint&&e.jsx("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:t.hint})]}),n.length>J&&e.jsxs("label",{className:"flex h-8 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 px-2.5 text-[13px] text-gray-500 dark:text-gray-400",children:[e.jsx(Oe,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:"Filter rows"}),e.jsx("input",{value:l,onChange:m=>{x(m.target.value),N(!1)},placeholder:"Filter rows",className:"w-36 bg-transparent text-[13px] text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-400"})]})]}),e.jsx("div",{className:"mt-3 overflow-x-auto rounded-lg border border-gray-200 dark:border-white/10",children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-gray-50 dark:bg-white/[0.04]",children:a.map((m,o)=>{const u=(r==null?void 0:r.col)===o;return e.jsx("th",{scope:"col","aria-sort":u?r.dir===1?"ascending":"descending":"none",className:`border-b border-gray-200 dark:border-white/10 px-3.5 py-2.5 text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400 whitespace-nowrap ${R[o]?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>M(o),className:"inline-flex items-center gap-1 uppercase hover:text-gray-900 dark:hover:text-gray-200",title:`Sort by ${m}`,children:[m,u&&(r.dir===1?e.jsx(He,{size:12,"aria-hidden":!0}):e.jsx(V,{size:12,"aria-hidden":!0}))]})},o)})})}),e.jsxs("tbody",{children:[A.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:a.length||1,className:"px-3.5 py-6 text-center text-[13px] text-gray-500 dark:text-gray-400",children:n.length===0?"No rows":"No rows match the filter"})}),A.map((m,o)=>e.jsx("tr",{className:"hover:bg-gray-50/70 dark:hover:bg-white/[0.03]",children:a.map((u,b)=>{const f=m[b]??"",d=lt.exec(f.trim()),v=C(m,b);let i=f;if(d){const h=ct[d[1].toLowerCase()]??"neutral";i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${dt[h]}`,children:`${d[1]}${d[2]??""}`.trim()}),d[3]&&e.jsx("span",{className:"ml-1.5 text-gray-500 dark:text-gray-400",children:d[3].trim()})]})}else v&&(i=e.jsx(Te,{to:v,className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",children:f}));return e.jsx("td",{title:f.length>60?f:void 0,className:`border-b border-gray-100 dark:border-white/[0.06] px-3.5 py-2.5 align-top text-gray-800 dark:text-gray-200 ${R[b]?"text-right tabular-nums whitespace-nowrap":""} ${b===0&&!v?"font-medium text-gray-900 dark:text-gray-100":""} max-w-[28rem] break-words`,children:i},b)})},o))]})]})}),L.length>J&&e.jsx("button",{type:"button",onClick:()=>N(m=>!m),className:"mt-2.5 text-[13px] font-medium text-blue-700 dark:text-blue-300 hover:underline",children:S?"Show fewer rows":`Show all ${L.length} rows`})]})}function gt({content:t}){const s=t.split(`
|
|
2
|
-
`),a=[];let n=[];const r=()=>{n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 text-sm text-gray-700 dark:text-gray-300 space-y-1.5 my-2 leading-relaxed",children:n.map((l,x)=>e.jsx("li",{dangerouslySetInnerHTML:{__html:g(l)}},x))},a.length)),n=[])},g=l=>l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/\*\*(.+?)\*\*/g,'<strong class="font-semibold text-gray-900 dark:text-gray-100">$1</strong>').replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 rounded bg-gray-100 dark:bg-white/10 font-mono text-[12px]">$1</code>');for(const l of s){const x=l.trim();if(!x){r();continue}x.startsWith("## ")||x.startsWith("### ")?(r(),a.push(e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.replace(/^#+\s/,""))}},a.length))):x.startsWith("# ")?(r(),a.push(e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.slice(2))}},a.length))):x.startsWith("- ")||x.startsWith("* ")?n.push(x.slice(2)):(r(),a.push(e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 my-1.5 leading-relaxed",dangerouslySetInnerHTML:{__html:g(x)}},a.length)))}return r(),e.jsx(e.Fragment,{children:a})}const mt=[{days:void 0,label:"Never"},{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}];function jt({spec:t,urls:s,savedId:a,initialShareToken:n,initialShareExpiresAt:r,readonly:g=!1,variant:l="card",chips:x,metaLine:S,leadActions:N,trailActions:R,links:C}){const{hasRole:L}=Qe(),A=!g&&L("tester"),[M,m]=p.useState(!1),[o,u]=p.useState(a),[b,f]=p.useState(!1),[d,v]=p.useState(n),[i,h]=p.useState(r),[y,k]=p.useState(!1),[j,w]=p.useState("closed"),[$,I]=p.useState(void 0),[_,U]=p.useState(!1),[ee,te]=p.useState(null),[re,ae]=p.useState(null);p.useEffect(()=>{a&&u(a)},[a]),p.useEffect(()=>{n&&v(n)},[n]),p.useEffect(()=>{r&&h(r)},[r]);const F=c=>{ae(c),setTimeout(()=>ae(null),2600)},D=d?`/reports/share/${d}`:o?`/reports/view/${o}`:(s==null?void 0:s.html)||"",Se=async()=>{if(!D)return;const c=`${window.location.origin}${D}`;try{await navigator.clipboard.writeText(c),m(!0),setTimeout(()=>m(!1),1500)}catch{}},se=async()=>{const c=await tt({title:t.title,spec:t,outputFiles:s?{html:s.html,json:s.json}:void 0});return u(c.id),c.id},ne=async()=>{if(!(o||b)){f(!0);try{await se(),F("Saved to your reports")}catch(c){F(`Save failed: ${c instanceof Error?c.message:String(c)}`)}finally{f(!1)}}},Ce=async()=>{if(!y){k(!0);try{const c=o??await se(),{token:E,shareExpiresAt:Ee}=await Ve(c,$);v(E),h(Ee),w("link"),F("Share link created")}catch(c){F(`Share failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},Ae=async()=>{if(!(!d||!o)){k(!0);try{await et(o),v(void 0),h(void 0),w("closed"),F("Share link revoked")}catch(c){F(`Revoke failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},W=d?`${window.location.origin}/reports/share/${d}`:"",Le=async()=>{if(W)try{await navigator.clipboard.writeText(W),F("Share URL copied")}catch{}},ie=g&&d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:o?Ze(`/api/reports/${encodeURIComponent(o)}/render.html`):d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:s!=null&&s.html?ue(s.html):null,$e=async c=>{U(!1),te(c);try{await Je(c,g&&d?{shareToken:d}:o?{reportId:o}:{spec:t,title:t.title})}catch(E){F(`Download failed: ${E instanceof Error?E.message:String(E)}`)}finally{te(null)}},Y=p.useRef(null);p.useEffect(()=>{if(!_)return;const c=E=>{Y.current&&!Y.current.contains(E.target)&&U(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[_]);const oe="inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",q="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-[13px] font-medium text-gray-800 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",le="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-600 dark:text-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:hover:bg-white/[0.08] dark:hover:text-gray-100 transition-colors",T=l==="page",de=()=>w(c=>c==="closed"?d?"link":"create":"closed"),ce=e.jsxs("div",{className:"relative",ref:Y,children:[e.jsxs("button",{onClick:()=>U(c=>!c),disabled:!!ee,title:"Download","aria-haspopup":"menu","aria-expanded":_,className:T?"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700 transition-colors disabled:opacity-60":q,children:[ee?e.jsx(B,{size:T?15:14,className:"animate-spin"}):e.jsx(Ke,{size:T?15:14}),"Download",e.jsx(V,{size:T?14:13,"aria-hidden":!0})]}),_&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 z-20 w-44 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",children:[ie&&e.jsx("a",{role:"menuitem",href:ie,download:`${t.title||t.id}.html`,onClick:()=>U(!1),className:"block px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([c,E])=>e.jsx("button",{role:"menuitem",onClick:()=>$e(c),className:"w-full text-left px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:E},c))]})]}),xe=e.jsxs(e.Fragment,{children:[A&&j==="create"&&!d&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Anyone with the link can view this report."}),e.jsxs("label",{className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 ml-auto",children:["Expires",e.jsx("select",{value:$??"",onChange:c=>I(c.target.value?Number(c.target.value):void 0),className:"px-1.5 py-0.5 rounded border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.05] text-[12px]",children:mt.map(c=>e.jsx("option",{value:c.days??"",children:c.label},c.label))})]}),e.jsx("button",{onClick:Ce,disabled:y,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Create link"})]}),A&&d&&j==="link"&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 flex-shrink-0",children:"Public link:"}),e.jsx("code",{className:"flex-1 min-w-[12rem] truncate font-mono text-[12px] text-blue-800 dark:text-blue-200 bg-white dark:bg-white/[0.05] border border-blue-200 dark:border-blue-400/20 rounded px-2 py-1",children:W}),e.jsx("span",{className:"text-[12px] text-gray-600 dark:text-gray-400",children:i?`Expires ${X(i)}`:"No expiry"}),e.jsx("button",{onClick:Le,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Copy"}),e.jsxs("button",{onClick:Ae,disabled:y,title:"Revoke this share link",className:"px-2 py-1 rounded-md text-[12px] font-semibold text-rose-700 dark:text-rose-400 hover:bg-rose-500/10 transition-colors flex items-center gap-1",children:[e.jsx(Pe,{size:12})," Revoke"]})]}),re&&e.jsx("div",{role:"status",className:`${T?"rounded-lg mb-4 border border-gray-200 dark:border-white/10":"border-b border-gray-200 dark:border-white/10"} px-5 py-1.5 text-[12px] text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-white/[0.02]`,children:re})]});return T?e.jsxs("div",{children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-4 mb-5","data-testid":"report-header",children:[e.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[x&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x}),e.jsx("h1",{className:"text-[28px] leading-tight font-bold tracking-tight text-gray-900 dark:text-gray-100",children:t.title}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[S,t.subtitle,`Data as of ${X(t.generatedAt)}`].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"report-actions",children:[N,A&&e.jsxs("button",{onClick:de,disabled:y,className:oe,"aria-expanded":j!=="closed",children:[y?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(z,{size:15}),d?"Shared":"Share"]}),A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:oe,children:[b?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(pe,{size:15})," Save"]}),ce,R]})]}),xe,e.jsx(je,{spec:t,links:C??!g})]}):e.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] flex flex-wrap items-start justify-between gap-x-4 gap-y-3","data-testid":"report-card-header",children:[e.jsxs("div",{className:"flex min-w-[16rem] flex-1 items-start gap-3",children:[e.jsx("span",{className:"mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300","aria-hidden":!0,children:e.jsx(We,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("h3",{className:"text-base font-semibold leading-snug text-gray-900 dark:text-gray-100",children:t.title}),o&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-50 px-1.5 py-0.5 text-[11px] font-semibold text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",children:[e.jsx(Ye,{size:11,"aria-hidden":!0})," Saved"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-blue-50 px-1.5 py-0.5 text-[11px] font-semibold text-blue-700 dark:bg-blue-500/15 dark:text-blue-300",children:[e.jsx(z,{size:11,"aria-hidden":!0})," Shared"]})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-gray-600 dark:text-gray-400",children:[t.subtitle,`Data as of ${X(t.generatedAt)}`].filter(Boolean).join(" · ")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:q,title:"Save to your reports",children:[b?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(pe,{size:14})," Save"]}),A&&e.jsxs("button",{onClick:de,disabled:y,"aria-expanded":j!=="closed",title:d?"Public link active — view or revoke":"Create a public share link",className:q,children:[y?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(z,{size:14}),d?"Shared":"Share"]}),ce,D&&e.jsx("a",{href:D.startsWith("/api/")?ue(D):D,target:"_blank",rel:"noopener noreferrer",title:d?"Open shareable full view (new tab)":o?"Open full view (new tab)":"Open HTML snapshot (new tab)","aria-label":"Open full view",className:le,children:e.jsx(qe,{size:14})}),D&&e.jsx("button",{onClick:Se,title:M?"Copied!":d?"Copy share link":o?"Copy link to full view":"Copy HTML snapshot link (signed-in users only)","aria-label":"Copy link",className:le,children:M?e.jsx(Xe,{size:14,className:"text-emerald-600"}):e.jsx(Ge,{size:14})})]})]}),xe,e.jsx("div",{className:"p-4",children:e.jsx(je,{spec:t,links:C??!g})})]})}export{jt as R};
|
|
1
|
+
import{r as p,j as e,u as Fe,L as Te}from"./vendor-react-DOVfxdUy.js";import{f as Y}from"./formatDate-T65-Y6Mi.js";import{T as he,a as Re,K as Me}from"./KpiTile-BKlWqjgN.js";import{R as O,P as De,m as Be,n as ze,T as H,o as K,B as ge,h as G,X as Q,Y as V,l as me,j as Ie,L as _e}from"./vendor-charts-By5uZ93z.js";import{z as J,S as Ue,w as Oe,cB as He,a1 as B,a6 as Ke,dm as z,an as Pe,dn as pe,L as We,dp as qe,$ as Xe,ah as Ye,df as Ge}from"./vendor-icons-Cm92aSc5.js";import{ae as Qe,b$ as Ve,a6 as ue,gU as Ze,gV as Je,gW as et,gX as tt}from"./index-BlA8ntjb.js";function be({active:t,payload:s,label:a,clickHint:n}){return!t||!s||s.length===0?null:e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-gray-900 shadow-lg px-2.5 py-2 text-xs min-w-[120px]",children:[a!=null&&a!==""&&e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-gray-500 dark:text-gray-400 mb-1.5",children:String(a)}),e.jsx("div",{className:"space-y-1",children:s.map((r,g)=>{var N;const l=r.value,x=String(r.name??r.dataKey??""),S=r.color||((N=r.payload)==null?void 0:N.fill)||"#3B82F6";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{background:S}}),x&&x!=="value"&&e.jsx("span",{className:"text-gray-600 dark:text-gray-300 flex-1 truncate",children:x}),e.jsx("span",{className:"tabular-nums font-semibold text-gray-900 dark:text-gray-100 ml-auto",children:typeof l=="number"?Number.isInteger(l)?l.toLocaleString():l.toFixed(2):String(l??"")})]},g)})}),n&&e.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-gray-100 dark:border-white/10 text-[11px] text-blue-700 dark:text-blue-300",children:n})]})}const ye={vibrant:["#8AB4F8","#F4A0A0","#7DD3AE","#F6C66E","#B3A1EE","#F2A5C7","#7CCFC6","#F7B489","#A2ACF2","#8BCFE6"],pastel:["#93C5FD","#FCA5A5","#6EE7B7","#FCD34D","#C4B5FD","#F9A8D4","#5EEAD4","#FDBA74","#A5B4FC","#67E8F9"]},rt={status:{passed:"#7DD3AE",failed:"#F4A0A0",skipped:"#F6C66E",blocked:"#F7B489",not_run:"#C3C9D2",in_progress:"#8AB4F8"},priority:{critical:"#F4A0A0",high:"#F7B489",medium:"#F6C66E",low:"#8AB4F8"},severity:{blocker:"#EE8F8F",critical:"#F4A0A0",major:"#F6C66E",minor:"#8AB4F8",trivial:"#C3C9D2"}};function fe(t,s,a){if(Array.isArray(a)&&a.length>=t.length&&a.every(g=>typeof g=="string"))return a;const n=ye.vibrant;if(s==="status"||s==="priority"||s==="severity"){const g=rt[s];return t.map((l,x)=>g[String(l).toLowerCase().replace(/\s+/g,"_")]||n[x%n.length])}const r=s==="pastel"?ye.pastel:n;return t.map((g,l)=>r[l%r.length])}const P=t=>s=>{const a=String(s??"");return a.length>t?`${a.slice(0,t-1)}…`:a},ke=t=>(Array.isArray(t)?t:[]).map(s=>typeof s=="number"&&Number.isFinite(s)?s:Number(s)||0);function at({cell:t,height:s=260,onPick:a,clickHint:n}){var v;const r=p.useMemo(()=>{var j;const i=(Array.isArray(t.labels)?t.labels:[]).map(w=>String(w??"")),h=(Array.isArray(t.datasets)?t.datasets:[]).filter(w=>w&&typeof w=="object").map((w,$)=>({label:String(w.label??`Series ${$+1}`),data:ke(w.data)})),y=t.chartType==="pie"||t.chartType==="doughnut",k=Array.isArray(t.data)&&t.data.length>0?ke(t.data):y?(j=h[0])==null?void 0:j.data:void 0;return{...t,labels:i,data:k,datasets:y?void 0:h.length>0?h:void 0}},[t]),g=p.useMemo(()=>fe(r.labels,r.colorScheme,r.colors),[r.labels,r.colorScheme,r.colors]),l=p.useMemo(()=>fe((r.datasets||[]).map(i=>i.label),r.colorScheme,r.colors),[r.datasets,r.colorScheme,r.colors]),x=r.datasets&&r.datasets.length>0?l:g,S=p.useMemo(()=>r.datasets&&r.datasets.length>0?r.labels.map((i,h)=>{const y={label:i};for(const k of r.datasets)y[k.label]=k.data[h]??0;return y}):r.labels.map((i,h)=>{var y;return{label:i,value:((y=r.data)==null?void 0:y[h])??0}}),[r.labels,r.data,r.datasets]),N=((v=r.datasets)==null?void 0:v.map(i=>i.label))??["value"],R=r.labels.reduce((i,h)=>Math.max(i,h.length),0),C={fill:"rgb(107 114 128)",fontSize:11},L="rgba(107,114,128,0.2)",A={stroke:"rgba(107,114,128,0.4)"},M={fill:"rgba(107,114,128,0.08)"},m=p.useMemo(()=>{var w;const i=(((w=r.datasets)==null?void 0:w.flatMap($=>$.data))??r.data??[]).filter($=>Number.isFinite($));if(i.length<2)return;const h=Math.min(...i),y=Math.max(...i),k=Math.max((y-h)*.15,Math.abs(y)*.01,1);return[h>=0?Math.max(0,Math.floor(h-k)):Math.floor(h-k),Math.ceil(y+k)]},[r.data,r.datasets]),o=a?i=>{const h=i==null?void 0:i.activeTooltipIndex;typeof h=="number"&&h>=0&&a(h)}:void 0,u=a?{cursor:"pointer"}:void 0,b=e.jsx(be,{clickHint:a?n:void 0}),f=i=>e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(i??"")}),d={fontSize:11,color:"rgb(107 114 128)",maxHeight:56,overflowY:"auto"};if(r.labels.length===0||!r.datasets&&!(r.data&&r.data.length>0))return e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 p-4 text-center",children:"No data to chart."});switch(r.chartType){case"line":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(Ie,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(Q,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(V,{tick:C,axisLine:!1,tickLine:!1,domain:m,allowDecimals:!0}),e.jsx(H,{content:b,cursor:A}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(_e,{type:"monotone",dataKey:i,stroke:x[h%x.length],strokeWidth:2,dot:{r:3,fill:x[h%x.length]},activeDot:{r:5}},i))]})});case"bar":case"stacked_bar":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(ge,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(Q,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(V,{tick:C,axisLine:!1,tickLine:!1}),e.jsx(H,{content:b,cursor:M}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[4,4,0,0],stackId:r.chartType==="stacked_bar"?"s1":void 0},i))]})});case"horizontal_bar":return e.jsx(O,{width:"100%",height:Math.max(s,r.labels.length*28+40),children:e.jsxs(ge,{data:S,layout:"vertical",margin:{top:8,right:24,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L,horizontal:!1}),e.jsx(Q,{type:"number",tick:C,axisLine:!1,tickLine:!1}),e.jsx(V,{type:"category",dataKey:"label",tick:C,axisLine:!1,tickLine:!1,width:Math.min(180,Math.max(60,R*6.5)),tickFormatter:P(28)}),e.jsx(H,{content:b,cursor:M}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[0,4,4,0]},i))]})});case"pie":case"doughnut":{const i=r.labels.map((k,j)=>{var w;return{name:k,value:((w=r.data)==null?void 0:w[j])??0}}),h=i.reduce((k,j)=>k+(Number(j.value)||0),0),y=(k,j)=>{var I;const w=Number((I=j==null?void 0:j.payload)==null?void 0:I.value)||0,$=h>0?Math.round(w/h*1e3)/10:0;return e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:`${P(28)(k)} · ${$}%`})};return e.jsx(O,{width:"100%",height:s,children:e.jsxs(De,{children:[e.jsx(Be,{data:i,dataKey:"value",nameKey:"name",innerRadius:r.chartType==="doughnut"?"55%":0,outerRadius:"85%",paddingAngle:2,children:i.map((k,j)=>e.jsx(ze,{fill:x[j%x.length],stroke:"transparent"},j))}),e.jsx(H,{content:e.jsx(be,{})}),e.jsx(K,{wrapperStyle:d,formatter:y})]})})}default:return e.jsxs("div",{className:"text-xs text-gray-500 p-4",children:["Unsupported chart type: ",r.chartType]})}}function st(){const t=p.useRef(null),[s,a]=p.useState(0);return p.useEffect(()=>{const n=t.current;if(!n||typeof ResizeObserver>"u")return;const r=new ResizeObserver(g=>{var l;return a(((l=g[0])==null?void 0:l.contentRect.width)??0)});return r.observe(n),a(n.getBoundingClientRect().width),()=>r.disconnect()},[]),[t,s]}function je({spec:t,links:s=!0}){const[a,n]=st(),r=n>0&&n<640,g=Array.isArray(t.cells)?t.cells:[],l=typeof t.method=="string"?t.method.trim():"";return e.jsxs("div",{ref:a,className:"flex flex-col gap-4",children:[t.summary&&e.jsx(nt,{summary:t.summary,narrow:r}),e.jsx("div",{className:"grid grid-cols-12 gap-4",children:g.map((x,S)=>e.jsx(it,{cell:x,narrow:r,links:s},S))}),l&&e.jsxs("details",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-3.5 group","data-testid":"report-method",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-semibold text-gray-800 dark:text-gray-200 list-none flex items-center gap-1.5",children:[e.jsx(J,{size:14,className:"transition-transform group-open:rotate-180","aria-hidden":!0}),"How this was calculated"]}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-gray-700 dark:text-gray-300 whitespace-pre-line",children:l})]})]})}const we={good:{sym:"✓",cls:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300"},warn:{sym:"~",cls:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300"},bad:{sym:"!",cls:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300"},info:{sym:"i",cls:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"}};function nt({summary:t,narrow:s}){const a=Array.isArray(t.findings)?t.findings:[],n=t.status&&he[t.status]?t.status:void 0;return e.jsxs("section",{className:`rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 grid gap-5 ${s||a.length===0?"grid-cols-1":"grid-cols-[minmax(220px,1fr)_minmax(0,2fr)]"}`,"aria-label":"Summary","data-testid":"report-summary",children:[e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[n&&e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${Re[n]}`,children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-current opacity-80","aria-hidden":!0}),he[n]]}),t.verdict&&e.jsx("p",{className:"text-lg leading-snug font-bold text-gray-900 dark:text-gray-100",children:t.verdict}),e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(Ue,{size:13,"aria-hidden":!0})," Summary written by the AI Assistant"]})]}),a.length>0&&e.jsx("ul",{className:"flex flex-col gap-2.5",children:a.map((r,g)=>{const l=we[r.tone]??we.info;return e.jsxs("li",{className:"flex items-start gap-2.5 text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:`mt-0.5 flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-full text-[11px] font-bold ${l.cls}`,"aria-hidden":!0,children:l.sym}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",children:r.title}),r.detail?` ${r.detail}`:""]})]},g)})})]})}function it({cell:t,narrow:s,links:a}){const n=t.type==="kpi"?3:t.type==="chart"?6:12,r=Math.max(1,Math.min(12,Math.round(Number(t.span)||n))),g=s?t.type==="kpi"?6:12:r,l={gridColumn:`span ${g} / span ${g}`};return t.type==="kpi"?e.jsx("div",{style:l,children:e.jsx(Me,{cell:t})}):t.type==="chart"?e.jsx("div",{style:l,children:e.jsx(ot,{cell:t,links:a})}):t.type==="table"?e.jsx("div",{style:l,children:e.jsx(ht,{cell:t,links:a})}):t.type==="markdown"?e.jsx("div",{style:l,children:e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4","data-testid":"report-note",children:e.jsx(gt,{content:String(t.content??"")})})}):null}function ot({cell:t,links:s}){const a=Fe(),n=s&&Array.isArray(t.runIds)&&t.runIds.some(Boolean)?t.runIds:null,r=n?g=>{const l=n[g];l&&a(`/results?runId=${encodeURIComponent(l)}`)}:void 0;return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-chart",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),(t.hint||n)&&e.jsxs("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:[t.hint,t.hint&&n?" ":"",n?"Click a bar or point to open the run.":""]}),e.jsx("div",{className:"mt-3",children:e.jsx(at,{cell:t,onPick:r,clickHint:"Click to open this run in Results"})})]})}const lt=/^(passed|pass|failed|fail|error|skipped|blocked|flaky|open|in progress|resolved|closed|fixed|rejected|never run|not run)(\s*\((?:error|fixed)\))?(?:\s*[—–-]\s+([\s\S]+))?$/i,dt={ok:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",bad:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300",warn:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300",neutral:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"},ct={passed:"ok",pass:"ok",resolved:"ok",closed:"ok",fixed:"ok",failed:"bad",fail:"bad",error:"bad",blocked:"bad",open:"bad",skipped:"warn",flaky:"warn","in progress":"warn"},Ne=/^[-+]?[\d,]+(\.\d+)?\s*(%|ms|s)?$/,xt=/^[A-Za-z0-9._-]{1,120}$/,Z=10;function ve(t){const s=t.trim();return Ne.test(s)?Number(s.replace(/[,%\s]|ms|s$/g,"")):null}function ht({cell:t,links:s=!0}){const a=(Array.isArray(t.headers)?t.headers:[]).map(m=>String(m??"")),n=p.useMemo(()=>(Array.isArray(t.rows)?t.rows:[]).map(m=>(Array.isArray(m)?m:[m]).map(o=>String(o??""))),[t.rows]),[r,g]=p.useState(null),[l,x]=p.useState(""),[S,N]=p.useState(!1),R=p.useMemo(()=>a.map((m,o)=>{const u=n.map(b=>(b[o]??"").trim()).filter(Boolean);return u.length>0&&u.every(b=>Ne.test(b))}),[a,n]),C=p.useMemo(()=>{const m=s&&t.columnLinks&&typeof t.columnLinks=="object"?t.columnLinks:{},o=a.findIndex(u=>m[u]==="file");return(u,b)=>{const f=m[a[b]??""],d=(u[b]??"").trim();if(!f||!d)return null;if(f==="run"){const v=d.split(/\s+/)[0]??"";return xt.test(v)?`/results?runId=${encodeURIComponent(v)}`:null}return f==="file"?`/tests?file=${encodeURIComponent(d)}`:f==="test"&&o>=0&&u[o]?`/tests?file=${encodeURIComponent(u[o].trim())}&test=${encodeURIComponent(d)}`:null}},[s,t.columnLinks,a]),L=p.useMemo(()=>{const m=l.trim().toLowerCase();let o=m?n.filter(u=>u.some(b=>b.toLowerCase().includes(m))):n;return r&&(o=[...o].sort((u,b)=>{const f=u[r.col]??"",d=b[r.col]??"",v=ve(f),i=ve(d);return(v!=null&&i!=null?v-i:f.localeCompare(d,void 0,{numeric:!0,sensitivity:"base"}))*r.dir})),o},[n,l,r]),A=S?L:L.slice(0,Z),M=m=>g(o=>{const u=R[m]?-1:1;return!o||o.col!==m?{col:m,dir:u}:o.dir===u?{col:m,dir:u===1?-1:1}:null});return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-table",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),t.hint&&e.jsx("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:t.hint})]}),n.length>Z&&e.jsxs("label",{className:"flex h-8 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 px-2.5 text-[13px] text-gray-500 dark:text-gray-400",children:[e.jsx(Oe,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:"Filter rows"}),e.jsx("input",{value:l,onChange:m=>{x(m.target.value),N(!1)},placeholder:"Filter rows",className:"w-36 bg-transparent text-[13px] text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-400"})]})]}),e.jsx("div",{className:"mt-3 overflow-x-auto rounded-lg border border-gray-200 dark:border-white/10",children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-gray-50 dark:bg-white/[0.04]",children:a.map((m,o)=>{const u=(r==null?void 0:r.col)===o;return e.jsx("th",{scope:"col","aria-sort":u?r.dir===1?"ascending":"descending":"none",className:`border-b border-gray-200 dark:border-white/10 px-3.5 py-2.5 text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400 whitespace-nowrap ${R[o]?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>M(o),className:"inline-flex items-center gap-1 uppercase hover:text-gray-900 dark:hover:text-gray-200",title:`Sort by ${m}`,children:[m,u&&(r.dir===1?e.jsx(He,{size:12,"aria-hidden":!0}):e.jsx(J,{size:12,"aria-hidden":!0}))]})},o)})})}),e.jsxs("tbody",{children:[A.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:a.length||1,className:"px-3.5 py-6 text-center text-[13px] text-gray-500 dark:text-gray-400",children:n.length===0?"No rows":"No rows match the filter"})}),A.map((m,o)=>e.jsx("tr",{className:"hover:bg-gray-50/70 dark:hover:bg-white/[0.03]",children:a.map((u,b)=>{const f=m[b]??"",d=lt.exec(f.trim()),v=C(m,b);let i=f;if(d){const h=ct[d[1].toLowerCase()]??"neutral";i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${dt[h]}`,children:`${d[1]}${d[2]??""}`.trim()}),d[3]&&e.jsx("span",{className:"ml-1.5 text-gray-500 dark:text-gray-400",children:d[3].trim()})]})}else v&&(i=e.jsx(Te,{to:v,className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",children:f}));return e.jsx("td",{title:f.length>60?f:void 0,className:`border-b border-gray-100 dark:border-white/[0.06] px-3.5 py-2.5 align-top text-gray-800 dark:text-gray-200 ${R[b]?"text-right tabular-nums whitespace-nowrap":""} ${b===0&&!v?"font-medium text-gray-900 dark:text-gray-100":""} max-w-[28rem] break-words`,children:i},b)})},o))]})]})}),L.length>Z&&e.jsx("button",{type:"button",onClick:()=>N(m=>!m),className:"mt-2.5 text-[13px] font-medium text-blue-700 dark:text-blue-300 hover:underline",children:S?"Show fewer rows":`Show all ${L.length} rows`})]})}function gt({content:t}){const s=t.split(`
|
|
2
|
+
`),a=[];let n=[];const r=()=>{n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 text-sm text-gray-700 dark:text-gray-300 space-y-1.5 my-2 leading-relaxed",children:n.map((l,x)=>e.jsx("li",{dangerouslySetInnerHTML:{__html:g(l)}},x))},a.length)),n=[])},g=l=>l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/\*\*(.+?)\*\*/g,'<strong class="font-semibold text-gray-900 dark:text-gray-100">$1</strong>').replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 rounded bg-gray-100 dark:bg-white/10 font-mono text-[12px]">$1</code>');for(const l of s){const x=l.trim();if(!x){r();continue}x.startsWith("## ")||x.startsWith("### ")?(r(),a.push(e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.replace(/^#+\s/,""))}},a.length))):x.startsWith("# ")?(r(),a.push(e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.slice(2))}},a.length))):x.startsWith("- ")||x.startsWith("* ")?n.push(x.slice(2)):(r(),a.push(e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 my-1.5 leading-relaxed",dangerouslySetInnerHTML:{__html:g(x)}},a.length)))}return r(),e.jsx(e.Fragment,{children:a})}const mt=[{days:void 0,label:"Never"},{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}];function jt({spec:t,urls:s,savedId:a,initialShareToken:n,initialShareExpiresAt:r,readonly:g=!1,variant:l="card",chips:x,metaLine:S,leadActions:N,trailActions:R,links:C}){const{hasRole:L}=Qe(),A=!g&&L("tester"),[M,m]=p.useState(!1),[o,u]=p.useState(a),[b,f]=p.useState(!1),[d,v]=p.useState(n),[i,h]=p.useState(r),[y,k]=p.useState(!1),[j,w]=p.useState("closed"),[$,I]=p.useState(void 0),[_,U]=p.useState(!1),[ee,te]=p.useState(null),[re,ae]=p.useState(null);p.useEffect(()=>{a&&u(a)},[a]),p.useEffect(()=>{n&&v(n)},[n]),p.useEffect(()=>{r&&h(r)},[r]);const F=c=>{ae(c),setTimeout(()=>ae(null),2600)},D=d?`/reports/share/${d}`:o?`/reports/view/${o}`:(s==null?void 0:s.html)||"",Se=async()=>{if(!D)return;const c=`${window.location.origin}${D}`;try{await navigator.clipboard.writeText(c),m(!0),setTimeout(()=>m(!1),1500)}catch{}},se=async()=>{const c=await tt({title:t.title,spec:t,outputFiles:s?{html:s.html,json:s.json}:void 0});return u(c.id),c.id},ne=async()=>{if(!(o||b)){f(!0);try{await se(),F("Saved to your reports")}catch(c){F(`Save failed: ${c instanceof Error?c.message:String(c)}`)}finally{f(!1)}}},Ce=async()=>{if(!y){k(!0);try{const c=o??await se(),{token:E,shareExpiresAt:Ee}=await Je(c,$);v(E),h(Ee),w("link"),F("Share link created")}catch(c){F(`Share failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},Ae=async()=>{if(!(!d||!o)){k(!0);try{await et(o),v(void 0),h(void 0),w("closed"),F("Share link revoked")}catch(c){F(`Revoke failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},W=d?`${window.location.origin}/reports/share/${d}`:"",Le=async()=>{if(W)try{await navigator.clipboard.writeText(W),F("Share URL copied")}catch{}},ie=g&&d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:o?Ve(`/api/reports/${encodeURIComponent(o)}/render.html`):d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:s!=null&&s.html?ue(s.html):null,$e=async c=>{U(!1),te(c);try{await Ze(c,g&&d?{shareToken:d}:o?{reportId:o}:{spec:t,title:t.title})}catch(E){F(`Download failed: ${E instanceof Error?E.message:String(E)}`)}finally{te(null)}},q=p.useRef(null);p.useEffect(()=>{if(!_)return;const c=E=>{q.current&&!q.current.contains(E.target)&&U(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[_]);const oe="inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",X="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-[13px] font-medium text-gray-800 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",le="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-600 dark:text-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:hover:bg-white/[0.08] dark:hover:text-gray-100 transition-colors",T=l==="page",de=()=>w(c=>c==="closed"?d?"link":"create":"closed"),ce=e.jsxs("div",{className:"relative",ref:q,children:[e.jsxs("button",{onClick:()=>U(c=>!c),disabled:!!ee,title:"Download","aria-haspopup":"menu","aria-expanded":_,className:T?"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700 transition-colors disabled:opacity-60":X,children:[ee?e.jsx(B,{size:T?15:14,className:"animate-spin"}):e.jsx(Ke,{size:T?15:14}),"Download",e.jsx(J,{size:T?14:13,"aria-hidden":!0})]}),_&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 z-20 w-44 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",children:[ie&&e.jsx("a",{role:"menuitem",href:ie,download:`${t.title||t.id}.html`,onClick:()=>U(!1),className:"block px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([c,E])=>e.jsx("button",{role:"menuitem",onClick:()=>$e(c),className:"w-full text-left px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:E},c))]})]}),xe=e.jsxs(e.Fragment,{children:[A&&j==="create"&&!d&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Anyone with the link can view this report."}),e.jsxs("label",{className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 ml-auto",children:["Expires",e.jsx("select",{value:$??"",onChange:c=>I(c.target.value?Number(c.target.value):void 0),className:"px-1.5 py-0.5 rounded border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.05] text-[12px]",children:mt.map(c=>e.jsx("option",{value:c.days??"",children:c.label},c.label))})]}),e.jsx("button",{onClick:Ce,disabled:y,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Create link"})]}),A&&d&&j==="link"&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 flex-shrink-0",children:"Public link:"}),e.jsx("code",{className:"flex-1 min-w-[12rem] truncate font-mono text-[12px] text-blue-800 dark:text-blue-200 bg-white dark:bg-white/[0.05] border border-blue-200 dark:border-blue-400/20 rounded px-2 py-1",children:W}),e.jsx("span",{className:"text-[12px] text-gray-600 dark:text-gray-400",children:i?`Expires ${Y(i)}`:"No expiry"}),e.jsx("button",{onClick:Le,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Copy"}),e.jsxs("button",{onClick:Ae,disabled:y,title:"Revoke this share link",className:"px-2 py-1 rounded-md text-[12px] font-semibold text-rose-700 dark:text-rose-400 hover:bg-rose-500/10 transition-colors flex items-center gap-1",children:[e.jsx(Pe,{size:12})," Revoke"]})]}),re&&e.jsx("div",{role:"status",className:`${T?"rounded-lg mb-4 border border-gray-200 dark:border-white/10":"border-b border-gray-200 dark:border-white/10"} px-5 py-1.5 text-[12px] text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-white/[0.02]`,children:re})]});return T?e.jsxs("div",{children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-4 mb-5","data-testid":"report-header",children:[e.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[x&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x}),e.jsx("h1",{className:"text-[28px] leading-tight font-bold tracking-tight text-gray-900 dark:text-gray-100",children:t.title}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[S,t.subtitle,`Data as of ${Y(t.generatedAt)}`].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"report-actions",children:[N,A&&e.jsxs("button",{onClick:de,disabled:y,className:oe,"aria-expanded":j!=="closed",children:[y?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(z,{size:15}),d?"Shared":"Share"]}),A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:oe,children:[b?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(pe,{size:15})," Save"]}),ce,R]})]}),xe,e.jsx(je,{spec:t,links:C??!g})]}):e.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] flex flex-wrap items-start justify-between gap-x-4 gap-y-3","data-testid":"report-card-header",children:[e.jsxs("div",{className:"flex min-w-[16rem] flex-1 items-start gap-3",children:[e.jsx("span",{className:"mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300","aria-hidden":!0,children:e.jsx(We,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("h3",{className:"text-base font-semibold leading-snug text-gray-900 dark:text-gray-100",children:t.title}),o&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-50 px-1.5 py-0.5 text-[11px] font-semibold text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",children:[e.jsx(qe,{size:11,"aria-hidden":!0})," Saved"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-blue-50 px-1.5 py-0.5 text-[11px] font-semibold text-blue-700 dark:bg-blue-500/15 dark:text-blue-300",children:[e.jsx(z,{size:11,"aria-hidden":!0})," Shared"]})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-gray-600 dark:text-gray-400",children:[t.subtitle,`Data as of ${Y(t.generatedAt)}`].filter(Boolean).join(" · ")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:X,title:"Save to your reports",children:[b?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(pe,{size:14})," Save"]}),A&&e.jsxs("button",{onClick:de,disabled:y,"aria-expanded":j!=="closed",title:d?"Public link active — view or revoke":"Create a public share link",className:X,children:[y?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(z,{size:14}),d?"Shared":"Share"]}),ce,D&&e.jsx("a",{href:D.startsWith("/api/")?ue(D):D,target:"_blank",rel:"noopener noreferrer",title:d?"Open shareable full view (new tab)":o?"Open full view (new tab)":"Open HTML snapshot (new tab)","aria-label":"Open full view",className:le,children:e.jsx(Xe,{size:14})}),D&&e.jsx("button",{onClick:Se,title:M?"Copied!":d?"Copy share link":o?"Copy link to full view":"Copy HTML snapshot link (signed-in users only)","aria-label":"Copy link",className:le,children:M?e.jsx(Ye,{size:14,className:"text-emerald-600"}):e.jsx(Ge,{size:14})})]})]}),xe,e.jsx("div",{className:"p-4",children:e.jsx(je,{spec:t,links:C??!g})})]})}export{jt as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as J,u as K,r as s,j as e,L as C}from"./vendor-react-DOVfxdUy.js";import{b as Q,ae as W,a5 as X,
|
|
1
|
+
import{o as J,u as K,r as s,j as e,L as C}from"./vendor-react-DOVfxdUy.js";import{b as Q,ae as W,a5 as X,iD as Y,iH as Z,iC as _,iE as ee}from"./index-BlA8ntjb.js";import{C as te}from"./ConfirmDialog-D_N9188T.js";import{R as re}from"./ReportCard-LOf1PXlb.js";import{i as se,t as ae,a as ne,s as ie,S as oe}from"./reportMeta-B9ZRW6ts.js";import{a1 as E,ak as z,a as le,a4 as A,bq as D,cx as de,bp as ce,b8 as me,S as ue,R as xe}from"./vendor-icons-Cm92aSc5.js";import"./vendor-query-DkZSMtfn.js";import"./formatDate-T65-Y6Mi.js";import"./KpiTile-BKlWqjgN.js";import"./vendor-charts-By5uZ93z.js";import"./CronBuilder-C7_JADb7.js";const i="inline-flex items-center gap-1.5 rounded-md px-2 py-0.5 text-xs font-semibold",L="inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60";function Se(){var N;const{id:c}=J(),$=K(),a=Q(),I=W().hasRole("tester"),[r,m]=s.useState(null),[o,k]=s.useState([]),[T,u]=s.useState(!0),[n,j]=s.useState(!1),[w,x]=s.useState(null),[P,v]=s.useState(!1),[F,p]=s.useState(!1),[l,d]=s.useState(!1),g=s.useRef(null),R=async t=>{try{const{schedules:y}=await Z();k(y.filter(G=>G.sourceReportId===t))}catch{k([])}},U=async()=>{if(!c){x("No report ID in URL"),u(!1);return}x(null);try{const t=await X(c);m(t),t.mine!==!1&&R(t.id)}catch(t){x(t instanceof Error?t.message:String(t))}finally{u(!1)}};s.useEffect(()=>{u(!0),U()},[c]),s.useEffect(()=>{if(!l)return;const t=y=>{g.current&&!g.current.contains(y.target)&&d(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[l]);const B=async()=>{if(r)try{await _(r.id),a.toast("success","Report deleted"),$("/reports")}catch(t){a.toast("error",`Delete failed: ${t instanceof Error?t.message:String(t)}`)}},M=async()=>{if(!(!r||n)){j(!0);try{const t=await ee(r.id);m(t),a.toast("success","Report refreshed with current data")}catch(t){a.toast("error",`Refresh failed: ${t instanceof Error?t.message:String(t)}`)}finally{j(!1)}}},O=async()=>{if(r){d(!1);try{const t=await Y(r.id,{pinned:!r.pinned});m({...r,pinned:t.pinned}),a.toast("success",t.pinned?"Pinned to the top of Reports":"Unpinned")}catch(t){a.toast("error",`Pin failed: ${t instanceof Error?t.message:String(t)}`)}}};if(T)return e.jsxs("div",{className:"p-6 flex items-center justify-center text-sm text-gray-600 dark:text-gray-400 gap-2",children:[e.jsx(E,{size:14,className:"animate-spin"})," Loading report…"]});if(w||!r)return e.jsxs("div",{className:"p-6 max-w-2xl mx-auto",children:[e.jsxs(C,{to:"/reports",className:"inline-flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 mb-4",children:[e.jsx(z,{size:15})," Reports"]}),e.jsxs("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/5 p-6 text-center",children:[e.jsx(le,{size:24,className:"text-rose-500 mx-auto mb-3"}),e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Could not load report"}),e.jsx("div",{className:"text-[13px] text-gray-600 dark:text-gray-400",children:w||"Report not found"})]})]});const h=r.mine!==!1,S=I&&h,b=(N=r.spec)==null?void 0:N.generatedAt,f=se(b,r.templateId),q=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`${i} bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300`,children:ae(r.templateId)}),b&&e.jsxs("span",{className:`${i} ${f?"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300":"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300"}`,title:f?"The data is out of date — Refresh data rebuilds it from current results":void 0,children:["Updated ",ne(b),f?" · out of date":""]}),o.map(t=>e.jsxs("span",{className:`${i} bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300`,children:[e.jsx(A,{size:12,"aria-hidden":!0})," ",ie(t)]},t.id)),r.pinned&&e.jsxs("span",{className:`${i} bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300`,children:[e.jsx(D,{size:12,"aria-hidden":!0})," Pinned"]}),!h&&r.sharedByName&&e.jsxs("span",{className:`${i} bg-blue-50 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300`,"data-testid":"report-shared-by",children:["Shared by ",r.sharedByName]})]}),H=S?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:M,disabled:n,className:L,title:"The AI rebuilds this report from current data — same layout, new numbers. Takes 30 seconds to 2 minutes and uses AI credits.",children:[n?e.jsx(E,{size:15,className:"animate-spin"}):e.jsx(xe,{size:15}),n?"Refreshing…":"Refresh data"]}),e.jsxs("button",{onClick:()=>p(!0),className:L,title:"Email this report on a schedule",children:[e.jsx(A,{size:15})," Schedule"]})]}):null,V=S?e.jsxs("div",{className:"relative",ref:g,children:[e.jsx("button",{onClick:()=>d(t=>!t),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/[0.08]","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":l,children:e.jsx(de,{size:16})}),l&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 z-20 w-44 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",children:[e.jsxs("button",{role:"menuitem",onClick:O,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:[r.pinned?e.jsx(ce,{size:14}):e.jsx(D,{size:14})," ",r.pinned?"Unpin":"Pin to top"]}),e.jsxs("button",{role:"menuitem",onClick:()=>{d(!1),v(!0)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-rose-700 dark:text-rose-400 hover:bg-rose-500/10",children:[e.jsx(me,{size:14})," Delete"]})]})]}):null;return e.jsxs("div",{className:"p-6 max-w-[1360px] mx-auto",children:[e.jsxs(C,{to:"/reports",className:"inline-flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 mb-4",children:[e.jsx(z,{size:15})," Reports"]}),n&&e.jsxs("div",{role:"status",className:"mb-4 flex items-center gap-2 rounded-xl border border-blue-200 dark:border-blue-400/20 bg-blue-50/70 dark:bg-blue-500/10 px-4 py-2.5 text-[13px] text-blue-900 dark:text-blue-200",children:[e.jsx(ue,{size:14,"aria-hidden":!0})," The AI is rebuilding this report from current data — same layout, new numbers. This takes 30 seconds to 2 minutes."]}),e.jsx(re,{variant:"page",spec:r.spec,urls:r.outputFiles,savedId:r.id,initialShareToken:r.shareToken,initialShareExpiresAt:r.shareExpiresAt,readonly:!h,links:!0,chips:q,leadActions:H,trailActions:V}),F&&e.jsx(oe,{reports:[r],editing:null,initialReportId:r.id,onClose:()=>p(!1),onSaved:async()=>{p(!1),await R(r.id)}}),e.jsx(te,{open:P,title:"Delete report?",description:`"${r.title}" will be permanently deleted. Any active share link will stop working.`+(o.length>0?` ${o.length} scheduled email${o.length===1?"":"s"} for this report will also be removed.`:""),confirmLabel:"Delete",onConfirm:B,onCancel:()=>v(!1)})]})}export{Se as ReportFullView};
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import{r as o,j as e,L as V,u as W,e as Ie}from"./vendor-react-DOVfxdUy.js";import{f as le}from"./formatDate-T65-Y6Mi.js";import{s as Le}from"./visibleInterval-BKsLfJZ3.js";import{b as Y,ae as X,iu as ze,bY as Pe,gP as De,gO as Fe,iv as _e,gN as Oe,iw as Be,ix as me,iy as Me,iz as ue,iA as Ue,iB as qe,iC as Ke}from"./index-D6sQYc_0.js";import{C as pe}from"./ConfirmDialog-DtotgVmI.js";import{t as L,i as J,S as ge,s as be,a as Qe}from"./reportMeta-3kxT7BIT.js";import{h as ye}from"./aiHandoff-vhtR29Fh.js";import{s as Ve}from"./KpiTile-BHLE3HVj.js";import{a0 as z,i as Z,S as U,v as He,c7 as Ge,c8 as We,bp as ee,R as te,a3 as F,dk as ae,a5 as Ye,y as fe,cu as Xe,bo as Je,b7 as je,b4 as Ze,ag as ie,X as et,a2 as tt}from"./vendor-icons-D_Dmmj8d.js";import"./vendor-query-DkZSMtfn.js";import"./CronBuilder-D2fERHt9.js";const oe="testver-reports-view",H={good:"text-emerald-700 dark:text-emerald-400",bad:"text-rose-700 dark:text-rose-400",warn:"text-amber-700 dark:text-amber-400",flat:"text-gray-600 dark:text-gray-400"},de={good:"#059669",bad:"#dc2626",warn:"#d97706",flat:"#94a3b8"},G="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3 text-[13px] font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",se="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",Q="h-9 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-sm text-gray-900 dark:text-gray-100",M="flex flex-col gap-1 text-xs font-semibold text-gray-600 dark:text-gray-400";function ce({shared:t,reports:n,schedules:a,loading:l,reload:i,onNewReport:x,onBrowseTemplates:d}){var re;const c=Y(),g=X().hasRole("tester"),[N,C]=o.useState(""),[w,S]=o.useState("all"),[k,b]=o.useState("any"),[R,A]=o.useState("updated"),[y,v]=o.useState(()=>{try{return localStorage.getItem(oe)==="list"?"list":"grid"}catch{return"grid"}}),[m,f]=o.useState(null),[p,r]=o.useState(null),[h,$]=o.useState(null);o.useEffect(()=>{try{localStorage.setItem(oe,y)}catch{}},[y]);const _=o.useMemo(()=>{const s=new Map;for(const u of a)s.set(u.sourceReportId,[...s.get(u.sourceReportId)??[],u]);return s},[a]),Te=o.useMemo(()=>[...new Set(n.map(s=>s.templateId||""))].sort((s,u)=>L(s).localeCompare(L(u))),[n]),P=o.useMemo(()=>{const s=N.trim().toLowerCase(),u=n.filter(j=>{var T,ne;if(s&&!`${j.title} ${L(j.templateId)} ${((T=j.preview)==null?void 0:T.verdict)??""}`.toLowerCase().includes(s)||w!=="all"&&(j.templateId||"")!==w)return!1;if(k!=="any"){const Ee=J((ne=j.preview)==null?void 0:ne.generatedAt,j.templateId);if(k==="stale"!==Ee)return!1}return!0}),E=j=>{var T;return((T=j.preview)==null?void 0:T.generatedAt)||j.updatedAt||""};return u.sort((j,T)=>R==="name"?j.title.localeCompare(T.title):R==="data"?E(T).localeCompare(E(j)):(T.updatedAt||"").localeCompare(j.updatedAt||""))},[n,N,w,k,R]),O=t?[]:P.filter(s=>s.pinned),q=t?P:P.filter(s=>!s.pinned),Ae=!!N.trim()||w!=="all"||k!=="any",Ce=s=>g&&s.mine!==!1,B=async(s,u)=>{f(s);try{await u()}finally{f(null)}},D=s=>s instanceof Error?s.message:String(s),K={canChange:Ce,busy:m,schedulesOf:s=>_.get(s.id)??[],refresh:s=>B(`${s.id}:refresh`,async()=>{try{await Be(s.id),c.toast("success",`"${s.title}" refreshed with current data`),await i()}catch(u){c.toast("error",`Refresh failed: ${D(u)}`)}}),exportAs:(s,u)=>B(`${s.id}:${u}`,async()=>{try{await Oe(u,{reportId:s.id})}catch(E){c.toast("error",`Download failed: ${D(E)}`)}}),togglePin:s=>B(`${s.id}:pin`,async()=>{try{await _e(s.id,{pinned:!s.pinned}),await i()}catch(u){c.toast("error",`Pin failed: ${D(u)}`)}}),toggleShare:s=>B(`${s.id}:share`,async()=>{try{if(s.shareToken)await De(s.id),c.toast("success","Share link revoked");else{const{shareUrl:u}=await Fe(s.id),E=`${window.location.origin}${u}`;try{await navigator.clipboard.writeText(E)}catch{}c.toast("success",`Share link copied: ${E}`)}await i()}catch(u){c.toast("error",`Share failed: ${D(u)}`)}}),schedule:s=>$(s),remove:s=>r(s)},$e=async()=>{if(p)try{await ze(p.id),r(null),c.toast("success","Report deleted"),await i()}catch(s){c.toast("error",`Delete failed: ${D(s)}`)}};return l?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 py-10 justify-center",children:[e.jsx(z,{size:14,className:"animate-spin"})," Loading reports…"]}):n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.02] px-6 py-14 text-center",children:[e.jsx(Z,{size:30,className:"mx-auto mb-3 text-gray-400","aria-hidden":!0}),e.jsx("p",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t?"No shared reports yet":"No saved reports yet"}),e.jsx("p",{className:"mt-1.5 text-sm text-gray-600 dark:text-gray-400 max-w-lg mx-auto",children:t?"Reports anyone in this workspace shares with a public link appear here, for every role.":"Ask the AI Assistant for a report in Reporting mode, then save it with the bookmark button on the report — or start from a template."}),!t&&g&&e.jsxs("div",{className:"mt-5 flex justify-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:x,className:"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-4 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(U,{size:15})," New report with AI"]}),e.jsx("button",{onClick:d,className:"inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 px-4 text-sm font-medium text-gray-900 dark:text-gray-100",children:"Browse templates"})]})]}):e.jsxs("div",{className:"flex flex-col gap-5","data-testid":"report-library",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3","data-testid":"report-toolbar",children:[e.jsxs("label",{className:`${M} flex-[1_1_260px]`,children:["Search",e.jsxs("span",{className:"flex h-9 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5",children:[e.jsx(He,{size:15,className:"text-gray-500","aria-hidden":!0}),e.jsx("input",{type:"search",value:N,onChange:s=>C(s.target.value),placeholder:"Search reports",className:"w-full bg-transparent text-sm font-normal text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-500"})]})]}),e.jsxs("label",{className:M,children:["Template",e.jsxs("select",{value:w,onChange:s=>S(s.target.value),className:Q,children:[e.jsx("option",{value:"all",children:"All templates"}),Te.map(s=>e.jsx("option",{value:s,children:L(s)},s||"custom"))]})]}),e.jsxs("label",{className:M,children:["Updated",e.jsxs("select",{value:k,onChange:s=>b(s.target.value),className:Q,children:[e.jsx("option",{value:"any",children:"Any time"}),e.jsx("option",{value:"fresh",children:"Up to date"}),e.jsx("option",{value:"stale",children:"Out of date"})]})]}),e.jsxs("label",{className:M,children:["Sort",e.jsxs("select",{value:R,onChange:s=>A(s.target.value),className:Q,children:[e.jsx("option",{value:"updated",children:"Recently changed"}),e.jsx("option",{value:"data",children:"Newest data"}),e.jsx("option",{value:"name",children:"Name"})]})]}),e.jsxs("div",{role:"group","aria-label":"View",className:"flex h-9 overflow-hidden rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04]",children:[e.jsx("button",{"aria-label":"Grid view","aria-pressed":y==="grid",onClick:()=>v("grid"),className:`flex w-9 items-center justify-center ${y==="grid"?"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-100":"text-gray-500"}`,children:e.jsx(Ge,{size:15})}),e.jsx("button",{"aria-label":"List view","aria-pressed":y==="list",onClick:()=>v("list"),className:`flex w-9 items-center justify-center ${y==="list"?"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-100":"text-gray-500"}`,children:e.jsx(We,{size:15})})]})]}),P.length===0&&e.jsxs("p",{className:"py-10 text-center text-sm text-gray-600 dark:text-gray-400",children:["No reports match",Ae?" these filters":"","."," ",e.jsx("button",{className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",onClick:()=>{C(""),S("all"),b("any")},children:"Clear filters"})]}),y==="list"?P.length>0&&e.jsx(st,{reports:[...O,...q],actions:K}):e.jsxs(e.Fragment,{children:[O.length>0&&e.jsxs("section",{className:"flex flex-col gap-3","aria-label":"Pinned reports",children:[e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-gray-600 dark:text-gray-400",children:"Pinned"}),e.jsx("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,420px),1fr))]",children:O.map(s=>e.jsx(he,{report:s,actions:K,large:!0},s.id))})]}),q.length>0&&e.jsxs("section",{className:"flex flex-col gap-3","aria-label":t?"Shared reports":"All reports",children:[O.length>0&&e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-gray-600 dark:text-gray-400",children:"All reports"}),e.jsx("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,300px),1fr))]",children:q.map(s=>e.jsx(he,{report:s,actions:K},s.id))})]})]}),h&&e.jsx(ge,{reports:[h],editing:null,initialReportId:h.id,onClose:()=>$(null),onSaved:async()=>{$(null),await i()}}),e.jsx(pe,{open:!!p,title:"Delete report?",description:`"${p==null?void 0:p.title}" will be permanently deleted. Any active share link will stop working.`+(p&&(((re=_.get(p.id))==null?void 0:re.length)??0)>0?` ${_.get(p.id).length} scheduled email${_.get(p.id).length===1?"":"s"} for this report will also be removed.`:""),confirmLabel:"Delete",onConfirm:$e,onCancel:()=>r(null)})]})}function we({report:t}){var l,i;const n=((l=t.preview)==null?void 0:l.generatedAt)||t.updatedAt,a=J((i=t.preview)==null?void 0:i.generatedAt,t.templateId);return e.jsxs("span",{className:`inline-flex items-center gap-1.5 ${a?"font-medium text-amber-700 dark:text-amber-400":""}`,title:a?"Out of date — Refresh rebuilds it from current results":void 0,children:[e.jsx("span",{className:`h-[7px] w-[7px] rounded-full ${a?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":!0}),"Updated ",Qe(n),a?" · out of date":""]})}function xe({preview:t,height:n}){var x,d;const a=t!=null&&t.trend?Ve(t.trend,160,n,5):"";if(!a)return null;const l=(t==null?void 0:t.status)??((x=t==null?void 0:t.kpis[0])==null?void 0:x.status)??((d=t==null?void 0:t.kpis[0])==null?void 0:d.tone)??"good",i=de[l]??de.good;return e.jsxs("svg",{viewBox:`0 0 160 ${n}`,preserveAspectRatio:"none",className:"block w-full",style:{height:n},role:"img","aria-label":"Trend",children:[e.jsx("polygon",{points:`0,${n} ${a} 160,${n}`,fill:i,fillOpacity:.1}),e.jsx("polyline",{points:a,fill:"none",stroke:i,strokeWidth:2,vectorEffect:"non-scaling-stroke",strokeLinejoin:"round"})]})}function at({preview:t,size:n}){const a=(t==null?void 0:t.kpis)??[];return a.length===0?t!=null&&t.verdict?e.jsx("p",{className:"text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:t.verdict}):e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Open the report to see it."}):e.jsx("div",{className:"grid grid-cols-3 gap-3",children:a.map((l,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-xs text-gray-600 dark:text-gray-400",title:l.title,children:l.title}),e.jsx("p",{className:`truncate font-bold tabular-nums text-gray-900 dark:text-gray-100 ${n==="lg"?"text-xl":"text-[17px]"} ${l.status?H[l.status]:""}`,title:l.value,children:l.value}),l.delta&&e.jsx("p",{className:`text-xs font-semibold ${H[l.tone]??""}`,children:l.delta})]},i))})}function he({report:t,actions:n,large:a=!1}){var c;const l=n.canChange(t),i=n.schedulesOf(t),x=J((c=t.preview)==null?void 0:c.generatedAt,t.templateId),d=n.busy===`${t.id}:refresh`;return e.jsxs("article",{className:"flex flex-col rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03]","data-testid":"report-card",children:[e.jsxs("div",{className:`flex flex-col gap-2 ${a?"px-5 pt-5":"px-4 pt-4"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"rounded-md bg-gray-100 dark:bg-white/10 px-2 py-0.5 text-xs font-semibold text-gray-700 dark:text-gray-300",children:L(t.templateId)}),t.pinned&&e.jsx(ee,{size:15,className:"text-amber-600","aria-label":"Pinned"})]}),e.jsx("h3",{className:`font-bold text-gray-900 dark:text-gray-100 ${a?"text-lg":"text-base"}`,children:e.jsx(V,{to:`/reports/view/${t.id}`,className:"hover:underline",children:t.title})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-gray-600 dark:text-gray-400",children:[e.jsx(we,{report:t}),i.map(g=>e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(F,{size:12,"aria-hidden":!0})," ",be(g)]},g.id))]})]}),e.jsxs("div",{className:`grid items-end gap-3 ${a?"grid-cols-[minmax(0,3fr)_minmax(0,1.2fr)] px-5 py-4":"grid-cols-1 px-4 pt-3.5 pb-1"}`,children:[e.jsx(at,{preview:t.preview,size:a?"lg":"md"}),a&&e.jsx(xe,{preview:t.preview,height:48})]}),!a&&e.jsx(xe,{preview:t.preview,height:40}),e.jsxs("div",{className:`mt-auto flex flex-wrap items-center gap-2 border-t border-gray-100 dark:border-white/[0.06] ${a?"px-5 py-3":"px-4 py-2.5"}`,children:[e.jsx(V,{to:`/reports/view/${t.id}`,className:`${G} ${a?"":"flex-1 justify-center"} !bg-brand-600 !text-white !border-brand-600 hover:!bg-brand-700`,children:"Open"}),l&&e.jsxs("button",{onClick:()=>n.refresh(t),disabled:d,className:`${G} ${x?"!border-amber-300 !bg-amber-50 !text-amber-800 dark:!bg-amber-500/15 dark:!text-amber-300 dark:!border-amber-400/30":""}`,title:"The AI rebuilds this report from current data (30 seconds to 2 minutes; uses AI credits)",children:[d?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(te,{size:14}),d?"Refreshing…":x?"Refresh now":"Refresh"]}),e.jsx(Ne,{report:t,actions:n,compact:!a}),l&&e.jsx(Se,{report:t,actions:n}),t.shareToken&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 rounded-md bg-emerald-50 dark:bg-emerald-500/15 px-2 py-0.5 text-xs font-semibold text-emerald-700 dark:text-emerald-300","data-testid":"report-shared-by",children:[e.jsx(ae,{size:11,"aria-hidden":!0}),t.mine===!1?`Shared${t.sharedByName?` by ${t.sharedByName}`:""}`:`Shared link · ${t.shareViews??0} view${t.shareViews===1?"":"s"}`]})]})]})}function st({reports:t,actions:n}){return e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03]",children:e.jsxs("table",{className:"w-full min-w-[900px] border-collapse text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 dark:bg-white/[0.04] text-left text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400",children:[e.jsx("th",{className:"px-4 py-2.5",children:"Report"}),e.jsx("th",{className:"px-4 py-2.5",children:"Headline"}),e.jsx("th",{className:"px-4 py-2.5",children:"Updated"}),e.jsx("th",{className:"px-4 py-2.5",children:"Schedule"}),e.jsx("th",{className:"px-4 py-2.5 text-right",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(a=>{var x;const l=(x=a.preview)==null?void 0:x.kpis[0],i=n.schedulesOf(a);return e.jsxs("tr",{className:"border-t border-gray-100 dark:border-white/[0.06] align-middle","data-testid":"report-row",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[a.pinned&&e.jsx(ee,{size:13,className:"text-amber-600 flex-shrink-0","aria-label":"Pinned"}),e.jsx(V,{to:`/reports/view/${a.id}`,className:"font-semibold text-gray-900 dark:text-gray-100 hover:underline",children:a.title})]}),e.jsxs("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-400",children:[L(a.templateId),a.shareToken?" · shared":""]})]}),e.jsx("td",{className:"px-4 py-3",children:l?e.jsxs("span",{className:"tabular-nums",children:[e.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[l.title," "]}),e.jsx("strong",{className:"text-gray-900 dark:text-gray-100",children:l.value}),l.delta&&e.jsx("span",{className:`ml-1.5 text-xs font-semibold ${H[l.tone]??""}`,children:l.delta})]}):e.jsx("span",{className:"text-gray-500",children:"—"})}),e.jsx("td",{className:"px-4 py-3 text-[13px] text-gray-600 dark:text-gray-400 whitespace-nowrap",children:e.jsx(we,{report:a})}),e.jsx("td",{className:"px-4 py-3 text-[13px] text-gray-600 dark:text-gray-400",children:i.length?i.map(be).join("; "):"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex justify-end gap-1.5",children:[n.canChange(a)&&e.jsx("button",{onClick:()=>n.refresh(a),disabled:n.busy===`${a.id}:refresh`,className:se,"aria-label":"Refresh data",title:"Refresh data",children:n.busy===`${a.id}:refresh`?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(te,{size:14})}),e.jsx(Ne,{report:a,actions:n,compact:!0}),n.canChange(a)&&e.jsx(Se,{report:a,actions:n})]})})]},a.id)})})]})})}function ke(){const[t,n]=o.useState(!1),a=o.useRef(null);return o.useEffect(()=>{if(!t)return;const l=x=>{a.current&&!a.current.contains(x.target)&&n(!1)},i=x=>{x.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",i)}},[t]),{open:t,setOpen:n,ref:a}}const ve="absolute right-0 top-full mt-1 z-20 w-48 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",I="w-full flex items-center gap-2 px-3 py-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5";function Ne({report:t,actions:n,compact:a=!1}){const{open:l,setOpen:i,ref:x}=ke(),d=!!n.busy&&n.busy.startsWith(`${t.id}:`)&&/:(pdf|docx|xlsx)$/.test(n.busy),c=t.mine===!1&&t.shareToken?`/api/reports/share/${encodeURIComponent(t.shareToken)}/render.html`:Pe(`/api/reports/${encodeURIComponent(t.id)}/render.html`);return e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>i(g=>!g),className:a?se:G,"aria-label":"Download","aria-haspopup":"menu","aria-expanded":l,disabled:d,children:[d?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14}),!a&&e.jsxs(e.Fragment,{children:["Download ",e.jsx(fe,{size:13,"aria-hidden":!0})]})]}),l&&e.jsxs("div",{role:"menu",className:ve,children:[e.jsx("a",{role:"menuitem",href:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>i(!1),className:I,children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([g,N])=>e.jsx("button",{role:"menuitem",className:I,onClick:()=>{i(!1),n.exportAs(t,g)},children:N},g))]})]})}function Se({report:t,actions:n}){const{open:a,setOpen:l,ref:i}=ke(),x=W(),d=c=>()=>{l(!1),c()};return e.jsxs("div",{className:"relative",ref:i,children:[e.jsx("button",{onClick:()=>l(c=>!c),className:se,"aria-label":"More actions","aria-haspopup":"menu","aria-expanded":a,children:e.jsx(Xe,{size:15})}),a&&e.jsxs("div",{role:"menu",className:ve,children:[e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>x(`/reports/view/${t.id}`)),children:[e.jsx(Z,{size:14})," Open"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>void n.togglePin(t)),children:[t.pinned?e.jsx(Je,{size:14}):e.jsx(ee,{size:14})," ",t.pinned?"Unpin":"Pin to top"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>void n.toggleShare(t)),children:[e.jsx(ae,{size:14})," ",t.shareToken?"Revoke share link":"Copy a share link"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>n.schedule(t)),children:[e.jsx(F,{size:14})," Schedule email…"]}),e.jsxs("button",{role:"menuitem",className:`${I} !text-rose-700 dark:!text-rose-400`,onClick:d(()=>n.remove(t)),children:[e.jsx(je,{size:14})," Delete"]})]})]})}const rt=["my","shared","scheduled","templates"];function yt(){const t=W(),n=Y(),a=X().hasRole("tester"),[l,i]=Ie(),x=l.get("tab"),d=x&&rt.includes(x)?x:"my",c=m=>i(f=>{const p=new URLSearchParams(f);return m==="my"?p.delete("tab"):p.set("tab",m),p},{replace:!0}),[g,N]=o.useState([]),[C,w]=o.useState([]),[S,k]=o.useState([]),[b,R]=o.useState(!0),A=async()=>{try{const[m,f,p]=await Promise.all([me(),Me(),ue().catch(()=>({schedules:[],count:0}))]);N(m.reports),w(f.reports),k(p.schedules)}catch(m){n.toast("error",`Load failed: ${m instanceof Error?m.message:String(m)}`)}finally{R(!1)}};o.useEffect(()=>{A()},[d]);const y=()=>ye(t,{mode:"reporting"}),v=[{id:"my",label:"My reports",Icon:Z,count:b?null:g.length},{id:"shared",label:"Shared",Icon:ae,count:b?null:C.length},{id:"scheduled",label:"Scheduled",Icon:F,count:b?null:S.length},{id:"templates",label:"Templates",Icon:U,count:Re.length}];return e.jsxs("div",{className:"p-6 max-w-[1360px] mx-auto flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[26px] font-bold tracking-tight text-gray-900 dark:text-gray-100",children:"Reports"}),e.jsxs("p",{className:"mt-1.5 text-sm text-gray-600 dark:text-gray-400 max-w-3xl",children:["Dashboards built by the AI Assistant in Reporting mode. Refresh, share, schedule or download any of them."," ",e.jsx("strong",{className:"font-semibold text-gray-800 dark:text-gray-200",children:"Shared"})," lists every report with a public link in this workspace — anyone signed in can open it."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>c("scheduled"),className:"inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08]",children:[e.jsx(F,{size:15})," Schedules"]}),a&&e.jsxs("button",{onClick:y,className:"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(U,{size:15})," New report with AI"]})]})]}),e.jsx("div",{role:"tablist",className:"flex gap-6 overflow-x-auto border-b border-gray-200 dark:border-white/10","data-testid":"report-tabs",children:v.map(m=>{const f=d===m.id;return e.jsxs("button",{role:"tab","aria-selected":f,onClick:()=>c(m.id),className:`flex h-10 flex-shrink-0 items-center gap-2 whitespace-nowrap border-b-2 px-0.5 text-sm transition-colors ${f?"border-gray-900 dark:border-gray-100 font-semibold text-gray-900 dark:text-gray-100":"border-transparent font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[e.jsx(m.Icon,{size:15,"aria-hidden":!0,className:f?"":"opacity-80"}),m.label,m.count!=null&&e.jsx("span",{className:`min-w-[22px] rounded-full px-2 py-px text-center text-xs font-semibold tabular-nums ${f?"bg-brand-600 text-white dark:bg-white dark:text-gray-900":"bg-gray-200 text-gray-700 dark:bg-white/10 dark:text-gray-300"}`,children:m.count})]},m.id)})}),d==="my"&&e.jsx(ce,{shared:!1,reports:g,schedules:S,loading:b,reload:A,onNewReport:y,onBrowseTemplates:()=>c("templates")}),d==="shared"&&e.jsx(ce,{shared:!0,reports:C,schedules:S,loading:b,reload:A,onNewReport:y,onBrowseTemplates:()=>c("templates")}),d==="scheduled"&&e.jsx(nt,{}),d==="templates"&&e.jsx(lt,{})]})}function nt(){const t=Y(),n=X().hasRole("tester"),[a,l]=o.useState([]),[i,x]=o.useState([]),[d,c]=o.useState(!0),[g,N]=o.useState(!1),[C,w]=o.useState(null),[S,k]=o.useState(!1),[b,R]=o.useState(null),[A,y]=o.useState(null),v=async r=>{r!=null&&r.initial?c(!0):r!=null&&r.silent||N(!0);try{const[h,$]=await Promise.all([ue(),me()]);l(h.schedules),x($.reports)}catch(h){r!=null&&r.silent||t.toast("error",`Load failed: ${h instanceof Error?h.message:String(h)}`)}finally{c(!1),N(!1)}};o.useEffect(()=>{v({initial:!0})},[]),o.useEffect(()=>{if(!(S||b))return Le(()=>{v({silent:!0})},2e4)},[S,b]);const m=async r=>{try{await qe(r.id,{enabled:!r.enabled}),await v()}catch(h){t.toast("error",`Update failed: ${h instanceof Error?h.message:String(h)}`)}},f=async r=>{y(r.id);try{const h=await Ue(r.id);h.success?t.toast("success","Dispatch succeeded"):t.toast("error",`Dispatch failed: ${h.error||"unknown"}`),await v()}catch(h){t.toast("error",`Run failed: ${h instanceof Error?h.message:String(h)}`)}finally{y(null)}},p=async()=>{if(b)try{await Ke(b.id),t.toast("success","Schedule deleted"),R(null),await v()}catch(r){t.toast("error",`Delete failed: ${r instanceof Error?r.message:String(r)}`)}};return d?e.jsxs("div",{className:"py-10 text-center text-sm text-gray-500",children:[e.jsx(z,{size:14,className:"inline animate-spin mr-2"})," Loading…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.length," schedule",a.length===1?"":"s"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>v(),disabled:g,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs text-gray-600 dark:text-gray-400 hover:bg-white/5 transition-colors disabled:opacity-60",title:"Refresh schedule list",children:[e.jsx(te,{size:12,className:g?"animate-spin":""}),g?"Refreshing…":"Refresh"]}),n&&e.jsxs("button",{onClick:()=>{w(null),k(!0)},disabled:i.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 transition-colors disabled:opacity-50",title:i.length===0?"Save a report first in Reporting mode, then you can schedule it":"Create a new schedule",children:[e.jsx(Ze,{size:12})," New schedule"]})]})]}),a.length===0?e.jsxs("div",{className:"text-center py-14 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(F,{size:28,className:"mx-auto mb-3 opacity-40"}),"No schedules yet. Click ",e.jsx("strong",{children:"New schedule"})," to dispatch a saved report on a recurring basis."]}):e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 overflow-hidden bg-white dark:bg-white/[0.03]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-white/[0.04]",children:e.jsxs("tr",{className:"text-left text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Title"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Source"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Schedule"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Format"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Recipients"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Last run"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Status"}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-white/[0.02]",children:a.map(r=>{const h=i.find($=>$.id===r.sourceReportId);return e.jsxs("tr",{className:"border-t border-gray-100 dark:border-white/5 bg-white dark:bg-transparent hover:bg-gray-50 dark:hover:bg-white/[0.04] transition-colors",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:r.title})}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-600 dark:text-gray-400 truncate max-w-[160px]",children:h?h.title:e.jsx("span",{className:"text-rose-500",children:"Missing"})}),e.jsxs("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300",title:r.cron,children:[r.cronHuman&&r.cronHuman!==r.cron?r.cronHuman:e.jsx("span",{className:"font-mono",children:r.cron}),r.enabled&&r.nextRun&&e.jsxs("div",{className:"text-[10px] text-gray-500",children:["next ",le(r.nextRun)]})]}),e.jsx("td",{className:"px-3 py-2 text-xs uppercase text-gray-600 dark:text-gray-400",children:r.format}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300 truncate max-w-[180px]",title:r.recipients.join(", "),children:r.recipients.length===1?r.recipients[0]:`${r.recipients.length} recipients`}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:r.lastRun?le(r.lastRun):"—"}),e.jsx("td",{className:"px-3 py-2 text-xs",children:r.enabled?r.lastStatus==="success"&&r.lastWarning?e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",title:r.lastWarning,children:[e.jsx(ie,{size:10})," Sent · stale data"]}):r.lastStatus==="success"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400",children:[e.jsx(ie,{size:10})," Success"]}):r.lastStatus==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-rose-600 dark:text-rose-400",title:r.lastError,children:[e.jsx(et,{size:10})," Error"]}):e.jsx("span",{className:"text-gray-500",children:"—"}):e.jsx("span",{className:"text-gray-500",children:"paused"})}),e.jsx("td",{className:"px-3 py-2",children:n&&e.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[e.jsx("button",{onClick:()=>f(r),disabled:A===r.id,className:"p-1 rounded text-gray-500 hover:text-emerald-600 hover:bg-emerald-500/10 disabled:opacity-50",title:"Run now",children:A===r.id?e.jsx(z,{size:12,className:"animate-spin"}):e.jsx(tt,{size:12})}),e.jsx("button",{onClick:()=>m(r),className:"p-1 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-white/5",title:r.enabled?"Pause — stop sending until resumed":"Resume — send on schedule again",children:r.enabled?e.jsx("span",{className:"text-[10px] font-semibold px-1",children:"PAUSE"}):e.jsx("span",{className:"text-[10px] font-semibold px-1 text-emerald-500",children:"RESUME"})}),e.jsx("button",{onClick:()=>{w(r),k(!0)},className:"p-1 rounded text-gray-500 hover:text-brand-500 hover:bg-brand-500/10",title:"Edit",children:e.jsx("span",{className:"text-[10px] font-semibold px-1",children:"EDIT"})}),e.jsx("button",{onClick:()=>R(r),className:"p-1 rounded text-gray-500 hover:text-rose-500 hover:bg-rose-500/10",title:"Delete",children:e.jsx(je,{size:12})})]})})]},r.id)})})]})}),S&&e.jsx(ge,{reports:i,editing:C,onClose:()=>{k(!1),w(null)},onSaved:async()=>{k(!1),w(null),await v()}}),e.jsx(pe,{open:!!b,title:"Delete schedule?",description:`"${b==null?void 0:b.title}" will stop dispatching. This cannot be undone.`,confirmLabel:"Delete",onConfirm:p,onCancel:()=>R(null)})]})}const Re=[{id:"executive",label:"Executive Summary",description:"High-level KPIs + pass-rate trend + top failures — for managers.",prompt:`Build an EXECUTIVE QA dashboard for the current sprint using the \`generate_dashboard\` tool.
|
|
2
|
-
|
|
3
|
-
Layout (4 rows on a 12-column grid):
|
|
4
|
-
1. Four KPI cards (span 3 each): Total Test Cases, Automation Coverage %, Latest Pass Rate %, Critical Failures (open).
|
|
5
|
-
2. A doughnut chart (span 6) "Automation Status" — Automated vs Manual.
|
|
6
|
-
3. A line chart (span 6) "Pass Rate Trend" over the last 7–10 runs.
|
|
7
|
-
4. A table (span 12) "Top 5 Failing Tests" with columns: Test Name, Failure Count, Last Failure, Category.
|
|
8
|
-
5. A markdown cell (span 12) with a 3–5 bullet executive summary covering sprint health, biggest risks, and recommended next steps.
|
|
9
|
-
|
|
10
|
-
Pull real numbers from Testver — query test cases, run history, coverage stats, and failure analysis. Title: "Executive QA Summary — <Sprint Name or Date>". Save the result (save_report with templateId "executive") so it appears under My Reports.`},{id:"qa_daily",label:"QA Daily Report",description:"Last 24h status, new failures, flaky tests — for QA standups.",prompt:`Build a QA DAILY dashboard for the last 24 hours using the \`generate_dashboard\` tool.
|
|
11
|
-
|
|
12
|
-
Layout:
|
|
13
|
-
1. Four KPI cards (span 3 each): Runs in Last 24h, Tests Executed, Pass Rate %, New Failures (since yesterday).
|
|
14
|
-
2. A stacked bar chart (span 6) "Pass / Fail / Skip per Run" for each run in the last 24h.
|
|
15
|
-
3. A doughnut chart (span 6) "Failure Categories" from the latest run (bug / environment / flaky / test-issue / timeout).
|
|
16
|
-
4. A table (span 12) "New Failures Today" with columns: Test Name, Error Signature, Run, First Seen.
|
|
17
|
-
5. A markdown cell (span 12) summarizing what changed since yesterday in 2–4 bullets — newly broken tests, fixed regressions, anything notable.
|
|
18
|
-
|
|
19
|
-
Pull live data from Testver run history and failure analysis. Title: "QA Daily — <Today's Date>". Save the result (save_report with templateId "qa_daily").`},{id:"release",label:"Release Readiness",description:"Latest run vs baseline: regressions, new failures, duration delta.",prompt:`Build a RELEASE READINESS dashboard comparing the LATEST run to the configured BASELINE run using the \`generate_dashboard\` tool.
|
|
20
|
-
|
|
21
|
-
Layout:
|
|
22
|
-
1. Four KPI cards (span 3 each): Total Tests in Latest Run, Pass Rate Δ vs Baseline (with up/down arrow), Duration Δ vs Baseline, Regressions Count.
|
|
23
|
-
2. A stacked bar chart (span 6) "Pass / Fail / Skip by Priority" for the latest run.
|
|
24
|
-
3. A horizontal bar chart (span 6) "Top 5 Regressions" — tests that passed in baseline but fail in latest, sorted by failure impact.
|
|
25
|
-
4. A table (span 12) "New Failures vs Baseline" with columns: Test Name, Baseline Result, Latest Result, Error Signature.
|
|
26
|
-
5. A markdown cell (span 12) with a Go / No-Go recommendation, 3–5 bullets summarizing release risk.
|
|
27
|
-
|
|
28
|
-
Use Testver baseline + comparison endpoints. Title: "Release Readiness — Run <latest run id> vs Baseline". Save the result (save_report with templateId "release").`},{id:"trend_analysis",label:"Trend Analysis",description:"Pass rate / coverage / flaky / anomalies deep-dive across the last 20 runs.",prompt:`Build a TREND ANALYSIS dashboard covering the last 20 runs using the \`generate_dashboard\` tool.
|
|
29
|
-
|
|
30
|
-
Layout:
|
|
31
|
-
1. Four KPI cards (span 3 each): Avg Pass Rate % (20 runs), Flaky Tests Count, Avg Run Duration, Coverage % (requirement coverage).
|
|
32
|
-
2. A line chart (span 6) "Pass Rate Trend — Last 20 Runs".
|
|
33
|
-
3. A line chart (span 6) "Duration Trend — Last 20 Runs" (avg seconds per run).
|
|
34
|
-
4. A horizontal bar chart (span 12) "Top 10 Flakiest Tests" — sorted by flip rate (pass↔fail toggles across the 20 runs).
|
|
35
|
-
5. A table (span 12) "Slowest 10 Tests" with columns: Test Name, Avg Duration, Max Duration, Runs Counted.
|
|
36
|
-
6. A markdown cell (span 12) calling out anomalies, regressions, and patterns — 4–6 bullets.
|
|
37
|
-
|
|
38
|
-
Pull from run history, flaky-test detection, and slowest-tests stats. Title: "Trend Analysis — Last 20 Runs". Save the result (save_report with templateId "trend_analysis").`},{id:"automation_inventory",label:"Automation Inventory",description:"Every automation script — passing, failing, never run, skipped — by folder, framework and owner.",prompt:`Build an AUTOMATION INVENTORY dashboard of the project's automation scripts using the \`generate_dashboard\` tool. Take the numbers from \`test_library\` action "summary" — it covers every script, including the ones that have never run.
|
|
39
|
-
|
|
40
|
-
Layout:
|
|
41
|
-
1. Four KPI cards (span 3 each): Total Scripts, Passing on Last Run %, Never Run, Not Linked to a Test Case.
|
|
42
|
-
2. A doughnut chart (span 6) "Scripts by Status" — passing / failing / never run / skipped in code.
|
|
43
|
-
3. A horizontal bar chart (span 6) "Scripts by Folder" — the folders with the most scripts.
|
|
44
|
-
4. A table (span 12) "Folders" with columns: Folder, Scripts, Failing, Never Run, Flaky.
|
|
45
|
-
5. A bar chart (span 6) "Scripts by Framework", and a table (span 6) "Scripts by Owner" (Owner, Scripts, Failing) when owners are known — otherwise a bar chart "Scripts by Tag".
|
|
46
|
-
6. A markdown cell (span 12) with 3–5 bullets: the biggest gaps (never-run and unlinked scripts), the folders with the most failures, and recommended next steps.
|
|
47
|
-
|
|
48
|
-
Title: "Automation Inventory — <Today's Date>". Save the result (save_report with templateId "automation_inventory").`},{id:"manual_vs_automated",label:"Manual vs Automated",description:"Quick breakdown of test cases by automation status.",prompt:'Generate a dashboard showing the breakdown of manual and automated test cases — totals, automation coverage percentage, and a list of currently-manual tests that could be prioritized for automation. Save the result (save_report with templateId "manual_vs_automated").'},{id:"coverage_by_requirement",label:"Coverage by Requirement",description:"Requirement coverage with orphan tests and uncovered requirements.",prompt:'Generate a dashboard showing requirement coverage — how many requirements have linked test cases, how many are uncovered, and which test cases are orphaned (no requirement linked). Save the result (save_report with templateId "coverage_by_requirement").'}];function lt(){const t=W(),n=a=>ye(t,{prompt:a,mode:"reporting"});return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Click a template to open the AI Assistant in Reporting mode with the prompt pre-filled. You can edit the prompt before submitting."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Re.map(a=>e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx(U,{size:14,className:"text-brand-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:a.label}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 leading-relaxed",children:a.description})]})]}),e.jsxs("div",{className:"text-[11px] text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-white/[0.02] border border-gray-100 dark:border-white/5 rounded-md p-2 font-mono mb-3 italic",children:['"',a.prompt,'"']}),e.jsxs("button",{onClick:()=>n(a.prompt),className:"w-full flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 transition-colors",children:["Run template ",e.jsx(fe,{size:11,className:"-rotate-90"})]})]},a.id))})]})}export{yt as ReportsPage};
|
|
1
|
+
import{r as o,j as e,L as H,u as W,e as Ie}from"./vendor-react-DOVfxdUy.js";import{f as le}from"./formatDate-T65-Y6Mi.js";import{s as Le}from"./visibleInterval-BKsLfJZ3.js";import{b as Y,ae as X,iC as ze,b$ as Pe,gW as De,gV as Fe,iD as _e,gU as Oe,iE as Be,iF as me,iG as Me,iH as ue,iI as Ue,iJ as qe,iK as Ke}from"./index-BlA8ntjb.js";import{C as pe}from"./ConfirmDialog-D_N9188T.js";import{t as L,i as J,S as ge,s as be,a as Ve}from"./reportMeta-B9ZRW6ts.js";import{h as ye}from"./aiHandoff-vhtR29Fh.js";import{s as He}from"./KpiTile-BKlWqjgN.js";import{a1 as z,j as Z,S as U,w as Qe,ca as Ge,cb as We,bq as ee,R as te,a4 as F,dm as ae,a6 as Ye,z as fe,cx as Xe,bp as Je,b8 as je,b5 as Ze,ah as ie,X as et,a3 as tt}from"./vendor-icons-Cm92aSc5.js";import"./vendor-query-DkZSMtfn.js";import"./CronBuilder-C7_JADb7.js";const oe="testver-reports-view",Q={good:"text-emerald-700 dark:text-emerald-400",bad:"text-rose-700 dark:text-rose-400",warn:"text-amber-700 dark:text-amber-400",flat:"text-gray-600 dark:text-gray-400"},de={good:"#059669",bad:"#dc2626",warn:"#d97706",flat:"#94a3b8"},G="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3 text-[13px] font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",se="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",V="h-9 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-sm text-gray-900 dark:text-gray-100",M="flex flex-col gap-1 text-xs font-semibold text-gray-600 dark:text-gray-400";function ce({shared:t,reports:n,schedules:a,loading:l,reload:i,onNewReport:x,onBrowseTemplates:d}){var re;const c=Y(),g=X().hasRole("tester"),[N,C]=o.useState(""),[w,S]=o.useState("all"),[k,b]=o.useState("any"),[R,A]=o.useState("updated"),[y,v]=o.useState(()=>{try{return localStorage.getItem(oe)==="list"?"list":"grid"}catch{return"grid"}}),[m,f]=o.useState(null),[p,r]=o.useState(null),[h,$]=o.useState(null);o.useEffect(()=>{try{localStorage.setItem(oe,y)}catch{}},[y]);const _=o.useMemo(()=>{const s=new Map;for(const u of a)s.set(u.sourceReportId,[...s.get(u.sourceReportId)??[],u]);return s},[a]),Te=o.useMemo(()=>[...new Set(n.map(s=>s.templateId||""))].sort((s,u)=>L(s).localeCompare(L(u))),[n]),P=o.useMemo(()=>{const s=N.trim().toLowerCase(),u=n.filter(j=>{var T,ne;if(s&&!`${j.title} ${L(j.templateId)} ${((T=j.preview)==null?void 0:T.verdict)??""}`.toLowerCase().includes(s)||w!=="all"&&(j.templateId||"")!==w)return!1;if(k!=="any"){const Ee=J((ne=j.preview)==null?void 0:ne.generatedAt,j.templateId);if(k==="stale"!==Ee)return!1}return!0}),E=j=>{var T;return((T=j.preview)==null?void 0:T.generatedAt)||j.updatedAt||""};return u.sort((j,T)=>R==="name"?j.title.localeCompare(T.title):R==="data"?E(T).localeCompare(E(j)):(T.updatedAt||"").localeCompare(j.updatedAt||""))},[n,N,w,k,R]),O=t?[]:P.filter(s=>s.pinned),q=t?P:P.filter(s=>!s.pinned),Ae=!!N.trim()||w!=="all"||k!=="any",Ce=s=>g&&s.mine!==!1,B=async(s,u)=>{f(s);try{await u()}finally{f(null)}},D=s=>s instanceof Error?s.message:String(s),K={canChange:Ce,busy:m,schedulesOf:s=>_.get(s.id)??[],refresh:s=>B(`${s.id}:refresh`,async()=>{try{await Be(s.id),c.toast("success",`"${s.title}" refreshed with current data`),await i()}catch(u){c.toast("error",`Refresh failed: ${D(u)}`)}}),exportAs:(s,u)=>B(`${s.id}:${u}`,async()=>{try{await Oe(u,{reportId:s.id})}catch(E){c.toast("error",`Download failed: ${D(E)}`)}}),togglePin:s=>B(`${s.id}:pin`,async()=>{try{await _e(s.id,{pinned:!s.pinned}),await i()}catch(u){c.toast("error",`Pin failed: ${D(u)}`)}}),toggleShare:s=>B(`${s.id}:share`,async()=>{try{if(s.shareToken)await De(s.id),c.toast("success","Share link revoked");else{const{shareUrl:u}=await Fe(s.id),E=`${window.location.origin}${u}`;try{await navigator.clipboard.writeText(E)}catch{}c.toast("success",`Share link copied: ${E}`)}await i()}catch(u){c.toast("error",`Share failed: ${D(u)}`)}}),schedule:s=>$(s),remove:s=>r(s)},$e=async()=>{if(p)try{await ze(p.id),r(null),c.toast("success","Report deleted"),await i()}catch(s){c.toast("error",`Delete failed: ${D(s)}`)}};return l?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 py-10 justify-center",children:[e.jsx(z,{size:14,className:"animate-spin"})," Loading reports…"]}):n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.02] px-6 py-14 text-center",children:[e.jsx(Z,{size:30,className:"mx-auto mb-3 text-gray-400","aria-hidden":!0}),e.jsx("p",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t?"No shared reports yet":"No saved reports yet"}),e.jsx("p",{className:"mt-1.5 text-sm text-gray-600 dark:text-gray-400 max-w-lg mx-auto",children:t?"Reports anyone in this workspace shares with a public link appear here, for every role.":"Ask the AI Assistant for a report in Reporting mode, then save it with the bookmark button on the report — or start from a template."}),!t&&g&&e.jsxs("div",{className:"mt-5 flex justify-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:x,className:"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-4 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(U,{size:15})," New report with AI"]}),e.jsx("button",{onClick:d,className:"inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 px-4 text-sm font-medium text-gray-900 dark:text-gray-100",children:"Browse templates"})]})]}):e.jsxs("div",{className:"flex flex-col gap-5","data-testid":"report-library",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3","data-testid":"report-toolbar",children:[e.jsxs("label",{className:`${M} flex-[1_1_260px]`,children:["Search",e.jsxs("span",{className:"flex h-9 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5",children:[e.jsx(Qe,{size:15,className:"text-gray-500","aria-hidden":!0}),e.jsx("input",{type:"search",value:N,onChange:s=>C(s.target.value),placeholder:"Search reports",className:"w-full bg-transparent text-sm font-normal text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-500"})]})]}),e.jsxs("label",{className:M,children:["Template",e.jsxs("select",{value:w,onChange:s=>S(s.target.value),className:V,children:[e.jsx("option",{value:"all",children:"All templates"}),Te.map(s=>e.jsx("option",{value:s,children:L(s)},s||"custom"))]})]}),e.jsxs("label",{className:M,children:["Updated",e.jsxs("select",{value:k,onChange:s=>b(s.target.value),className:V,children:[e.jsx("option",{value:"any",children:"Any time"}),e.jsx("option",{value:"fresh",children:"Up to date"}),e.jsx("option",{value:"stale",children:"Out of date"})]})]}),e.jsxs("label",{className:M,children:["Sort",e.jsxs("select",{value:R,onChange:s=>A(s.target.value),className:V,children:[e.jsx("option",{value:"updated",children:"Recently changed"}),e.jsx("option",{value:"data",children:"Newest data"}),e.jsx("option",{value:"name",children:"Name"})]})]}),e.jsxs("div",{role:"group","aria-label":"View",className:"flex h-9 overflow-hidden rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04]",children:[e.jsx("button",{"aria-label":"Grid view","aria-pressed":y==="grid",onClick:()=>v("grid"),className:`flex w-9 items-center justify-center ${y==="grid"?"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-100":"text-gray-500"}`,children:e.jsx(Ge,{size:15})}),e.jsx("button",{"aria-label":"List view","aria-pressed":y==="list",onClick:()=>v("list"),className:`flex w-9 items-center justify-center ${y==="list"?"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-100":"text-gray-500"}`,children:e.jsx(We,{size:15})})]})]}),P.length===0&&e.jsxs("p",{className:"py-10 text-center text-sm text-gray-600 dark:text-gray-400",children:["No reports match",Ae?" these filters":"","."," ",e.jsx("button",{className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",onClick:()=>{C(""),S("all"),b("any")},children:"Clear filters"})]}),y==="list"?P.length>0&&e.jsx(st,{reports:[...O,...q],actions:K}):e.jsxs(e.Fragment,{children:[O.length>0&&e.jsxs("section",{className:"flex flex-col gap-3","aria-label":"Pinned reports",children:[e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-gray-600 dark:text-gray-400",children:"Pinned"}),e.jsx("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,420px),1fr))]",children:O.map(s=>e.jsx(he,{report:s,actions:K,large:!0},s.id))})]}),q.length>0&&e.jsxs("section",{className:"flex flex-col gap-3","aria-label":t?"Shared reports":"All reports",children:[O.length>0&&e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-gray-600 dark:text-gray-400",children:"All reports"}),e.jsx("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,300px),1fr))]",children:q.map(s=>e.jsx(he,{report:s,actions:K},s.id))})]})]}),h&&e.jsx(ge,{reports:[h],editing:null,initialReportId:h.id,onClose:()=>$(null),onSaved:async()=>{$(null),await i()}}),e.jsx(pe,{open:!!p,title:"Delete report?",description:`"${p==null?void 0:p.title}" will be permanently deleted. Any active share link will stop working.`+(p&&(((re=_.get(p.id))==null?void 0:re.length)??0)>0?` ${_.get(p.id).length} scheduled email${_.get(p.id).length===1?"":"s"} for this report will also be removed.`:""),confirmLabel:"Delete",onConfirm:$e,onCancel:()=>r(null)})]})}function we({report:t}){var l,i;const n=((l=t.preview)==null?void 0:l.generatedAt)||t.updatedAt,a=J((i=t.preview)==null?void 0:i.generatedAt,t.templateId);return e.jsxs("span",{className:`inline-flex items-center gap-1.5 ${a?"font-medium text-amber-700 dark:text-amber-400":""}`,title:a?"Out of date — Refresh rebuilds it from current results":void 0,children:[e.jsx("span",{className:`h-[7px] w-[7px] rounded-full ${a?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":!0}),"Updated ",Ve(n),a?" · out of date":""]})}function xe({preview:t,height:n}){var x,d;const a=t!=null&&t.trend?He(t.trend,160,n,5):"";if(!a)return null;const l=(t==null?void 0:t.status)??((x=t==null?void 0:t.kpis[0])==null?void 0:x.status)??((d=t==null?void 0:t.kpis[0])==null?void 0:d.tone)??"good",i=de[l]??de.good;return e.jsxs("svg",{viewBox:`0 0 160 ${n}`,preserveAspectRatio:"none",className:"block w-full",style:{height:n},role:"img","aria-label":"Trend",children:[e.jsx("polygon",{points:`0,${n} ${a} 160,${n}`,fill:i,fillOpacity:.1}),e.jsx("polyline",{points:a,fill:"none",stroke:i,strokeWidth:2,vectorEffect:"non-scaling-stroke",strokeLinejoin:"round"})]})}function at({preview:t,size:n}){const a=(t==null?void 0:t.kpis)??[];return a.length===0?t!=null&&t.verdict?e.jsx("p",{className:"text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:t.verdict}):e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Open the report to see it."}):e.jsx("div",{className:"grid grid-cols-3 gap-3",children:a.map((l,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-xs text-gray-600 dark:text-gray-400",title:l.title,children:l.title}),e.jsx("p",{className:`truncate font-bold tabular-nums text-gray-900 dark:text-gray-100 ${n==="lg"?"text-xl":"text-[17px]"} ${l.status?Q[l.status]:""}`,title:l.value,children:l.value}),l.delta&&e.jsx("p",{className:`text-xs font-semibold ${Q[l.tone]??""}`,children:l.delta})]},i))})}function he({report:t,actions:n,large:a=!1}){var c;const l=n.canChange(t),i=n.schedulesOf(t),x=J((c=t.preview)==null?void 0:c.generatedAt,t.templateId),d=n.busy===`${t.id}:refresh`;return e.jsxs("article",{className:"flex flex-col rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03]","data-testid":"report-card",children:[e.jsxs("div",{className:`flex flex-col gap-2 ${a?"px-5 pt-5":"px-4 pt-4"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"rounded-md bg-gray-100 dark:bg-white/10 px-2 py-0.5 text-xs font-semibold text-gray-700 dark:text-gray-300",children:L(t.templateId)}),t.pinned&&e.jsx(ee,{size:15,className:"text-amber-600","aria-label":"Pinned"})]}),e.jsx("h3",{className:`font-bold text-gray-900 dark:text-gray-100 ${a?"text-lg":"text-base"}`,children:e.jsx(H,{to:`/reports/view/${t.id}`,className:"hover:underline",children:t.title})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-gray-600 dark:text-gray-400",children:[e.jsx(we,{report:t}),i.map(g=>e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(F,{size:12,"aria-hidden":!0})," ",be(g)]},g.id))]})]}),e.jsxs("div",{className:`grid items-end gap-3 ${a?"grid-cols-[minmax(0,3fr)_minmax(0,1.2fr)] px-5 py-4":"grid-cols-1 px-4 pt-3.5 pb-1"}`,children:[e.jsx(at,{preview:t.preview,size:a?"lg":"md"}),a&&e.jsx(xe,{preview:t.preview,height:48})]}),!a&&e.jsx(xe,{preview:t.preview,height:40}),e.jsxs("div",{className:`mt-auto flex flex-wrap items-center gap-2 border-t border-gray-100 dark:border-white/[0.06] ${a?"px-5 py-3":"px-4 py-2.5"}`,children:[e.jsx(H,{to:`/reports/view/${t.id}`,className:`${G} ${a?"":"flex-1 justify-center"} !bg-brand-600 !text-white !border-brand-600 hover:!bg-brand-700`,children:"Open"}),l&&e.jsxs("button",{onClick:()=>n.refresh(t),disabled:d,className:`${G} ${x?"!border-amber-300 !bg-amber-50 !text-amber-800 dark:!bg-amber-500/15 dark:!text-amber-300 dark:!border-amber-400/30":""}`,title:"The AI rebuilds this report from current data (30 seconds to 2 minutes; uses AI credits)",children:[d?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(te,{size:14}),d?"Refreshing…":x?"Refresh now":"Refresh"]}),e.jsx(Ne,{report:t,actions:n,compact:!a}),l&&e.jsx(Se,{report:t,actions:n}),t.shareToken&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 rounded-md bg-emerald-50 dark:bg-emerald-500/15 px-2 py-0.5 text-xs font-semibold text-emerald-700 dark:text-emerald-300","data-testid":"report-shared-by",children:[e.jsx(ae,{size:11,"aria-hidden":!0}),t.mine===!1?`Shared${t.sharedByName?` by ${t.sharedByName}`:""}`:`Shared link · ${t.shareViews??0} view${t.shareViews===1?"":"s"}`]})]})]})}function st({reports:t,actions:n}){return e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03]",children:e.jsxs("table",{className:"w-full min-w-[900px] border-collapse text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 dark:bg-white/[0.04] text-left text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400",children:[e.jsx("th",{className:"px-4 py-2.5",children:"Report"}),e.jsx("th",{className:"px-4 py-2.5",children:"Headline"}),e.jsx("th",{className:"px-4 py-2.5",children:"Updated"}),e.jsx("th",{className:"px-4 py-2.5",children:"Schedule"}),e.jsx("th",{className:"px-4 py-2.5 text-right",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(a=>{var x;const l=(x=a.preview)==null?void 0:x.kpis[0],i=n.schedulesOf(a);return e.jsxs("tr",{className:"border-t border-gray-100 dark:border-white/[0.06] align-middle","data-testid":"report-row",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[a.pinned&&e.jsx(ee,{size:13,className:"text-amber-600 flex-shrink-0","aria-label":"Pinned"}),e.jsx(H,{to:`/reports/view/${a.id}`,className:"font-semibold text-gray-900 dark:text-gray-100 hover:underline",children:a.title})]}),e.jsxs("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-400",children:[L(a.templateId),a.shareToken?" · shared":""]})]}),e.jsx("td",{className:"px-4 py-3",children:l?e.jsxs("span",{className:"tabular-nums",children:[e.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[l.title," "]}),e.jsx("strong",{className:"text-gray-900 dark:text-gray-100",children:l.value}),l.delta&&e.jsx("span",{className:`ml-1.5 text-xs font-semibold ${Q[l.tone]??""}`,children:l.delta})]}):e.jsx("span",{className:"text-gray-500",children:"—"})}),e.jsx("td",{className:"px-4 py-3 text-[13px] text-gray-600 dark:text-gray-400 whitespace-nowrap",children:e.jsx(we,{report:a})}),e.jsx("td",{className:"px-4 py-3 text-[13px] text-gray-600 dark:text-gray-400",children:i.length?i.map(be).join("; "):"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex justify-end gap-1.5",children:[n.canChange(a)&&e.jsx("button",{onClick:()=>n.refresh(a),disabled:n.busy===`${a.id}:refresh`,className:se,"aria-label":"Refresh data",title:"Refresh data",children:n.busy===`${a.id}:refresh`?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(te,{size:14})}),e.jsx(Ne,{report:a,actions:n,compact:!0}),n.canChange(a)&&e.jsx(Se,{report:a,actions:n})]})})]},a.id)})})]})})}function ke(){const[t,n]=o.useState(!1),a=o.useRef(null);return o.useEffect(()=>{if(!t)return;const l=x=>{a.current&&!a.current.contains(x.target)&&n(!1)},i=x=>{x.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",i)}},[t]),{open:t,setOpen:n,ref:a}}const ve="absolute right-0 top-full mt-1 z-20 w-48 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",I="w-full flex items-center gap-2 px-3 py-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5";function Ne({report:t,actions:n,compact:a=!1}){const{open:l,setOpen:i,ref:x}=ke(),d=!!n.busy&&n.busy.startsWith(`${t.id}:`)&&/:(pdf|docx|xlsx)$/.test(n.busy),c=t.mine===!1&&t.shareToken?`/api/reports/share/${encodeURIComponent(t.shareToken)}/render.html`:Pe(`/api/reports/${encodeURIComponent(t.id)}/render.html`);return e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>i(g=>!g),className:a?se:G,"aria-label":"Download","aria-haspopup":"menu","aria-expanded":l,disabled:d,children:[d?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14}),!a&&e.jsxs(e.Fragment,{children:["Download ",e.jsx(fe,{size:13,"aria-hidden":!0})]})]}),l&&e.jsxs("div",{role:"menu",className:ve,children:[e.jsx("a",{role:"menuitem",href:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>i(!1),className:I,children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([g,N])=>e.jsx("button",{role:"menuitem",className:I,onClick:()=>{i(!1),n.exportAs(t,g)},children:N},g))]})]})}function Se({report:t,actions:n}){const{open:a,setOpen:l,ref:i}=ke(),x=W(),d=c=>()=>{l(!1),c()};return e.jsxs("div",{className:"relative",ref:i,children:[e.jsx("button",{onClick:()=>l(c=>!c),className:se,"aria-label":"More actions","aria-haspopup":"menu","aria-expanded":a,children:e.jsx(Xe,{size:15})}),a&&e.jsxs("div",{role:"menu",className:ve,children:[e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>x(`/reports/view/${t.id}`)),children:[e.jsx(Z,{size:14})," Open"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>void n.togglePin(t)),children:[t.pinned?e.jsx(Je,{size:14}):e.jsx(ee,{size:14})," ",t.pinned?"Unpin":"Pin to top"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>void n.toggleShare(t)),children:[e.jsx(ae,{size:14})," ",t.shareToken?"Revoke share link":"Copy a share link"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>n.schedule(t)),children:[e.jsx(F,{size:14})," Schedule email…"]}),e.jsxs("button",{role:"menuitem",className:`${I} !text-rose-700 dark:!text-rose-400`,onClick:d(()=>n.remove(t)),children:[e.jsx(je,{size:14})," Delete"]})]})]})}const rt=["my","shared","scheduled","templates"];function yt(){const t=W(),n=Y(),a=X().hasRole("tester"),[l,i]=Ie(),x=l.get("tab"),d=x&&rt.includes(x)?x:"my",c=m=>i(f=>{const p=new URLSearchParams(f);return m==="my"?p.delete("tab"):p.set("tab",m),p},{replace:!0}),[g,N]=o.useState([]),[C,w]=o.useState([]),[S,k]=o.useState([]),[b,R]=o.useState(!0),A=async()=>{try{const[m,f,p]=await Promise.all([me(),Me(),ue().catch(()=>({schedules:[],count:0}))]);N(m.reports),w(f.reports),k(p.schedules)}catch(m){n.toast("error",`Load failed: ${m instanceof Error?m.message:String(m)}`)}finally{R(!1)}};o.useEffect(()=>{A()},[d]);const y=()=>ye(t,{mode:"reporting"}),v=[{id:"my",label:"My reports",Icon:Z,count:b?null:g.length},{id:"shared",label:"Shared",Icon:ae,count:b?null:C.length},{id:"scheduled",label:"Scheduled",Icon:F,count:b?null:S.length},{id:"templates",label:"Templates",Icon:U,count:Re.length}];return e.jsxs("div",{className:"p-6 max-w-[1360px] mx-auto flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[26px] font-bold tracking-tight text-gray-900 dark:text-gray-100",children:"Reports"}),e.jsxs("p",{className:"mt-1.5 text-sm text-gray-600 dark:text-gray-400 max-w-3xl",children:["Dashboards built by the AI Assistant in Reporting mode. Refresh, share, schedule or download any of them."," ",e.jsx("strong",{className:"font-semibold text-gray-800 dark:text-gray-200",children:"Shared"})," lists every report with a public link in this workspace — anyone signed in can open it."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>c("scheduled"),className:"inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08]",children:[e.jsx(F,{size:15})," Schedules"]}),a&&e.jsxs("button",{onClick:y,className:"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(U,{size:15})," New report with AI"]})]})]}),e.jsx("div",{role:"tablist",className:"flex gap-6 overflow-x-auto border-b border-gray-200 dark:border-white/10","data-testid":"report-tabs",children:v.map(m=>{const f=d===m.id;return e.jsxs("button",{role:"tab","aria-selected":f,onClick:()=>c(m.id),className:`flex h-10 flex-shrink-0 items-center gap-2 whitespace-nowrap border-b-2 px-0.5 text-sm transition-colors ${f?"border-gray-900 dark:border-gray-100 font-semibold text-gray-900 dark:text-gray-100":"border-transparent font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[e.jsx(m.Icon,{size:15,"aria-hidden":!0,className:f?"":"opacity-80"}),m.label,m.count!=null&&e.jsx("span",{className:`min-w-[22px] rounded-full px-2 py-px text-center text-xs font-semibold tabular-nums ${f?"bg-brand-600 text-white dark:bg-white dark:text-gray-900":"bg-gray-200 text-gray-700 dark:bg-white/10 dark:text-gray-300"}`,children:m.count})]},m.id)})}),d==="my"&&e.jsx(ce,{shared:!1,reports:g,schedules:S,loading:b,reload:A,onNewReport:y,onBrowseTemplates:()=>c("templates")}),d==="shared"&&e.jsx(ce,{shared:!0,reports:C,schedules:S,loading:b,reload:A,onNewReport:y,onBrowseTemplates:()=>c("templates")}),d==="scheduled"&&e.jsx(nt,{}),d==="templates"&&e.jsx(lt,{})]})}function nt(){const t=Y(),n=X().hasRole("tester"),[a,l]=o.useState([]),[i,x]=o.useState([]),[d,c]=o.useState(!0),[g,N]=o.useState(!1),[C,w]=o.useState(null),[S,k]=o.useState(!1),[b,R]=o.useState(null),[A,y]=o.useState(null),v=async r=>{r!=null&&r.initial?c(!0):r!=null&&r.silent||N(!0);try{const[h,$]=await Promise.all([ue(),me()]);l(h.schedules),x($.reports)}catch(h){r!=null&&r.silent||t.toast("error",`Load failed: ${h instanceof Error?h.message:String(h)}`)}finally{c(!1),N(!1)}};o.useEffect(()=>{v({initial:!0})},[]),o.useEffect(()=>{if(!(S||b))return Le(()=>{v({silent:!0})},2e4)},[S,b]);const m=async r=>{try{await qe(r.id,{enabled:!r.enabled}),await v()}catch(h){t.toast("error",`Update failed: ${h instanceof Error?h.message:String(h)}`)}},f=async r=>{y(r.id);try{const h=await Ue(r.id);h.success?t.toast("success","Dispatch succeeded"):t.toast("error",`Dispatch failed: ${h.error||"unknown"}`),await v()}catch(h){t.toast("error",`Run failed: ${h instanceof Error?h.message:String(h)}`)}finally{y(null)}},p=async()=>{if(b)try{await Ke(b.id),t.toast("success","Schedule deleted"),R(null),await v()}catch(r){t.toast("error",`Delete failed: ${r instanceof Error?r.message:String(r)}`)}};return d?e.jsxs("div",{className:"py-10 text-center text-sm text-gray-500",children:[e.jsx(z,{size:14,className:"inline animate-spin mr-2"})," Loading…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.length," schedule",a.length===1?"":"s"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>v(),disabled:g,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs text-gray-600 dark:text-gray-400 hover:bg-white/5 transition-colors disabled:opacity-60",title:"Refresh schedule list",children:[e.jsx(te,{size:12,className:g?"animate-spin":""}),g?"Refreshing…":"Refresh"]}),n&&e.jsxs("button",{onClick:()=>{w(null),k(!0)},disabled:i.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 transition-colors disabled:opacity-50",title:i.length===0?"Save a report first in Reporting mode, then you can schedule it":"Create a new schedule",children:[e.jsx(Ze,{size:12})," New schedule"]})]})]}),a.length===0?e.jsxs("div",{className:"text-center py-14 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(F,{size:28,className:"mx-auto mb-3 opacity-40"}),"No schedules yet. Click ",e.jsx("strong",{children:"New schedule"})," to dispatch a saved report on a recurring basis."]}):e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 overflow-hidden bg-white dark:bg-white/[0.03]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-white/[0.04]",children:e.jsxs("tr",{className:"text-left text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Title"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Source"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Schedule"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Format"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Recipients"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Last run"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Status"}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-white/[0.02]",children:a.map(r=>{const h=i.find($=>$.id===r.sourceReportId);return e.jsxs("tr",{className:"border-t border-gray-100 dark:border-white/5 bg-white dark:bg-transparent hover:bg-gray-50 dark:hover:bg-white/[0.04] transition-colors",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:r.title})}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-600 dark:text-gray-400 truncate max-w-[160px]",children:h?h.title:e.jsx("span",{className:"text-rose-500",children:"Missing"})}),e.jsxs("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300",title:r.cron,children:[r.cronHuman&&r.cronHuman!==r.cron?r.cronHuman:e.jsx("span",{className:"font-mono",children:r.cron}),r.enabled&&r.nextRun&&e.jsxs("div",{className:"text-[10px] text-gray-500",children:["next ",le(r.nextRun)]})]}),e.jsx("td",{className:"px-3 py-2 text-xs uppercase text-gray-600 dark:text-gray-400",children:r.format}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300 truncate max-w-[180px]",title:r.recipients.join(", "),children:r.recipients.length===1?r.recipients[0]:`${r.recipients.length} recipients`}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:r.lastRun?le(r.lastRun):"—"}),e.jsx("td",{className:"px-3 py-2 text-xs",children:r.enabled?r.lastStatus==="success"&&r.lastWarning?e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",title:r.lastWarning,children:[e.jsx(ie,{size:10})," Sent · stale data"]}):r.lastStatus==="success"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400",children:[e.jsx(ie,{size:10})," Success"]}):r.lastStatus==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-rose-600 dark:text-rose-400",title:r.lastError,children:[e.jsx(et,{size:10})," Error"]}):e.jsx("span",{className:"text-gray-500",children:"—"}):e.jsx("span",{className:"text-gray-500",children:"paused"})}),e.jsx("td",{className:"px-3 py-2",children:n&&e.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[e.jsx("button",{onClick:()=>f(r),disabled:A===r.id,className:"p-1 rounded text-gray-500 hover:text-emerald-600 hover:bg-emerald-500/10 disabled:opacity-50",title:"Run now",children:A===r.id?e.jsx(z,{size:12,className:"animate-spin"}):e.jsx(tt,{size:12})}),e.jsx("button",{onClick:()=>m(r),className:"p-1 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-white/5",title:r.enabled?"Pause — stop sending until resumed":"Resume — send on schedule again",children:r.enabled?e.jsx("span",{className:"text-[10px] font-semibold px-1",children:"PAUSE"}):e.jsx("span",{className:"text-[10px] font-semibold px-1 text-emerald-500",children:"RESUME"})}),e.jsx("button",{onClick:()=>{w(r),k(!0)},className:"p-1 rounded text-gray-500 hover:text-brand-500 hover:bg-brand-500/10",title:"Edit",children:e.jsx("span",{className:"text-[10px] font-semibold px-1",children:"EDIT"})}),e.jsx("button",{onClick:()=>R(r),className:"p-1 rounded text-gray-500 hover:text-rose-500 hover:bg-rose-500/10",title:"Delete",children:e.jsx(je,{size:12})})]})})]},r.id)})})]})}),S&&e.jsx(ge,{reports:i,editing:C,onClose:()=>{k(!1),w(null)},onSaved:async()=>{k(!1),w(null),await v()}}),e.jsx(pe,{open:!!b,title:"Delete schedule?",description:`"${b==null?void 0:b.title}" will stop dispatching. This cannot be undone.`,confirmLabel:"Delete",onConfirm:p,onCancel:()=>R(null)})]})}const Re=[{id:"executive",label:"Executive Summary",description:"High-level KPIs + pass-rate trend + top failures — for managers.",prompt:`Build an EXECUTIVE QA dashboard for the current sprint using the \`generate_dashboard\` tool.
|
|
2
|
+
|
|
3
|
+
Layout (4 rows on a 12-column grid):
|
|
4
|
+
1. Four KPI cards (span 3 each): Total Test Cases, Automation Coverage %, Latest Pass Rate %, Critical Failures (open).
|
|
5
|
+
2. A doughnut chart (span 6) "Automation Status" — Automated vs Manual.
|
|
6
|
+
3. A line chart (span 6) "Pass Rate Trend" over the last 7–10 runs.
|
|
7
|
+
4. A table (span 12) "Top 5 Failing Tests" with columns: Test Name, Failure Count, Last Failure, Category.
|
|
8
|
+
5. A markdown cell (span 12) with a 3–5 bullet executive summary covering sprint health, biggest risks, and recommended next steps.
|
|
9
|
+
|
|
10
|
+
Pull real numbers from Testver — query test cases, run history, coverage stats, and failure analysis. Title: "Executive QA Summary — <Sprint Name or Date>". Save the result (save_report with templateId "executive") so it appears under My Reports.`},{id:"qa_daily",label:"QA Daily Report",description:"Last 24h status, new failures, flaky tests — for QA standups.",prompt:`Build a QA DAILY dashboard for the last 24 hours using the \`generate_dashboard\` tool.
|
|
11
|
+
|
|
12
|
+
Layout:
|
|
13
|
+
1. Four KPI cards (span 3 each): Runs in Last 24h, Tests Executed, Pass Rate %, New Failures (since yesterday).
|
|
14
|
+
2. A stacked bar chart (span 6) "Pass / Fail / Skip per Run" for each run in the last 24h.
|
|
15
|
+
3. A doughnut chart (span 6) "Failure Categories" from the latest run (bug / environment / flaky / test-issue / timeout).
|
|
16
|
+
4. A table (span 12) "New Failures Today" with columns: Test Name, Error Signature, Run, First Seen.
|
|
17
|
+
5. A markdown cell (span 12) summarizing what changed since yesterday in 2–4 bullets — newly broken tests, fixed regressions, anything notable.
|
|
18
|
+
|
|
19
|
+
Pull live data from Testver run history and failure analysis. Title: "QA Daily — <Today's Date>". Save the result (save_report with templateId "qa_daily").`},{id:"release",label:"Release Readiness",description:"Latest run vs baseline: regressions, new failures, duration delta.",prompt:`Build a RELEASE READINESS dashboard comparing the LATEST run to the configured BASELINE run using the \`generate_dashboard\` tool.
|
|
20
|
+
|
|
21
|
+
Layout:
|
|
22
|
+
1. Four KPI cards (span 3 each): Total Tests in Latest Run, Pass Rate Δ vs Baseline (with up/down arrow), Duration Δ vs Baseline, Regressions Count.
|
|
23
|
+
2. A stacked bar chart (span 6) "Pass / Fail / Skip by Priority" for the latest run.
|
|
24
|
+
3. A horizontal bar chart (span 6) "Top 5 Regressions" — tests that passed in baseline but fail in latest, sorted by failure impact.
|
|
25
|
+
4. A table (span 12) "New Failures vs Baseline" with columns: Test Name, Baseline Result, Latest Result, Error Signature.
|
|
26
|
+
5. A markdown cell (span 12) with a Go / No-Go recommendation, 3–5 bullets summarizing release risk.
|
|
27
|
+
|
|
28
|
+
Use Testver baseline + comparison endpoints. Title: "Release Readiness — Run <latest run id> vs Baseline". Save the result (save_report with templateId "release").`},{id:"trend_analysis",label:"Trend Analysis",description:"Pass rate / coverage / flaky / anomalies deep-dive across the last 20 runs.",prompt:`Build a TREND ANALYSIS dashboard covering the last 20 runs using the \`generate_dashboard\` tool.
|
|
29
|
+
|
|
30
|
+
Layout:
|
|
31
|
+
1. Four KPI cards (span 3 each): Avg Pass Rate % (20 runs), Flaky Tests Count, Avg Run Duration, Coverage % (requirement coverage).
|
|
32
|
+
2. A line chart (span 6) "Pass Rate Trend — Last 20 Runs".
|
|
33
|
+
3. A line chart (span 6) "Duration Trend — Last 20 Runs" (avg seconds per run).
|
|
34
|
+
4. A horizontal bar chart (span 12) "Top 10 Flakiest Tests" — sorted by flip rate (pass↔fail toggles across the 20 runs).
|
|
35
|
+
5. A table (span 12) "Slowest 10 Tests" with columns: Test Name, Avg Duration, Max Duration, Runs Counted.
|
|
36
|
+
6. A markdown cell (span 12) calling out anomalies, regressions, and patterns — 4–6 bullets.
|
|
37
|
+
|
|
38
|
+
Pull from run history, flaky-test detection, and slowest-tests stats. Title: "Trend Analysis — Last 20 Runs". Save the result (save_report with templateId "trend_analysis").`},{id:"automation_inventory",label:"Automation Inventory",description:"Every automation script — passing, failing, never run, skipped — by folder, framework and owner.",prompt:`Build an AUTOMATION INVENTORY dashboard of the project's automation scripts using the \`generate_dashboard\` tool. Take the numbers from \`test_library\` action "summary" — it covers every script, including the ones that have never run.
|
|
39
|
+
|
|
40
|
+
Layout:
|
|
41
|
+
1. Four KPI cards (span 3 each): Total Scripts, Passing on Last Run %, Never Run, Not Linked to a Test Case.
|
|
42
|
+
2. A doughnut chart (span 6) "Scripts by Status" — passing / failing / never run / skipped in code.
|
|
43
|
+
3. A horizontal bar chart (span 6) "Scripts by Folder" — the folders with the most scripts.
|
|
44
|
+
4. A table (span 12) "Folders" with columns: Folder, Scripts, Failing, Never Run, Flaky.
|
|
45
|
+
5. A bar chart (span 6) "Scripts by Framework", and a table (span 6) "Scripts by Owner" (Owner, Scripts, Failing) when owners are known — otherwise a bar chart "Scripts by Tag".
|
|
46
|
+
6. A markdown cell (span 12) with 3–5 bullets: the biggest gaps (never-run and unlinked scripts), the folders with the most failures, and recommended next steps.
|
|
47
|
+
|
|
48
|
+
Title: "Automation Inventory — <Today's Date>". Save the result (save_report with templateId "automation_inventory").`},{id:"manual_vs_automated",label:"Manual vs Automated",description:"Quick breakdown of test cases by automation status.",prompt:'Generate a dashboard showing the breakdown of manual and automated test cases — totals, automation coverage percentage, and a list of currently-manual tests that could be prioritized for automation. Save the result (save_report with templateId "manual_vs_automated").'},{id:"coverage_by_requirement",label:"Coverage by Requirement",description:"Requirement coverage with orphan tests and uncovered requirements.",prompt:'Generate a dashboard showing requirement coverage — how many requirements have linked test cases, how many are uncovered, and which test cases are orphaned (no requirement linked). Save the result (save_report with templateId "coverage_by_requirement").'}];function lt(){const t=W(),n=a=>ye(t,{prompt:a,mode:"reporting"});return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Click a template to open the AI Assistant in Reporting mode with the prompt pre-filled. You can edit the prompt before submitting."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Re.map(a=>e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx(U,{size:14,className:"text-brand-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:a.label}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 leading-relaxed",children:a.description})]})]}),e.jsxs("div",{className:"text-[11px] text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-white/[0.02] border border-gray-100 dark:border-white/5 rounded-md p-2 font-mono mb-3 italic",children:['"',a.prompt,'"']}),e.jsxs("button",{onClick:()=>n(a.prompt),className:"w-full flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 transition-colors",children:["Run template ",e.jsx(fe,{size:11,className:"-rotate-90"})]})]},a.id))})]})}export{yt as ReportsPage};
|