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.
Part of #1264, see checklist here.
The Duplicate action is a cross between create and edit: a "create new archetype" form is opened, but its fields are all prefilled as if we are editing an existing archetype. The prefilled name has an appended " (duplicate)" suffix on it.
Just for fun, in case a user duplicates the same archetype multiple times without touching the default name, we check to see if the new default name is taken and use " (duplicate N)" as the suffix, with N incrementing until we get a name that isn't taken. This is probably unnecessary, but I found it annoying that the "name must be unique" error didn't appear until I touched the field, so this makes sure that case never comes up.
Because ArchetypeForm already had the logic for prefilling the form for editing, all we needed to do was pass in an
archetype
and anisDuplicating
boolean which slightly changes the behavior:isDuplicating
is true. This way you can rapid-fire duplicating things without touching the form if you so desire (useful for testing the pagination in ✨ Add client-side pagination to Archetypes table #1370 😄)