@testver/testver 1.4.3 → 1.5.1
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 +38415 -21751
- 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{o as m,r as
|
|
1
|
+
import{o as m,r as t,j as e}from"./vendor-react-DOVfxdUy.js";import{a as l}from"./formatDate-T65-Y6Mi.js";import{iB as p}from"./index-BlA8ntjb.js";import{R as h}from"./ReportCard-LOf1PXlb.js";import{a1 as f,a as g,am as u}from"./vendor-icons-Cm92aSc5.js";import"./vendor-query-DkZSMtfn.js";import"./KpiTile-BKlWqjgN.js";import"./vendor-charts-By5uZ93z.js";function R(){const{token:a}=m(),[r,c]=t.useState(null),[x,n]=t.useState(!0),[d,o]=t.useState(null);return t.useEffect(()=>{if(!a){o("No share token provided"),n(!1);return}p(a).then(s=>c(s)).catch(s=>{const i=s instanceof Error?s.message:String(s);o(i.includes("not found")||i.includes("revoked")?"This share link is no longer valid — it expired or was revoked. Ask the report owner for a fresh link.":i)}).finally(()=>n(!1))},[a]),x?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-surface-0",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(f,{size:18,className:"animate-spin"}),e.jsx("span",{children:"Loading shared report…"})]})}):d||!r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-surface-0 px-6",children:e.jsxs("div",{className:"max-w-md w-full rounded-xl border border-rose-500/30 bg-white dark:bg-white/[0.03] p-6 text-center",children:[e.jsx(g,{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:"Share link unavailable"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:d||"Share link not found"})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-surface-0",children:e.jsxs("div",{className:"max-w-[1360px] mx-auto px-4 sm:px-6 py-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-5 text-[12px] text-gray-600 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-semibold tracking-wide uppercase",children:"Testver"}),e.jsx(u,{size:10,className:"opacity-50"}),e.jsx("span",{children:"Shared Report"})]}),e.jsxs("div",{children:["Read-only view · ",l(r.updatedAt||r.createdAt),r.shareExpiresAt&&e.jsxs(e.Fragment,{children:[" · link expires ",l(r.shareExpiresAt)]})]})]}),e.jsx(h,{variant:"page",spec:r.spec,savedId:r.id,initialShareToken:a,readonly:!0,links:!1}),e.jsx("div",{className:"text-center text-[11px] text-gray-400 dark:text-gray-600 mt-6",children:"Generated by Testver"})]})})}export{R as SharedReportView};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{u as
|
|
2
|
-
`;const p=Array.isArray(s.content)?s.content:[],n=p.map(i=>_(i)).join("");switch(s.type){case"doc":return n;case"paragraph":return n+`
|
|
3
|
-
`;case"heading":return n+`
|
|
4
|
-
`;case"bulletList":case"orderedList":return p.map((i,h)=>(s.type==="orderedList"?`${h+1}. `:"• ")+_(i).trim()).join(`
|
|
5
|
-
`)+`
|
|
6
|
-
`;case"listItem":return n;case"blockquote":return"> "+n.trim()+`
|
|
7
|
-
`;case"codeBlock":return"```\n"+n+"```\n";case"table":return p.map(i=>(Array.isArray(i==null?void 0:i.content)?i.content:[]).map(h=>_(h).trim()).join(" | ")).join(`
|
|
8
|
-
`)+`
|
|
9
|
-
`;case"tableRow":return n;case"tableCell":case"tableHeader":return n;case"mediaSingle":case"media":return`[media]
|
|
10
|
-
`;case"panel":return n;case"rule":return`---
|
|
11
|
-
`;default:return n}}function lt(s){const p=_(s==null?void 0:s.description),n=s!=null&&s.customfield_10028?_(s.customfield_10028):"";return[p,n?`
|
|
12
|
-
|
|
13
|
-
Acceptance Criteria:
|
|
14
|
-
${n}`:""].join("").trim()}const he=[{id:"requirement",label:"Requirements",icon:e.jsx(K,{size:16}),description:"Add requirements via text or document upload"},{id:"nlp",label:"Notes",icon:e.jsx(ye,{size:16}),description:"Free-form text — requirements, scenarios, ideas, anything in your own words"},{id:"jira",label:"JIRA",icon:e.jsx(re,{size:16}),description:"Pull stories and tasks from JIRA"},{id:"document",label:"Other Sources",icon:e.jsx(ae,{size:16}),description:"Documents, images, and references"}],ee={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},ve={requirement:e.jsx(K,{size:14,className:"text-blue-400"}),nlp:e.jsx(ye,{size:14,className:"text-purple-400"}),jira:e.jsx(re,{size:14}),document:e.jsx(ae,{size:14,className:"text-amber-400"})};function re({size:s=16}){return e.jsxs("svg",{width:s,height:s,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{x1:"98.03%",y1:"0.16%",x2:"58.89%",y2:"40.77%",id:"sjg1",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]}),e.jsxs("linearGradient",{x1:"100.67%",y1:"0.46%",x2:"55.4%",y2:"44.73%",id:"sjg2",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]})]}),e.jsxs("g",{children:[e.jsx("path",{d:"M244.658,0 L121.707,0 C121.707,14.72 127.554,28.837 137.963,39.246 C148.372,49.655 162.489,55.502 177.209,55.502 L199.858,55.502 L199.858,77.369 C199.877,107.994 224.699,132.816 255.324,132.836 L255.324,10.667 C255.324,4.776 250.549,0 244.658,0 Z",fill:"#2684FF"}),e.jsx("path",{d:"M183.822,61.262 L60.871,61.262 C60.891,91.887 85.713,116.709 116.338,116.729 L138.987,116.729 L138.987,138.667 C139.026,169.292 163.864,194.098 194.489,194.098 L194.489,71.929 C194.489,66.038 189.713,61.262 183.822,61.262 Z",fill:"url(#sjg1)"}),e.jsx("path",{d:"M122.951,122.489 L0,122.489 C0,153.142 24.849,177.991 55.502,177.991 L78.222,177.991 L78.222,199.858 C78.242,230.455 103.02,255.266 133.618,255.324 L133.618,133.156 C133.618,127.265 128.842,122.489 122.951,122.489 Z",fill:"url(#sjg2)"})]})]})}function Nt(){var oe;const{user:s}=Me(),p=$e(),n=fe(),b=(s==null?void 0:s.displayName)||(s==null?void 0:s.username)||"",[r,f]=Le("tab",["requirement","nlp","jira","document"],"requirement"),[i,h]=d.useState(""),[N,j]=d.useState(!1),[S,y]=d.useState(null),[P,x]=d.useState(null),[v,z]=d.useState(null),[g,k]=d.useState(null),{toast:F}=be(),Z=Ze({mutationFn:Qe,onSuccess:t=>{z(t),n.invalidateQueries({queryKey:["tm-plans"]})},onError:t=>F("error",(t==null?void 0:t.message)||"Failed to create plan")}),[q,I]=d.useState(""),[T,L]=d.useState(""),[Y,O]=d.useState("medium"),[G,U]=d.useState(""),[B,D]=d.useState(""),[a,l]=d.useState(""),[c,u]=d.useState(0),[A,$]=d.useState(""),{data:J}=ge({type:r,search:i||void 0}),M=Ee(),H=Oe(),W=Ue(),w=d.useMemo(()=>{const t=(J==null?void 0:J.sources)??[];return Array.isArray(t)?t:[]},[J]),[R]=Je("sourceId");d.useEffect(()=>{!R||!w.some(t=>t.id===R)||(x(R),requestAnimationFrame(()=>{var t;return(t=document.getElementById(`source-${R}`))==null?void 0:t.scrollIntoView({block:"center",behavior:"smooth"})}))},[R,w]);const C=()=>{I(""),L(""),O("medium"),U(""),D(""),l(""),u(0),$(""),y(null),j(!1)},we=t=>{y(t),I(t.title),L(t.content),O(t.metadata&&JSON.parse(t.metadata||"{}").priority||"medium"),U(t.externalUrl||""),D(t.fileName||""),l(t.fileType||""),u(t.fileSize||0),$(t.fileData||""),j(!0)},Ce=()=>{if(!q.trim())return;const t=JSON.stringify({priority:Y}),m={title:q.trim(),type:r,content:T.trim(),metadata:t,externalUrl:G.trim(),fileName:B,fileType:a,fileSize:c,fileData:A,createdBy:b};S?H.mutate({id:S.id,data:m},{onSuccess:o=>{var ce;C();const E=((ce=o==null?void 0:o.change)==null?void 0:ce.flaggedCases)??0;E>0&&(F("info",`${o.change.changedRequirements} requirement${o.change.changedRequirements===1?"":"s"} changed — ${E} test case${E===1?"":"s"} flagged for review (Test Cases shows what changed).`),n.invalidateQueries({queryKey:["tm-test-cases"]}))},onError:o=>F("error",(o==null?void 0:o.message)||"Could not save the source")}):M.mutate(m,{onSuccess:C,onError:o=>F("error",(o==null?void 0:o.message)||"Could not save the source")})},Se=t=>{k({id:t.id,title:t.title||"this source",type:t.type||"document",linkedTestCaseCount:t.linkedTestCaseCount??0})},ke=()=>{if(!g)return;const t=g.id;k(null),W.mutate(t,{onSuccess:()=>{n.invalidateQueries({queryKey:["tm-sources"]}),n.invalidateQueries({queryKey:["tm-sources-with-test-cases"]}),n.invalidateQueries({queryKey:["tm-source-traceability"]}),n.invalidateQueries({queryKey:["tm-coverage-stats"]})},onError:m=>{F("error",`Failed to delete: ${(m==null?void 0:m.message)||m}`)}})},Te=[".txt",".md",".csv",".json",".xml",".yaml",".yml",".log",".html",".htm"],Ae=(t,m)=>m.startsWith("text/")||m==="application/json"||m==="application/xml"||Te.some(o=>t.toLowerCase().endsWith(o)),ne=t=>{if(t.size>10*1024*1024)return;const m=new FileReader;if(m.onload=()=>{const o=m.result.split(",")[1]||"";$(o),D(t.name),l(t.type),u(t.size),q.trim()||I(t.name)},m.readAsDataURL(t),Ae(t.name,t.type)){const o=new FileReader;o.onload=()=>{const E=o.result;E&&!T.trim()&&L(E)},o.readAsText(t)}},Re=t=>{var o;const m=(o=t.target.files)==null?void 0:o[0];m&&ne(m),t.target.value=""},[Q,V]=d.useState(!1),Pe=t=>{t.preventDefault(),t.stopPropagation(),Q||V(!0)},ze=t=>{t.preventDefault(),t.stopPropagation(),V(!1)},Fe=t=>{var o;t.preventDefault(),t.stopPropagation(),V(!1);const m=(o=t.dataTransfer.files)==null?void 0:o[0];m&&ne(m)},qe=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,De=t=>t==null?void 0:t.startsWith("image/"),ie=()=>{const t=he.find(m=>m.id===r);return(t==null?void 0:t.label)||"Source"},le=(()=>{switch(r){case"requirement":return{title:"e.g. User Authentication Flow",content:"Describe the requirement in detail..."};case"nlp":return{title:"e.g. Shopping cart checkout flow",content:"Type any text here — a requirement, user story, BDD scenario, edge case description, or open question. Anything that helps describe what to test."};case"jira":return{title:"e.g. PROJ-1234: Add SSO Support",content:"Story description or acceptance criteria..."};case"document":return{title:"e.g. API Specification v2.0",content:"Notes or description about this document..."}}})();return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(We,{size:24,className:"text-brand-300"}),"Sources"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage requirements, notes, JIRA tickets, and reference documents"})]})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 flex gap-1",children:he.map(t=>e.jsxs("button",{onClick:()=>{f(t.id),h(""),j(!1),C()},className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${r===t.id?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[t.icon,t.label,w.length>0&&r===t.id&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-surface-2 text-gray-400",children:w.length})]},t.id))})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(je,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:`Search ${ie().toLowerCase()}...`,value:i,onChange:t=>h(t.target.value)})]}),e.jsxs("button",{onClick:()=>{C(),j(!0)},className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(de,{size:15}),"Add ",r==="document"?"Document":r==="nlp"?"Note":r==="jira"?"Ticket":"Requirement"]})]}),e.jsxs("div",{className:"space-y-3",children:[r==="jira"&&e.jsx(dt,{createSource:M,currentUserName:b}),N&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-200",children:[S?"Edit":"Add"," ",r==="document"?"Document":r==="nlp"?"Note":r==="jira"?"JIRA Ticket":"Requirement"]}),e.jsx("button",{onClick:C,className:"p-1 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200",children:e.jsx(me,{size:16})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Title *"}),e.jsx("input",{className:"w-full bg-surface-0 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:le.title,value:q,onChange:t=>I(t.target.value)})]}),(r==="nlp"||r==="jira")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:r==="nlp"?"Content":"Story / Acceptance Criteria"}),e.jsx("textarea",{className:"w-full bg-surface-0 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 min-h-[120px] resize-y",placeholder:le.content,value:T,onChange:t=>L(t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r==="requirement"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Priority"}),e.jsxs("select",{className:"w-full bg-surface-0 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:Y,onChange:t=>O(t.target.value),children:[e.jsx("option",{value:"critical",children:"Critical"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"low",children:"Low"})]})]}),r==="jira"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"JIRA URL"}),e.jsx("input",{className:"w-full bg-surface-0 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:"https://yourcompany.atlassian.net/browse/PROJ-1234",value:G,onChange:t=>U(t.target.value)})]})]}),(r==="document"||r==="requirement")&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:["Attach File ",e.jsx("span",{className:"text-red-400",children:"*"})]}),B?e.jsxs("div",{className:"flex items-center gap-3 bg-surface-0 rounded-lg p-3 border border-white/5",children:[De(a)?e.jsx("img",{src:`data:${a};base64,${A}`,alt:"",className:"w-10 h-10 rounded object-cover"}):e.jsx(X,{size:20,className:"text-gray-400"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:B}),e.jsx("p",{className:"text-xs text-gray-500",children:qe(c)})]}),e.jsx("button",{onClick:()=>{$(""),D(""),l(""),u(0)},className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-red-400",children:e.jsx(me,{size:14})})]}):e.jsxs("label",{onDragOver:Pe,onDragLeave:ze,onDrop:Fe,className:`flex items-center justify-center gap-2 border-2 border-dashed rounded-lg cursor-pointer transition-all duration-200 ${Q?"border-brand-500 bg-brand-500/5 py-16 scale-[1.01]":"border-white/10 hover:border-white/20 py-6"}`,children:[e.jsx(Xe,{size:16,className:Q?"text-brand-400":"text-gray-500"}),e.jsx("span",{className:`text-sm ${Q?"text-brand-300":"text-gray-400"}`,children:Q?"Drop file to upload":"Click or drag a file here (max 10MB)"}),e.jsx("input",{type:"file",className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.xlsm,.pptx,.txt,.md,.csv,.json,.xml,.yaml,.yml,.html,.htm,.rtf",onChange:Re})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx("button",{onClick:C,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-0 text-gray-400 border border-white/10",children:"Cancel"}),e.jsxs("button",{onClick:Ce,disabled:!q.trim()||(r==="requirement"||r==="document")&&!A,title:(r==="requirement"||r==="document")&&!A?"Attach a file to enable Save":"",className:"flex items-center gap-1.5 px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50 transition-colors",children:[e.jsx(Ve,{size:14}),S?"Update":"Save"]})]})]}),w.length>0?e.jsx("div",{className:"space-y-2",children:w.map(t=>e.jsx("div",{id:`source-${t.id}`,children:e.jsx(ot,{source:t,isExpanded:P===t.id,onToggle:()=>x(P===t.id?null:t.id),onEdit:()=>we(t),onDelete:()=>Se(t),activeTab:r,onCreatePlan:()=>Z.mutate({sourceId:t.id,createdBy:b}),creatingPlan:Z.isPending})},t.id))}):N?null:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-surface-1 border border-white/5 mb-4",children:ve[r]||e.jsx(X,{size:24,className:"text-gray-500"})}),e.jsxs("h3",{className:"text-sm font-medium text-gray-300 mb-1",children:["No ",ie().toLowerCase()," yet"]}),e.jsxs("p",{className:"text-xs text-gray-500 mb-4",children:["Add your first ",r==="requirement"?"requirement":r==="nlp"?"note":r==="jira"?"JIRA ticket":"document"," to get started"]}),e.jsxs("button",{onClick:()=>{C(),j(!0)},className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(de,{size:15}),"Add ",r==="document"?"Document":r==="nlp"?"Note":r==="jira"?"Ticket":"Requirement"]})]})]}),v&&e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>z(null)}),e.jsx("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/15 flex items-center justify-center mx-auto mb-4",children:e.jsx(et,{size:28,className:"text-emerald-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-100 mb-2",children:"Test Plan Created!"}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:e.jsx("strong",{className:"text-gray-200",children:(oe=v.plan)==null?void 0:oe.name})}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-sm text-gray-400 mb-6",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(K,{size:14,className:"text-brand-400"})," ",v.testCaseCount," test cases"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xe,{size:14,className:"text-emerald-400"})," Cycle ready"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("button",{onClick:()=>z(null),className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 rounded-lg transition-colors",children:"Close"}),e.jsxs("button",{onClick:()=>{z(null),p("/test-plans")},className:"flex items-center gap-2 px-5 py-2 text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors",children:[e.jsx(xe,{size:14})," Go to Execution"]})]})]})})]}),e.jsx(Ke,{open:!!g,title:g?`Delete this ${g.type==="requirement"?"requirement":g.type==="nlp"?"note":g.type==="jira"?"JIRA ticket":"source"}?`:"",description:(()=>{if(!g)return"";const t=g.linkedTestCaseCount>0?` It currently has ${g.linkedTestCaseCount} linked test case${g.linkedTestCaseCount===1?"":"s"} — those test cases will NOT be deleted, but their link to this source will be removed and traceability for this requirement will be lost.`:"";return`"${g.title}" will be permanently removed from the catalog.${t} This action cannot be undone.`})(),confirmLabel:"Delete",onConfirm:ke,onCancel:()=>k(null)})]})]})}function ot({source:s,isExpanded:p,onToggle:n,onEdit:b,onDelete:r,activeTab:f,onCreatePlan:i,creatingPlan:h}){var P;const{data:N}=Be(p?s.id:void 0),j=(N==null?void 0:N.testCases)??[],y=(s.metadata?JSON.parse(s.metadata||"{}"):{}).priority||"medium";return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 hover:border-white/10 transition-colors overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5 cursor-pointer",onClick:n,children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-surface-2 border border-white/5 flex items-center justify-center",children:ve[s.type]||e.jsx(X,{size:14,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.title}),f==="requirement"&&e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold ${ee[y]||ee.medium}`,children:y.charAt(0).toUpperCase()+y.slice(1)})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-gray-500",children:[s.content&&e.jsxs("span",{className:"truncate max-w-[300px]",children:[s.content.substring(0,80),s.content.length>80?"...":""]}),s.fileName&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ae,{size:10}),s.fileName]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-surface-2 text-gray-400 border border-white/5",children:[e.jsx(K,{size:10}),s.linkedTestCaseCount??0," TC",(s.linkedTestCaseCount??0)!==1?"s":""]}),(s.linkedTestCaseCount??0)>0&&i&&e.jsxs("button",{onClick:x=>{x.stopPropagation(),i()},disabled:h,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-brand-500/10 text-brand-400 border border-brand-500/20 hover:bg-brand-500/20 transition-colors disabled:opacity-50",title:"Create Test Plan with all linked test cases",children:[h?e.jsx(te,{size:10,className:"animate-spin"}):e.jsx(st,{size:10}),"Create Plan"]}),(s.staleCases??0)>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-amber-500/20 text-amber-300",title:"The text changed after these test cases were generated — Test Cases shows what changed",children:[e.jsx(se,{size:10}),s.staleCases," to review"]}),s.type==="jira"&&e.jsx(ct,{sourceId:s.id}),s.externalUrl&&e.jsx("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-brand-300",children:e.jsx(Ne,{size:14})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),b()},className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(at,{size:14})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),r()},className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-red-400",children:e.jsx(rt,{size:14})}),e.jsx(nt,{size:14,className:`text-gray-500 transition-transform ${p?"rotate-180":""}`})]})]}),p&&e.jsxs("div",{className:"border-t border-white/5 px-4 py-4 space-y-3",children:[s.content&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Content"}),e.jsx("p",{className:"text-sm text-gray-300 bg-surface-0 rounded-lg p-3 border border-white/5 whitespace-pre-wrap max-h-[200px] overflow-y-auto",children:s.content})]}),s.fileName&&s.fileData&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Attachment"}),e.jsx("div",{className:"flex items-center gap-3 bg-surface-0 rounded-lg p-3 border border-white/5",children:(P=s.fileType)!=null&&P.startsWith("image/")?e.jsx("img",{src:`data:${s.fileType};base64,${s.fileData}`,alt:s.fileName,className:"max-w-[200px] max-h-[150px] rounded-lg object-contain"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{size:16,className:"text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-300",children:s.fileName}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",s.fileSize?(s.fileSize/1024).toFixed(1)+" KB":"",")"]})]})})]}),j.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:["Linked Test Cases (",j.length,")"]}),e.jsx("div",{className:"space-y-1",children:j.map(x=>e.jsxs("div",{className:"flex items-center gap-2 bg-surface-0 rounded-lg px-3 py-2 border border-white/5",children:[e.jsx(K,{size:12,className:"text-brand-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-brand-300 flex-shrink-0",children:x.id}),e.jsx("span",{className:"text-sm text-gray-300 truncate",children:x.title}),e.jsx("span",{className:`ml-auto text-[10px] font-medium px-1.5 py-0.5 rounded ${ee[x.priority]||""}`,children:x.priority})]},x.id))})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[s.createdBy&&e.jsxs("span",{children:["Added by ",s.createdBy]}),e.jsx("span",{children:Ie(s.createdAt)})]})]})]})}function ct({sourceId:s}){const p=fe(),{toast:n}=be(),[b,r]=d.useState(!1);return e.jsx("button",{onClick:async f=>{f.stopPropagation(),r(!0);try{const i=await _e(s);p.invalidateQueries({queryKey:["tm-sources"]}),i.refreshed?i.change.flaggedCases>0?(p.invalidateQueries({queryKey:["tm-test-cases"]}),n("info",`Updated from Jira — ${i.change.flaggedCases} test case${i.change.flaggedCases===1?"":"s"} flagged for review.`)):n("success","Updated from Jira. No test case is affected."):n("success","Already up to date with Jira.")}catch(i){n("error",(i==null?void 0:i.message)||"Refresh failed")}finally{r(!1)}},disabled:b,title:"Refresh from Jira","aria-label":"Refresh from Jira",className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-blue-300 disabled:opacity-50",children:e.jsx(it,{size:14,className:b?"animate-spin":""})})}function dt({createSource:s,currentUserName:p}){var D;const{connectorId:n,isConfigured:b,baseUrl:r}=Ye(),{data:f}=Ge(n),i=He(),[h,N]=d.useState(""),[j,S]=d.useState(""),[y,P]=d.useState([]),[x,v]=d.useState(new Set),[z,g]=d.useState(0),{data:k}=ge({type:"jira"}),F=d.useMemo(()=>{const a=new Set,l=(k==null?void 0:k.sources)||[];for(const c of l){if(typeof c.externalUrl=="string"){const u=c.externalUrl.match(/\/browse\/([A-Z][A-Z0-9_]*-\d+)/i);u&&u[1]&&a.add(u[1].toUpperCase())}if(typeof c.title=="string"){const u=c.title.match(/^([A-Z][A-Z0-9_]*-\d+)/i);u&&u[1]&&a.add(u[1].toUpperCase())}}return a},[k]),Z=(f==null?void 0:f.projects)||[],q=()=>{if(!n||!h)return;const a=j.trim()||`project = "${h}" ORDER BY updated DESC`;i.mutate({connectorId:n,jql:a,maxResults:50},{onSuccess:l=>{const c=(l==null?void 0:l.issues)||[];P(c),v(new Set)}})},I=a=>{N(a),a&&S(`project = "${a}" ORDER BY updated DESC`)},T=a=>F.has(String(a).toUpperCase()),L=a=>{T(a)||v(l=>{const c=new Set(l);return c.has(a)?c.delete(a):c.add(a),c})},Y=()=>v(new Set(y.filter(a=>!T(a.key)).map(a=>a.key))),O=()=>v(new Set),G=async()=>{const a=y.filter(l=>x.has(l.key)&&!T(l.key));g(a.length);for(const l of a){const c=l.fields||{},u=lt(c);try{await s.mutateAsync({type:"jira",title:`${l.key}: ${c.summary||"Untitled"}`,content:u||c.summary||"",externalUrl:`${r}/browse/${l.key}`,createdBy:p})}catch{}}g(0),v(new Set)};if(!b)return e.jsxs("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-6 text-center",children:[e.jsx(ue,{className:"w-8 h-8 text-blue-400 mx-auto mb-3"}),e.jsx("h3",{className:"text-sm font-semibold text-blue-300 mb-1",children:"JIRA Not Connected"}),e.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Configure your JIRA connector to pull stories and tasks directly."}),e.jsxs("a",{href:"/connectors",className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-brand-400 bg-brand-500/10 hover:bg-brand-500/20 rounded-lg border border-brand-500/20",children:[e.jsx(ue,{className:"w-3.5 h-3.5"})," Go to Connectors"]})]});const U={Highest:"text-red-400",High:"text-orange-400",Medium:"text-amber-400",Low:"text-blue-400",Lowest:"text-gray-400"},B={"To Do":"bg-gray-500/15 text-gray-400","In Progress":"bg-blue-500/15 text-blue-400",Done:"bg-emerald-500/15 text-emerald-400"};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(re,{size:18}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Pull from JIRA"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs text-gray-500 mb-1",children:["Project ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsxs("select",{value:h,onChange:a=>I(a.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 text-sm focus:outline-none focus:ring-1 focus:ring-brand-500",children:[e.jsx("option",{value:"",children:"Select a project…"}),Z.map(a=>e.jsxs("option",{value:a.key,children:[a.key," — ",a.name]},a.key))]})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"JQL Query"}),e.jsx("input",{type:"text",value:j,onChange:a=>S(a.target.value),placeholder:'project = "PROJ" ORDER BY updated DESC',className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 text-sm placeholder:text-gray-600 focus:outline-none focus:ring-1 focus:ring-brand-500 font-mono"})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("button",{onClick:q,disabled:i.isPending||!h,title:h?"":"Select a project first",className:"w-full flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[i.isPending?e.jsx(te,{className:"w-4 h-4 animate-spin"}):e.jsx(je,{className:"w-4 h-4"}),"Search"]})})]}),!h&&e.jsxs("p",{className:"text-xs text-gray-500 mt-2 flex items-center gap-1.5",children:[e.jsx(se,{className:"w-3.5 h-3.5 text-amber-400"}),"Pick a project from the dropdown to search its tickets."]})]}),y.length>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-gray-300",children:[y.length," issues found"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:Y,className:"text-xs text-brand-400 hover:text-brand-300",children:"Select All"}),e.jsx("button",{onClick:O,className:"text-xs text-gray-500 hover:text-gray-300",children:"Deselect All"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[x.size," selected"]}),x.size>0&&e.jsxs("button",{onClick:G,disabled:z>0,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg disabled:opacity-50",children:[z>0?e.jsx(te,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(tt,{className:"w-3.5 h-3.5"}),"Import ",x.size," to Sources"]})]})]}),e.jsx("div",{className:"max-h-[400px] overflow-y-auto divide-y divide-white/5",children:y.map(a=>{var M,H,W,w,R;const l=a.fields||{},c=T(a.key),u=x.has(a.key),A=((M=l.priority)==null?void 0:M.name)||"",$=((H=l.status)==null?void 0:H.name)||"",J=((w=(W=l.status)==null?void 0:W.statusCategory)==null?void 0:w.name)||$;return e.jsxs("div",{onClick:()=>L(a.key),className:`flex items-center gap-3 px-4 py-3 transition-colors ${c?"opacity-60 cursor-not-allowed":u?"bg-brand-500/10 cursor-pointer":"hover:bg-white/[0.03] cursor-pointer"}`,title:c?"Already imported into Sources — duplicates are not allowed":void 0,children:[e.jsx("div",{className:`w-5 h-5 rounded border flex items-center justify-center shrink-0 ${c?"bg-gray-700 border-gray-600 text-gray-500":u?"bg-brand-500 border-brand-500 text-white":"border-gray-600"}`,children:c?e.jsx(pe,{className:"w-3 h-3"}):u&&e.jsx(pe,{className:"w-3 h-3"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-mono text-blue-400 shrink-0",children:a.key}),e.jsx("span",{className:"text-sm text-gray-200 truncate",children:l.summary}),c&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/15 text-emerald-300 border border-emerald-500/20 shrink-0",children:"Already imported"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${B[J]||"bg-gray-500/15 text-gray-400"}`,children:$}),A&&e.jsx("span",{className:`text-[10px] ${U[A]||"text-gray-400"}`,children:A}),e.jsx("span",{className:"text-[10px] text-gray-500",children:(R=l.issuetype)==null?void 0:R.name}),l.assignee&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["→ ",l.assignee.displayName]})]})]}),e.jsx("a",{href:`${r}/browse/${a.key}`,target:"_blank",rel:"noopener",onClick:C=>C.stopPropagation(),className:"text-gray-500 hover:text-blue-400 shrink-0",children:e.jsx(Ne,{className:"w-3.5 h-3.5"})})]},a.key)})})]}),i.isError&&e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4 text-red-400"}),e.jsx("span",{className:"text-xs text-red-400",children:((D=i.error)==null?void 0:D.message)||"Search failed"})]})]})}export{Nt as default};
|
|
1
|
+
import{u as De,r as d,j as e}from"./vendor-react-DOVfxdUy.js";import{a as Ie}from"./formatDate-T65-Y6Mi.js";import{u as Le,a as Je}from"./useTabParam-CyYAP90W.js";import{ah as ge,aI as Ee,aJ as Oe,aK as Ue,aL as Be}from"./useTestManagement-ommXjx0q.js";import{ae as Me,b as be,iz as Qe,iA as _e}from"./index-BlA8ntjb.js";import{C as Ke}from"./ConfirmDialog-D_N9188T.js";import{a as fe,c as Ze}from"./vendor-query-DkZSMtfn.js";import{u as Ye,d as Ge,b as He}from"./useJiraConnector--JZhbYrT.js";import{B as We,w as je,b5 as de,X as me,j as X,be as Xe,b1 as Ve,s as et,d as K,a3 as xe,bi as ye,bk as ae,a8 as ue,a1 as te,p as se,a6 as tt,ah as pe,$ as Ne,e as st,bc as at,b8 as rt,z as nt,R as it}from"./vendor-icons-Cm92aSc5.js";function _(s){var b,r,f;if(!s)return"";if(typeof s=="string")return s;if(s.type==="text")return s.text||"";if(s.type==="inlineCard")return((b=s.attrs)==null?void 0:b.url)||"";if(s.type==="mention")return`@${((r=s.attrs)==null?void 0:r.text)||""}`;if(s.type==="emoji")return((f=s.attrs)==null?void 0:f.shortName)||"";if(s.type==="hardBreak")return`
|
|
2
|
+
`;const p=Array.isArray(s.content)?s.content:[],n=p.map(i=>_(i)).join("");switch(s.type){case"doc":return n;case"paragraph":return n+`
|
|
3
|
+
`;case"heading":return n+`
|
|
4
|
+
`;case"bulletList":case"orderedList":return p.map((i,h)=>(s.type==="orderedList"?`${h+1}. `:"• ")+_(i).trim()).join(`
|
|
5
|
+
`)+`
|
|
6
|
+
`;case"listItem":return n;case"blockquote":return"> "+n.trim()+`
|
|
7
|
+
`;case"codeBlock":return"```\n"+n+"```\n";case"table":return p.map(i=>(Array.isArray(i==null?void 0:i.content)?i.content:[]).map(h=>_(h).trim()).join(" | ")).join(`
|
|
8
|
+
`)+`
|
|
9
|
+
`;case"tableRow":return n;case"tableCell":case"tableHeader":return n;case"mediaSingle":case"media":return`[media]
|
|
10
|
+
`;case"panel":return n;case"rule":return`---
|
|
11
|
+
`;default:return n}}function lt(s){const p=_(s==null?void 0:s.description),n=s!=null&&s.customfield_10028?_(s.customfield_10028):"";return[p,n?`
|
|
12
|
+
|
|
13
|
+
Acceptance Criteria:
|
|
14
|
+
${n}`:""].join("").trim()}const he=[{id:"requirement",label:"Requirements",icon:e.jsx(K,{size:16}),description:"Add requirements via text or document upload"},{id:"nlp",label:"Notes",icon:e.jsx(ye,{size:16}),description:"Free-form text — requirements, scenarios, ideas, anything in your own words"},{id:"jira",label:"JIRA",icon:e.jsx(re,{size:16}),description:"Pull stories and tasks from JIRA"},{id:"document",label:"Other Sources",icon:e.jsx(ae,{size:16}),description:"Documents, images, and references"}],ee={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},ve={requirement:e.jsx(K,{size:14,className:"text-blue-400"}),nlp:e.jsx(ye,{size:14,className:"text-purple-400"}),jira:e.jsx(re,{size:14}),document:e.jsx(ae,{size:14,className:"text-amber-400"})};function re({size:s=16}){return e.jsxs("svg",{width:s,height:s,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{x1:"98.03%",y1:"0.16%",x2:"58.89%",y2:"40.77%",id:"sjg1",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]}),e.jsxs("linearGradient",{x1:"100.67%",y1:"0.46%",x2:"55.4%",y2:"44.73%",id:"sjg2",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]})]}),e.jsxs("g",{children:[e.jsx("path",{d:"M244.658,0 L121.707,0 C121.707,14.72 127.554,28.837 137.963,39.246 C148.372,49.655 162.489,55.502 177.209,55.502 L199.858,55.502 L199.858,77.369 C199.877,107.994 224.699,132.816 255.324,132.836 L255.324,10.667 C255.324,4.776 250.549,0 244.658,0 Z",fill:"#2684FF"}),e.jsx("path",{d:"M183.822,61.262 L60.871,61.262 C60.891,91.887 85.713,116.709 116.338,116.729 L138.987,116.729 L138.987,138.667 C139.026,169.292 163.864,194.098 194.489,194.098 L194.489,71.929 C194.489,66.038 189.713,61.262 183.822,61.262 Z",fill:"url(#sjg1)"}),e.jsx("path",{d:"M122.951,122.489 L0,122.489 C0,153.142 24.849,177.991 55.502,177.991 L78.222,177.991 L78.222,199.858 C78.242,230.455 103.02,255.266 133.618,255.324 L133.618,133.156 C133.618,127.265 128.842,122.489 122.951,122.489 Z",fill:"url(#sjg2)"})]})]})}function Nt(){var oe;const{user:s}=Me(),p=De(),n=fe(),b=(s==null?void 0:s.displayName)||(s==null?void 0:s.username)||"",[r,f]=Le("tab",["requirement","nlp","jira","document"],"requirement"),[i,h]=d.useState(""),[N,j]=d.useState(!1),[S,y]=d.useState(null),[z,x]=d.useState(null),[v,P]=d.useState(null),[g,k]=d.useState(null),{toast:F}=be(),Z=Ze({mutationFn:Qe,onSuccess:t=>{P(t),n.invalidateQueries({queryKey:["tm-plans"]})},onError:t=>F("error",(t==null?void 0:t.message)||"Failed to create plan")}),[q,I]=d.useState(""),[T,L]=d.useState(""),[Y,O]=d.useState("medium"),[G,U]=d.useState(""),[B,$]=d.useState(""),[a,l]=d.useState(""),[c,u]=d.useState(0),[A,D]=d.useState(""),{data:J}=ge({type:r,search:i||void 0}),M=Ee(),H=Oe(),W=Ue(),w=d.useMemo(()=>{const t=(J==null?void 0:J.sources)??[];return Array.isArray(t)?t:[]},[J]),[R]=Je("sourceId");d.useEffect(()=>{!R||!w.some(t=>t.id===R)||(x(R),requestAnimationFrame(()=>{var t;return(t=document.getElementById(`source-${R}`))==null?void 0:t.scrollIntoView({block:"center",behavior:"smooth"})}))},[R,w]);const C=()=>{I(""),L(""),O("medium"),U(""),$(""),l(""),u(0),D(""),y(null),j(!1)},we=t=>{y(t),I(t.title),L(t.content),O(t.metadata&&JSON.parse(t.metadata||"{}").priority||"medium"),U(t.externalUrl||""),$(t.fileName||""),l(t.fileType||""),u(t.fileSize||0),D(t.fileData||""),j(!0)},Ce=()=>{if(!q.trim())return;const t=JSON.stringify({priority:Y}),m={title:q.trim(),type:r,content:T.trim(),metadata:t,externalUrl:G.trim(),fileName:B,fileType:a,fileSize:c,fileData:A,createdBy:b};S?H.mutate({id:S.id,data:m},{onSuccess:o=>{var ce;C();const E=((ce=o==null?void 0:o.change)==null?void 0:ce.flaggedCases)??0;E>0&&(F("info",`${o.change.changedRequirements} requirement${o.change.changedRequirements===1?"":"s"} changed — ${E} test case${E===1?"":"s"} flagged for review (Test Cases shows what changed).`),n.invalidateQueries({queryKey:["tm-test-cases"]}))},onError:o=>F("error",(o==null?void 0:o.message)||"Could not save the source")}):M.mutate(m,{onSuccess:C,onError:o=>F("error",(o==null?void 0:o.message)||"Could not save the source")})},Se=t=>{k({id:t.id,title:t.title||"this source",type:t.type||"document",linkedTestCaseCount:t.linkedTestCaseCount??0})},ke=()=>{if(!g)return;const t=g.id;k(null),W.mutate(t,{onSuccess:()=>{n.invalidateQueries({queryKey:["tm-sources"]}),n.invalidateQueries({queryKey:["tm-sources-with-test-cases"]}),n.invalidateQueries({queryKey:["tm-source-traceability"]}),n.invalidateQueries({queryKey:["tm-coverage-stats"]})},onError:m=>{F("error",`Failed to delete: ${(m==null?void 0:m.message)||m}`)}})},Te=[".txt",".md",".csv",".json",".xml",".yaml",".yml",".log",".html",".htm"],Ae=(t,m)=>m.startsWith("text/")||m==="application/json"||m==="application/xml"||Te.some(o=>t.toLowerCase().endsWith(o)),ne=t=>{if(t.size>10*1024*1024)return;const m=new FileReader;if(m.onload=()=>{const o=m.result.split(",")[1]||"";D(o),$(t.name),l(t.type),u(t.size),q.trim()||I(t.name)},m.readAsDataURL(t),Ae(t.name,t.type)){const o=new FileReader;o.onload=()=>{const E=o.result;E&&!T.trim()&&L(E)},o.readAsText(t)}},Re=t=>{var o;const m=(o=t.target.files)==null?void 0:o[0];m&&ne(m),t.target.value=""},[Q,V]=d.useState(!1),ze=t=>{t.preventDefault(),t.stopPropagation(),Q||V(!0)},Pe=t=>{t.preventDefault(),t.stopPropagation(),V(!1)},Fe=t=>{var o;t.preventDefault(),t.stopPropagation(),V(!1);const m=(o=t.dataTransfer.files)==null?void 0:o[0];m&&ne(m)},qe=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,$e=t=>t==null?void 0:t.startsWith("image/"),ie=()=>{const t=he.find(m=>m.id===r);return(t==null?void 0:t.label)||"Source"},le=(()=>{switch(r){case"requirement":return{title:"e.g. User Authentication Flow",content:"Describe the requirement in detail..."};case"nlp":return{title:"e.g. Shopping cart checkout flow",content:"Type any text here — a requirement, user story, BDD scenario, edge case description, or open question. Anything that helps describe what to test."};case"jira":return{title:"e.g. PROJ-1234: Add SSO Support",content:"Story description or acceptance criteria..."};case"document":return{title:"e.g. API Specification v2.0",content:"Notes or description about this document..."}}})();return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(We,{size:24,className:"text-brand-300"}),"Sources"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage requirements, notes, JIRA tickets, and reference documents"})]})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 flex gap-1",children:he.map(t=>e.jsxs("button",{onClick:()=>{f(t.id),h(""),j(!1),C()},className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${r===t.id?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[t.icon,t.label,w.length>0&&r===t.id&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-surface-2 text-gray-400",children:w.length})]},t.id))})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(je,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:`Search ${ie().toLowerCase()}...`,value:i,onChange:t=>h(t.target.value)})]}),e.jsxs("button",{onClick:()=>{C(),j(!0)},className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(de,{size:15}),"Add ",r==="document"?"Document":r==="nlp"?"Note":r==="jira"?"Ticket":"Requirement"]})]}),e.jsxs("div",{className:"space-y-3",children:[r==="jira"&&e.jsx(dt,{createSource:M,currentUserName:b}),N&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-200",children:[S?"Edit":"Add"," ",r==="document"?"Document":r==="nlp"?"Note":r==="jira"?"JIRA Ticket":"Requirement"]}),e.jsx("button",{onClick:C,className:"p-1 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200",children:e.jsx(me,{size:16})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Title *"}),e.jsx("input",{className:"w-full bg-surface-0 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:le.title,value:q,onChange:t=>I(t.target.value)})]}),(r==="nlp"||r==="jira")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:r==="nlp"?"Content":"Story / Acceptance Criteria"}),e.jsx("textarea",{className:"w-full bg-surface-0 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 min-h-[120px] resize-y",placeholder:le.content,value:T,onChange:t=>L(t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r==="requirement"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Priority"}),e.jsxs("select",{className:"w-full bg-surface-0 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:Y,onChange:t=>O(t.target.value),children:[e.jsx("option",{value:"critical",children:"Critical"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"low",children:"Low"})]})]}),r==="jira"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"JIRA URL"}),e.jsx("input",{className:"w-full bg-surface-0 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:"https://yourcompany.atlassian.net/browse/PROJ-1234",value:G,onChange:t=>U(t.target.value)})]})]}),(r==="document"||r==="requirement")&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:["Attach File ",e.jsx("span",{className:"text-red-400",children:"*"})]}),B?e.jsxs("div",{className:"flex items-center gap-3 bg-surface-0 rounded-lg p-3 border border-white/5",children:[$e(a)?e.jsx("img",{src:`data:${a};base64,${A}`,alt:"",className:"w-10 h-10 rounded object-cover"}):e.jsx(X,{size:20,className:"text-gray-400"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:B}),e.jsx("p",{className:"text-xs text-gray-500",children:qe(c)})]}),e.jsx("button",{onClick:()=>{D(""),$(""),l(""),u(0)},className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-red-400",children:e.jsx(me,{size:14})})]}):e.jsxs("label",{onDragOver:ze,onDragLeave:Pe,onDrop:Fe,className:`flex items-center justify-center gap-2 border-2 border-dashed rounded-lg cursor-pointer transition-all duration-200 ${Q?"border-brand-500 bg-brand-500/5 py-16 scale-[1.01]":"border-white/10 hover:border-white/20 py-6"}`,children:[e.jsx(Xe,{size:16,className:Q?"text-brand-400":"text-gray-500"}),e.jsx("span",{className:`text-sm ${Q?"text-brand-300":"text-gray-400"}`,children:Q?"Drop file to upload":"Click or drag a file here (max 10MB)"}),e.jsx("input",{type:"file",className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.xlsm,.pptx,.txt,.md,.csv,.json,.xml,.yaml,.yml,.html,.htm,.rtf",onChange:Re})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx("button",{onClick:C,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-0 text-gray-400 border border-white/10",children:"Cancel"}),e.jsxs("button",{onClick:Ce,disabled:!q.trim()||(r==="requirement"||r==="document")&&!A,title:(r==="requirement"||r==="document")&&!A?"Attach a file to enable Save":"",className:"flex items-center gap-1.5 px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50 transition-colors",children:[e.jsx(Ve,{size:14}),S?"Update":"Save"]})]})]}),w.length>0?e.jsx("div",{className:"space-y-2",children:w.map(t=>e.jsx("div",{id:`source-${t.id}`,children:e.jsx(ot,{source:t,isExpanded:z===t.id,onToggle:()=>x(z===t.id?null:t.id),onEdit:()=>we(t),onDelete:()=>Se(t),activeTab:r,onCreatePlan:()=>Z.mutate({sourceId:t.id,createdBy:b}),creatingPlan:Z.isPending})},t.id))}):N?null:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-surface-1 border border-white/5 mb-4",children:ve[r]||e.jsx(X,{size:24,className:"text-gray-500"})}),e.jsxs("h3",{className:"text-sm font-medium text-gray-300 mb-1",children:["No ",ie().toLowerCase()," yet"]}),e.jsxs("p",{className:"text-xs text-gray-500 mb-4",children:["Add your first ",r==="requirement"?"requirement":r==="nlp"?"note":r==="jira"?"JIRA ticket":"document"," to get started"]}),e.jsxs("button",{onClick:()=>{C(),j(!0)},className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(de,{size:15}),"Add ",r==="document"?"Document":r==="nlp"?"Note":r==="jira"?"Ticket":"Requirement"]})]})]}),v&&e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>P(null)}),e.jsx("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/15 flex items-center justify-center mx-auto mb-4",children:e.jsx(et,{size:28,className:"text-emerald-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-100 mb-2",children:"Test Plan Created!"}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:e.jsx("strong",{className:"text-gray-200",children:(oe=v.plan)==null?void 0:oe.name})}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-sm text-gray-400 mb-6",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(K,{size:14,className:"text-brand-400"})," ",v.testCaseCount," test cases"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xe,{size:14,className:"text-emerald-400"})," Cycle ready"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("button",{onClick:()=>P(null),className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 rounded-lg transition-colors",children:"Close"}),e.jsxs("button",{onClick:()=>{P(null),p("/test-plans")},className:"flex items-center gap-2 px-5 py-2 text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors",children:[e.jsx(xe,{size:14})," Go to Execution"]})]})]})})]}),e.jsx(Ke,{open:!!g,title:g?`Delete this ${g.type==="requirement"?"requirement":g.type==="nlp"?"note":g.type==="jira"?"JIRA ticket":"source"}?`:"",description:(()=>{if(!g)return"";const t=g.linkedTestCaseCount>0?` It currently has ${g.linkedTestCaseCount} linked test case${g.linkedTestCaseCount===1?"":"s"} — those test cases will NOT be deleted, but their link to this source will be removed and traceability for this requirement will be lost.`:"";return`"${g.title}" will be permanently removed from the catalog.${t} This action cannot be undone.`})(),confirmLabel:"Delete",onConfirm:ke,onCancel:()=>k(null)})]})]})}function ot({source:s,isExpanded:p,onToggle:n,onEdit:b,onDelete:r,activeTab:f,onCreatePlan:i,creatingPlan:h}){var z;const{data:N}=Be(p?s.id:void 0),j=(N==null?void 0:N.testCases)??[],y=(s.metadata?JSON.parse(s.metadata||"{}"):{}).priority||"medium";return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 hover:border-white/10 transition-colors overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5 cursor-pointer",onClick:n,children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-surface-2 border border-white/5 flex items-center justify-center",children:ve[s.type]||e.jsx(X,{size:14,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.title}),f==="requirement"&&e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold ${ee[y]||ee.medium}`,children:y.charAt(0).toUpperCase()+y.slice(1)})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-gray-500",children:[s.content&&e.jsxs("span",{className:"truncate max-w-[300px]",children:[s.content.substring(0,80),s.content.length>80?"...":""]}),s.fileName&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ae,{size:10}),s.fileName]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-surface-2 text-gray-400 border border-white/5",children:[e.jsx(K,{size:10}),s.linkedTestCaseCount??0," TC",(s.linkedTestCaseCount??0)!==1?"s":""]}),(s.linkedTestCaseCount??0)>0&&i&&e.jsxs("button",{onClick:x=>{x.stopPropagation(),i()},disabled:h,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-brand-500/10 text-brand-400 border border-brand-500/20 hover:bg-brand-500/20 transition-colors disabled:opacity-50",title:"Create Test Plan with all linked test cases",children:[h?e.jsx(te,{size:10,className:"animate-spin"}):e.jsx(st,{size:10}),"Create Plan"]}),(s.staleCases??0)>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-amber-500/20 text-amber-300",title:"The text changed after these test cases were generated — Test Cases shows what changed",children:[e.jsx(se,{size:10}),s.staleCases," to review"]}),s.type==="jira"&&e.jsx(ct,{sourceId:s.id}),s.externalUrl&&e.jsx("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-brand-300",children:e.jsx(Ne,{size:14})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),b()},className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(at,{size:14})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),r()},className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-red-400",children:e.jsx(rt,{size:14})}),e.jsx(nt,{size:14,className:`text-gray-500 transition-transform ${p?"rotate-180":""}`})]})]}),p&&e.jsxs("div",{className:"border-t border-white/5 px-4 py-4 space-y-3",children:[s.content&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Content"}),e.jsx("p",{className:"text-sm text-gray-300 bg-surface-0 rounded-lg p-3 border border-white/5 whitespace-pre-wrap max-h-[200px] overflow-y-auto",children:s.content})]}),s.fileName&&s.fileData&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Attachment"}),e.jsx("div",{className:"flex items-center gap-3 bg-surface-0 rounded-lg p-3 border border-white/5",children:(z=s.fileType)!=null&&z.startsWith("image/")?e.jsx("img",{src:`data:${s.fileType};base64,${s.fileData}`,alt:s.fileName,className:"max-w-[200px] max-h-[150px] rounded-lg object-contain"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{size:16,className:"text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-300",children:s.fileName}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",s.fileSize?(s.fileSize/1024).toFixed(1)+" KB":"",")"]})]})})]}),j.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:["Linked Test Cases (",j.length,")"]}),e.jsx("div",{className:"space-y-1",children:j.map(x=>e.jsxs("div",{className:"flex items-center gap-2 bg-surface-0 rounded-lg px-3 py-2 border border-white/5",children:[e.jsx(K,{size:12,className:"text-brand-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-brand-300 flex-shrink-0",children:x.id}),e.jsx("span",{className:"text-sm text-gray-300 truncate",children:x.title}),e.jsx("span",{className:`ml-auto text-[10px] font-medium px-1.5 py-0.5 rounded ${ee[x.priority]||""}`,children:x.priority})]},x.id))})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[s.createdBy&&e.jsxs("span",{children:["Added by ",s.createdBy]}),e.jsx("span",{children:Ie(s.createdAt)})]})]})]})}function ct({sourceId:s}){const p=fe(),{toast:n}=be(),[b,r]=d.useState(!1);return e.jsx("button",{onClick:async f=>{f.stopPropagation(),r(!0);try{const i=await _e(s);p.invalidateQueries({queryKey:["tm-sources"]}),i.refreshed?i.change.flaggedCases>0?(p.invalidateQueries({queryKey:["tm-test-cases"]}),n("info",`Updated from Jira — ${i.change.flaggedCases} test case${i.change.flaggedCases===1?"":"s"} flagged for review.`)):n("success","Updated from Jira. No test case is affected."):n("success","Already up to date with Jira.")}catch(i){n("error",(i==null?void 0:i.message)||"Refresh failed")}finally{r(!1)}},disabled:b,title:"Refresh from Jira","aria-label":"Refresh from Jira",className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-blue-300 disabled:opacity-50",children:e.jsx(it,{size:14,className:b?"animate-spin":""})})}function dt({createSource:s,currentUserName:p}){var $;const{connectorId:n,isConfigured:b,baseUrl:r}=Ye(),{data:f}=Ge(n),i=He(),[h,N]=d.useState(""),[j,S]=d.useState(""),[y,z]=d.useState([]),[x,v]=d.useState(new Set),[P,g]=d.useState(0),{data:k}=ge({type:"jira"}),F=d.useMemo(()=>{const a=new Set,l=(k==null?void 0:k.sources)||[];for(const c of l){if(typeof c.externalUrl=="string"){const u=c.externalUrl.match(/\/browse\/([A-Z][A-Z0-9_]*-\d+)/i);u&&u[1]&&a.add(u[1].toUpperCase())}if(typeof c.title=="string"){const u=c.title.match(/^([A-Z][A-Z0-9_]*-\d+)/i);u&&u[1]&&a.add(u[1].toUpperCase())}}return a},[k]),Z=(f==null?void 0:f.projects)||[],q=()=>{if(!n||!h)return;const a=j.trim()||`project = "${h}" ORDER BY updated DESC`;i.mutate({connectorId:n,jql:a,maxResults:50},{onSuccess:l=>{const c=(l==null?void 0:l.issues)||[];z(c),v(new Set)}})},I=a=>{N(a),a&&S(`project = "${a}" ORDER BY updated DESC`)},T=a=>F.has(String(a).toUpperCase()),L=a=>{T(a)||v(l=>{const c=new Set(l);return c.has(a)?c.delete(a):c.add(a),c})},Y=()=>v(new Set(y.filter(a=>!T(a.key)).map(a=>a.key))),O=()=>v(new Set),G=async()=>{const a=y.filter(l=>x.has(l.key)&&!T(l.key));g(a.length);for(const l of a){const c=l.fields||{},u=lt(c);try{await s.mutateAsync({type:"jira",title:`${l.key}: ${c.summary||"Untitled"}`,content:u||c.summary||"",externalUrl:`${r}/browse/${l.key}`,createdBy:p})}catch{}}g(0),v(new Set)};if(!b)return e.jsxs("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-6 text-center",children:[e.jsx(ue,{className:"w-8 h-8 text-blue-400 mx-auto mb-3"}),e.jsx("h3",{className:"text-sm font-semibold text-blue-300 mb-1",children:"JIRA Not Connected"}),e.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Configure your JIRA connector to pull stories and tasks directly."}),e.jsxs("a",{href:"/connectors",className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-brand-400 bg-brand-500/10 hover:bg-brand-500/20 rounded-lg border border-brand-500/20",children:[e.jsx(ue,{className:"w-3.5 h-3.5"})," Go to Connectors"]})]});const U={Highest:"text-red-400",High:"text-orange-400",Medium:"text-amber-400",Low:"text-blue-400",Lowest:"text-gray-400"},B={"To Do":"bg-gray-500/15 text-gray-400","In Progress":"bg-blue-500/15 text-blue-400",Done:"bg-emerald-500/15 text-emerald-400"};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(re,{size:18}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Pull from JIRA"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs text-gray-500 mb-1",children:["Project ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsxs("select",{value:h,onChange:a=>I(a.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 text-sm focus:outline-none focus:ring-1 focus:ring-brand-500",children:[e.jsx("option",{value:"",children:"Select a project…"}),Z.map(a=>e.jsxs("option",{value:a.key,children:[a.key," — ",a.name]},a.key))]})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"JQL Query"}),e.jsx("input",{type:"text",value:j,onChange:a=>S(a.target.value),placeholder:'project = "PROJ" ORDER BY updated DESC',className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 text-sm placeholder:text-gray-600 focus:outline-none focus:ring-1 focus:ring-brand-500 font-mono"})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("button",{onClick:q,disabled:i.isPending||!h,title:h?"":"Select a project first",className:"w-full flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[i.isPending?e.jsx(te,{className:"w-4 h-4 animate-spin"}):e.jsx(je,{className:"w-4 h-4"}),"Search"]})})]}),!h&&e.jsxs("p",{className:"text-xs text-gray-500 mt-2 flex items-center gap-1.5",children:[e.jsx(se,{className:"w-3.5 h-3.5 text-amber-400"}),"Pick a project from the dropdown to search its tickets."]})]}),y.length>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-gray-300",children:[y.length," issues found"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:Y,className:"text-xs text-brand-400 hover:text-brand-300",children:"Select All"}),e.jsx("button",{onClick:O,className:"text-xs text-gray-500 hover:text-gray-300",children:"Deselect All"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[x.size," selected"]}),x.size>0&&e.jsxs("button",{onClick:G,disabled:P>0,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg disabled:opacity-50",children:[P>0?e.jsx(te,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(tt,{className:"w-3.5 h-3.5"}),"Import ",x.size," to Sources"]})]})]}),e.jsx("div",{className:"max-h-[400px] overflow-y-auto divide-y divide-white/5",children:y.map(a=>{var M,H,W,w,R;const l=a.fields||{},c=T(a.key),u=x.has(a.key),A=((M=l.priority)==null?void 0:M.name)||"",D=((H=l.status)==null?void 0:H.name)||"",J=((w=(W=l.status)==null?void 0:W.statusCategory)==null?void 0:w.name)||D;return e.jsxs("div",{onClick:()=>L(a.key),className:`flex items-center gap-3 px-4 py-3 transition-colors ${c?"opacity-60 cursor-not-allowed":u?"bg-brand-500/10 cursor-pointer":"hover:bg-white/[0.03] cursor-pointer"}`,title:c?"Already imported into Sources — duplicates are not allowed":void 0,children:[e.jsx("div",{className:`w-5 h-5 rounded border flex items-center justify-center shrink-0 ${c?"bg-gray-700 border-gray-600 text-gray-500":u?"bg-brand-500 border-brand-500 text-white":"border-gray-600"}`,children:c?e.jsx(pe,{className:"w-3 h-3"}):u&&e.jsx(pe,{className:"w-3 h-3"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-mono text-blue-400 shrink-0",children:a.key}),e.jsx("span",{className:"text-sm text-gray-200 truncate",children:l.summary}),c&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/15 text-emerald-300 border border-emerald-500/20 shrink-0",children:"Already imported"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${B[J]||"bg-gray-500/15 text-gray-400"}`,children:D}),A&&e.jsx("span",{className:`text-[10px] ${U[A]||"text-gray-400"}`,children:A}),e.jsx("span",{className:"text-[10px] text-gray-500",children:(R=l.issuetype)==null?void 0:R.name}),l.assignee&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["→ ",l.assignee.displayName]})]})]}),e.jsx("a",{href:`${r}/browse/${a.key}`,target:"_blank",rel:"noopener",onClick:C=>C.stopPropagation(),className:"text-gray-500 hover:text-blue-400 shrink-0",children:e.jsx(Ne,{className:"w-3.5 h-3.5"})})]},a.key)})})]}),i.isError&&e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4 text-red-400"}),e.jsx("span",{className:"text-xs text-red-400",children:(($=i.error)==null?void 0:$.message)||"Search failed"})]})]})}export{Nt as default};
|