Skip to content

New dashboard: notification to point users there #11161

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

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions readthedocs/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def readthedocs_processor(request):
"USE_ORGANIZATIONS": settings.RTD_ALLOW_ORGANIZATIONS,
"SUPPORT_EMAIL": settings.SUPPORT_EMAIL,
"PUBLIC_API_URL": settings.PUBLIC_API_URL,
"RTD_EXT_THEME_ENABLED": settings.RTD_EXT_THEME_ENABLED,
}
return exports

Expand Down
22 changes: 21 additions & 1 deletion readthedocs/core/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

from django.utils.translation import gettext_lazy as _

from readthedocs.notifications.constants import WARNING
from readthedocs.notifications.constants import INFO, WARNING
from readthedocs.notifications.messages import Message, registry

MESSAGE_EMAIL_VALIDATION_PENDING = "core:email:validation-pending"
MESSAGE_BETA_DASHBOARD_AVAILABLE = "core:dashboard:beta-available"
messages = [
Message(
id=MESSAGE_EMAIL_VALIDATION_PENDING,
Expand All @@ -22,6 +23,25 @@
),
type=WARNING,
),
Message(
id=MESSAGE_BETA_DASHBOARD_AVAILABLE,
header=_("New beta dashboard available"),
body=_(
textwrap.dedent(
"""
{% if RTD_EXT_THEME_ENABLED %}
This dashboard is currently in beta,
you can <a href="https://{{ PRODUCTION_DOMAIN }}">return to the legacy dashboard</a> if you encounter any problems.
Feel free to <a href="https://{{ PRODUCTION_DOMAIN }}/support/">report any feedback</a> you may have.
{% else %}
Our new <strong>beta dashboard</strong> is now available for testing.
<a href="https://beta.{{ PRODUCTION_DOMAIN }}/">Give it a try</a> and send us feedback.
{% endif %}
Comment on lines +32 to +39
Copy link
Contributor

Choose a reason for hiding this comment

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

🤯

I knew we were using templating, but I somehow totally missed the fact we could use template logic in the notification. This is fantastic.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is fantastic

"Fantastic" is a big word, tho. I think saying a "nice hack" fits better here 😝

"""
).strip(),
),
type=INFO,
),
]


Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static-src/core/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Dismiss a notification
module.exports.handle_notification_dismiss = function () {
$(document).ready(function () {
$('ul.notifications li.notification > a').click(function (ev) {
$('ul.notifications li.notification > a.notification-action').click(function (ev) {
var url = $(this).attr('href');
var dismiss_url = $(this).parent().attr('data-dismiss-url');
var csrf_token = $(this).parent().attr('data-csrf-token');
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static/core/js/site.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions readthedocs/rtd_tests/tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class TestNotification(EmailNotification):
"PRODUCTION_DOMAIN": "readthedocs.org",
"PUBLIC_DOMAIN": mock.ANY,
"PUBLIC_API_URL": mock.ANY,
"RTD_EXT_THEME_ENABLED": mock.ANY,
"SITE_ROOT": mock.ANY,
"SUPPORT_EMAIL": "[email protected]",
"TEMPLATE_ROOT": mock.ANY,
Expand Down