Add endpoint for explicitly requesting SubmissionMetadata
lock
#1299
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.
These changes are in support of having the Field Notes app respect the
locked_by
field onSubmissionMetadata
records (microbiomedata/nmdc-field-notes#90). There are two issues I'm trying to address here:GET
requests whenever possible. The underlying assumption of the caching layer is thatGET
requests have no side effects. Currently, however, a request toGET /metadata_submission/{id}
may also modify the record being returned by updating thelocked_by
field.SubmissionMetadata
records, whereas the the Field Notes app allows you to view aSubmissionMetadata
before allowing the user to navigate to a separate edit interface. There would be no reason to read or write thelocked_by
field from the view interface.To address both of those issues, these changes introduce a separate
/metadata_submission/{id}/lock
endpoint (called with aPUT
method). This seemed like a natural counterpart to the existing/metadata_submission/{id}/unlock
endpoint. Both of these endpoints now return aLockOperationResult
object which indicates whether the lock or unlock was successful and who (if anyone) now holds the lock. Unsuccessful operations are also returned with a409 Conflict
status. With the assumption that a client should explicitly request the lock before making updates, there is no longer an attempt to claim the lock in theGET /metadata_submission/{id}
handler.On the frontend side there was only one function (see:
web/src/views/SubmissionPortal/store/index.ts
) where theGET /metadata_submission/{id}
endpoint was invoked. So to keep the Submission Portal behaving the same way it did before, I added a call toPUT /metadata_submission/{id}/lock
in that function. While testing I fixed a minor issues where there was an unnecessary extra call togetRecord
(inweb/src/views/SubmissionPortal/Components/SubmissionList.vue
).Tangentially related, there was another bug where a link presented in the "this submission is locked" case was forcing a full page refresh instead of client-side navigation (using
<a>
instead of<router-link>
). Fixing that bug revealed that theisEditingSubmission
state inStepperView
was not correctly reacting to route changes. This is fixed by using the existingid
prop on the component instead of getting it from the route.