diff --git a/src/main/java/be/seeseepuff/webgit/controller/HomeController.java b/src/main/java/be/seeseepuff/webgit/controller/HomeController.java index d9118f1..7d2a6bc 100644 --- a/src/main/java/be/seeseepuff/webgit/controller/HomeController.java +++ b/src/main/java/be/seeseepuff/webgit/controller/HomeController.java @@ -20,7 +20,11 @@ public class HomeController @GetMapping("/") public String frameset(@RequestParam(required = false) String repo, Model model) throws IOException { + boolean showCloneForm = "__clone__".equals(repo); + if (showCloneForm) + repo = null; model.addAttribute("selectedRepo", repo); + model.addAttribute("showCloneForm", showCloneForm); return "frameset"; } diff --git a/src/main/resources/templates/frameset.html b/src/main/resources/templates/frameset.html index 78e20af..68c0509 100644 --- a/src/main/resources/templates/frameset.html +++ b/src/main/resources/templates/frameset.html @@ -4,7 +4,7 @@ - + <body> <p>Your browser does not support frames. <a href="/repos">Click here</a> to continue.</p> diff --git a/src/main/resources/templates/nav.html b/src/main/resources/templates/nav.html index 6cf8432..e7f0db8 100644 --- a/src/main/resources/templates/nav.html +++ b/src/main/resources/templates/nav.html @@ -10,16 +10,12 @@ <select name="repo"> <option value="">-- Select repo --</option> <option th:each="r : ${repositories}" th:value="${r}" th:text="${r}" th:selected="${r == selectedRepo}"></option> +<option value="__clone__">Clone New...</option> </select> <br> <input type="submit" value="Go"> </form> -<hr> - -<a href="/repos" target="content">Repositories</a><br> -<a href="/clone-form" target="content">Clone New</a><br> - <th:block th:if="${selectedRepo != null}"> <hr> <b th:text="${selectedRepo}"></b><br> diff --git a/src/test/java/be/seeseepuff/webgit/controller/HomeControllerTest.java b/src/test/java/be/seeseepuff/webgit/controller/HomeControllerTest.java index b95e0a8..a4ce14a 100644 --- a/src/test/java/be/seeseepuff/webgit/controller/HomeControllerTest.java +++ b/src/test/java/be/seeseepuff/webgit/controller/HomeControllerTest.java @@ -30,7 +30,8 @@ class HomeControllerTest mockMvc.perform(get("/")) .andExpect(status().isOk()) .andExpect(view().name("frameset")) - .andExpect(model().attributeDoesNotExist("selectedRepo")); + .andExpect(model().attributeDoesNotExist("selectedRepo")) + .andExpect(model().attribute("showCloneForm", false)); } @Test @@ -39,7 +40,18 @@ class HomeControllerTest mockMvc.perform(get("/").param("repo", "myrepo")) .andExpect(status().isOk()) .andExpect(view().name("frameset")) - .andExpect(model().attribute("selectedRepo", "myrepo")); + .andExpect(model().attribute("selectedRepo", "myrepo")) + .andExpect(model().attribute("showCloneForm", false)); + } + + @Test + void rootWithCloneSentinelShowsCloneForm() throws Exception + { + mockMvc.perform(get("/").param("repo", "__clone__")) + .andExpect(status().isOk()) + .andExpect(view().name("frameset")) + .andExpect(model().attributeDoesNotExist("selectedRepo")) + .andExpect(model().attribute("showCloneForm", true)); } @Test