Skip to content

Commit 8b44b9e

Browse files
agjohnsonhumitos
andauthored
Changes to support GHA integration (#617)
This adds some metadata to the integration display to show GHA integrations: - Locked state blocking removal - Disconnection state on GHA errors - Links to the GHA page on GitHub for configuration ![image](https://github.com/user-attachments/assets/a62158bd-b530-422e-a2d3-16ee90d173fc) ---- - Requires readthedocs/readthedocs.org#12273 - Fixes readthedocs/readthedocs.org#12130 --------- Co-authored-by: Manuel Kaufmann <[email protected]>
1 parent 2ca4b1f commit 8b44b9e

File tree

4 files changed

+104
-58
lines changed

4 files changed

+104
-58
lines changed

readthedocsext/theme/templates/includes/components/config_label.html

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% load i18n %}
1+
{% load trans from i18n %}
22

33
{% comment "rst" %}
44
config_label
@@ -32,17 +32,9 @@
3232

3333
{% endcomment %}
3434

35-
<span
36-
{% if popup %}
37-
data-content="{{ popup }}"
38-
aria-label="{{ popup }}"
39-
{% endif %}
40-
{% if url %}
41-
href="{{ url }}"
42-
{% endif %}
43-
class="ui {% if classes %}{{ classes }} {% endif %}label">
44-
{% if icon %}
45-
<i class="{{ icon }} icon"></i>
46-
{% endif %}
35+
<span {% if popup %}data-content="{{ popup }}" aria-label="{{ popup }}"{% endif %}
36+
{% if url %}href="{{ url }}"{% endif %}
37+
class="ui {% if classes %}{{ classes }}{% else %}{% if not text %}icon{% endif %}{% endif %} label">
38+
{% if icon %}<i class="{{ icon }} icon"></i>{% endif %}
4739
{{ text }}
4840
</span>

readthedocsext/theme/templates/includes/crud/remove_button.html

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,34 @@
6464
data-content="{{ action_text }}">
6565
<i class="fa-solid fa-trash icon"></i>
6666

67-
{% comment %}
68-
This placement is important, as ``.ui.buttons`` uses :last-child, so we
69-
can't place this after the last ``.ui.button``
70-
{% endcomment %}
71-
<div class="ui {% if warning_text %}tiny{% else %}mini{% endif %} modal"
72-
data-modal-id="remove-{{ id }}">
73-
<div class="header">{{ action_text }}</div>
74-
<div class="content">
75-
<p>{{ content_text }}</p>
76-
{% if warning_text %}
77-
<div class="ui warning message">{{ warning_text }}</div>
78-
{% endif %}
79-
</div>
80-
<div class="actions">
81-
<form method="post" action="{{ form_url }}">
82-
{% csrf_token %}
83-
{% if field_name and field_value %}
84-
<input type="hidden" name="{{ field_name }}" value="{{ field_value }}" />
67+
{# Avoid rogue modals leaking this UI if the button is disabled #}
68+
{% if not is_disabled %}
69+
{% comment %}
70+
This placement is important, as ``.ui.buttons`` uses :last-child, so we
71+
can't place this after the last ``.ui.button``
72+
{% endcomment %}
73+
<div class="ui {% if warning_text %}tiny{% else %}mini{% endif %} modal"
74+
data-modal-id="remove-{{ id }}">
75+
<div class="header">{{ action_text }}</div>
76+
<div class="content">
77+
<p>{{ content_text }}</p>
78+
{% if warning_text %}
79+
<div class="ui warning message">{{ warning_text }}</div>
8580
{% endif %}
86-
<div class="ui cancel button">{% trans "Cancel" %}</div>
87-
<input class="ui button negative"
88-
type="submit"
89-
value="{{ action_text }}"
90-
name="{{ action_name }}">
91-
</form>
81+
</div>
82+
<div class="actions">
83+
<form method="post" action="{{ form_url }}">
84+
{% csrf_token %}
85+
{% if field_name and field_value %}
86+
<input type="hidden" name="{{ field_name }}" value="{{ field_value }}" />
87+
{% endif %}
88+
<div class="ui cancel button">{% trans "Cancel" %}</div>
89+
<input class="ui button negative"
90+
type="submit"
91+
value="{{ action_text }}"
92+
name="{{ action_name }}">
93+
</form>
94+
</div>
9295
</div>
93-
</div>
96+
{% endif %}
9497
</div>

readthedocsext/theme/templates/projects/integration_list.html

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

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

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

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

1016
{% block project_edit_content %}
11-
{% include "projects/partials/edit/integration_list.html" with objects=object_list %}
12-
{% endblock %}
17+
{% include "projects/partials/edit/integration_list.html" with objects=subclassed_object_list %}
18+
{% endblock project_edit_content %}
1319

1420
{% block project_edit_sidebar_help_topics %}
1521
{% include "includes/elements/link.html" with url="https://docs.readthedocs.io/page/guides/connecting-git-account.html" text="How to connect your Read the Docs account to your Git provider" is_external=True class="item" %}

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

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

33
{% load trans blocktrans from i18n %}
4+
{% load naturaltime from humanize %}
45

56
{% block top_left_menu_items %}
67
{% endblock top_left_menu_items %}
@@ -35,33 +36,77 @@
3536
{% endblock list_placeholder_text %}
3637

3738
{% block list_item_right_buttons %}
38-
<a class="ui icon button"
39-
href="{% url 'projects_integrations_detail' project_slug=project.slug integration_pk=object.pk %}">
40-
<i class="fa-duotone fa-wrench icon"></i>
41-
</a>
39+
{# This URL is to the detail page for the integration or for the GitHub App page #}
40+
{% with url=object.get_absolute_url %}
41+
<a class="ui {% if not url %}disabled{% endif %} icon button"
42+
href="{% firstof url '#' %}"
43+
{% if object.is_remote_only %}target="_blank"{% endif %}>
44+
<i class="fa-duotone fa-wrench icon"></i>
45+
</a>
46+
{% endwith %}
4247

4348
{% url 'projects_integrations_delete' project_slug=project.slug integration_pk=object.pk as form_url %}
4449
{% trans "Remove integration" as action_text %}
4550
{% blocktrans trimmed asvar content_text with description=object.get_integration_type_display %}
4651
Remove integration {{ description }}?
4752
{% endblocktrans %}
48-
{% include "includes/crud/remove_button.html" with id=object.pk form_url=form_url action_text=action_text content_text=content_text %}
53+
{% include "includes/crud/remove_button.html" with id=object.pk form_url=form_url action_text=action_text content_text=content_text is_disabled=object.is_remote_only %}
4954
{% endblock list_item_right_buttons %}
5055

5156
{% block list_item_icon %}
5257
<i class="fa-duotone fa-exchange icon"></i>
5358
{% endblock list_item_icon %}
5459

5560
{% block list_item_header %}
56-
<a href="{% url 'projects_integrations_detail' project_slug=project.slug integration_pk=object.pk %}">
57-
{{ object.get_integration_type_display }}
58-
</a>
59-
{% if object.has_sync and object.can_sync %}
60-
<i class="fa-duotone fa-wand-magic-sparkles icon"
61-
data-content="{% trans "Automatically managed" %}"></i>
61+
{# This URL is to the detail page for the integration or for the GitHub App page #}
62+
{% with url=object.get_absolute_url %}
63+
{% if url %}
64+
<a href="{{ url }}"
65+
{% if object.is_remote_only %}target="_blank"{% endif %}>
66+
{{ object.get_integration_type_display }}
67+
</a>
68+
{% else %}
69+
{# Mostly for GHA integrations that are disconnected. We have nothing to link to #}
70+
{{ object.get_integration_type_display }}
71+
{% endif %}
72+
{% endwith %}
73+
74+
{% if object.is_remote_only %}
75+
{% blocktrans trimmed asvar popup %}
76+
This integration is managed by the provider and cannot be removed
77+
{% endblocktrans %}
78+
{% include "includes/components/config_label.html" with icon="fa-duotone fa-lock" popup=popup %}
79+
{% elif not object.has_sync and not object.can_sync %}
80+
{% blocktrans trimmed asvar popup %}
81+
This integration is not automatically managed and will require manual setup
82+
{% endblocktrans %}
83+
{% include "includes/components/config_label.html" with icon="fa-duotone fa-user-gear" popup=popup %}
6284
{% endif %}
6385
{% endblock list_item_header %}
6486

65-
{% block list_item_meta %}
66-
<div class="item">{{ object.exchanges.count }} exchanges</div>
67-
{% endblock list_item_meta %}
87+
{% block list_item_meta_items %}
88+
{% if object.is_remote_only and not object.is_active %}
89+
{% trans "Disconnected" context "The integration is in a disconnected state" as text %}
90+
{% blocktrans trimmed with version=object.verbose_name asvar popup %}
91+
This integration is disconnected, check with your provider
92+
{% endblocktrans %}
93+
<div class="item">
94+
{% include "includes/components/config_label.html" with classes="red" icon="fa-solid fa-circle-exclamation" text=text popup=popup %}
95+
</div>
96+
{% elif object.is_remote_only and object.is_active %}
97+
{# `is_active` ensures there is a connected remote repository #}
98+
<div class="item">
99+
{# Translators: this is time since connecting this integraiton and will read "Connected 1 year, 5 months ago" #}
100+
{% blocktrans with time_since=object.created|naturaltime trimmed %}
101+
Connected {{ time_since }}
102+
{% endblocktrans %}
103+
</div>
104+
{% elif not object.is_remote_only %}
105+
<div class="item">
106+
{# Translators: this is the number of HTTP request/response exchanges for this integration, as in "10 exchanges" #}
107+
{% blocktrans with count=object.exchanges.count trimmed %}
108+
{{ count }} exchanges
109+
{% endblocktrans %}
110+
</div>
111+
{% endif %}
112+
{% endblock list_item_meta_items %}

0 commit comments

Comments
 (0)