New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove use of conditional publish from Forms.createNew #1143
Merged
Conversation
This file contains 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
ktuite
commented
May 10, 2024
ktuite
commented
May 10, 2024
ktuite
commented
May 10, 2024
ktuite
commented
May 10, 2024
ktuite
commented
May 10, 2024
ktuite
commented
May 10, 2024
ktuite
force-pushed
the
ktuite/refactor_form_flow
branch
from
May 10, 2024 21:01
a864f2f
to
5e95823
Compare
ktuite
commented
May 10, 2024
ktuite
commented
May 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this to add reset()
to global.enketo
?
const reset = () => {
if (global.enketo === undefined) global.enketo = { reset };
Object.assign(global.enketo, defaults);
cancelToken += 1;
};
ktuite
commented
May 17, 2024
matthew-white
approved these changes
May 17, 2024
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.
Closes #1136
This PR consolidates Form publishing in one place, because Dataset publishing is tied to Form publishing. There were three different places to possibly publish a Dataset (creating a new form, updating a form, just publishing a form) and it was too hard to think about which Form scenario led to which Dataset scenario.
As of 5/10/24:
So far, I've removed
publish=true
fromForms.createNew()
. Any time creating a new form was also going to publish the form, theForms.publish()
is now called separately.One downside is that those lines of code aren't as cute and concise anymore. This only happened in one resource, in a test fixture, and in some tests.
Another downside is that the enketo test mock had a way to put it into an erroneous state for the next request, but a certain form POST request will trigger two enketo requests behind the scenes. I mucked with the enketo test mock to require you to remove the error state, but it's kind of ugly and required modifying multiple tests.
As of 5/14/24:
I decided that keeping
publish=true
inForms.createVersion()
had utility. There is one rare situation with encrypting existing forms where it really helps to publish concurrently, e.g. when there is both a published version and draft version of a form, and both active versions need to be encrypted. Because this has nothing to do with Datasets, Forms.createVersion does not have code to publish a dataset. I tried to clarify this with comments, too.I also trie to make
Forms.createNew()
andForms.createVersion()
more similar. There are some things they both do (parse the form XML to get form fields and dataset info, insert form fields, insert attachments, do enketo things) and some things that are special (comparing against previous schemas for updated forms).Checklist
_createNewDef
tocreateVersion
What has been done to verify that this works as intended?
Why is this the best possible solution? Were any other approaches considered?
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.
Before submitting this PR, please make sure you have:
make test
and confirmed all checks still pass OR confirm CircleCI build passes