Skip to content

Commit

Permalink
Add build detail view beta notification (#11208)
Browse files Browse the repository at this point in the history
* Add build detail view beta notification

This adds a notification to the corresponding beta build detail view,
and works for both community and commercial. There are two separate
patterns here as the authentication is a little bit different between
the two sites.

* Fix typo

* Update logic to support a link on the new dashboard too
  • Loading branch information
agjohnson committed Mar 12, 2024
1 parent e4b9e12 commit ed1f564
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
22 changes: 21 additions & 1 deletion readthedocs/builds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,28 @@ def get_context_data(self, **kwargs):
context["project"] = self.project

build = self.get_object()
context["notifications"] = build.notifications.all()

# Temporary notification to point to the same page on the new dashboard
#
# To support readthedocs.com, we have to point to the login view. We
# can't point directly to the build view on the new dashboard as this
# will give the users a 404 because they aren't logged in.
#
# On community, we _don't want this_ as this requires the user to have
# a login to view the new dashboard.
url_domain = settings.PRODUCTION_DOMAIN
if url_domain.startswith("beta."):
url_domain = url_domain[5:]
else:
url_domain = f"beta.{url_domain}"
url_build = build.get_absolute_url()
# Point to the login view with the build as ?next. We are expecting
# users to have accounts to view this.
if settings.RTD_ALLOW_ORGANIZATIONS:
url_build = reverse("account_login") + f"?next={url_build}"
context["url_switch_dashboard"] = f"https://{url_domain}{url_build}"

context["notifications"] = build.notifications.all()
if not build.notifications.filter(
message_id=BuildAppError.GENERIC_WITH_BUILD_ID
).exists():
Expand Down
16 changes: 16 additions & 0 deletions readthedocs/templates/builds/build_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@
{% endblock %}

{% block content %}
{% block build_detail_beta %}
{% comment %}
Temporary notification to point to the beta dashboard, url_beta comes from the view
{% endcomment %}
{% if url_switch_dashboard %}
<div class="notifications">
<p class="notification notification-20">
{% blocktrans trimmed with url=url_switch_dashboard %}
Our new beta dashboard is now available for testing!
<a href="{{ url }}">Try viewing this build on the new dashboard</a>.
{% endblocktrans %}
</p>
</div>
{% endif %}
{% endblock build_detail_beta %}

<div class="build build-detail" id="build-detail">

{% if build.state != "finished" and build.state != "cancelled" and request.user|is_admin:project %}
Expand Down

0 comments on commit ed1f564

Please sign in to comment.