Skip to content

fix(host-pm-web): save draft before deleting removed documents (#32734)#1123

Merged
jimmypalelil merged 1 commit intobcgov:mainfrom
jimmypalelil:32734-save-draft-then-delete
Mar 23, 2026
Merged

fix(host-pm-web): save draft before deleting removed documents (#32734)#1123
jimmypalelil merged 1 commit intobcgov:mainfrom
jimmypalelil:32734-save-draft-then-delete

Conversation

@jimmypalelil
Copy link
Copy Markdown
Collaborator

Issue:

Description of changes:

  • Host PM (strr-host-pm-web): When removing an uploaded document, persist the application draft (with the document removed from the local list) before calling DELETE /documents, so application_json.registration.documents stays consistent with storage and examiners do not hit broken links / 502s for removed files.
  • If draft save fails, restore the document to storedDocuments, log the error, and show the generic document upload error modal.
  • Tests: Extended store-document.spec.ts for removal flows.
  • Version: Bumped strr-host-pm-web patch version.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the BC Registry and Digital Services BSD 3-Clause License

@jimmypalelil jimmypalelil force-pushed the 32734-save-draft-then-delete branch from aa5bc16 to 6a0ac0b Compare March 23, 2026 15:32
@bcregistry-sre
Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-hosts-dev--pr-1123-psy8tk9s.web.app

1 similar comment
@bcregistry-sre
Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-hosts-dev--pr-1123-psy8tk9s.web.app

@jimmypalelil jimmypalelil requested a review from dimak1 March 23, 2026 15:47
@dimak1 dimak1 requested a review from JazzarKarim March 23, 2026 15:57
Comment thread strr-host-pm-web/app/stores/document.ts
@jimmypalelil jimmypalelil requested a review from dimak1 March 23, 2026 16:50
Comment thread strr-host-pm-web/app/stores/document.ts
Comment thread strr-host-pm-web/app/stores/document.ts Outdated
storedDocuments.value.splice(index, 0, uiDoc)
logFetchError(e, 'Error saving draft when removing document')
strrModal.openErrorModal(
t('error.docUpload.generic.title'),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generic title/description is for 'Error Uploading Document', which may be confusing for a user when they are trying to delete the document?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea good call.

how about we reuse the existing modal thats shown during draft submission error like below:

image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm ok with reusing it, as long as it is added to the ticket requirements and later QA'd.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the paths to be tested to the ticket for visibliity & QA: #1152 (comment)

Call submitApplication with the updated document list before DELETE /documents so application_json stays aligned with storage and examiners avoid 502s on removed files. Restore the document to storedDocuments when draft save fails.

Add unit tests for removal when no application id exists, save-then-delete, failed save, and failed delete after save.

Made-with: Cursor
@jimmypalelil jimmypalelil force-pushed the 32734-save-draft-then-delete branch from 6a0ac0b to 9a18314 Compare March 23, 2026 17:25
@sonarqubecloud
Copy link
Copy Markdown

@bcregistry-sre
Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-hosts-dev--pr-1123-psy8tk9s.web.app

Copy link
Copy Markdown
Collaborator

@dimak1 dimak1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG! Thanks for making the updates and adding the tests.

@jimmypalelil jimmypalelil merged commit 2d8f082 into bcgov:main Mar 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants