This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git


The following commit(s) were added to refs/heads/main by this push:
     new 4e50b76  Port the new deletion form to the modify page as well for 
comparison
4e50b76 is described below

commit 4e50b76030be8fbef4f57bf897287d5e9adebcb2
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Mar 28 16:47:34 2025 +0200

    Port the new deletion form to the modify page as well for comparison
---
 atr/routes/draft.py             |  4 ++++
 atr/templates/draft-modify.html | 53 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/atr/routes/draft.py b/atr/routes/draft.py
index 1d6b48a..c33d68d 100644
--- a/atr/routes/draft.py
+++ b/atr/routes/draft.py
@@ -406,6 +406,9 @@ async def modify(session: routes.CommitterSession) -> str:
     user_projects = await session.user_projects
     user_candidate_drafts = await session.user_candidate_drafts
 
+    # Create the delete form
+    delete_form = await DeleteForm.create_form()
+
     return await quart.render_template(
         "draft-modify.html",
         asf_id=session.uid,
@@ -413,6 +416,7 @@ async def modify(session: routes.CommitterSession) -> str:
         server_domain=session.host,
         number_of_release_files=_number_of_release_files,
         candidate_drafts=user_candidate_drafts,
+        delete_form=delete_form,
     )
 
 
diff --git a/atr/templates/draft-modify.html b/atr/templates/draft-modify.html
index 85f4ac6..2eb5d31 100644
--- a/atr/templates/draft-modify.html
+++ b/atr/templates/draft-modify.html
@@ -21,6 +21,7 @@
 
   <div class="row row-cols-1 row-cols-md-2 g-4 mb-5">
     {% for release in candidate_drafts %}
+      {% set release_id = release.name.replace('.', '_') %}
       <div class="col" id="{{ release.name }}">
         <div class="card h-100">
           <div class="card-body position-relative">
@@ -38,6 +39,9 @@
                  class="btn btn-sm btn-outline-primary">View files</a>
               <a href="{{ as_url(routes.draft.add_project, 
project_name=release.project.name, version_name=release.version) }}"
                  class="btn btn-sm btn-outline-primary">Upload file</a>
+              <button class="btn btn-sm btn-outline-danger"
+                      data-bs-toggle="modal"
+                      data-bs-target="#delete-{{ release_id }}">Delete 
draft</button>
             </div>
             <p class="card-text mt-3">
               {% if number_of_release_files(release) > 0 %}
@@ -58,6 +62,50 @@
           </div>
         </div>
       </div>
+
+      <div class="modal modal-lg fade"
+           id="delete-{{ release_id }}"
+           data-bs-backdrop="static"
+           data-bs-keyboard="false"
+           tabindex="-1"
+           aria-labelledby="delete-{{ release_id }}-label"
+           aria-hidden="true">
+        <div class="modal-dialog border-primary">
+          <div class="modal-content">
+            <div class="modal-header bg-danger bg-opacity-10 text-danger">
+              <h1 class="modal-title fs-5" id="delete-{{ release_id 
}}-label">Delete candidate draft</h1>
+              <button type="button"
+                      class="btn-close"
+                      data-bs-dismiss="modal"
+                      aria-label="Close"></button>
+            </div>
+            <div class="modal-body">
+              <p class="text-muted mb-3">Warning: This action will permanently 
delete this candidate draft and cannot be undone.</p>
+              <form method="post" action="{{ as_url(routes.draft.delete) }}">
+                {{ delete_form.hidden_tag() }}
+                <input type="hidden" name="candidate_draft_name" value="{{ 
release.name }}" />
+                <div class="mb-3">
+                  <label for="confirm_delete_{{ release_id }}" 
class="form-label">
+                    Type <strong>DELETE</strong> to confirm:
+                  </label>
+                  <input class="form-control mt-2"
+                         id="confirm_delete_{{ release_id }}"
+                         name="confirm_delete"
+                         placeholder="DELETE"
+                         required=""
+                         type="text"
+                         value=""
+                         onkeyup="updateDeleteButton(this, 'delete-button-{{ 
release_id }}')" />
+                </div>
+                <button type="submit"
+                        id="delete-button-{{ release_id }}"
+                        disabled
+                        class="btn btn-danger">Delete candidate draft</button>
+              </form>
+            </div>
+          </div>
+        </div>
+      </div>
     {% endfor %}
     {% if candidate_drafts|length == 0 %}
       <div class="col-12">
@@ -103,5 +151,10 @@
               });
           });
       });
+
+      function updateDeleteButton(inputElement, buttonId) {
+          let button = document.getElementById(buttonId);
+          button.disabled = inputElement.value !== "DELETE";
+      }
   </script>
 {% endblock javascripts %}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to