fix(documents): translate document's files from js to ts - #7611
fix(documents): translate document's files from js to ts#7611Camille Roux (camrrx) wants to merge 4 commits into
Conversation
|
📖 Documentation check — ✅ Passed 21 functional file(s), 0 doc file(s) changed. No documentation gaps detected. |
There was a problem hiding this comment.
Pull request overview
Migrates the Documents feature (admin UI) from legacy .jsx/react-final-form patterns to TypeScript + React Hook Form, aligning document creation/editing with typed inputs and newer queryable pagination patterns.
Changes:
- Converted Documents list, creation flow, and helper components from
.jsxto.tsx(including a newDocumentFormbased on React Hook Form + Zod). - Added a React Hook Form-compatible file upload controller (
FileFieldController) and updated scenario/simulation selectors to support RHF multiple selection. - Tightened action typings for document creation (FormData support) and exercise lookups (typed request body).
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| openaev-front/src/components/fields/SimulationField.tsx | Adds RHF multiple-selection mode for simulations/exercises; updates imports and props typing. |
| openaev-front/src/components/fields/ScenarioField.tsx | Adds RHF controller-based multiple-selection mode and introduces disabled prop support. |
| openaev-front/src/components/fields/FileFieldController.tsx | New RHF controller for file selection with filtering and helper text rendering. |
| openaev-front/src/components/ExerciseField.jsx | Removes deprecated legacy ExerciseField (react-final-form). |
| openaev-front/src/admin/components/components/documents/DocumentType.tsx | New TypeScript functional version of the DocumentType chip renderer. |
| openaev-front/src/admin/components/components/documents/DocumentType.jsx | Removes legacy class-based DocumentType implementation. |
| openaev-front/src/admin/components/components/documents/Documents.tsx | New TypeScript documents list using Queryable V2 pagination + prefetching related exercises/scenarios by id. |
| openaev-front/src/admin/components/components/documents/Documents.jsx | Removes legacy documents list implementation. |
| openaev-front/src/admin/components/components/documents/DocumentPopover.tsx | Refactors edit/delete/remove flows to typed inputs + RHF-based form and updated dialog usage. |
| openaev-front/src/admin/components/components/documents/DocumentForm.tsx | New RHF + Zod document form with typed input model and conditional file requirement. |
| openaev-front/src/admin/components/components/documents/DocumentForm.jsx | Removes legacy react-final-form document form. |
| openaev-front/src/admin/components/components/documents/CreateDocument.tsx | New TypeScript create flow using FormData + typed initial values from context. |
| openaev-front/src/admin/components/components/documents/CreateDocument.jsx | Removes legacy connected create component. |
| openaev-front/src/admin/components/common/articles/ArticleForm.tsx | Updates DocumentPopover usage to match new component API. |
| openaev-front/src/admin/components/common/articles/ArticleAddDocuments.tsx | Aligns create callback types and normalizes filters to undefined instead of null. |
| openaev-front/src/actions/scenarios/scenario-helper.d.ts | Extends helper typing with getScenariosMap() used by Documents list. |
| openaev-front/src/actions/Exercise.ts | Fixes fetchExercisesById to accept the endpoint’s typed request body. |
| openaev-front/src/actions/Document.ts | Allows addDocument to accept FormData for multipart document creation. |
Suppressed comments (1)
openaev-front/src/admin/components/components/documents/DocumentPopover.tsx:79
- issue (blocking):
documentIdfalls back to an empty string whendocument.document_idis missing, but it is then used for update/delete/fetch calls, which can hit incorrect endpoints (e.g./api/documents//relations). Treatdocument_idas required (or guard and disable actions) instead of defaulting to ''.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
f654cca to
c0a5247
Compare
c0a5247 to
eff9e10
Compare
There was a problem hiding this comment.
The two files ScenarioFieldController.tsx and SimulationFieldController.tsx are almost identical; shouldn't we merge them to make them easier to maintain EntityMultiSelectFieldController ?
Gaetan Santucci (GaetanSantucci)
left a comment
There was a problem hiding this comment.
Dead code left behind: exerciseOptions and scenarioOptions (src/utils/Option.ts) no longer have any callers since the removal of DocumentPopover.jsx.
ce518e0 to
ebdf9fd
Compare
Proposed changes
Testing Instructions