Fix Artifacts dropdown to show options conditionally#1425
Conversation
📝 WalkthroughWalkthroughA single component file was modified to adjust conditional rendering logic for a dropdown menu. The visibility of the Artifacts dropdown and its child menu items (View Datasets, View Models) now depends on different data properties than previously implemented. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/components/Experiment/Tasks/JobsList.tsx (1)
336-347: Strengthen conditions for dataset and model menu items.Lines 336 and 343 render menu entries based on loose truthiness checks. Menu items will appear for empty arrays and may expose no-op actions when callbacks are undefined.
Verify that
generated_datasetsandmodelsare populated before rendering menu items, and ensure handlers are present:Suggested refactor
- {job?.job_data?.generated_datasets && ( + {onViewJobDatasets && job?.job_data?.generated_datasets && ( <MenuItem onClick={() => onViewJobDatasets?.(job?.id)} > View Datasets </MenuItem> )} - {job?.job_data?.models && ( + {onViewJobModels && job?.job_data?.models && ( <MenuItem onClick={() => onViewJobModels?.(job?.id)}> View Models </MenuItem> )}Additionally, address the broader type safety issue:
jobsis typed asany[](line 26), which violates the coding guideline to "Avoidanyin TypeScript; define interfaces for all props and API responses to ensure type safety". Define a properJobinterface with explicit typing forjob_data,generated_datasets, andmodelsfields.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/renderer/components/Experiment/Tasks/JobsList.tsx` around lines 336 - 347, The menu items render on loose truthiness; update the conditionals in JobsList so that you only render the "View Datasets" MenuItem when job.job_data?.generated_datasets is an array with length > 0 and onViewJobDatasets is a defined function, and likewise only render "View Models" when job.job_data?.models is an array with length > 0 and onViewJobModels exists; also replace the any[] jobs prop with a concrete Job interface (include job.id, job_data with generated_datasets: any[] and models: any[] at minimum) and use that interface for the component props and any local job variables to remove the any and ensure proper typing for these checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/renderer/components/Experiment/Tasks/JobsList.tsx`:
- Around line 336-347: The menu items render on loose truthiness; update the
conditionals in JobsList so that you only render the "View Datasets" MenuItem
when job.job_data?.generated_datasets is an array with length > 0 and
onViewJobDatasets is a defined function, and likewise only render "View Models"
when job.job_data?.models is an array with length > 0 and onViewJobModels
exists; also replace the any[] jobs prop with a concrete Job interface (include
job.id, job_data with generated_datasets: any[] and models: any[] at minimum)
and use that interface for the component props and any local job variables to
remove the any and ensure proper typing for these checks.
Summary by CodeRabbit