code: Fix file tab link bug
For files of root path, 'file' tab menu link isn't properly set. This commit fix that problem. See: Yona Github issue #189
@1b873ae29356ecd95fe660f8a7403e0f9eb2d08c
--- app/views/code/view.scala.html
+++ app/views/code/view.scala.html
... | ... | @@ -46,6 +46,14 @@ |
46 | 46 |
} |
47 | 47 |
} |
48 | 48 |
|
49 |
+@pathWithoutFileName(path:String) = @{ |
|
50 |
+ if(path.lastIndexOf("/") > 0){ |
|
51 |
+ path.substring(0, path.lastIndexOf("/")) |
|
52 |
+ } else { |
|
53 |
+ "" |
|
54 |
+ } |
|
55 |
+} |
|
56 |
+ |
|
49 | 57 |
@projectLayout(Messages("menu.code"), project, utils.MenuType.CODE){ |
50 | 58 |
@projectMenu(project, utils.MenuType.CODE, "main-menu-only") |
51 | 59 |
<div class="page-wrap-outer"> |
... | ... | @@ -53,11 +61,7 @@ |
53 | 61 |
<div class="code-browse-wrap"> |
54 | 62 |
@if(fieldText(recursiveData{0}, "type").eq("folder")){ |
55 | 63 |
<ul class="nav nav-tabs"> |
56 |
- @if(path.lastIndexOf("/") > 0){ |
|
57 |
- <li class="active"><a href="@routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, URLEncoder.encode(branch, "UTF-8"), path.substring(0, path.lastIndexOf("/")))">@Messages("code.files")</a></li> |
|
58 |
- } else { |
|
59 |
- <li class="active"><a href="@routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, URLEncoder.encode(branch, "UTF-8"), path)">@Messages("code.files")</a></li> |
|
60 |
- } |
|
64 |
+ <li class="active"><a href="@routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, URLEncoder.encode(branch, "UTF-8"), pathWithoutFileName(path))">@Messages("code.files")</a></li> |
|
61 | 65 |
@if(branch.eq("HEAD")){ |
62 | 66 |
<li><a href="@routes.CodeHistoryApp.historyUntilHead(project.owner, project.name)">@Messages("code.commits")</a></li> |
63 | 67 |
} else { |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?