Skip to content

Commit

Permalink
feat: add quarantine button on project details
Browse files Browse the repository at this point in the history
A button that re-uses the malware routes.
We can create bespoke routes and views for quarantine manipulation if we
find that using this feature leads to confusing redirects, but for now
I'm opting for simpler implementation.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman committed Jun 28, 2024
1 parent 1752128 commit 4ab2b82
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion warehouse/admin/templates/admin/projects/delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<div class="card card-danger collapsed-card">
<div class="card-header">
<h3 class="card-title">Delete Project</h3>
<h3 class="card-title">Delete / Quarantine Project</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-plus"></i></button>
</div>
Expand All @@ -29,6 +29,7 @@ <h3 class="card-title">Delete Project</h3>
<p>
Deleting will irreversibly delete this project along with
<a href="{{ request.route_path('admin.project.releases', project_name=project_name) }}">{{ project.releases|length() }} releases</a>.
Consider Quarantine if you want to keep the project but make it unavailable.
</p>
<div class="form-group col-sm-12">
<label for="confirm_project_name">
Expand All @@ -39,9 +40,49 @@ <h3 class="card-title">Delete Project</h3>
</div>

<div class="card-footer">
<div class="float-left">
<button type="button"
class="btn btn-block btn-outline-warning"
data-toggle="modal"
data-target="#modal-quarantine">Quarantine Project</button>
</div>
<div class="float-right">
<button type="submit" class="btn btn-primary" title="{{ 'Deleting requires superuser privileges' if not request.has_permission(Permissions.AdminProjectsDelete) }}" {{ "disabled" if not request.has_permission(Permissions.AdminProjectsDelete) }}>Confirm</button>
</div>
</div>
</div>
</form>

<div class="modal fade" id="modal-quarantine">
<div class="modal-dialog modal-quarantine">
<form id="quarantine"
action="{{ request.route_path('admin.malware_reports.project.verdict_quarantine', project_name=project_name) }}"
method="post">
<input name="csrf_token"
type="hidden"
value="{{ request.session.get_csrf_token() }}">
<div class="modal-content">
<div class="modal-header bg-warning">
<h4 class="modal-title">Quarantine Project</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>
Confirming that <code>{{ project_name }}</code> needs further examination.
</p>
<p>
This will remove the Project from being installable,
and prohibit the Project from being changed by the Owner.
</p>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-warning">Verdict: Quarantine Project</button>
</div>
</div>
</form>
</div>
</div>
<!-- /.modal -->

0 comments on commit 4ab2b82

Please sign in to comment.