Skip to content

Commit 7ce5496

Browse files
committed
keyboard shortcuts to verify/close finding
1 parent 0cdbc44 commit 7ce5496

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

dojo/templates/dojo/view_finding.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ <h4>Credential
11691169
</div>
11701170

11711171
<div class="protip">
1172-
<i class="fa-solid fa-lightbulb"></i> <strong>ProTip!</strong> Type <kbd>e</kbd> to edit any finding, <kbd>p</kbd> and <kbd>n</kbd> to navigate to the previous or next finding.
1172+
<i class="fa-solid fa-lightbulb"></i> <strong>ProTip!</strong> Type <kbd>e</kbd> to edit any finding, <kbd>p</kbd> and <kbd>n</kbd> to navigate to the previous or next finding, <kbd>v</kbd> to verify, and <kbd>c</kbd> to close the finding.
11731173
</div>
11741174
</div>
11751175
{% endblock %}
@@ -1182,6 +1182,9 @@ <h4>Credential
11821182
var firstID = {% if findings_list.0 %}{{findings_list.0}}{% else %}null{% endif %};
11831183
var currentID = {% if finding.id %}{{finding.id}}{% else %}null{% endif %};
11841184
var lastID = {% if findings_list_lastElement %}{{findings_list_lastElement}}{% else %}null{% endif %};
1185+
var canEditFinding = {% if finding|has_object_permission:"Finding_Edit" %}true{% else %}false{% endif %};
1186+
var findingIsMitigated = {% if finding.mitigated %}true{% else %}false{% endif %};
1187+
var findingIsVerified = {% if finding.verified %}true{% else %}false{% endif %};
11851188
if(currentID != firstID)
11861189
{
11871190
$('.PrevAndNext_Buttons').append('<a href="{% url 'view_finding' prev_finding_id %}" class="btn btn-primary">Previous Finding</a> ');
@@ -1261,6 +1264,34 @@ <h4>Credential
12611264
window.location.assign('{% url 'view_finding' next_finding_id %}');
12621265
});
12631266

1267+
$(document).on('keypress', null, 'v', function () {
1268+
if (!canEditFinding) {
1269+
alert('You do not have permission to verify this finding.');
1270+
return;
1271+
}
1272+
if (findingIsMitigated) {
1273+
alert('Finding is already closed and cannot be verified.');
1274+
return;
1275+
}
1276+
if (findingIsVerified) {
1277+
alert('Finding has already been verified.');
1278+
return;
1279+
}
1280+
window.location.assign('{% url 'verify_finding' finding.id %}');
1281+
});
1282+
1283+
$(document).on('keypress', null, 'c', function () {
1284+
if (!canEditFinding) {
1285+
alert('You do not have permission to close this finding.');
1286+
return;
1287+
}
1288+
if (findingIsMitigated) {
1289+
alert('Finding has already been closed.');
1290+
return;
1291+
}
1292+
window.location.assign('{% url 'close_finding' finding.id %}');
1293+
});
1294+
12641295
$('a.delete-finding').on('click', function (e) {
12651296
if (confirm('Are you sure you want to delete this finding?')) {
12661297
$("form#delete-finding-form").submit();

0 commit comments

Comments
 (0)