Skip to content

Commit 5d030e8

Browse files
authored
Don't use links for disabled buttons (#10774)
* Don't use links for disabled buttons * Update translations
1 parent 968f11f commit 5d030e8

File tree

2 files changed

+41
-34
lines changed

2 files changed

+41
-34
lines changed

warehouse/locale/messages.pot

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,8 @@ msgid "from %(ip_address)s"
25072507
msgstr ""
25082508

25092509
#: warehouse/templates/manage/manage_base.html:16
2510-
#: warehouse/templates/manage/projects.html:108
2510+
#: warehouse/templates/manage/projects.html:106
2511+
#: warehouse/templates/manage/projects.html:111
25112512
#: warehouse/templates/manage/releases.html:88
25122513
msgid "Manage"
25132514
msgstr ""
@@ -2746,40 +2747,41 @@ msgstr ""
27462747
msgid "Sole owner"
27472748
msgstr ""
27482749

2749-
#: warehouse/templates/manage/projects.html:92
2750+
#: warehouse/templates/manage/projects.html:94
27502751
msgid "PyPI requires 2FA to be enabled to manage this project"
27512752
msgstr ""
27522753

2753-
#: warehouse/templates/manage/projects.html:94
2754+
#: warehouse/templates/manage/projects.html:96
27542755
msgid "This project requires 2FA to be enabled to manage"
27552756
msgstr ""
27562757

2757-
#: warehouse/templates/manage/projects.html:96
2758+
#: warehouse/templates/manage/projects.html:98
27582759
msgid "2FA Required"
27592760
msgstr ""
27602761

2761-
#: warehouse/templates/manage/projects.html:103
2762+
#: warehouse/templates/manage/projects.html:105
27622763
msgid "Manage this project"
27632764
msgstr ""
27642765

2765-
#: warehouse/templates/manage/projects.html:106
2766+
#: warehouse/templates/manage/projects.html:110
27662767
msgid "You are not an owner of this project"
27672768
msgstr ""
27682769

2769-
#: warehouse/templates/manage/projects.html:114
2770+
#: warehouse/templates/manage/projects.html:118
27702771
msgid "View this project's public page"
27712772
msgstr ""
27722773

2773-
#: warehouse/templates/manage/projects.html:117
2774-
msgid "This project has no releases"
2775-
msgstr ""
2776-
27772774
#: warehouse/templates/manage/projects.html:119
2775+
#: warehouse/templates/manage/projects.html:122
27782776
#: warehouse/templates/manage/releases.html:94
27792777
msgid "View"
27802778
msgstr ""
27812779

2782-
#: warehouse/templates/manage/projects.html:126
2780+
#: warehouse/templates/manage/projects.html:121
2781+
msgid "This project has no releases"
2782+
msgstr ""
2783+
2784+
#: warehouse/templates/manage/projects.html:131
27832785
#, python-format
27842786
msgid ""
27852787
"You have not uploaded any projects to PyPI, yet. To learn how to get "

warehouse/templates/manage/projects.html

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,39 +84,44 @@ <h3 class="package-snippet__title">{{ project.name }}
8484
</div>
8585
<div class="package-snippet__buttons">
8686

87-
{% if not user_has_two_factor and project.name in projects_requiring_2fa %}
88-
<a
89-
href="{{ request.route_path('manage.account.two-factor') }}"
90-
class="button button--danger"
91-
{% if project.pypi_mandates_2fa %}
92-
title="{% trans %}PyPI requires 2FA to be enabled to manage this project{% endtrans %}"
93-
{% else %}
94-
title="{% trans %}This project requires 2FA to be enabled to manage{% endtrans %}"
95-
{% endif %}
96-
>{% trans %}2FA Required{% endtrans %}</a>
87+
{% if project.name in projects_owned %}
88+
{% if not user_has_two_factor and project.name in projects_requiring_2fa %}
89+
{# Show 2FA required button #}
90+
<a
91+
href="{{ request.route_path('manage.account.two-factor') }}"
92+
class="button button--danger"
93+
{% if project.pypi_mandates_2fa %}
94+
title="{% trans %}PyPI requires 2FA to be enabled to manage this project{% endtrans %}"
95+
{% else %}
96+
title="{% trans %}This project requires 2FA to be enabled to manage{% endtrans %}"
97+
{% endif %}
98+
>{% trans %}2FA Required{% endtrans %}</a>
9799

98-
{% else %}
99-
<a
100+
{% else %}
101+
{# Show manage button #}
102+
<a
100103
href="{{ request.route_path('manage.project.releases', project_name=project.normalized_name) }}"
101104
class="button button--primary"
102-
{% if project.name in projects_owned %}
103105
title="{% trans %}Manage this project{% endtrans %}"
104-
{% else %}
105-
disabled
106-
title="{% trans %}You are not an owner of this project{% endtrans %}"
107-
{% endif %}
108106
>{% trans %}Manage{% endtrans %}</a>
107+
{% endif %}
108+
{% else %}
109+
{# Show disabled button #}
110+
<button class="button button--primary" disabled title="{% trans %}You are not an owner of this project{% endtrans %}">
111+
{% trans %}Manage{% endtrans %}
112+
</button>
109113
{% endif %}
114+
{% if project.releases %}
110115
<a
111116
href="{{ request.route_path('packaging.project', name=project.normalized_name) }}"
112117
class="button"
113-
{% if project.releases %}
114118
title="{% trans %}View this project's public page{% endtrans %}"
115-
{% else %}
116-
disabled
117-
title="{% trans %}This project has no releases{% endtrans %}"
118-
{% endif %}
119119
>{% trans %}View{% endtrans %}</a>
120+
{% else %}
121+
<button class="button" disabled title="{% trans %}This project has no releases{% endtrans %}" >
122+
{% trans %}View{% endtrans %}
123+
</button>
124+
{% endif %}
120125
</div>
121126
</div>
122127
</div>

0 commit comments

Comments
 (0)