Testcraft Studio frontend 27: src/pages/Dashboard.jsx
importReactfrom'react';importIconfrom'../Icon.jsx';import{useStudio,workspaceStatus,visibleWorkspaces}from'../store.jsx';import{Badge,Button,Empty,Heading}from'../ui.jsx';exportdefaultfunctionDashboard({navigate}){const{state:s,mutate}=useStudio();constlist=visibleWorkspaces(s),baselines=s.baselines.filter(b=>b.team===s.session.team&&['Active','Approved'].includes(b.status));constsuites=s.suites.filter(suite=>list.some(w=>w.id===suite.workspaceId));constopen=w=>{mutate(d=>{d.activeWorkspaceId=w.id;});navigate('workspace');};conststeps=[['folder','Create a workspace','Give your testing work a dedicated space.','workspaces?create'],['layers','Add a System Baseline','Upload documents and request approval.','baselines?create'],['chat','Explore your evidence','Ask the system about uploaded knowledge.','chat'],['spark','Generate test cases','Use a default or Excel template.','readiness']];return<><Headingeyebrow={`${s.session.team} · YOUR TESTING SPACE`}title="Workspace overview"description="From system knowledge to well-grounded test cases."><Buttonicon="plus"variant="primary"onClick={()=>navigate('workspaces?create')}>Create workspace</Button></Heading><divclassName="stats-grid">{[{label:'Workspaces',value:list.length,icon:'folder',note:'Across your team',tone:'purple',page:'workspaces'},{label:'Approved baselines',value:baselines.length,icon:'layers',note:'Ready to use',tone:'blue',page:'baselines'},{label:'Test suites',value:suites.length,icon:'checkSquare',note:'Generated from your evidence',tone:'green',page:'suites'},{label:'Templates',value:s.templates.filter(t=>t.team===s.session.team).length,icon:'file',note:'Your preferred output format',tone:'purple',page:'templates'}].map(stat=><buttonclassName="stat-card"key={stat.label}onClick={()=>navigate(stat.page)}><divclassName="stat-top"><span>{stat.label}</span><spanclassName={`stat-icon soft-${stat.tone}`}><Iconname={stat.icon}size={18}/></span></div><strong>{stat.value}</strong><spanclassName="stat-note">{stat.note}</span></button>)}</div><sectionclassName="card start-guide"><divclassName="section-heading"><h2>A clear path from evidence to tests</h2><Badgetone="purple">Your workflow</Badge></div><divclassName="onboarding-grid">{steps.map(([icon,title,description,page],index)=><buttonclassName="onboarding-step"key={title}onClick={()=>navigate(page)}><spanclassName="step-kicker">0{index+1}<Iconname={icon}size={22}/></span><strong>{title}</strong><p>{description}</p><Iconname="arrow"size={16}/></button>)}</div></section><sectionclassName="card workspace-list margin-top"><divclassName="section-heading"><h2>Your workspaces</h2><buttonclassName="text-button"onClick={()=>navigate('workspaces')}>View all <Iconname="arrow"size={14}/></button></div>{list.length?<divclassName="table-scroll"><table><thead><tr><th>WORKSPACE</th><th>SYSTEM BASELINE</th><th>STATUS</th><th/></tr></thead><tbody>{list.slice(0,5).map(w=><trkey={w.id}><td><buttonclassName="workspace-table-name"onClick={()=>open(w)}><spanclassName="table-icon soft-purple"><Iconname="folder"size={17}/></span><span><strong>{w.name}</strong><small>{w.ref}</small></span></button></td><td>{s.baselines.find(b=>b.id===w.baselineId)?.ref||'Not connected yet'}</td><td><Badge>{workspaceStatus(s,w)}</Badge></td><td><ButtononClick={()=>open(w)}>Open workspace</Button></td></tr>)}</tbody></table></div>:<Emptytitle="Make room for your first test journey"description="Start with a workspace. You can create its System Baseline next."action={<Buttonvariant="primary"icon="plus"onClick={()=>navigate('workspaces?create')}>Create your first workspace</Button>}/>}</section></>;}
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)