Skip to content
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

Addons: allow users to show/hide notifications on latest/non-stable #11718

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

humitos
Copy link
Member

@humitos humitos commented Oct 29, 2024

We currently allow users to disable the latest and non-stable notifications with only one checkbox. This PR split this checkbox into two, so users can decide to show a notification on latest and/or on non-stable versions individually.

Note this PR also changes the addons API response: non_latest_version_warning and external_version_warning are combined into notifications. I think nobody is using this yet, so I'm not expecting issues with it. Let me know if you think differently here.

Required by readthedocs/addons#133

We currently allow users to disable the latest and non-stable notifications with
only one checkbox. This PR split this checkbox into two, so users can decide to
show a notification on latest and/or on non-stable versions individually.

Note this PR also changes the addons API response: `non_latest_version_warning`
and `external_version_warning` are combined into `notifications`. I think nobody
is using this yet, so I'm not expecting issues with it. Let me know if you think
differently here.

Required by readthedocs/addons#133
@humitos humitos requested a review from a team as a code owner October 29, 2024 14:44
humitos added a commit to readthedocs/addons that referenced this pull request Oct 29, 2024
humitos added a commit to readthedocs/ext-theme that referenced this pull request Oct 29, 2024
Instead of showing one checkbox to enable "Show notification on latest and
non-stable versions" we have two checkboxes now:

- "Show notification on latest version"
- "Show notification on non-stable versions"

Requires readthedocs/addons#414
Requires readthedocs/readthedocs.org#11718
Comment on lines +216 to +219
notifications_enabled = models.BooleanField(default=True)
notifications_show_on_latest = models.BooleanField(default=True)
notifications_show_on_non_stable = models.BooleanField(default=True)
notifications_show_on_external = models.BooleanField(default=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these should be nullable to avoid downtime.

https://dev.readthedocs.io/en/stable/migrations.html#adding-a-new-field

If we are okay with not allowing to create/edit this model while the migration takes place, that's okay, I guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, it should be a quick migration?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder if we want to default all of these to True, though? In particular, I'm not sure we want latest to have a default warning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the field has a default value it doesn't need to be nullable, right? Once the field is added, it will be the default value automatically and when creating a new row from an old instance without passing the new value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder if we want to default all of these to True, though? In particular, I'm not sure we want latest to have a default warning?

I haven't thought too much about this, I just followed the defaults we had previously. Apart from that, I think it's good to enable all the addons by default as a way to immediately expose these features to users and leave users to decide if they want to use them or not.

The only ones I'm have to turn off by default are those that cost us money and are not very used by our users, eg. analytics.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to talk more about this and change this default now and/or in the future, tho.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the field has a default value it doesn't need to be nullable, right?

No, the default value is set at the django level, not at the db level. Django 5.x has an option to set default values at the db level.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point 👍🏼 . We should mention that in that document to avoid this confusion every time 😄 .

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. This seems like a good chance to add some docs for this functionality, since we're changing it? It's listed in the main addons page as PR build notifications, but not any other subpage. I might suggest adding a page for Documentation Notifications, or at least listing them a bit more nicely in that page.

Comment on lines +216 to +219
notifications_enabled = models.BooleanField(default=True)
notifications_show_on_latest = models.BooleanField(default=True)
notifications_show_on_non_stable = models.BooleanField(default=True)
notifications_show_on_external = models.BooleanField(default=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, it should be a quick migration?

@ericholscher
Copy link
Member

Pushed up a basic start of docs.

@ericholscher ericholscher requested a review from a team as a code owner October 29, 2024 23:04
humitos and others added 8 commits October 30, 2024 09:04
Co-authored-by: Eric Holscher <25510+ericholscher@users.noreply.github.com>
…om:readthedocs/readthedocs.org into humitos/addons-notifications-latest-stable
@humitos
Copy link
Member Author

humitos commented Oct 30, 2024

@agjohnson there is a test failing for ext-theme that I wasn't able to understand what's going on. It seems a crispy field cannot be rendered due to the field passed being "", which confuses me 🤷🏼 . Do you know what I'm doing wrong here?

@humitos
Copy link
Member Author

humitos commented Oct 30, 2024

Is it because it's using the old/deleted fields? If that's the case, this will be solved once we merge readthedocs/ext-theme#513

@humitos
Copy link
Member Author

humitos commented Oct 30, 2024

Yeap, that's the reason. Updating the file .tox/ext-theme/lib/python3.10/site-packages/readthedocsext/theme/templates/projects/addons_form.html solves this issue 💯 . Tests pass locally with this change. So, we are ready to merge here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants