-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add Pull Request builds page to settings #10656
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
Conversation
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.
I'm not sure to understand what's the context or the goal of this PR. Can you expand on the background of it?
@humitos It's adding a page in settings to configure PR builds. It's a huge feature that is important to users, so we should unhide it, and make it much more visible. More info here: readthedocs/ext-theme#199 |
model = Project | ||
form_class = ProjectPullRequestForm | ||
success_message = _("Pull request settings have been updated") | ||
template_name = "projects/project_pull_requests.html" |
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.
In the new dashboard, I'm trying to stick to a naming convention closer to Django's built in naming and I have been removing our prefixes like project_
. For this, I'd use:
template_name = "projects/project_pull_requests.html" | |
template_name = "projects/pull_requests_form.html" |
I'm guessing this might leak into next week, one of us can jump in and take assignment here if this needs anything else. The change was small enough here and I don't have much to add to this, but I'll defer to @humitos on anything else needed here. |
The change looks good to me after talking a little more about this with Eric. However, tests and checks are failing, so I think there is no need to rush here. |
This is a basic form for now, but we can spruce it up before it goes live.
22eb01d
to
9cc292b
Compare
I patched things up, tests are looking like they will pass. |
This PR is related to readthedocs/ext-theme#211 that talks about adding a completely new admin page to configure the addons. Since there is an addon that's related with PRs (the external version warning), we could consider that issue here as well. |
Ah yes, true. Ultimately, when addons are fully deployed for all projects, it would make a lot of sense to group all the options on a single admin page (that is, options "Enable pull request builds" and "Show pull request build notification in documentation"). I'm not sure how we'd treat the notification in the admin until then though, given we probably want that option dependent on whether or not the project has opted into the addons beta as well. Let's keep this in mind as we work towards some sort of beta opt-in page, as perhaps it is a good option to add to this admin page. At very least we should link to the opt-in admin page from this admin page though. |
I created this issue to talk about this in particular: readthedocs/ext-theme#212 |
I got this ready for merging last week, but I do think we should preserve how the field is conditionally enabled when there is a connected remote repo. We could add the existing logic to the form instance here, disabling the field if there are no remote repos attached. I think I'd probably opt for raising a validation error though, as the greyed out field isn't super obvious and can be easy to miss. The best solution would probably be doing something stronger at the template level, and conditionally disabling/showing the form when the remote repo is missing. This would give a good place to help describe the problem and point the user in the right direction. We sort of have this with the help text now, but I'm picturing some more complex UI here -- buttons linking out to resources, and perhaps make the warning a I'll hand this back over to @eric. Either option works great, we can always come back later and make the templates nicer. |
Cool, I will take a look at how the field is disabled, and look at adding some additional info into the page to make it a nicer UX. |
I updated this PR to pull over the validation logic into the PR build form. I noticed that when the field is disabled, you can't see the help_text. I wasn't sure the best pattern for showing the error validation message in the form. @agjohnson do we have a pattern here? Should I set an error on the form or something so that it shows in a nicer way to the user? There was a pile of logic trying to figure out if the form should be disabled, so I didn't want to port that over the the templates. (Believe readthedocs/common#198 should fix tests) |
This is a good question, and actually the work I am doing on #11095 is relevant here too. Help text can be helpful for giving hints to users about a particular field, but it's also really good at making forms way too noisy. So, I would like to move away from relying on help text for these sorts of scenarios, and especially a case where the form should be disabled when a condition isn't met. Using the PR above as base, the Form instance here could implement a |
This isn't a standard Django thing, so you're suggesting we build our own |
Yes, this is implemented already in the PR I linked though. The work required here is to throw a validation error from the Form, similar to this:
I pasted an example in that PR: #11095 (comment) These validation errors are added as standard non-field errors. The PR also includes a validation error class that includes a custom header, which I'd also suggest here. |
@agjohnson I tried to update this to use the prevalidation logic, but getting this weird error, and it's not disabling the form: ![]() |
I think your code looks correct, but the form error is not displaying as I would expect. Are you using If the error display correctly, it should display the validation error
This requires a class addition at the form at the moment. If we want a nice pattern here, there must be some way to do this programmatically from the form/view though. For now, you can set The first example I did using this didn't quite do what you are doing, there is only technically a form (hence just showing the errors for now): |
The error displayed fine for me, so I think you maybe have an old base for your PR on ext-theme. What is not working is |
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.
I also got 'UpdateProjectForm' object has no attribute 'setup_external_builds_option'
loading the main setting page, which seems related.
This looks close, I think we could visit tuning up the prevalidation form pattern separately -- though it does involve coming back and fixing this form either way.
@@ -574,8 +580,24 @@ def clean_alias(self): | |||
return alias | |||
|
|||
|
|||
class AddonsConfigForm(forms.ModelForm): | |||
class ProjectPullRequestForm(forms.ModelForm, ProjectPRBuildsMixin): |
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.
I suspect form.is_disabled
isn't working correctly from the templates because of ModelForm
base, but I haven't quite pinpointed that one yet.
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.
Yeah, so far form.errors
was called first, populating all the correct errors. The template logic if form.errors and form.is_disabled
is correct for now.
Noted in:
@agjohnson Not really sure the best steps here? You can just push to this PR if you want changes vs. suggestions, but it sounds like it's not ready to merge? |
What is blocking this currently:
I didn't look into solving the bug introduced here with the main settings view. I did rebase these PRs locally to have everything up to date. If you aren't noticing the exception locally, you likely should after rebasing. With everything rebased, the form errors were working as expected. |
…ll-request-settings
Co-authored-by: Anthony <[email protected]>
I believe these changes should be addressed in the updated PRs 👍 |
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.
Looks good to go for now! We can revisit this pattern with some fixes to prevalidation forms in #11270
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.
This looks good. I noted to come back to these patterns in #11270 and update the code here.
Co-authored-by: Anthony <[email protected]>
This is a basic form for now,
but we can spruce it up before it goes live.
Closes #10411