Skip to content

Commit b7c3379

Browse files
committed
Updates for new dashboard linking
- Fix user new dashboard notification, support both legacy and new dashbaord - Update other pointers in the UI to the new dashboard - Drop the beta build notification ---- - Refs #11209
1 parent a94aa1f commit b7c3379

File tree

6 files changed

+59
-43
lines changed

6 files changed

+59
-43
lines changed

readthedocs/builds/views.py

+3-21
Original file line numberDiff line numberDiff line change
@@ -192,27 +192,9 @@ def get_context_data(self, **kwargs):
192192

193193
build = self.get_object()
194194

195-
# Temporary notification to point to the same page on the new dashboard
196-
#
197-
# To support readthedocs.com, we have to point to the login view. We
198-
# can't point directly to the build view on the new dashboard as this
199-
# will give the users a 404 because they aren't logged in.
200-
#
201-
# On community, we _don't want this_ as this requires the user to have
202-
# a login to view the new dashboard.
203-
url_domain = settings.PRODUCTION_DOMAIN
204-
if url_domain.startswith("app."):
205-
url_domain = url_domain[4:]
206-
else:
207-
url_domain = f"app.{url_domain}"
208-
url_build = build.get_absolute_url()
209-
# Point to the login view with the build as ?next. We are expecting
210-
# users to have accounts to view this.
211-
if settings.RTD_ALLOW_ORGANIZATIONS:
212-
url_build = reverse("account_login") + f"?next={url_build}"
213-
context["url_switch_dashboard"] = f"https://{url_domain}{url_build}"
214-
215-
context["notifications"] = build.notifications.all()
195+
# We consume these notifications through the API in the new dashboard
196+
if not settings.RTD_EXT_THEME_ENABLED:
197+
context["notifications"] = build.notifications.all()
216198
if not build.notifications.filter(
217199
message_id=BuildAppError.GENERIC_WITH_BUILD_ID
218200
).exists():

readthedocs/core/context_processors.py

+3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ def readthedocs_processor(request):
1313
If you need to add something that depends on the request,
1414
create a new context processor.
1515
"""
16+
1617
exports = {
1718
"PUBLIC_DOMAIN": settings.PUBLIC_DOMAIN,
1819
"PRODUCTION_DOMAIN": settings.PRODUCTION_DOMAIN,
20+
# TODO this can be removed with RTD_EXT_THEME_ENABLED
21+
"SWITCH_PRODUCTION_DOMAIN": settings.SWITCH_PRODUCTION_DOMAIN,
1922
"GLOBAL_ANALYTICS_CODE": settings.GLOBAL_ANALYTICS_CODE,
2023
"DASHBOARD_ANALYTICS_CODE": settings.DASHBOARD_ANALYTICS_CODE,
2124
"SITE_ROOT": settings.SITE_ROOT + "/",

readthedocs/core/notifications.py

+32-18
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
from django.utils.translation import gettext_lazy as _
66

7-
from readthedocs.notifications.constants import INFO, WARNING
7+
from readthedocs.notifications.constants import TIP, WARNING
88
from readthedocs.notifications.messages import Message, registry
99

1010
MESSAGE_EMAIL_VALIDATION_PENDING = "core:email:validation-pending"
11-
MESSAGE_BETA_DASHBOARD_AVAILABLE = "core:dashboard:beta-available"
11+
MESSAGE_NEW_DASHBOARD = "core:dashboard:new"
1212
messages = [
1313
Message(
1414
id=MESSAGE_EMAIL_VALIDATION_PENDING,
@@ -23,24 +23,38 @@
2323
),
2424
type=WARNING,
2525
),
26+
# This message looks quite odd because we need to show different content in
27+
# the notification depending on which instance the user is on -- if the user
28+
# is on our legacy dashboard, we don't want a notification "Welcome to our
29+
# new dashboard!".
30+
#
31+
# Localization is avoided because the body has template logic inside and we
32+
# don't want to push that to our translations sources.
2633
Message(
27-
id=MESSAGE_BETA_DASHBOARD_AVAILABLE,
28-
header=_("New beta dashboard"),
29-
body=_(
30-
textwrap.dedent(
31-
"""
32-
{% if RTD_EXT_THEME_ENABLED %}
33-
This dashboard is currently in beta,
34-
you can <a href="https://{{ PRODUCTION_DOMAIN }}">return to the legacy dashboard</a> if you encounter any problems.
35-
Feel free to <a href="https://{{ PRODUCTION_DOMAIN }}/support/">report any feedback</a> you may have.
36-
{% else %}
37-
Our new <strong>beta dashboard</strong> is now available for testing.
38-
<a href="https://app.{{ PRODUCTION_DOMAIN }}/">Give it a try</a> and send us feedback.
39-
{% endif %}
34+
id=MESSAGE_NEW_DASHBOARD,
35+
header=textwrap.dedent(
4036
"""
41-
).strip(),
42-
),
43-
type=INFO,
37+
{% if RTD_EXT_THEME_ENABLED %}
38+
Welcome to our new dashboard!
39+
{% else %}
40+
Our new dashboard is ready!
41+
{% endif %}
42+
"""
43+
).strip(),
44+
body=textwrap.dedent(
45+
"""
46+
{% if RTD_EXT_THEME_ENABLED %}
47+
We are beginning to direct users to our new dashboard as we work to retire our legacy dashboard.
48+
{% else %}
49+
You are currently using our legacy dashboard, which will be retired on <time datetime="2025-03-01">March 1st, 2025</time>.
50+
You should <a href="//{{ SWITCH_PRODUCTION_DOMAIN }}{% url "account_login" %}">switch to our new dashboard</a> before then.
51+
{% endif %}
52+
For more information on this change and what to expect,
53+
<a href="https://about.readthedocs.com/blog/2024/11/new-dashboard/">read our blog post</a>.
54+
"""
55+
).strip(),
56+
type=TIP,
57+
icon_classes="fad fa-sparkles",
4458
),
4559
]
4660

readthedocs/notifications/messages.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121

2222

2323
class Message:
24-
def __init__(self, id, header, body, type, icon_classes=None):
24+
def __init__(self, id, header, body, type, icon_classes=None, format_values=None):
2525
self.id = id
2626
self.header = header
2727
self.body = body
2828
self.type = type # (ERROR, WARNING, INFO, NOTE, TIP)
2929
self.icon_classes = icon_classes
30-
self.format_values = {}
30+
if format_values is None:
31+
format_values = {}
32+
self.format_values = format_values
3133

3234
def __repr__(self):
3335
return f"<Message: {self.id}>"
@@ -36,7 +38,7 @@ def __str__(self):
3638
return f"Message: {self.id} | {self.header}"
3739

3840
def set_format_values(self, format_values):
39-
self.format_values = format_values
41+
self.format_values.update(format_values)
4042

4143
def get_display_icon_classes(self):
4244
if self.icon_classes:

readthedocs/projects/views/private.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,16 @@ def get_context_data(self, **kwargs):
123123
template_name = None
124124
projects = AdminPermission.projects(user=self.request.user, admin=True)
125125
n_projects = projects.count()
126-
if n_projects == 0 or (
126+
127+
# TODO remove this with RTD_EXT_THEME_ENABLED
128+
# This is going to try hard to show the new dashboard announcement.
129+
# We can't yet back down to another announcement as we don't have
130+
# the ability to evaluate local storage. Until we add the ability to
131+
# dynamically change the announcement, this is going to be the only
132+
# announcement shown.
133+
if True:
134+
template_name = "new-dashboard.html"
135+
elif n_projects == 0 or (
127136
n_projects < 3 and (timezone.now() - projects.first().pub_date).days < 7
128137
):
129138
template_name = "example-projects.html"

readthedocs/settings/base.py

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ def SHOW_DEBUG_TOOLBAR(self):
8686
RTD_INTERSPHINX_URL = "https://{}".format(PRODUCTION_DOMAIN)
8787
RTD_EXTERNAL_VERSION_DOMAIN = "external-builds.readthedocs.io"
8888

89+
@property
90+
def SWITCH_PRODUCTION_DOMAIN(self):
91+
if self.RTD_EXT_THEME_ENABLED:
92+
return self.PRODUCTION_DOMAIN.removeprefix("app.")
93+
return f"app.{self.PRODUCTION_DOMAIN}"
94+
8995
# Doc Builder Backends
9096
MKDOCS_BACKEND = "readthedocs.doc_builder.backends.mkdocs"
9197
SPHINX_BACKEND = "readthedocs.doc_builder.backends.sphinx"

0 commit comments

Comments
 (0)