Skip to content

Commit 4ad0608

Browse files
stsewdagjohnson
andauthored
Add migration page for GitHub App (#570)
While this still requires readthedocs/readthedocs.org#12112, I think it should be safe to review, as the UI shouldn't change much. ~~I still need to finishe a couple of things: make all strings translable, and check for users with multiple GH accounts connected~~. - Step by step guide to connect your account to the new GH app, and also to migrate projects. - Partial support for users with more than one GH account linked (they just need to repeat the migration twice), we don't have a lot of users with more than one account connected, so this should be fine. - Automatically refresh the page once the GH tab has been closed, this should work for most cases, but it won't work if the user doesn't close the page, or if the page refreshes before our application was able to sync the repos. We still show a message about refreshing the page, so. https://github.com/user-attachments/assets/a836dfaf-4f30-41ca-a84b-8a669c838aef --------- Co-authored-by: Anthony <[email protected]>
1 parent 9ca2acd commit 4ad0608

File tree

10 files changed

+661
-2
lines changed

10 files changed

+661
-2
lines changed

readthedocsext/theme/static/readthedocsext/theme/js/site.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{% extends "includes/crud/table_list.html" %}
2+
3+
{% load trans blocktrans from i18n %}
4+
5+
{% comment rst %}
6+
This template is used by the GHA migration template to list projects to migrate
7+
{% endcomment %}
8+
9+
{% block list_placeholder_icon_class %}
10+
fa-duotone fa-octagon-xmark
11+
{% endblock list_placeholder_icon_class %}
12+
{% block list_placeholder_header %}
13+
{% blocktrans trimmed %}
14+
No projects can be migrated
15+
{% endblocktrans %}
16+
<div class="sub header">
17+
{% blocktrans trimmed %}
18+
You don't have any projects to migrate.
19+
{% endblocktrans %}
20+
</div>
21+
{% endblock list_placeholder_header %}
22+
{% block list_placeholder_text %}
23+
<a class="ui button"
24+
href="?step=revoke"
25+
aria-label="{% trans "Skip this step" %}"
26+
target="_blank">{% trans "Skip this step" %}</a>
27+
{% endblock list_placeholder_text %}
28+
29+
{% block top_right_menu_items %}
30+
{% if objects %}
31+
<div class="item">
32+
<em>
33+
{% blocktrans trimmed %}
34+
You may need to manually refresh after installation or migration
35+
{% endblocktrans %}
36+
</em>
37+
</div>
38+
{% endif %}
39+
<div class="item">
40+
<a class="ui small compact primary {% if not objects %}disabled{% endif %} button"
41+
href="{{ current_page }}">
42+
<i class="fas fa-refresh icon"></i>
43+
{% trans "Refresh" %}
44+
</a>
45+
</div>
46+
{% endblock top_right_menu_items %}
47+
48+
{% block list_item_image %}
49+
{% endblock list_item_image %}
50+
51+
{% block list_item_header %}
52+
<a href="{% url 'projects_detail' object.project.slug %}"
53+
target="_blank">{{ object.project.name }}</a>
54+
{% endblock list_item_header %}
55+
56+
{% block list_item_right_menu %}
57+
{% if not object.has_installation %}
58+
<a class="ui button small"
59+
href="{{ object.installation_link }}"
60+
data-bind="click: trackLinkClick"
61+
target="_blank"
62+
data-content="{% trans "You need to install our GitHub app on this repository in order to migrate this project" %}">
63+
{% trans "Install" %}
64+
</a>
65+
{% elif not object.is_admin %}
66+
<div data-content="{% trans "Your GitHub user must have admin access to the repository in order to migrate this project" %}">
67+
<button class="ui small disabled negative button">
68+
<i class="fas fa-triangle-exclamation icon"></i>
69+
{% trans "Migrate" %}
70+
</button>
71+
</div>
72+
{% else %}
73+
<form method="post" action="." class="ui form">
74+
{% csrf_token %}
75+
<input type="hidden" name="project" value="{{ object.project.slug }}">
76+
<button class="ui button small" type="submit">{% trans "Migrate" %}</button>
77+
</form>
78+
{% endif %}
79+
{% endblock list_item_right_menu %}
80+
81+
{% block list_item_meta_items %}
82+
<div class="item">
83+
{% with repo=object.project.remote_repository %}
84+
<a href="{{ repo.html_url }}" class="ui small basic image nowrap label">
85+
<img alt="{% blocktrans with name=project.name %}Project {{ name }} avatar{% endblocktrans %}"
86+
src="{{ repo.avatar_url }}" />
87+
<code>{{ repo.full_name }}</code>
88+
</a>
89+
{% endwith %}
90+
</div>
91+
{% endblock list_item_meta_items %}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{% extends "includes/crud/table_list.html" %}
2+
3+
{% load trans blocktrans from i18n %}
4+
5+
{% comment rst %}
6+
This template is used by the GHA migration template to list projects that have been migrated already.
7+
{% endcomment %}
8+
9+
{% block list_placeholder_icon_class %}
10+
fa-duotone fa-octagon-xmark
11+
{% endblock list_placeholder_icon_class %}
12+
13+
{% block list_placeholder_icon %}
14+
{% endblock list_placeholder_icon %}
15+
{% block list_placeholder_header %}
16+
{% blocktrans trimmed %}
17+
No projects have been migrated yet
18+
{% endblocktrans %}
19+
<div class="sub header">
20+
{% blocktrans trimmed %}
21+
Install our GitHub App and migrate your projects above before proceeding.
22+
{% endblocktrans %}
23+
</div>
24+
{% endblock list_placeholder_header %}
25+
{% block list_placeholder_text %}
26+
{% endblock list_placeholder_text %}
27+
28+
{% block top_menu %}
29+
{% endblock top_menu %}
30+
31+
{% block list_item_image %}
32+
{% endblock list_item_image %}
33+
34+
{% block list_item_header %}
35+
<a href="{% url 'projects_detail' object.slug %}" target="_blank">{{ object.name }}</a>
36+
{% endblock list_item_header %}
37+
38+
{% block list_item_right_menu %}
39+
<div class="ui green text">
40+
<i class="fas fa-circle-check icon"></i>
41+
{% trans "Migrated" %}
42+
</div>
43+
{% endblock list_item_right_menu %}
44+
45+
{% block list_item_meta_items %}
46+
<div class="item">
47+
{% with repo=object.remote_repository %}
48+
<a href="{{ repo.html_url }}" class="ui small basic image nowrap label">
49+
<img alt="{% blocktrans with name=object.name %}Project {{ name }} avatar{% endblocktrans %}"
50+
src="{{ repo.avatar_url }}" />
51+
<code>{{ repo.full_name }}</code>
52+
</a>
53+
{% endwith %}
54+
</div>
55+
{% endblock list_item_meta_items %}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{% extends "includes/crud/table_list.html" %}
2+
3+
{% load trans blocktrans from i18n %}
4+
5+
{% comment rst %}
6+
This template is used by the GHA migration template to list GHA
7+
installation targets like organization and user accounts.
8+
9+
:param objects: List of installation target organizations and user accounts
10+
:type objects: InstallationTargetGroup
11+
{% endcomment %}
12+
13+
{% block list_placeholder_icon_class %}
14+
fa-duotone fa-code-commit
15+
{% endblock list_placeholder_icon_class %}
16+
{% block list_placeholder_header %}
17+
{% blocktrans trimmed %}
18+
No installation targets found
19+
{% endblocktrans %}
20+
<div class="sub header">
21+
{% blocktrans trimmed %}
22+
You don't have any projects connected to GitHub repositories.
23+
{% endblocktrans %}
24+
</div>
25+
{% endblock list_placeholder_header %}
26+
{% block list_placeholder_text %}
27+
<a class="ui button"
28+
href="?step=revoke"
29+
aria-label="{% trans "Skip this step" %}"
30+
target="_blank">{% trans "Skip this step" %}</a>
31+
{% endblock list_placeholder_text %}
32+
33+
{% block top_right_menu_items %}
34+
{% if objects %}
35+
<div class="item">
36+
<em>
37+
{% blocktrans trimmed %}
38+
You may need to refresh after installation to continue
39+
{% endblocktrans %}
40+
</em>
41+
</div>
42+
{% endif %}
43+
<div class="item">
44+
<a class="ui small compact primary {% if not objects %}disabled{% endif %} button"
45+
href="{{ current_page }}">
46+
<i class="fas fa-refresh icon"></i>
47+
{% trans "Refresh" %}
48+
</a>
49+
</div>
50+
{% endblock top_right_menu_items %}
51+
52+
{% block list_item_meta_items %}
53+
{% endblock list_item_meta_items %}
54+
55+
{% block list_item_image %}
56+
<img class="ui rounded image"
57+
src="{{ object.target.avatar_url }}"
58+
height="28"
59+
alt="{% trans "Account avatar" %}"
60+
width="28" />
61+
{% endblock list_item_image %}
62+
63+
{% block list_item_header %}
64+
{{ object.target.login }}
65+
<div class="sub header">
66+
<a href="{{ object.target.profile_url }}" target="_blank">
67+
{{ object.target.profile_url }}
68+
</a>
69+
</div>
70+
{% endblock list_item_header %}
71+
72+
{% block list_item_right_menu %}
73+
{% if object.installed %}
74+
<div class="ui green text">
75+
<i class="fa-solid fa-circle-check icon"></i>
76+
{% trans "Installed" %}
77+
</div>
78+
{% else %}
79+
<a href="{{ object.link }}"
80+
target="_blank"
81+
class="ui small button"
82+
data-bind="click: trackLinkClick">{% trans "Install" %}</a>
83+
{% endif %}
84+
{% endblock list_item_right_menu %}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{% extends "socialaccount/partials/social_account_list.html" %}
2+
3+
{% comment %}
4+
This template is used by the GHA migration template to list _just_ GitHub
5+
OAuth accounts that need to be disconnected.
6+
{% endcomment %}
7+
8+
{% load trans from i18n %}
9+
{% load provider_login_url from socialaccount %}
10+
11+
{% block top_menu %}
12+
{% endblock top_menu %}
13+
14+
{% block list_placeholder %}
15+
{% endblock list_placeholder %}
16+
17+
{% block list_item_meta_items %}
18+
{% endblock list_item_meta_items %}
19+
20+
{% block list_item_right_menu %}
21+
<form class="ui form"
22+
method="post"
23+
action="{% url 'socialaccount_connections' %}">
24+
{% csrf_token %}
25+
<input type="hidden" name="account" value="{{ object.id }}" />
26+
<button class="ui button" type="submit">
27+
<i class="fa-brands fa-github icon"></i>
28+
{% trans "Disconnect" %}
29+
</button>
30+
</form>
31+
{% endblock list_item_right_menu %}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{% extends "socialaccount/partials/social_account_list.html" %}
2+
{% load has_github_app_account from readthedocs.socialaccounts %}
3+
4+
{% comment %}
5+
This template is used by the GHA migration template to list _just_ GitHub
6+
OAuth accounts that need connection to our new GHA.
7+
{% endcomment %}
8+
9+
{% load trans from i18n %}
10+
{% load provider_login_url from socialaccount %}
11+
12+
{% block top_menu %}
13+
{% endblock top_menu %}
14+
15+
{% block list_placeholder %}
16+
{% endblock list_placeholder %}
17+
18+
{% block list_item_meta_items %}
19+
{% endblock list_item_meta_items %}
20+
21+
{% block list_item_right_menu %}
22+
{% if object|has_github_app_account %}
23+
<span class="ui green text">
24+
<i class="fas fa-circle-check icon"></i>
25+
{% trans "Connected" %}
26+
</span>
27+
{% else %}
28+
<form class="ui form"
29+
method="post"
30+
action="{% provider_login_url "githubapp" process="connect" next=request.get_full_path %}">
31+
{% csrf_token %}
32+
<button class="ui button" type="submit">
33+
<i class="fa-brands fa-github icon"></i>
34+
{% trans "Connect" %}
35+
</button>
36+
</form>
37+
{% endif %}
38+
{% endblock list_item_right_menu %}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{% extends "socialaccount/partials/social_account_list.html" %}
2+
{% load is_access_revoked from readthedocs.socialaccounts %}
3+
4+
{% comment %}
5+
This template is used by the GHA migration template to list _just_ GitHub
6+
OAuth accounts that need to be revoked.
7+
{% endcomment %}
8+
9+
{% load trans blocktrans from i18n %}
10+
{% load provider_login_url from socialaccount %}
11+
12+
{% block list_placeholder %}
13+
{% endblock list_placeholder %}
14+
15+
{% block top_right_menu_items %}
16+
{% if not step_revoke_completed %}
17+
<div class="item">
18+
<em>
19+
{% blocktrans trimmed %}
20+
You may need to manually refresh after revoking access
21+
{% endblocktrans %}
22+
</em>
23+
</div>
24+
{% endif %}
25+
<div class="item">
26+
<a class="ui small compact primary {% if step_revoke_completed %}disabled{% endif %} button"
27+
href="{{ current_page }}">
28+
<i class="fas fa-refresh icon"></i>
29+
{% trans "Refresh" %}
30+
</a>
31+
</div>
32+
{% endblock top_right_menu_items %}
33+
34+
{% block list_item_meta_items %}
35+
{% endblock list_item_meta_items %}
36+
37+
{% block list_item_right_menu %}
38+
{% if object|is_access_revoked %}
39+
<span class="ui green text">
40+
<i class="fas fa-circle-check icon"></i>
41+
{% trans "Revoked" %}
42+
</span>
43+
{% else %}
44+
<a href="{{ old_application_link }}"
45+
target="_blank"
46+
class="ui button"
47+
data-bind="click: trackLinkClick">
48+
<i class="fa-brands fa-github icon"></i>
49+
{% trans "Revoke" %}
50+
</a>
51+
{% endif %}
52+
{% endblock list_item_right_menu %}

0 commit comments

Comments
 (0)