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

Merged
merged 11 commits into from
Nov 4, 2024

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 humitos requested a review from ericholscher 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
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.

humitos added a commit to readthedocs/ext-theme that referenced this pull request Nov 4, 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"



![Screenshot_2024-10-29_15-52-36](https://github.com/user-attachments/assets/60a35c09-cf9d-4429-af53-41515f00ecac)

Requires readthedocs/addons#414
Requires readthedocs/readthedocs.org#11718
@humitos humitos merged commit 7120315 into main Nov 4, 2024
5 of 7 checks passed
@humitos humitos deleted the humitos/addons-notifications-latest-stable branch November 4, 2024 10:15
humitos added a commit to readthedocs/addons that referenced this pull request Nov 4, 2024
Copy link

sentry-io bot commented Nov 5, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ KeyboardInterrupt readthedocs.projects.migrations.0128_addons_not... View Issue

Did you find this useful? React with a 👍 or 👎

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