[MDS-7019] - Fix replace documents in Major Projects on Core - #3996
Merged
Merged
Conversation
added 2 commits
September 11, 2026 15:25
…hooks; add document replacement support in `DocumentTable`. Signed-off-by: Mat Busby <mat.busby@studio.ey.com>
…istency. Signed-off-by: Mat Busby <mat.busby@studio.ey.com>
matbusby-fw
force-pushed
the
mds-7019-major-project-document-mismatch
branch
from
September 11, 2026 21:25
d7d5e87 to
8eef7c1
Compare
…geTab`. Signed-off-by: Mat Busby <mat.busby@studio.ey.com>
alazar-aot
requested changes
Sep 14, 2026
alazar-aot
left a comment
Collaborator
There was a problem hiding this comment.
Noticed 2 small things, but looks super solid overall! Should be easy fixes
… enhance `DecisionPackageTab` with initial mount check. Signed-off-by: Mat Busby <mat.busby@studio.ey.com>
|
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





Objective
MDS-7019
Fix document replacement display issues in Major Projects where replacing an existing document caused version ordering in the accordion to invert (newest at bottom, oldest at top) and left the table row displaying stale details. Also migrates
DecisionPackageTabfrom JavaScript to TypeScript (.tsx).Source of the Issue
Version History Inversion in Constructor:
ReplaceDocumentModal.tsx, the list of existing versions was reversed before creating the new version entries. However, theMineDocumentmodel constructor also performs its own sort/reversal handling for version history. This resulted in a double reversal: the newest replaced version was pushed to the bottom of the accordion list instead of remaining at the top.Date Format Inconsistency:
YYYY-MM-DDTHH:mm:ssZ) in Ant Design table sorters to tie or sort inconsistently.Loss of Document Subclass / Metadata:
MineDocument, dropping subclass-specific attributes and prototype methods associated withMajorMineApplicationDocument(e.g., category codes, labels, and document subtypes).Missing Callback Propagation (
onReplaceDocument):DocumentTableopened the replacement modal and triggered the upload action, but did not accept or invoke anonReplaceDocumentcallback upon completion. Because the parent tabs (ProjectDocumentsTab,MajorMineApplicationTab,DecisionPackageTab) were not notified of the replacement, the parent container never re-fetched the updated project/document list from the backend, leaving the table display out of sync until a manual page reload.Why This Fixes It
Corrects Version Array Ordering & Subclass Preservation (
ReplaceDocumentModal.tsx):MajorMineApplicationDocument) so all custom getters and metadata remain intact.update_timestampusingnew Date().toISOString()for exact chronological comparison against backend timestamps.props.handleSubmit(newDocument)before closing the modal.Propagates Refresh Callbacks (
DocumentTable.tsx,ProjectDocumentsTab.tsx,ProjectDocumentsTabSection.tsx):onReplaceDocument?: (document: T) => void | Promise<void>prop toDocumentTableProps.onReplaceDocumentinProjectDocumentsTabto triggerrefreshData/refreshAmsAppsacross all document sections (primary, appendix, supporting, ministry decision, authorization amendment, and AMS documents).onReplaceDocument={fetchData}inMajorMineApplicationTab.tsxandDecisionPackageTab.tsx.Migrated
DecisionPackageTabto TypeScript (DecisionPackageTab.tsx):FC) using React hooks (useDispatch,useSelector,useParams,useFeatureFlag,useState,useEffect).DecisionPackageTabPropsto remain backward-compatible with unit tests that pass props directly while cleanly falling back to Redux selectors and React Router hooks when mounted inProject.tsx.DecisionPackageTab.js.Automated Tests & Verification
DocumentTable.spec.tsx: Added test verifying thatonReplaceDocumentis invoked with the updated document when a replacement is submitted.ReplaceDocumentModal.spec.tsx: Added test verifying that document version history correctly sorts newest versions first.yarn workspace @mds/common run test DocumentTable.spec.tsx ReplaceDocumentModal.spec.tsx