Skip to content

Commit a32ff7a

Browse files
committed
add confirmation modal for the API key revoke
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 848eb7c commit a32ff7a

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

dje/templates/account/profile.html

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
{% endif %}
4949
</div>
5050
<div>
51-
<a href="#" class="btn btn-outline-dark" data-bs-toggle="modal" data-bs-target="#generate-api-key">
51+
<button type="button" class="btn btn-outline-dark" data-bs-toggle="modal" data-bs-target="#generate-api-key">
5252
Generate API key
53-
</a>
53+
</button>
5454
{% if request.user.api_token %}
55-
<form action="{% url 'revoke_api_key' %}" id="revoke-api-key-form" class="d-inline" method="post">{% csrf_token %}
56-
<button type="submit" class="btn btn-outline-danger">Revoke API key</button>
57-
</form>
55+
<button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#revoke-api-key">
56+
Revoke API key
57+
</button>
5858
{% endif %}
5959
</div>
6060
</div>
@@ -86,4 +86,31 @@ <h5 class="modal-title">Generate API key</h5>
8686
</div>
8787
</div>
8888
</div>
89+
90+
<div class="modal" tabindex="-1" role="dialog" id="revoke-api-key">
91+
<div class="modal-dialog" role="document">
92+
<div class="modal-content">
93+
<div class="modal-header">
94+
<h5 class="modal-title">Revoke API key</h5>
95+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
96+
</div>
97+
<div class="modal-body bg-body-tertiary">
98+
<p>
99+
<strong>Are you sure you want to delete your API key?</strong>
100+
</p>
101+
<div class="alert alert-danger m-0 mb-3" role="alert">
102+
<strong>
103+
Your existing key will be immediately revoked.
104+
</strong>
105+
</div>
106+
</div>
107+
<div class="modal-footer">
108+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
109+
<form action="{% url 'revoke_api_key' %}" id="revoke-api-key-form" method="post">{% csrf_token %}
110+
<button type="submit" class="btn btn-danger">Revoke API key</button>
111+
</form>
112+
</div>
113+
</div>
114+
</div>
115+
</div>
89116
{% endblock %}

0 commit comments

Comments
 (0)