-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Addons: update form to show all the options #11031
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
Changes from 3 commits
919d10a
b6f51e8
7dfe3a3
984277f
1382a8b
d65bb87
2c37afe
133dd49
38d7f19
af95aff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -529,7 +529,17 @@ class AddonsConfigForm(forms.ModelForm): | |
|
||
class Meta: | ||
model = AddonsConfig | ||
fields = ("enabled", "project") | ||
fields = ( | ||
"enabled", | ||
"project", | ||
"analytics_enabled", | ||
"doc_diff_enabled", | ||
"external_version_warning_enabled", | ||
"flyout_enabled", | ||
"hotkeys_enabled", | ||
"search_enabled", | ||
"stable_latest_version_warning_enabled", | ||
) | ||
|
||
def __init__(self, *args, **kwargs): | ||
self.project = kwargs.pop("project", None) | ||
|
@@ -541,6 +551,72 @@ def __init__(self, *args, **kwargs): | |
except AddonsConfig.DoesNotExist: | ||
self.fields["enabled"].initial = False | ||
|
||
fieldsets = [ | ||
Fieldset( | ||
_("Global"), | ||
"enabled", | ||
), | ||
Fieldset( | ||
_("Analytics"), | ||
HTML( | ||
"<p>Analytics addon allows you to store traffic analytics in your project.</p>" | ||
), | ||
*[field for field in self.fields if field.startswith("analytics_")], | ||
), | ||
Fieldset( | ||
_("DocDiff"), | ||
HTML( | ||
"<p>DocDicc addon helps you to review changes from PR by visually showing the differences.</p>" | ||
), | ||
*[field for field in self.fields if field.startswith("doc_diff_")], | ||
), | ||
Fieldset( | ||
_("Flyout"), | ||
HTML( | ||
"<p>Flyout addon shows a small menu at bottom-right of each page with useful links to switch between versions and translations.</p>" | ||
), | ||
*[field for field in self.fields if field.startswith("flyout_")], | ||
), | ||
Fieldset( | ||
_("Hotkeys"), | ||
HTML( | ||
"<p>Hotkeys addon enables keyboard shortcuts to access other addons quickly.</p>" | ||
), | ||
*[field for field in self.fields if field.startswith("hotkeys_")], | ||
), | ||
Fieldset( | ||
_("Search"), | ||
HTML( | ||
"<p>Search addon improves your search experience with the search-as-you-type feature.</p>" | ||
), | ||
*[field for field in self.fields if field.startswith("search_")], | ||
), | ||
Fieldset( | ||
_("Warning on PR previews"), | ||
HTML("<p>Shows a warning notification on PR previews.</p>"), | ||
*[ | ||
field | ||
for field in self.fields | ||
if field.startswith("external_version_warning_") | ||
], | ||
), | ||
Fieldset( | ||
_("Warning on non-stable/latest versions"), | ||
HTML( | ||
"<p>Shows a warning notification stable and latest versions letting the user know they may be reading an outdated page or a non-released one.</p>" | ||
), | ||
*[ | ||
field | ||
for field in self.fields | ||
if field.startswith("stable_latest_version_warning_") | ||
], | ||
), | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted at readthedocs/ext-theme#262 (comment) Two things that are important here: First, I think this interface will eventually use a tabbed interface, not fieldsets, or might even use separate form/views entirely -- we'll know more once we start adding deeper configuration options here. But for that, I am gathering fieldsets will probably be removed in the future. Second, I wanted to discuss avoiding (and probably removing) use of Crispy layouts and the layout API. Having HTML authoring removed from template code is a bit awkward already, just given the code/template separation and repository split, but it gets much worse if we want JS/Knockout/etc code in the form. For that, I might suggest keeping this incredibly simple for a first pass and removing fieldsets and Python HTML authoring. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How do you imagine that version? Just a bunch of inline checkboxes, as shown in readthedocs/ext-theme#262 (comment))? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that seems like plenty 👍 It will look minimal, but should be fine -- especially with a fix for block display checkboxes. We definitely will want to improve on that later in some way in the future, and we can start mocking out what that looks like once we know what other configuration fields we want there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will move forward with the required changes on this PR and we can tackle that CSS issue in ext-theme, I guess. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that sounds good. I agree it's probably minor and I should be able to squeeze a fix into the crispy field template before deploy |
||
|
||
self.helper = FormHelper() | ||
self.helper.layout = Layout(*fieldsets) | ||
self.helper.add_input(Submit("save", _("Save"))) | ||
|
||
def clean_project(self): | ||
return self.project | ||
|
||
|
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'd say the only thing I noticed is that this field renders as
Enabled
, and should probably be more descriptive regardless of the pattern we use --Enable Addons
or something.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, good point. I originally used the layout approach and added some text explaining this was "global". I'll check with the serializer if I can change how it renders since we are already using the
help_text
to explain the same thing.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 thought we can use better labels for:
What do you think?
Also also, we can remove the
enabled
part from all of them and just leave the name of the addon with the checkbox?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.
Uh oh!
There was an error while loading. Please reload this page.
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 those look better! Just a small note that "Pull Request" should use proper noun capitalization, "pull request builds" can be used instead. I follow what GitHub uses: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests
Aye, we could for this UI. Though thinking ahead to when we split it up to multiple pages/tabs, we might want the full verbose version "Flyout enabled"? I suppose I'd leave the "enabled" part on the text for now and if we want to remove it later we can. For now, the extra
enabled
isn't making the options any less clear.