Skip to content

Commit 00b081d

Browse files
humitosagjohnson
authored andcommitted
Show connect buttons for installed apps only (#3394)
* Show connect buttons for installed apps only Instead of hardcode the button/form for each of the services, we share the ``provider_list.html`` file used in the "Connected Services" tab from "Account Settings". This template shows only buttons for the Services installed in the database. * Fix lint * Add missing CSS class used at .com * Use proper GitLab icon from FontAwesome * Force tuple but without breaking prospector * Do not loose the next attribute * Fix styling
1 parent 4373cba commit 00b081d

File tree

9 files changed

+42
-55
lines changed

9 files changed

+42
-55
lines changed

media/css/core.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,19 +690,16 @@ div.project-import-remote button.remote-sync:before {
690690
content: "\f021";
691691
}
692692

693-
div.project-import-remote form.import-connect-github button:before,
694693
a.socialaccount-provider.github:before {
695694
font-family: FontAwesome;
696695
content: "\f09b";
697696
}
698697

699-
div.project-import-remote form.import-connect-gitlab button:before,
700698
a.socialaccount-provider.gitlab:before {
701699
font-family: FontAwesome;
702-
content: "\f1d3";
700+
content: "\f296";
703701
}
704702

705-
div.project-import-remote form.import-connect-bitbucket button:before,
706703
a.socialaccount-provider.bitbucket:before,
707704
a.socialaccount-provider.bitbucket_oauth2:before {
708705
font-family: FontAwesome;
Binary file not shown.
Binary file not shown.

readthedocs/projects/static-src/projects/css/import.less

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,25 @@ div.project-import-remote {
6060
}
6161
}
6262

63-
form.import-connect {
63+
ul.socialaccount_providers {
6464
overflow: auto;
65-
display: inline;
66-
67-
button {
68-
display: inline;
69-
margin-bottom: .5em;
70-
font-size: 1em;
71-
font-weight: normal;
65+
display: block;
66+
list-style: none;
67+
68+
li {
69+
margin-top: 0.5em;
70+
display: block;
71+
overflow: auto;
72+
text-align: center;
73+
74+
a.socialaccount-provider {
75+
float: none;
76+
display: inline-block;
77+
margin-bottom: 0.5em;
78+
margin-top: 0.5em;
79+
font-size: 1em;
80+
font-weight: normal;
81+
}
7282
}
7383
}
7484
}

readthedocs/projects/static/projects/css/import.css

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,22 @@ div.project-import-remote li.remote-repo ul.remote-repo-menu {
4949
top: 10px;
5050
right: 10px;
5151
}
52-
div.project-import-remote form.import-connect {
52+
div.project-import-remote ul.socialaccount_providers {
5353
overflow: auto;
54-
display: inline;
54+
display: block;
55+
list-style: none;
56+
}
57+
div.project-import-remote ul.socialaccount_providers li {
58+
margin-top: 0.5em;
59+
display: block;
60+
overflow: auto;
61+
text-align: center;
5562
}
56-
div.project-import-remote form.import-connect button {
57-
display: inline;
58-
margin-bottom: .5em;
63+
div.project-import-remote ul.socialaccount_providers li a.socialaccount-provider {
64+
float: none;
65+
display: inline-block;
66+
margin-bottom: 0.5em;
67+
margin-top: 0.5em;
5968
font-size: 1em;
6069
font-weight: normal;
6170
}

readthedocs/restapi/views/footer_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_version_compare_data(project, base_version=None):
4343
}
4444
if highest_version_obj:
4545
ret_val['url'] = highest_version_obj.get_absolute_url()
46-
ret_val['slug'] = highest_version_obj.slug,
46+
ret_val['slug'] = (highest_version_obj.slug,)
4747
if base_version and base_version.slug != LATEST:
4848
try:
4949
base_version_comparable = parse_version_failsafe(

readthedocs/templates/projects/project_import.html

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -93,41 +93,12 @@ <h1>{% trans "Import a Repository" %}</h1>
9393
{% endblocktrans %}
9494
</p>
9595

96-
<div class="project-import-providers">
97-
<form
98-
method="get"
99-
action="{% provider_login_url "github" %}"
100-
class="import-connect import-connect-github">
101-
<button>
102-
{% trans "Connect to GitHub" %}
103-
</button>
104-
<input type="hidden" name="process" value="connect">
105-
<input type="hidden" name="next" value="/dashboard/import/">
106-
</form>
107-
108-
<form
109-
method="get"
110-
action="{% provider_login_url "gitlab" %}"
111-
class="import-connect import-connect-gitlab">
112-
<button>
113-
{% trans "Connect to GitLab" %}
114-
</button>
115-
<input type="hidden" name="process" value="connect">
116-
<input type="hidden" name="next" value="/dashboard/import/">
117-
</form>
11896

119-
<form
120-
method="get"
121-
action="{% provider_login_url "bitbucket_oauth2" %}"
122-
class="import-connect import-connect-bitbucket">
123-
<button>
124-
{% trans "Connect to Bitbucket" %}
125-
</button>
126-
<input type="hidden" name="process" value="connect">
127-
<input type="hidden" name="next" value="/dashboard/import/">
128-
</form>
97+
<div class="project-import-providers">
98+
<ul class="socialaccount_providers">
99+
{% include "socialaccount/snippets/provider_list.html" with process="connect" next="/dashboard/import/" %}
100+
</ul>
129101
</div>
130-
131102
{% endif %}
132103
</li>
133104
</ul>

readthedocs/templates/socialaccount/connections.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
</div>
7474

7575
<ul class="socialaccount_providers">
76-
{% include "socialaccount/snippets/provider_list.html" with process="connect" %}
76+
{% include "socialaccount/snippets/provider_list.html" with process="connect" next="" %}
7777
</ul>
7878

7979
{% include "socialaccount/snippets/login_extra.html" %}

readthedocs/templates/socialaccount/snippets/provider_list.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
{% for brand in provider.get_brands %}
99
<li>
1010
<a title="{{ brand.name }}"
11-
class="socialaccount-provider {{ provider.id }} {{ brand.id }}"
12-
href="{% provider_login_url provider.id openid=brand.openid_url process=process %}"
11+
class="socialaccount-provider {{ provider.id }} {{ brand.id }} button"
12+
href="{% provider_login_url provider.id openid=brand.openid_url process=process next=next %}"
1313
>
1414
{% blocktrans with brand_name=brand.name %}
1515
Connect to {{ brand_name }}
@@ -22,7 +22,7 @@
2222
<li>
2323
<a title="{{ provider.name }}"
2424
class="socialaccount-provider {{ provider.id }} button"
25-
href="{% provider_login_url provider.id process=process scope=scope auth_params=auth_params %}"
25+
href="{% provider_login_url provider.id process=process scope=scope auth_params=auth_params next=next %}"
2626
>
2727
{% blocktrans with provider_name=provider.name %}
2828
Connect to {{ provider_name }}

0 commit comments

Comments
 (0)