-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't reset repo on invalid
WorkspaceCreateForm
.
`WorkspaceCreateForm` constructs repo and branch `ChoiceFields` dynamically based on the state of GitHub at request-time. The code that does this was not doing anything to maintain the initial value from any submitted form POST data. The Django machinery does not do this automatically for these fields as they are dynamically constructed. Therefore if an invalid form was submitted (e.g., with a name that is not a valid slug), these fields were reverting to their default value of the first element in the list, which is bad UX as they need to reselect the repo and branch on validation failure. Set the `initial` property on each field to the value from the POST data, or `None` if not present. `initial` from the `ChoiceField` API is not automatically respected by our `form_select` components, so set the initial selected value in the template. Make the branching logic clearer and add more comments. Add dummy invalid repo option. This hints that the user needs to do something, and prevent auto-selecting the first repo by default if the user does not change the field. We expect that this can never be submiited because the branch choices will not be populated on an unbound form. If it somehow were, the `clean()` already validates that the repo URL can be found in `repos_with_branches`, which won't be the case for our dummy value.
- Loading branch information
1 parent
2ea4731
commit d1e4103
Showing
3 changed files
with
49 additions
and
33 deletions.
There are no files selected for viewing
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
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
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