Skip to content

Commit 494f89b

Browse files
authored
Unify disabled feature upgrade patterns (#490)
* Fix exception with missing pagination tag From #486, linting introduced a missing template tag * Prelint files changed * Unify disabled feature upgrade patterns Use a callout and disable the page content if the feature is disabled. This shows the full view but in a disabled state.
1 parent f8eeef9 commit 494f89b

File tree

9 files changed

+168
-171
lines changed

9 files changed

+168
-171
lines changed
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
{% load i18n %}
1+
{% load blocktrans from i18n %}
22

33
{# We need to handle both cases, when an organization or a project are given. #}
44
{% firstof organization.slug project.organizations.first.slug as organization_slug %}
5-
{% url 'subscription_detail' organization_slug as subscription_url %}
5+
{% url "subscription_detail" organization_slug as subscription_url %}
66

7-
<div class="ui warning message">
8-
<i class="fad fa-exclamation-circle"></i>
9-
{% blocktrans trimmed with subscription_url=subscription_url %}
10-
This feature is not available for your organization.
11-
<a href="{{ subscription_url }}">Upgrade your subscription</a> to enable this feature.
12-
{% endblocktrans %}
7+
<div class="ui notification info message">
8+
<h5 class="header">
9+
<i class="fad fa-circle-up icon"></i>
10+
{% blocktrans trimmed with plan=plan|default:"Pro" %}
11+
{{ plan }} plan feature
12+
{% endblocktrans %}
13+
</h5>
14+
<p>
15+
{% blocktrans trimmed with subscription_url=subscription_url %}
16+
This feature is not available for your organization.
17+
<a href="{{ subscription_url }}">Upgrade your subscription</a> to enable this feature.
18+
{% endblocktrans %}
19+
</p>
1320
</div>

readthedocsext/theme/templates/organizations/settings/saml.html

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
{% endblock organization_edit_sidebar_help_topics %}
1414

1515
{% block organization_edit_content %}
16+
{% if not sso_saml_enabled %}
17+
{% include "organizations/includes/feature_disabled.html" with organization=organization plan="Pro" %}
18+
{% endif %}
19+
1620
{% if sso_integration %}
1721
<div class="ui basic segment">
1822
<div class="ui message">
@@ -55,70 +59,72 @@
5559
</div>
5660
{% endif %}
5761

58-
<div class="ui basic segment">
59-
<h3>{% trans "Configure your SAML provider" %}</h3>
62+
{% if sso_saml_enabled %}
63+
<div class="ui segment">
64+
<h3>{% trans "Configure your SAML provider" %}</h3>
6065

61-
<p>
62-
{% blocktrans %}
63-
Use the following information to configure your SAML integration in your identity provider (IdP).
64-
{% endblocktrans %}
65-
</p>
66+
<p>
67+
{% blocktrans %}
68+
Use the following information to configure your SAML integration in your identity provider (IdP).
69+
{% endblocktrans %}
70+
</p>
6671

67-
<div class="ui form">
68-
<div class="field">
69-
<label>{% trans "Single sign-on URL" %}</label>
70-
<div class="ui fluid action input">
71-
<input type="text"
72-
value="{{ rtd_saml_sso_url }}"
73-
id="saml-sso-url"
74-
readonly="true">
75-
<button class="ui right icon button"
76-
data-clipboard-target="input#saml-sso-url">
77-
<i class="fas fa-copy icon"></i>
78-
</button>
72+
<div class="ui form">
73+
<div class="field">
74+
<label>{% trans "Single sign-on URL" %}</label>
75+
<div class="ui fluid action input">
76+
<input type="text"
77+
value="{{ rtd_saml_sso_url }}"
78+
id="saml-sso-url"
79+
readonly="true">
80+
<button class="ui right icon button"
81+
data-clipboard-target="input#saml-sso-url">
82+
<i class="fas fa-copy icon"></i>
83+
</button>
84+
</div>
7985
</div>
80-
</div>
81-
<div class="field">
82-
<label>{% trans "Audience URI (SP entity ID)" %}</label>
83-
<div class="ui fluid action input">
84-
<input type="text"
85-
value="{{ rtd_saml_sp_url }}"
86-
id="saml-sp-url"
87-
readonly="true">
88-
<button class="ui right icon button"
89-
data-clipboard-target="input#saml-sp-url">
90-
<i class="fas fa-copy icon"></i>
91-
</button>
86+
<div class="field">
87+
<label>{% trans "Audience URI (SP entity ID)" %}</label>
88+
<div class="ui fluid action input">
89+
<input type="text"
90+
value="{{ rtd_saml_sp_url }}"
91+
id="saml-sp-url"
92+
readonly="true">
93+
<button class="ui right icon button"
94+
data-clipboard-target="input#saml-sp-url">
95+
<i class="fas fa-copy icon"></i>
96+
</button>
97+
</div>
9298
</div>
93-
</div>
94-
<div class="field">
95-
<label>{% trans "Name ID format" %}</label>
96-
<div class="ui fluid action input">
97-
<input type="text"
98-
value="EmailAddress"
99-
id="saml-name-id-format"
100-
readonly="true">
101-
<button class="ui right icon button"
102-
data-clipboard-target="input#saml-name-id-format">
103-
<i class="fas fa-copy icon"></i>
104-
</button>
99+
<div class="field">
100+
<label>{% trans "Name ID format" %}</label>
101+
<div class="ui fluid action input">
102+
<input type="text"
103+
value="EmailAddress"
104+
id="saml-name-id-format"
105+
readonly="true">
106+
<button class="ui right icon button"
107+
data-clipboard-target="input#saml-name-id-format">
108+
<i class="fas fa-copy icon"></i>
109+
</button>
110+
</div>
105111
</div>
106-
</div>
107-
<div class="field">
108-
<label>{% trans "Application username" %}</label>
109-
<div class="ui fluid action input">
110-
<input type="text"
111-
value="Email"
112-
id="saml-application-username"
113-
readonly="true">
114-
<button class="ui right icon button"
115-
data-clipboard-target="input#saml-application-username">
116-
<i class="fas fa-copy icon"></i>
117-
</button>
112+
<div class="field">
113+
<label>{% trans "Application username" %}</label>
114+
<div class="ui fluid action input">
115+
<input type="text"
116+
value="Email"
117+
id="saml-application-username"
118+
readonly="true">
119+
<button class="ui right icon button"
120+
data-clipboard-target="input#saml-application-username">
121+
<i class="fas fa-copy icon"></i>
122+
</button>
123+
</div>
118124
</div>
119125
</div>
120126
</div>
121-
</div>
127+
{% endif %}
122128

123129
{% if sso_integration %}
124130
<div class="ui basic segment">
@@ -160,10 +166,8 @@ <h3>{% trans "SAML integration details" %}</h3>
160166
</div>
161167
</div>
162168
</div>
163-
{% elif not sso_saml_enabled %}
164-
{% include "organizations/includes/feature_disabled.html" with organization=organization %}
165169
{% else %}
166-
<div class="ui padded">
170+
<div class="ui basic fitted {% if not sso_saml_enabled %}disabled{% endif %} segment">
167171
<h3>{% trans "Create SAML integration" %}</h3>
168172

169173
<form class="ui form" method="post" action=".">
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
{% extends "organizations/settings/base.html" %}
22

3-
{% load i18n %}
3+
{% load trans from i18n %}
44

5-
{% load crispy_forms_tags %}
5+
{% block title %}
6+
{{ organization.name }} - {% trans "Security log" %}
7+
{% endblock title %}
68

7-
{% block title %}{{ organization.name }} - {% trans "Security log" %}{% endblock %}
8-
9-
{% block organization_security_log_active %}active{% endblock %}
10-
{% block organization_edit_content_header %}{% trans "Security log" %}{% endblock %}
9+
{% block organization_security_log_active %}
10+
active
11+
{% endblock organization_security_log_active %}
12+
{% block organization_edit_content_header %}
13+
{% trans "Security log" %}
14+
{% endblock organization_edit_content_header %}
1115

1216
{% block organization_edit_sidebar_help_topics %}
1317
{% include "includes/elements/link.html" with url="https://docs.readthedocs.io/page/security-log.html#organization-security-log" text=_("Organization security log") is_external=True class="item" %}
@@ -16,8 +20,9 @@
1620
{% block organization_edit_content %}
1721
{# Note: this feature is enabled for most modern subscription, but disabled for old subscriptions #}
1822
{% if not enabled %}
19-
{% include 'organizations/includes/feature_disabled.html' with organization=organization %}
20-
{% else %}
21-
{% include "organizations/partials/log_list.html" with objects=object_list omit_user=False %}
23+
{% include "organizations/includes/feature_disabled.html" with organization=organization %}
2224
{% endif %}
25+
<div class="{% if not enabled %}ui basic fitted disabled segment{% endif %}">
26+
{% include "organizations/partials/log_list.html" with objects=object_list omit_user=False %}
27+
</div>
2328
{% endblock organization_edit_content %}

readthedocsext/theme/templates/projects/domain_list.html

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
11
{% extends "projects/project_edit_base.html" %}
22

3-
{% load i18n %}
3+
{% load trans from i18n %}
44

5-
{% block title %}{{ project.name }} - {% trans "Domains" %}{% endblock %}
5+
{% block title %}
6+
{{ project.name }} - {% trans "Domains" %}
7+
{% endblock title %}
68

7-
{% block project_domains_active %}active{% endblock %}
8-
{% block project_edit_content_header %}{% trans "Domains" %}{% endblock %}
9+
{% block project_domains_active %}
10+
active
11+
{% endblock project_domains_active %}
12+
{% block project_edit_content_header %}
13+
{% trans "Domains" %}
14+
{% endblock project_edit_content_header %}
915

1016
{% block project_edit_content %}
11-
{% include "projects/partials/edit/domain_list.html" with objects=object_list %}
12-
{% endblock %}
17+
{% comment %}
18+
Conditionally show this block if feature is enabled for organization. The
19+
``enabled`` variable comes from the view.
20+
21+
If the feature is enabled the top menu child blocks below will show. Otherwise
22+
overriding the ``top_menu`` block causes these blocks to not render.
23+
{% endcomment %}
24+
{% if not enabled %}
25+
{% include "organizations/includes/feature_disabled.html" with project=project plan="Advanced" %}
26+
{% endif %}
27+
<div class="{% if not enabled %}ui basic fitted disabled segment{% endif %}">
28+
{% include "projects/partials/edit/domain_list.html" with objects=object_list %}
29+
</div>
30+
{% endblock project_edit_content %}
1331

1432
{% block project_edit_sidebar_help_topics %}
1533
{% include "includes/elements/link.html" with url="https://docs.readthedocs.io/page/guides/custom-domains.html" text="How to manage custom domains" is_external=True class="item" %}

readthedocsext/theme/templates/projects/partials/edit/domain_list.html

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
{% extends "includes/crud/table_list.html" %}
22

3-
{% load i18n %}
4-
5-
{% load gravatar %}
6-
7-
{% load core_tags %}
8-
{% load privacy_tags %}
9-
{% load projects_tags %}
10-
11-
{% comment %}
12-
Conditionally show this block if feature is enabled for organization. The
13-
``enabled`` variable comes from the view.
14-
15-
If the feature is enabled the top menu child blocks below will show. Otherwise
16-
overriding the ``top_menu`` block causes these blocks to not render.
17-
{% endcomment %}
18-
{% block top_menu %}
19-
{% if not enabled %}
20-
{% include "organizations/includes/feature_disabled.html" with project=project %}
21-
{% else %}
22-
{{ block.super }}
23-
{% endif %}
24-
{% endblock top_menu %}
3+
{% load blocktrans trans from i18n %}
254

265
{% block top_left_menu_items %}
276
{% endblock top_left_menu_items %}

readthedocsext/theme/templates/projects/partials/edit/search_query_list.html

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
{% extends "includes/crud/table_list.html" %}
22

3-
{% load i18n %}
4-
5-
{% load gravatar %}
6-
7-
{% load core_tags %}
8-
{% load privacy_tags %}
9-
{% load projects_tags %}
10-
11-
{% comment %}
12-
Conditionally show this block if feature is enabled for organization. The
13-
``enabled`` variable comes from the view.
14-
15-
If the feature is enabled the top menu child blocks below will show. Otherwise
16-
overriding the ``top_menu`` block causes these blocks to not render.
17-
{% endcomment %}
18-
{% block top_menu %}
19-
{% if not enabled %}
20-
{% include "organizations/includes/feature_disabled.html" with project=project %}
21-
{% else %}
22-
{{ block.super }}
23-
{% endif %}
24-
{% endblock top_menu %}
3+
{% load blocktrans trans from i18n %}
254

265
{% block top_left_menu_items %}
276
{% endblock top_left_menu_items %}

readthedocsext/theme/templates/projects/partials/edit/traffic_list.html

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
{% extends "includes/crud/table_list.html" %}
22

3-
{% load i18n %}
4-
5-
{% load gravatar %}
6-
7-
{% load core_tags %}
8-
{% load privacy_tags %}
9-
{% load projects_tags %}
10-
11-
{% comment %}
12-
Conditionally show this block if feature is enabled for organization. The
13-
``enabled`` variable comes from the view.
14-
15-
If the feature is enabled the top menu child blocks below will show. Otherwise
16-
overriding the ``top_menu`` block causes these blocks to not render.
17-
{% endcomment %}
18-
{% block top_menu %}
19-
{% if not enabled %}
20-
{% include "organizations/includes/feature_disabled.html" with project=project %}
21-
{% else %}
22-
{{ block.super }}
23-
{% endif %}
24-
{% endblock top_menu %}
3+
{% load blocktrans trans from i18n %}
254

265
{% block top_left_menu_items %}
276
{% endblock top_left_menu_items %}

readthedocsext/theme/templates/projects/search_analytics.html

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
11
{% extends "projects/project_edit_base.html" %}
22

3-
{% load i18n %}
4-
{% load static %}
3+
{% load trans from i18n %}
54

6-
{% block title %}{% trans "Search Analytics" %}{% endblock %}
7-
{% block project_search_analytics_active %}active{% endblock %}
8-
{% block project_edit_content_header %}{% trans "Search Analytics" %}{% endblock %}
5+
{% block title %}
6+
{% trans "Search Analytics" %}
7+
{% endblock title %}
8+
{% block project_search_analytics_active %}
9+
active
10+
{% endblock project_search_analytics_active %}
11+
{% block project_edit_content_header %}
12+
{% trans "Search Analytics" %}
13+
{% endblock project_edit_content_header %}
914

1015
{% block project_edit_content %}
11-
<div data-bind="using: ProjectSearchAnalyticsView()">
16+
{% comment %}
17+
Conditionally show this block if feature is enabled for organization. The
18+
``enabled`` variable comes from the view.
19+
20+
If the feature is enabled the top menu child blocks below will show. Otherwise
21+
overriding the ``top_menu`` block causes these blocks to not render.
22+
{% endcomment %}
23+
{% if not enabled %}
24+
{% include "organizations/includes/feature_disabled.html" with project=project plan="Advanced" %}
25+
{% endif %}
26+
<div class="{% if not enabled %}ui basic fitted disabled segment{% endif %}"
27+
data-bind="using: ProjectSearchAnalyticsView()">
1228

1329
{% include "projects/partials/edit/search_query_list.html" with objects=queries %}
1430

1531
<h3 class="ui small header">
1632
{% trans "Overview" %}
17-
<div class="sub header">
18-
{% trans "For the last month" %}
19-
</div>
33+
<div class="sub header">{% trans "For the last month" %}</div>
2034
</h3>
2135
{% if query_count_of_1_month.labels and query_count_of_1_month.int_data %}
2236
<div class="ui loading segment" data-bind="css: {loading: is_loading}">
@@ -52,7 +66,7 @@ <h3 class="ui small header">
5266
</div>
5367
{% endif %}
5468
</div>
55-
{% endblock %}
69+
{% endblock project_edit_content %}
5670

5771
{% block project_edit_sidebar_help_topics %}
5872
{% include "includes/elements/link.html" with url="https://docs.readthedocs.io/page/guides/search-analytics.html" text="How to use search analytics" is_external=True class="item" %}

0 commit comments

Comments
 (0)