From 031018f47ccc7683c16e1113fb494f7b6c65f55c Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 23 Sep 2019 22:29:15 -0400 Subject: [PATCH] Adds view toggling buttons --- CHANGELOG.md | 5 ++ images/dark/icon-view-auto.svg | 5 ++ images/dark/icon-view-list.svg | 3 + images/dark/icon-view-tree.svg | 4 + images/light/icon-view-auto.svg | 5 ++ images/light/icon-view-list.svg | 3 + images/light/icon-view-tree.svg | 4 + package.json | 166 ++++++++++++++++++++++++++++------------ src/views/repositoriesView.ts | 15 ++++ 9 files changed, 163 insertions(+), 47 deletions(-) create mode 100644 images/dark/icon-view-auto.svg create mode 100644 images/dark/icon-view-list.svg create mode 100644 images/dark/icon-view-tree.svg create mode 100644 images/light/icon-view-auto.svg create mode 100644 images/light/icon-view-list.svg create mode 100644 images/light/icon-view-tree.svg diff --git a/CHANGELOG.md b/CHANGELOG.md index 13600de..5438893 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Added + +- Adds a button to toggle the file layout (list vs. tree vs. auto) to the _Repositories_, _Compare_, and _Search Commits_ views +- Adds a button to toggle the branch layout (list vs. tree) to the _Branches_ node of the _Repositories_ view + ### Changed - Changes the experimental _Incoming Activity_ node in the _Repositories_ view to be available for everyone (not just if `"gitlens.insiders": true`) diff --git a/images/dark/icon-view-auto.svg b/images/dark/icon-view-auto.svg new file mode 100644 index 0000000..5089244 --- /dev/null +++ b/images/dark/icon-view-auto.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/images/dark/icon-view-list.svg b/images/dark/icon-view-list.svg new file mode 100644 index 0000000..95f4866 --- /dev/null +++ b/images/dark/icon-view-list.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/images/dark/icon-view-tree.svg b/images/dark/icon-view-tree.svg new file mode 100644 index 0000000..5afb119 --- /dev/null +++ b/images/dark/icon-view-tree.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/images/light/icon-view-auto.svg b/images/light/icon-view-auto.svg new file mode 100644 index 0000000..e05ebe7 --- /dev/null +++ b/images/light/icon-view-auto.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/images/light/icon-view-list.svg b/images/light/icon-view-list.svg new file mode 100644 index 0000000..c60fee5 --- /dev/null +++ b/images/light/icon-view-list.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/images/light/icon-view-tree.svg b/images/light/icon-view-tree.svg new file mode 100644 index 0000000..e70c661 --- /dev/null +++ b/images/light/icon-view-tree.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/package.json b/package.json index 70637ab..641de56 100644 --- a/package.json +++ b/package.json @@ -2959,19 +2959,49 @@ } }, { + "command": "gitlens.views.repositories.setBranchesLayoutToList", + "title": "Toggle Branch Layout (Tree)", + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-tree.svg", + "light": "images/light/icon-view-tree.svg" + } + }, + { + "command": "gitlens.views.repositories.setBranchesLayoutToTree", + "title": "Toggle Branch Layout (List)", + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-list.svg", + "light": "images/light/icon-view-list.svg" + } + }, + { "command": "gitlens.views.repositories.setFilesLayoutToAuto", - "title": "Automatic Layout", - "category": "GitLens" + "title": "Toggle File Layout (Tree)", + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-tree.svg", + "light": "images/light/icon-view-tree.svg" + } }, { "command": "gitlens.views.repositories.setFilesLayoutToList", - "title": "List Layout", - "category": "GitLens" + "title": "Toggle File Layout (Auto)", + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-auto.svg", + "light": "images/light/icon-view-auto.svg" + } }, { "command": "gitlens.views.repositories.setFilesLayoutToTree", - "title": "Tree Layout", - "category": "GitLens" + "title": "Toggle File Layout (List)", + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-list.svg", + "light": "images/light/icon-view-list.svg" + } }, { "command": "gitlens.views.repositories.setAutoRefreshToOn", @@ -3105,17 +3135,29 @@ { "command": "gitlens.views.compare.setFilesLayoutToAuto", "title": "Automatic Layout", - "category": "GitLens" + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-tree.svg", + "light": "images/light/icon-view-tree.svg" + } }, { "command": "gitlens.views.compare.setFilesLayoutToList", "title": "List Layout", - "category": "GitLens" + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-auto.svg", + "light": "images/light/icon-view-auto.svg" + } }, { "command": "gitlens.views.compare.setFilesLayoutToTree", "title": "Tree Layout", - "category": "GitLens" + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-list.svg", + "light": "images/light/icon-view-list.svg" + } }, { "command": "gitlens.views.compare.setKeepResultsToOn", @@ -3192,17 +3234,29 @@ { "command": "gitlens.views.search.setFilesLayoutToAuto", "title": "Automatic Layout", - "category": "GitLens" + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-tree.svg", + "light": "images/light/icon-view-tree.svg" + } }, { "command": "gitlens.views.search.setFilesLayoutToList", "title": "List Layout", - "category": "GitLens" + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-auto.svg", + "light": "images/light/icon-view-auto.svg" + } }, { "command": "gitlens.views.search.setFilesLayoutToTree", "title": "Tree Layout", - "category": "GitLens" + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-view-list.svg", + "light": "images/light/icon-view-list.svg" + } }, { "command": "gitlens.views.search.setKeepResultsToOn", @@ -3839,6 +3893,14 @@ "when": "false" }, { + "command": "gitlens.views.repositories.setBranchesLayoutToList", + "when": "false" + }, + { + "command": "gitlens.views.repositories.setBranchesLayoutToTree", + "when": "false" + }, + { "command": "gitlens.views.repositories.setFilesLayoutToAuto", "when": "false" }, @@ -4312,24 +4374,24 @@ "group": "navigation@12" }, { - "command": "gitlens.views.repositories.refresh", - "when": "view =~ /^gitlens\\.views\\.repositories:/", - "group": "navigation@99" + "command": "gitlens.views.repositories.setFilesLayoutToList", + "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == auto", + "group": "navigation@13" }, { - "command": "gitlens.views.repositories.setFilesLayoutToAuto", - "when": "view =~ /^gitlens\\.views\\.repositories:/", - "group": "1_gitlens" + "command": "gitlens.views.repositories.setFilesLayoutToTree", + "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == list", + "group": "navigation@13" }, { - "command": "gitlens.views.repositories.setFilesLayoutToList", - "when": "view =~ /^gitlens\\.views\\.repositories:/", - "group": "1_gitlens" + "command": "gitlens.views.repositories.setFilesLayoutToAuto", + "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == tree", + "group": "navigation@13" }, { - "command": "gitlens.views.repositories.setFilesLayoutToTree", + "command": "gitlens.views.repositories.refresh", "when": "view =~ /^gitlens\\.views\\.repositories:/", - "group": "1_gitlens" + "group": "navigation@99" }, { "command": "gitlens.views.repositories.setAutoRefreshToOn", @@ -4417,29 +4479,29 @@ "group": "navigation@11" }, { - "command": "gitlens.views.compare.clear", - "when": "view =~ /^gitlens\\.views\\.compare:/", - "group": "navigation@98" + "command": "gitlens.views.compare.setFilesLayoutToList", + "when": "view =~ /^gitlens\\.views\\.compare:/ && config.gitlens.views.compare.files.layout == auto", + "group": "navigation@12" }, { - "command": "gitlens.views.compare.refresh", - "when": "view =~ /^gitlens\\.views\\.compare:/", - "group": "navigation@99" + "command": "gitlens.views.compare.setFilesLayoutToTree", + "when": "view =~ /^gitlens\\.views\\.compare:/ && config.gitlens.views.compare.files.layout == list", + "group": "navigation@12" }, { "command": "gitlens.views.compare.setFilesLayoutToAuto", - "when": "view =~ /^gitlens\\.views\\.compare:/", - "group": "1_gitlens" + "when": "view =~ /^gitlens\\.views\\.compare:/ && config.gitlens.views.compare.files.layout == tree", + "group": "navigation@12" }, { - "command": "gitlens.views.compare.setFilesLayoutToList", + "command": "gitlens.views.compare.clear", "when": "view =~ /^gitlens\\.views\\.compare:/", - "group": "1_gitlens" + "group": "navigation@98" }, { - "command": "gitlens.views.compare.setFilesLayoutToTree", + "command": "gitlens.views.compare.refresh", "when": "view =~ /^gitlens\\.views\\.compare:/", - "group": "1_gitlens" + "group": "navigation@99" }, { "command": "gitlens.views.search.searchCommits", @@ -4457,29 +4519,29 @@ "group": "navigation@11" }, { - "command": "gitlens.views.search.clear", - "when": "view =~ /^gitlens\\.views\\.search:/", - "group": "navigation@98" + "command": "gitlens.views.search.setFilesLayoutToList", + "when": "view =~ /^gitlens\\.views\\.search:/ && config.gitlens.views.search.files.layout == auto", + "group": "navigation@12" }, { - "command": "gitlens.views.search.refresh", - "when": "view =~ /^gitlens\\.views\\.search:/", - "group": "navigation@99" + "command": "gitlens.views.search.setFilesLayoutToTree", + "when": "view =~ /^gitlens\\.views\\.search:/ && config.gitlens.views.search.files.layout == list", + "group": "navigation@12" }, { "command": "gitlens.views.search.setFilesLayoutToAuto", - "when": "view =~ /^gitlens\\.views\\.search:/", - "group": "1_gitlens" + "when": "view =~ /^gitlens\\.views\\.search:/ && config.gitlens.views.search.files.layout == tree", + "group": "navigation@12" }, { - "command": "gitlens.views.search.setFilesLayoutToList", + "command": "gitlens.views.search.clear", "when": "view =~ /^gitlens\\.views\\.search:/", - "group": "1_gitlens" + "group": "navigation@98" }, { - "command": "gitlens.views.search.setFilesLayoutToTree", + "command": "gitlens.views.search.refresh", "when": "view =~ /^gitlens\\.views\\.search:/", - "group": "1_gitlens" + "group": "navigation@99" }, { "command": "gitlens.supportGitLens", @@ -4514,6 +4576,16 @@ ], "view/item/context": [ { + "command": "gitlens.views.repositories.setBranchesLayoutToList", + "when": "viewItem =~ /gitlens:branches\\b/ && config.gitlens.views.repositories.branches.layout == tree", + "group": "inline@1" + }, + { + "command": "gitlens.views.repositories.setBranchesLayoutToTree", + "when": "viewItem =~ /gitlens:branches\\b/ && config.gitlens.views.repositories.branches.layout == list", + "group": "inline@1" + }, + { "command": "gitlens.openBranchesInRemote", "when": "viewItem =~ /gitlens:branches\\b(?=.*?\\b\\+remotes\\b)/", "group": "inline@98" diff --git a/src/views/repositoriesView.ts b/src/views/repositoriesView.ts index 9910cf9..3660c1f 100644 --- a/src/views/repositoriesView.ts +++ b/src/views/repositoriesView.ts @@ -11,6 +11,7 @@ import { import { configuration, RepositoriesViewConfig, + ViewBranchesLayout, ViewFilesLayout, ViewsConfig, ViewShowBranchComparison @@ -60,6 +61,16 @@ export class RepositoriesView extends ViewBase { ); commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this); commands.registerCommand( + this.getQualifiedCommand('setBranchesLayoutToList'), + () => this.setBranchesLayout(ViewBranchesLayout.List), + this + ); + commands.registerCommand( + this.getQualifiedCommand('setBranchesLayoutToTree'), + () => this.setBranchesLayout(ViewBranchesLayout.Tree), + this + ); + commands.registerCommand( this.getQualifiedCommand('setFilesLayoutToAuto'), () => this.setFilesLayout(ViewFilesLayout.Auto), this @@ -304,6 +315,10 @@ export class RepositoriesView extends ViewBase { return node.setComparisonType(comparisonType); } + private setBranchesLayout(layout: ViewBranchesLayout) { + return configuration.updateEffective('views', 'repositories', 'branches', 'layout', layout); + } + private setFilesLayout(layout: ViewFilesLayout) { return configuration.updateEffective('views', 'repositories', 'files', 'layout', layout); }