Skip to content

Commit 5a60253

Browse files
authored
Domain: show warning in a modal when deleting domain (#515)
![Screenshot 2024-10-31 at 14-00-33 test-public - Domains - Read the Docs](https://github.com/user-attachments/assets/f3e66db4-a7fd-4757-baba-4769c7e8f2c9) ![Screenshot 2024-10-31 at 14-00-28 test-public - Domains - Read the Docs](https://github.com/user-attachments/assets/c8d0bd4f-6d2a-4119-9481-3f8b866f2c82) - Closes #429 - Closes readthedocs/readthedocs.org#11242
1 parent 7fb730a commit 5a60253

File tree

3 files changed

+64
-30
lines changed

3 files changed

+64
-30
lines changed

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

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% load trans blocktrans from i18n %}
12
{% comment "rst" %}
23
Remove button
34
=============
@@ -48,6 +49,10 @@
4849

4950
Modal content text
5051

52+
.. describe:: warning_text
53+
54+
Optional warning text
55+
5156
.. describe:: is_disabled
5257

5358
Show the button as disabled
@@ -63,18 +68,26 @@
6368
This placement is important, as ``.ui.buttons`` uses :last-child, so we
6469
can't place this after the last ``.ui.button``
6570
{% endcomment %}
66-
<div class="ui mini modal" data-modal-id="remove-{{ id }}">
71+
<div class="ui {% if warning_text %}tiny{% else %}mini{% endif %} modal"
72+
data-modal-id="remove-{{ id }}">
6773
<div class="header">{{ action_text }}</div>
6874
<div class="content">
69-
{{ content_text }}
75+
<p>{{ content_text }}</p>
76+
{% if warning_text %}
77+
<div class="ui warning message">{{ warning_text }}</div>
78+
{% endif %}
7079
</div>
7180
<div class="actions">
7281
<form method="post" action="{{ form_url }}">
7382
{% csrf_token %}
7483
{% if field_name and field_value %}
7584
<input type="hidden" name="{{ field_name }}" value="{{ field_value }}" />
7685
{% endif %}
77-
<input class="ui button" type="submit" value="{{ action_text }}" name="{{ action_name }}">
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 }}">
7891
</form>
7992
</div>
8093
</div>

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@
3838
data-content="{% trans "Edit" %}">
3939
<i class="fa-solid fa-wrench icon"></i>
4040
</a>
41-
<a class="ui icon button"
42-
href="{% url 'projects_domains_delete' project.slug object.pk %}"
43-
data-content="{% trans "Delete" %}">
44-
<i class="fa-duotone fa-trash icon"></i>
45-
</a>
41+
42+
{% url "projects_domains_delete" project_slug=project.slug domain_pk=object.pk as delete_url %}
43+
{% trans "Remove domain" as action_text %}
44+
{% blocktrans trimmed asvar content_text with domain=object.domain %}
45+
Remove domain {{ domain }}?
46+
{% endblocktrans %}
47+
{% blocktrans trimmed asvar warning_text %}
48+
Make sure to also remove the DNS record for this domain,
49+
or another project might be able to reuse this domain (also known as domain hijacking).
50+
{% endblocktrans %}
51+
{% include "includes/crud/remove_button.html" with id=object.pk form_url=delete_url action_text=action_text content_text=content_text warning_text=warning_text %}
4652
{% endblock list_item_right_buttons %}
4753

4854
{% block list_item_image %}

readthedocsext/theme/templates/projects/settings_basics_form.html

+37-22
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
{% extends "projects/project_edit_base.html" %}
22

3-
{% load i18n %}
4-
{% load crispy_forms_tags %}
3+
{% load trans blocktrans from i18n %}
4+
{% load crispy from crispy_forms_tags %}
55

6-
{% block title %}{% trans "Edit Project" %}{% endblock %}
7-
{% block project_edit_content_header %}{% trans "Settings" %}{% endblock %}
8-
{% block project_edit_active %}active{% endblock %}
6+
{% block title %}
7+
{% trans "Edit Project" %}
8+
{% endblock title %}
9+
{% block project_edit_content_header %}
10+
{% trans "Settings" %}
11+
{% endblock project_edit_content_header %}
12+
{% block project_edit_active %}
13+
active
14+
{% endblock project_edit_active %}
915

1016
{% block project_edit_content %}
1117
<form class="ui form" method="post" action=".">
@@ -14,14 +20,10 @@
1420
<input class="ui primary button" type="submit" value="{% trans "Save" %}" />
1521
</form>
1622

17-
<div class="ui horizontal divider">
18-
{% trans "More" %}
19-
</div>
23+
<div class="ui horizontal divider">{% trans "More" %}</div>
2024

2125
<div class="ui red segment">
22-
<h3 class="ui small header">
23-
{% trans "Delete project" %}
24-
</h3>
26+
<h3 class="ui small header">{% trans "Delete project" %}</h3>
2527

2628
<p>
2729
{% blocktrans trimmed %}
@@ -30,29 +32,42 @@ <h3 class="ui small header">
3032
{% endblocktrans %}
3133
</p>
3234

33-
<a class="ui button" data-bind="click: $root.show_modal('project-delete')">
35+
<a class="ui button"
36+
data-bind="click: $root.show_modal('project-delete')">
3437
<i class="fa-duotone fa-trash icon"></i>
3538
{% trans "Delete project" %}
3639
</a>
37-
<div class="ui mini modal" data-modal-id="project-delete">
38-
<div class="header">
39-
{% trans "Delete project" %}
40-
</div>
40+
<div class="ui tiny modal" data-modal-id="project-delete">
41+
<div class="header">{% trans "Delete project" %}</div>
4142
<div class="content">
42-
{% blocktrans trimmed with project=project.name %}
43-
Are you sure you want to delete the project {{project}}? This action
44-
cannot be undone.
45-
{% endblocktrans %}
43+
<p>
44+
{% blocktrans trimmed with project=project.name %}
45+
Are you sure you want to delete the project {{ project }}? This action
46+
cannot be undone.
47+
{% endblocktrans %}
48+
</p>
49+
{% if project.domains.exists %}
50+
<div class="ui warning message">
51+
{% url "projects_domains" project.slug as domain_list_url %}
52+
{% blocktrans trimmed with domain_list_url=domain_list_url %}
53+
Your project has a <a href="{{ domain_list_url }}">custom domain</a> configured.
54+
Make sure to also remove the DNS records for all custom domains or another project might be able to reuse the domain (also known as domain hijacking).
55+
{% endblocktrans %}
56+
</div>
57+
{% endif %}
4658
</div>
4759
<div class="actions">
4860
<form method="post" action="{% url "projects_delete" project.slug %}">
4961
{% csrf_token %}
50-
<input class="ui negative button" type="submit" value="{% trans "Delete project" %}">
62+
<div class="ui cancel button">{% trans "Cancel" %}</div>
63+
<input class="ui negative button"
64+
type="submit"
65+
value="{% trans "Delete project" %}">
5166
</form>
5267
</div>
5368
</div>
5469
</div>
55-
{% endblock %}
70+
{% endblock project_edit_content %}
5671

5772
{% block project_edit_sidebar_help_topics_content %}
5873
<div class="ui mini header">{% trans "Tutorials" %}</div>

0 commit comments

Comments
 (0)