Skip to content

Commit 031018f

Browse files
committed
Adds view toggling buttons
1 parent 723e5e0 commit 031018f

File tree

9 files changed

+163
-47
lines changed

9 files changed

+163
-47
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Adds a button to toggle the file layout (list vs. tree vs. auto) to the _Repositories_, _Compare_, and _Search Commits_ views
12+
- Adds a button to toggle the branch layout (list vs. tree) to the _Branches_ node of the _Repositories_ view
13+
914
### Changed
1015

1116
- Changes the experimental _Incoming Activity_ node in the _Repositories_ view to be available for everyone (not just if `"gitlens.insiders": true`)

images/dark/icon-view-auto.svg

Lines changed: 5 additions & 0 deletions
Loading

images/dark/icon-view-list.svg

Lines changed: 3 additions & 0 deletions
Loading

images/dark/icon-view-tree.svg

Lines changed: 4 additions & 0 deletions
Loading

images/light/icon-view-auto.svg

Lines changed: 5 additions & 0 deletions
Loading

images/light/icon-view-list.svg

Lines changed: 3 additions & 0 deletions
Loading

images/light/icon-view-tree.svg

Lines changed: 4 additions & 0 deletions
Loading

package.json

Lines changed: 119 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,20 +2958,50 @@
29582958
"light": "images/light/icon-compare-refs.svg"
29592959
}
29602960
},
2961+
{
2962+
"command": "gitlens.views.repositories.setBranchesLayoutToList",
2963+
"title": "Toggle Branch Layout (Tree)",
2964+
"category": "GitLens",
2965+
"icon": {
2966+
"dark": "images/dark/icon-view-tree.svg",
2967+
"light": "images/light/icon-view-tree.svg"
2968+
}
2969+
},
2970+
{
2971+
"command": "gitlens.views.repositories.setBranchesLayoutToTree",
2972+
"title": "Toggle Branch Layout (List)",
2973+
"category": "GitLens",
2974+
"icon": {
2975+
"dark": "images/dark/icon-view-list.svg",
2976+
"light": "images/light/icon-view-list.svg"
2977+
}
2978+
},
29612979
{
29622980
"command": "gitlens.views.repositories.setFilesLayoutToAuto",
2963-
"title": "Automatic Layout",
2964-
"category": "GitLens"
2981+
"title": "Toggle File Layout (Tree)",
2982+
"category": "GitLens",
2983+
"icon": {
2984+
"dark": "images/dark/icon-view-tree.svg",
2985+
"light": "images/light/icon-view-tree.svg"
2986+
}
29652987
},
29662988
{
29672989
"command": "gitlens.views.repositories.setFilesLayoutToList",
2968-
"title": "List Layout",
2969-
"category": "GitLens"
2990+
"title": "Toggle File Layout (Auto)",
2991+
"category": "GitLens",
2992+
"icon": {
2993+
"dark": "images/dark/icon-view-auto.svg",
2994+
"light": "images/light/icon-view-auto.svg"
2995+
}
29702996
},
29712997
{
29722998
"command": "gitlens.views.repositories.setFilesLayoutToTree",
2973-
"title": "Tree Layout",
2974-
"category": "GitLens"
2999+
"title": "Toggle File Layout (List)",
3000+
"category": "GitLens",
3001+
"icon": {
3002+
"dark": "images/dark/icon-view-list.svg",
3003+
"light": "images/light/icon-view-list.svg"
3004+
}
29753005
},
29763006
{
29773007
"command": "gitlens.views.repositories.setAutoRefreshToOn",
@@ -3105,17 +3135,29 @@
31053135
{
31063136
"command": "gitlens.views.compare.setFilesLayoutToAuto",
31073137
"title": "Automatic Layout",
3108-
"category": "GitLens"
3138+
"category": "GitLens",
3139+
"icon": {
3140+
"dark": "images/dark/icon-view-tree.svg",
3141+
"light": "images/light/icon-view-tree.svg"
3142+
}
31093143
},
31103144
{
31113145
"command": "gitlens.views.compare.setFilesLayoutToList",
31123146
"title": "List Layout",
3113-
"category": "GitLens"
3147+
"category": "GitLens",
3148+
"icon": {
3149+
"dark": "images/dark/icon-view-auto.svg",
3150+
"light": "images/light/icon-view-auto.svg"
3151+
}
31143152
},
31153153
{
31163154
"command": "gitlens.views.compare.setFilesLayoutToTree",
31173155
"title": "Tree Layout",
3118-
"category": "GitLens"
3156+
"category": "GitLens",
3157+
"icon": {
3158+
"dark": "images/dark/icon-view-list.svg",
3159+
"light": "images/light/icon-view-list.svg"
3160+
}
31193161
},
31203162
{
31213163
"command": "gitlens.views.compare.setKeepResultsToOn",
@@ -3192,17 +3234,29 @@
31923234
{
31933235
"command": "gitlens.views.search.setFilesLayoutToAuto",
31943236
"title": "Automatic Layout",
3195-
"category": "GitLens"
3237+
"category": "GitLens",
3238+
"icon": {
3239+
"dark": "images/dark/icon-view-tree.svg",
3240+
"light": "images/light/icon-view-tree.svg"
3241+
}
31963242
},
31973243
{
31983244
"command": "gitlens.views.search.setFilesLayoutToList",
31993245
"title": "List Layout",
3200-
"category": "GitLens"
3246+
"category": "GitLens",
3247+
"icon": {
3248+
"dark": "images/dark/icon-view-auto.svg",
3249+
"light": "images/light/icon-view-auto.svg"
3250+
}
32013251
},
32023252
{
32033253
"command": "gitlens.views.search.setFilesLayoutToTree",
32043254
"title": "Tree Layout",
3205-
"category": "GitLens"
3255+
"category": "GitLens",
3256+
"icon": {
3257+
"dark": "images/dark/icon-view-list.svg",
3258+
"light": "images/light/icon-view-list.svg"
3259+
}
32063260
},
32073261
{
32083262
"command": "gitlens.views.search.setKeepResultsToOn",
@@ -3838,6 +3892,14 @@
38383892
"command": "gitlens.views.repositories.setBranchComparisonToBranch",
38393893
"when": "false"
38403894
},
3895+
{
3896+
"command": "gitlens.views.repositories.setBranchesLayoutToList",
3897+
"when": "false"
3898+
},
3899+
{
3900+
"command": "gitlens.views.repositories.setBranchesLayoutToTree",
3901+
"when": "false"
3902+
},
38413903
{
38423904
"command": "gitlens.views.repositories.setFilesLayoutToAuto",
38433905
"when": "false"
@@ -4312,24 +4374,24 @@
43124374
"group": "navigation@12"
43134375
},
43144376
{
4315-
"command": "gitlens.views.repositories.refresh",
4316-
"when": "view =~ /^gitlens\\.views\\.repositories:/",
4317-
"group": "navigation@99"
4377+
"command": "gitlens.views.repositories.setFilesLayoutToList",
4378+
"when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == auto",
4379+
"group": "navigation@13"
43184380
},
43194381
{
4320-
"command": "gitlens.views.repositories.setFilesLayoutToAuto",
4321-
"when": "view =~ /^gitlens\\.views\\.repositories:/",
4322-
"group": "1_gitlens"
4382+
"command": "gitlens.views.repositories.setFilesLayoutToTree",
4383+
"when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == list",
4384+
"group": "navigation@13"
43234385
},
43244386
{
4325-
"command": "gitlens.views.repositories.setFilesLayoutToList",
4326-
"when": "view =~ /^gitlens\\.views\\.repositories:/",
4327-
"group": "1_gitlens"
4387+
"command": "gitlens.views.repositories.setFilesLayoutToAuto",
4388+
"when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == tree",
4389+
"group": "navigation@13"
43284390
},
43294391
{
4330-
"command": "gitlens.views.repositories.setFilesLayoutToTree",
4392+
"command": "gitlens.views.repositories.refresh",
43314393
"when": "view =~ /^gitlens\\.views\\.repositories:/",
4332-
"group": "1_gitlens"
4394+
"group": "navigation@99"
43334395
},
43344396
{
43354397
"command": "gitlens.views.repositories.setAutoRefreshToOn",
@@ -4417,29 +4479,29 @@
44174479
"group": "navigation@11"
44184480
},
44194481
{
4420-
"command": "gitlens.views.compare.clear",
4421-
"when": "view =~ /^gitlens\\.views\\.compare:/",
4422-
"group": "navigation@98"
4482+
"command": "gitlens.views.compare.setFilesLayoutToList",
4483+
"when": "view =~ /^gitlens\\.views\\.compare:/ && config.gitlens.views.compare.files.layout == auto",
4484+
"group": "navigation@12"
44234485
},
44244486
{
4425-
"command": "gitlens.views.compare.refresh",
4426-
"when": "view =~ /^gitlens\\.views\\.compare:/",
4427-
"group": "navigation@99"
4487+
"command": "gitlens.views.compare.setFilesLayoutToTree",
4488+
"when": "view =~ /^gitlens\\.views\\.compare:/ && config.gitlens.views.compare.files.layout == list",
4489+
"group": "navigation@12"
44284490
},
44294491
{
44304492
"command": "gitlens.views.compare.setFilesLayoutToAuto",
4431-
"when": "view =~ /^gitlens\\.views\\.compare:/",
4432-
"group": "1_gitlens"
4493+
"when": "view =~ /^gitlens\\.views\\.compare:/ && config.gitlens.views.compare.files.layout == tree",
4494+
"group": "navigation@12"
44334495
},
44344496
{
4435-
"command": "gitlens.views.compare.setFilesLayoutToList",
4497+
"command": "gitlens.views.compare.clear",
44364498
"when": "view =~ /^gitlens\\.views\\.compare:/",
4437-
"group": "1_gitlens"
4499+
"group": "navigation@98"
44384500
},
44394501
{
4440-
"command": "gitlens.views.compare.setFilesLayoutToTree",
4502+
"command": "gitlens.views.compare.refresh",
44414503
"when": "view =~ /^gitlens\\.views\\.compare:/",
4442-
"group": "1_gitlens"
4504+
"group": "navigation@99"
44434505
},
44444506
{
44454507
"command": "gitlens.views.search.searchCommits",
@@ -4457,29 +4519,29 @@
44574519
"group": "navigation@11"
44584520
},
44594521
{
4460-
"command": "gitlens.views.search.clear",
4461-
"when": "view =~ /^gitlens\\.views\\.search:/",
4462-
"group": "navigation@98"
4522+
"command": "gitlens.views.search.setFilesLayoutToList",
4523+
"when": "view =~ /^gitlens\\.views\\.search:/ && config.gitlens.views.search.files.layout == auto",
4524+
"group": "navigation@12"
44634525
},
44644526
{
4465-
"command": "gitlens.views.search.refresh",
4466-
"when": "view =~ /^gitlens\\.views\\.search:/",
4467-
"group": "navigation@99"
4527+
"command": "gitlens.views.search.setFilesLayoutToTree",
4528+
"when": "view =~ /^gitlens\\.views\\.search:/ && config.gitlens.views.search.files.layout == list",
4529+
"group": "navigation@12"
44684530
},
44694531
{
44704532
"command": "gitlens.views.search.setFilesLayoutToAuto",
4471-
"when": "view =~ /^gitlens\\.views\\.search:/",
4472-
"group": "1_gitlens"
4533+
"when": "view =~ /^gitlens\\.views\\.search:/ && config.gitlens.views.search.files.layout == tree",
4534+
"group": "navigation@12"
44734535
},
44744536
{
4475-
"command": "gitlens.views.search.setFilesLayoutToList",
4537+
"command": "gitlens.views.search.clear",
44764538
"when": "view =~ /^gitlens\\.views\\.search:/",
4477-
"group": "1_gitlens"
4539+
"group": "navigation@98"
44784540
},
44794541
{
4480-
"command": "gitlens.views.search.setFilesLayoutToTree",
4542+
"command": "gitlens.views.search.refresh",
44814543
"when": "view =~ /^gitlens\\.views\\.search:/",
4482-
"group": "1_gitlens"
4544+
"group": "navigation@99"
44834545
},
44844546
{
44854547
"command": "gitlens.supportGitLens",
@@ -4513,6 +4575,16 @@
45134575
}
45144576
],
45154577
"view/item/context": [
4578+
{
4579+
"command": "gitlens.views.repositories.setBranchesLayoutToList",
4580+
"when": "viewItem =~ /gitlens:branches\\b/ && config.gitlens.views.repositories.branches.layout == tree",
4581+
"group": "inline@1"
4582+
},
4583+
{
4584+
"command": "gitlens.views.repositories.setBranchesLayoutToTree",
4585+
"when": "viewItem =~ /gitlens:branches\\b/ && config.gitlens.views.repositories.branches.layout == list",
4586+
"group": "inline@1"
4587+
},
45164588
{
45174589
"command": "gitlens.openBranchesInRemote",
45184590
"when": "viewItem =~ /gitlens:branches\\b(?=.*?\\b\\+remotes\\b)/",

src/views/repositoriesView.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import {
1212
configuration,
1313
RepositoriesViewConfig,
14+
ViewBranchesLayout,
1415
ViewFilesLayout,
1516
ViewsConfig,
1617
ViewShowBranchComparison
@@ -59,6 +60,16 @@ export class RepositoriesView extends ViewBase<RepositoriesNode> {
5960
this
6061
);
6162
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
63+
commands.registerCommand(
64+
this.getQualifiedCommand('setBranchesLayoutToList'),
65+
() => this.setBranchesLayout(ViewBranchesLayout.List),
66+
this
67+
);
68+
commands.registerCommand(
69+
this.getQualifiedCommand('setBranchesLayoutToTree'),
70+
() => this.setBranchesLayout(ViewBranchesLayout.Tree),
71+
this
72+
);
6273
commands.registerCommand(
6374
this.getQualifiedCommand('setFilesLayoutToAuto'),
6475
() => this.setFilesLayout(ViewFilesLayout.Auto),
@@ -304,6 +315,10 @@ export class RepositoriesView extends ViewBase<RepositoriesNode> {
304315
return node.setComparisonType(comparisonType);
305316
}
306317

318+
private setBranchesLayout(layout: ViewBranchesLayout) {
319+
return configuration.updateEffective('views', 'repositories', 'branches', 'layout', layout);
320+
}
321+
307322
private setFilesLayout(layout: ViewFilesLayout) {
308323
return configuration.updateEffective('views', 'repositories', 'files', 'layout', layout);
309324
}

0 commit comments

Comments
 (0)