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 {