From 383864469dcff7d96fbac42d6a187cd77d2dd58b Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Fri, 27 Feb 2026 09:31:03 +0100 Subject: [PATCH] Add delete confirmation page before removing repository The Delete Repository button now navigates to a confirmation page asking 'Are you sure?' with Yes/No options. Only the Yes button performs the actual delete POST. No JavaScript required. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../webgit/controller/RepoController.java | 7 ++++++ .../resources/templates/confirm-delete.html | 22 +++++++++++++++++++ src/main/resources/templates/manage.html | 2 +- .../webgit/controller/RepoControllerTest.java | 10 +++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/templates/confirm-delete.html diff --git a/src/main/java/be/seeseepuff/webgit/controller/RepoController.java b/src/main/java/be/seeseepuff/webgit/controller/RepoController.java index 4d2b13a..a960468 100644 --- a/src/main/java/be/seeseepuff/webgit/controller/RepoController.java +++ b/src/main/java/be/seeseepuff/webgit/controller/RepoController.java @@ -114,6 +114,13 @@ public class RepoController return "redirect:/repo/" + name + "/remote"; } + @GetMapping("/repo/{name}/confirm-delete") + public String confirmDelete(@PathVariable String name, Model model) + { + model.addAttribute("name", name); + return "confirm-delete"; + } + @PostMapping("/repo/{name}/delete") public String delete(@PathVariable String name) throws IOException { diff --git a/src/main/resources/templates/confirm-delete.html b/src/main/resources/templates/confirm-delete.html new file mode 100644 index 0000000..a7f05af --- /dev/null +++ b/src/main/resources/templates/confirm-delete.html @@ -0,0 +1,22 @@ + + + +Confirm Delete + + +

Are you sure?

+

This will permanently delete the repository and its working tree.

+ + + + + +
+
+ +
+
+No +
+ + diff --git a/src/main/resources/templates/manage.html b/src/main/resources/templates/manage.html index 3c3ff13..c3a6ffd 100644 --- a/src/main/resources/templates/manage.html +++ b/src/main/resources/templates/manage.html @@ -8,7 +8,7 @@

Danger Zone

This will permanently delete the repository and its working tree.

-
+
diff --git a/src/test/java/be/seeseepuff/webgit/controller/RepoControllerTest.java b/src/test/java/be/seeseepuff/webgit/controller/RepoControllerTest.java index 6401e41..3cead9f 100644 --- a/src/test/java/be/seeseepuff/webgit/controller/RepoControllerTest.java +++ b/src/test/java/be/seeseepuff/webgit/controller/RepoControllerTest.java @@ -194,6 +194,16 @@ class RepoControllerTest verify(gitService).updateRemoteUrl("myrepo", "origin", "https://new-url.com/repo.git"); } + @Test + void confirmDeleteShowsConfirmation() throws Exception + { + mockMvc.perform(get("/repo/myrepo/confirm-delete")) + .andExpect(status().isOk()) + .andExpect(view().name("confirm-delete")) + .andExpect(model().attribute("name", "myrepo")) + .andExpect(content().string(org.hamcrest.Matchers.containsString("Are you sure?"))); + } + @Test void deleteRedirectsToRoot() throws Exception {