Skip to content

Commit 015fc0c

Browse files
committed
Add confirmation modal for the "Refresh Scan" button
Signed-off-by: tdruez <[email protected]>
1 parent 881b9b9 commit 015fc0c

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed

component_catalog/templates/component_catalog/includes/scan_actions_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{% endif %}
2323
{% if scan.refresh_url %}
2424
<li class="list-inline-item"{% if not show_btn_label %} data-bs-toggle="tooltip"{% endif %} data-bs-title="Refresh Scan">
25-
<a class="btn btn-outline-dark btn-sm" href="{{ scan.refresh_url }}">
25+
<a class="btn btn-outline-dark btn-sm scan_refresh_link" href="#scan-refresh-modal" role="button" data-refresh-url="{{ scan.refresh_url }}" data-bs-toggle="modal">
2626
<i class="fa-solid fa-rotate-right"></i>{% if show_btn_label %} Refresh Scan{% endif %}
2727
</a>
2828
</li>

component_catalog/templates/component_catalog/includes/scan_delete_modal.html renamed to component_catalog/templates/component_catalog/modals/scan_delete_modal.html

File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{% load i18n %}
2+
<div id="scan-refresh-modal" class="modal" tabindex="-1" role="dialog">
3+
<div class="modal-dialog" role="document">
4+
<div class="modal-content">
5+
<div class="modal-header">
6+
<h5 class="modal-title">Refresh {% trans 'Scan' %}</h5>
7+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
8+
</div>
9+
<div class="modal-body bg-body-tertiary">
10+
<p><strong>Are you sure you want to refresh this Scan?</strong></p>
11+
<p>
12+
All current data and results related to the Scan will be lost.<br>
13+
If the Scan is in progress, it will be canceled.
14+
</p>
15+
</div>
16+
<div class="modal-footer">
17+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
18+
<a class="btn btn-success refresh-confirm" href="">Refresh Scan</a>
19+
</div>
20+
</div>
21+
</div>
22+
</div>

component_catalog/templates/component_catalog/scan_list.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
{% if has_add_package_permission %}
3030
{% include 'component_catalog/includes/add_package_modal.html' %}
3131
{% endif %}
32-
{% include 'component_catalog/includes/scan_delete_modal.html' %}
32+
{% include 'component_catalog/modals/scan_delete_modal.html' %}
33+
{% include 'component_catalog/modals/scan_refresh_modal.html' %}
3334
{% endblock %}
3435

3536
{% block javascripts %}
@@ -42,6 +43,12 @@
4243
document.querySelector('#scan-delete-modal a.delete-confirm').setAttribute('href', deleteUrl);
4344
});
4445
});
46+
document.querySelectorAll('.scan_refresh_link').forEach(link => {
47+
link.addEventListener('click', function() {
48+
let refreshUrl = this.getAttribute('data-refresh-url');
49+
document.querySelector('#scan-refresh-modal a.refresh-confirm').setAttribute('href', refreshUrl);
50+
});
51+
});
4552
});
4653
</script>
4754
{% endblock %}

component_catalog/templates/component_catalog/tables/scan_list_table.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
Created <span title="{{ scan.created_date }}">{{ scan.created_date|naturaltime }}</span>
4040
</div>
4141
</div>
42-
<div class="col-2">
42+
<div class="col-auto">
4343
{% include 'component_catalog/includes/scan_progress.html' with scan=scan only %}
4444
</div>
4545
</div>

component_catalog/templates/component_catalog/tabs/tab_scan.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@
2828
{% if scan_summary_to_package_form %}
2929
{% include 'component_catalog/includes/scan_summary_to_package_modal.html' %}
3030
{% endif %}
31-
{% include 'component_catalog/includes/scan_delete_modal.html' %}
31+
{% include 'component_catalog/modals/scan_delete_modal.html' %}
32+
{% include 'component_catalog/modals/scan_refresh_modal.html' %}
3233
<script>
3334
document.querySelectorAll('.scan_delete_link').forEach(link => {
3435
link.addEventListener('click', function() {
3536
let deleteUrl = this.getAttribute('data-delete-url');
3637
document.querySelector('#scan-delete-modal a.delete-confirm').setAttribute('href', deleteUrl);
3738
});
3839
});
40+
document.querySelectorAll('.scan_refresh_link').forEach(link => {
41+
link.addEventListener('click', function() {
42+
let refreshUrl = this.getAttribute('data-refresh-url');
43+
document.querySelector('#scan-refresh-modal a.refresh-confirm').setAttribute('href', refreshUrl);
44+
});
45+
});
3946
</script>
4047
{% endif %}

0 commit comments

Comments
 (0)