Skip to content

Commit 40ee965

Browse files
ybosyybosy
authored andcommitted
collapsible group repositories
1 parent 2f74123 commit 40ee965

File tree

5 files changed

+106
-3
lines changed

5 files changed

+106
-3
lines changed

src/main/distrib/data/defaults.properties

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,3 +2147,17 @@ filestore.storageFolder = ${baseFolder}/lfs
21472147
# Common unit suffixes of k, m, or g are supported.
21482148
# SINCE 1.7.0
21492149
filestore.maxUploadSize = -1
2150+
2151+
# Specify the behaviour of the Repository groups on the "Repositories"
2152+
# page, specifically whether they can be collapsed and expanded, and
2153+
# their default state on loading the page.
2154+
# Only on repositoryListType grouped
2155+
#
2156+
# Values (case-insensitive):
2157+
# disabled - Repository groups cannot collapsed; maintains behaviour
2158+
# from previous versions of GitBlit.
2159+
# expanded - On loading the page all repository groups are expanded.
2160+
# collapsed - On loading the page all repository groups are collapsed.
2161+
#
2162+
# SINCE 1.9.0
2163+
web.collapsibleRepositoryGroups = disabled

src/main/java/com/gitblit/wicket/pages/BasePage.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151

5252
<!-- Include scripts at end for faster page loading -->
5353
<script type="text/javascript" src="bootstrap/js/jquery.js"></script>
54-
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
54+
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
55+
<script type="text/javascript" src="gitblit/js/collapsible-table.js"></script>
5556
<wicket:container wicket:id="bottomScripts"></wicket:container>
5657
</body>
5758
</html>

src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
</tbody>
1919
</table>
2020

21+
<wicket:fragment wicket:id="emptyFragment">
22+
</wicket:fragment>
23+
2124
<wicket:fragment wicket:id="repoIconFragment">
2225
<span class="octicon octicon-centered octicon-repo"></span>
2326
</wicket:fragment>
@@ -72,9 +75,15 @@
7275
</tr>
7376
</wicket:fragment>
7477

78+
<wicket:fragment wicket:id="tableAllCollapsible">
79+
<i title="Click to expand all" class="fa fa-plus-square-o table-openall-collapsible" aria-hidden="true" style="padding-right:3px;cursor:pointer;"></i>
80+
<i title="Click to collapse all" class="fa fa-minus-square-o table-closeall-collapsible" aria-hidden="true" style="padding-right:3px;cursor:pointer;"></i>
81+
</wicket:fragment>
82+
7583
<wicket:fragment wicket:id="groupRepositoryHeader">
7684
<tr>
7785
<th class="left">
86+
<span wicket:id="allCollapsible"></span>
7887
<img style="vertical-align: middle;" src="git-black-16x16.png"/>
7988
<wicket:message key="gb.repository">Repository</wicket:message>
8089
</th>
@@ -86,8 +95,16 @@
8695
</tr>
8796
</wicket:fragment>
8897

98+
<wicket:fragment wicket:id="tableGroupMinusCollapsible">
99+
<i title="Click to expand/collapse" class="fa fa-minus-square-o table-group-collapsible" aria-hidden="true" style="padding-right:3px;cursor:pointer;"></i>
100+
</wicket:fragment>
101+
102+
<wicket:fragment wicket:id="tableGroupPlusCollapsible">
103+
<i title="Click to expand/collapse" class="fa fa-plus-square-o table-group-collapsible" aria-hidden="true" style="padding-right:3px;cursor:pointer;"></i>
104+
</wicket:fragment>
105+
89106
<wicket:fragment wicket:id="groupRepositoryRow">
90-
<td colspan="1"><span wicket:id="groupName">[group name]</span></td>
107+
<td colspan="1"><span wicket:id="groupCollapsible"></span><span wicket:id="groupName">[group name]</span></td>
91108
<td colspan="6" style="padding: 2px;"><span class="hidden-phone" style="font-weight:normal;color:#666;" wicket:id="groupDescription">[description]</span></td>
92109
</wicket:fragment>
93110

src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@
5858
public class RepositoriesPanel extends BasePanel {
5959

6060
private static final long serialVersionUID = 1L;
61+
62+
private enum CollapsibleRepositorySetting {
63+
DISABLED,
64+
65+
EXPANDED,
66+
67+
COLLAPSED;
68+
69+
public static CollapsibleRepositorySetting get(String name) {
70+
CollapsibleRepositorySetting returnVal = CollapsibleRepositorySetting.DISABLED;
71+
for (CollapsibleRepositorySetting setting : values()) {
72+
if (setting.name().equalsIgnoreCase(name)) {
73+
returnVal = setting;
74+
break;
75+
}
76+
}
77+
return returnVal;
78+
}
79+
}
6180

6281
public RepositoriesPanel(String wicketId, final boolean showAdmin, final boolean showManagement,
6382
List<RepositoryModel> models, boolean enableLinks,
@@ -66,6 +85,8 @@ public RepositoriesPanel(String wicketId, final boolean showAdmin, final boolean
6685

6786
final boolean linksActive = enableLinks;
6887
final boolean showSize = app().settings().getBoolean(Keys.web.showRepositorySizes, true);
88+
final String collapsibleRespositorySetting = app().settings().getString(Keys.web.collapsibleRepositoryGroups, null);
89+
final CollapsibleRepositorySetting collapsibleRepoGroups = CollapsibleRepositorySetting.get(collapsibleRespositorySetting);
6990

7091
final UserModel user = GitBlitWebSession.get().getUser();
7192

@@ -160,6 +181,16 @@ public void populateItem(final Item<RepositoryModel> item) {
160181
GroupRepositoryModel groupRow = (GroupRepositoryModel) entry;
161182
currGroupName = entry.name;
162183
Fragment row = new Fragment("rowContent", "groupRepositoryRow", this);
184+
if(collapsibleRepoGroups == CollapsibleRepositorySetting.EXPANDED) {
185+
Fragment groupCollapsible = new Fragment("groupCollapsible", "tableGroupMinusCollapsible", this);
186+
row.add(groupCollapsible);
187+
} else if(collapsibleRepoGroups == CollapsibleRepositorySetting.COLLAPSED) {
188+
Fragment groupCollapsible = new Fragment("groupCollapsible", "tableGroupPlusCollapsible", this);
189+
row.add(groupCollapsible);
190+
} else {
191+
Fragment groupCollapsible = new Fragment("groupCollapsible", "emptyFragment", this);
192+
row.add(groupCollapsible);
193+
}
163194
item.add(row);
164195

165196
String name = groupRow.name;
@@ -174,7 +205,7 @@ public void populateItem(final Item<RepositoryModel> item) {
174205
row.add(new LinkPanel("groupName", null, groupRow.toString(), ProjectPage.class, WicketUtils.newProjectParameter(entry.name)));
175206
row.add(new Label("groupDescription", entry.description == null ? "":entry.description));
176207
}
177-
WicketUtils.setCssClass(item, "group");
208+
WicketUtils.setCssClass(item, "group collapsible");
178209
// reset counter so that first row is light background
179210
counter = 0;
180211
return;
@@ -319,6 +350,14 @@ public void populateItem(final Item<RepositoryModel> item) {
319350
} else {
320351
// not sortable
321352
Fragment fragment = new Fragment("headerContent", "groupRepositoryHeader", this);
353+
if(collapsibleRepoGroups == CollapsibleRepositorySetting.EXPANDED ||
354+
collapsibleRepoGroups == CollapsibleRepositorySetting.COLLAPSED) {
355+
Fragment allCollapsible = new Fragment("allCollapsible", "tableAllCollapsible", this);
356+
fragment.add(allCollapsible);
357+
} else {
358+
Fragment allCollapsible = new Fragment("allCollapsible", "emptyFragment", this);
359+
fragment.add(allCollapsible);
360+
}
322361
add(fragment);
323362
}
324363
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$(function() {
2+
$('i.table-group-collapsible')
3+
.click(function(){
4+
$(this).closest('tr.group.collapsible').nextUntil('tr.group.collapsible').toggle();
5+
$(this).toggleClass('fa-minus-square-o');
6+
$(this).toggleClass('fa-plus-square-o');
7+
});
8+
9+
$('i.table-openall-collapsible')
10+
.click(function(){
11+
$('tr.group.collapsible').first().find('i').addClass('fa-minus-square-o');
12+
$('tr.group.collapsible').first().find('i').removeClass('fa-plus-square-o');
13+
$('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').show();
14+
$('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').addClass('fa-minus-square-o');
15+
$('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').removeClass('fa-plus-square-o');
16+
});
17+
18+
$('i.table-closeall-collapsible')
19+
.click(function(){
20+
$('tr.group.collapsible').first().find('i').addClass('fa-plus-square-o');
21+
$('tr.group.collapsible').first().find('i').removeClass('fa-minus-square-o');
22+
$('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').hide();
23+
$('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').addClass('fa-plus-square-o');
24+
$('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').removeClass('fa-minus-square-o');
25+
});
26+
27+
$( document ).ready(function() {
28+
if($('tr.group.collapsible').first().find('i').hasClass('fa-plus-square-o')) {
29+
$('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').hide();
30+
}
31+
});
32+
});

0 commit comments

Comments
 (0)