From e2e212609b636080cfe63dc46b426b1d94018146 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 30 Mar 2020 01:42:33 -0400 Subject: [PATCH] Adds menu toggle to control view avatars --- package.json | 154 +++++++++++++++++++++++++++++++++++++++--- src/views/compareView.ts | 19 +++++- src/views/fileHistoryView.ts | 17 ++++- src/views/lineHistoryView.ts | 17 ++++- src/views/repositoriesView.ts | 23 ++++++- src/views/searchView.ts | 17 ++++- 6 files changed, 230 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 00ec4e5..c40f29c 100644 --- a/package.json +++ b/package.json @@ -3060,6 +3060,16 @@ "category": "GitLens" }, { + "command": "gitlens.views.repositories.setShowAvatarsOn", + "title": "Show Avatars", + "category": "GitLens" + }, + { + "command": "gitlens.views.repositories.setShowAvatarsOff", + "title": "Hide Avatars", + "category": "GitLens" + }, + { "command": "gitlens.views.fileHistory.refresh", "title": "Refresh", "category": "GitLens", @@ -3094,6 +3104,16 @@ "category": "GitLens" }, { + "command": "gitlens.views.fileHistory.setShowAvatarsOn", + "title": "Show Avatars", + "category": "GitLens" + }, + { + "command": "gitlens.views.fileHistory.setShowAvatarsOff", + "title": "Hide Avatars", + "category": "GitLens" + }, + { "command": "gitlens.views.lineHistory.refresh", "title": "Refresh", "category": "GitLens", @@ -3128,6 +3148,16 @@ "category": "GitLens" }, { + "command": "gitlens.views.lineHistory.setShowAvatarsOn", + "title": "Show Avatars", + "category": "GitLens" + }, + { + "command": "gitlens.views.lineHistory.setShowAvatarsOff", + "title": "Hide Avatars", + "category": "GitLens" + }, + { "command": "gitlens.views.compare.selectForCompare", "title": "Compare References...", "category": "GitLens", @@ -3179,6 +3209,16 @@ "icon": "$(lock)" }, { + "command": "gitlens.views.compare.setShowAvatarsOn", + "title": "Show Avatars", + "category": "GitLens" + }, + { + "command": "gitlens.views.compare.setShowAvatarsOff", + "title": "Hide Avatars", + "category": "GitLens" + }, + { "command": "gitlens.views.compare.pinComparison", "title": "Pin Comparison", "category": "GitLens", @@ -3254,6 +3294,16 @@ "icon": "$(lock)" }, { + "command": "gitlens.views.search.setShowAvatarsOn", + "title": "Show Avatars", + "category": "GitLens" + }, + { + "command": "gitlens.views.search.setShowAvatarsOff", + "title": "Hide Avatars", + "category": "GitLens" + }, + { "command": "gitlens.views.dismissNode", "title": "Dismiss", "category": "GitLens", @@ -3924,6 +3974,14 @@ "when": "false" }, { + "command": "gitlens.views.repositories.setShowAvatarsOn", + "when": "false" + }, + { + "command": "gitlens.views.repositories.setShowAvatarsOff", + "when": "false" + }, + { "command": "gitlens.views.fileHistory.refresh", "when": "false" }, @@ -3948,6 +4006,14 @@ "when": "false" }, { + "command": "gitlens.views.fileHistory.setShowAvatarsOn", + "when": "false" + }, + { + "command": "gitlens.views.fileHistory.setShowAvatarsOff", + "when": "false" + }, + { "command": "gitlens.views.lineHistory.refresh", "when": "false" }, @@ -3972,6 +4038,14 @@ "when": "false" }, { + "command": "gitlens.views.lineHistory.setShowAvatarsOn", + "when": "false" + }, + { + "command": "gitlens.views.lineHistory.setShowAvatarsOff", + "when": "false" + }, + { "command": "gitlens.views.compare.selectForCompare", "when": "gitlens:enabled && config.gitlens.views.compare.enabled" }, @@ -4004,6 +4078,14 @@ "when": "false" }, { + "command": "gitlens.views.compare.setShowAvatarsOn", + "when": "false" + }, + { + "command": "gitlens.views.compare.setShowAvatarsOff", + "when": "false" + }, + { "command": "gitlens.views.compare.pinComparison", "when": "false" }, @@ -4044,6 +4126,14 @@ "when": "false" }, { + "command": "gitlens.views.search.setShowAvatarsOn", + "when": "false" + }, + { + "command": "gitlens.views.search.setShowAvatarsOff", + "when": "false" + }, + { "command": "gitlens.views.dismissNode", "when": "false" }, @@ -4412,14 +4502,24 @@ "group": "navigation@99" }, { + "command": "gitlens.views.repositories.setShowAvatarsOn", + "when": "view =~ /^gitlens\\.views\\.repositories:/ && !config.gitlens.views.repositories.avatars", + "group": "1_gitlens@0" + }, + { + "command": "gitlens.views.repositories.setShowAvatarsOff", + "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.avatars", + "group": "1_gitlens@0" + }, + { "command": "gitlens.views.repositories.setAutoRefreshToOn", "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.autoRefresh && !gitlens:views:repositories:autoRefresh", - "group": "2_gitlens" + "group": "2_gitlens@0" }, { "command": "gitlens.views.repositories.setAutoRefreshToOff", "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.autoRefresh && gitlens:views:repositories:autoRefresh", - "group": "2_gitlens" + "group": "2_gitlens@0" }, { "command": "gitlens.views.fileHistory.setEditorFollowingOn", @@ -4442,14 +4542,22 @@ "group": "navigation@99" }, { + "command": "gitlens.views.fileHistory.setShowAvatarsOn", + "when": "view =~ /^gitlens\\.views\\.fileHistory:/ && !config.gitlens.views.fileHistory.avatars", + "group": "1_gitlens@0" + }, + { + "command": "gitlens.views.fileHistory.setShowAvatarsOff", + "when": "view =~ /^gitlens\\.views\\.fileHistory:/ && config.gitlens.views.fileHistory.avatars", + "group": "1_gitlens@0" + }, + { "command": "gitlens.views.fileHistory.setRenameFollowingOn", - "when": "view =~ /^gitlens\\.views\\.fileHistory:/ && !config.gitlens.advanced.fileHistoryFollowsRenames", - "group": "1_gitlens" + "group": "2_gitlens@0" }, { "command": "gitlens.views.fileHistory.setRenameFollowingOff", - "when": "view =~ /^gitlens\\.views\\.fileHistory:/ && config.gitlens.advanced.fileHistoryFollowsRenames", - "group": "1_gitlens" + "group": "2_gitlens@0" }, { "command": "gitlens.views.lineHistory.setEditorFollowingOn", @@ -4472,14 +4580,24 @@ "group": "navigation@99" }, { + "command": "gitlens.views.lineHistory.setShowAvatarsOn", + "when": "view =~ /^gitlens\\.views\\.lineHistory:/ && !config.gitlens.views.lineHistory.avatars", + "group": "1_gitlens@0" + }, + { + "command": "gitlens.views.lineHistory.setShowAvatarsOff", + "when": "view =~ /^gitlens\\.views\\.lineHistory:/ && config.gitlens.views.lineHistory.avatars", + "group": "1_gitlens@0" + }, + { "command": "gitlens.views.lineHistory.setRenameFollowingOn", "when": "view =~ /^gitlens\\.views\\.lineHistory:/ && !config.gitlens.advanced.fileHistoryFollowsRenames", - "group": "1_gitlens" + "group": "2_gitlens@0" }, { "command": "gitlens.views.lineHistory.setRenameFollowingOff", "when": "view =~ /^gitlens\\.views\\.lineHistory:/ && config.gitlens.advanced.fileHistoryFollowsRenames", - "group": "1_gitlens" + "group": "2_gitlens@0" }, { "command": "gitlens.views.compare.selectForCompare", @@ -4522,6 +4640,16 @@ "group": "navigation@99" }, { + "command": "gitlens.views.compare.setShowAvatarsOn", + "when": "view =~ /^gitlens\\.views\\.compare:/ && !config.gitlens.views.compare.avatars", + "group": "1_gitlens@0" + }, + { + "command": "gitlens.views.compare.setShowAvatarsOff", + "when": "view =~ /^gitlens\\.views\\.compare:/ && config.gitlens.views.compare.avatars", + "group": "1_gitlens@0" + }, + { "command": "gitlens.views.search.searchCommits", "when": "view =~ /^gitlens\\.views\\.search:/", "group": "navigation@10" @@ -4562,6 +4690,16 @@ "group": "navigation@99" }, { + "command": "gitlens.views.search.setShowAvatarsOn", + "when": "view =~ /^gitlens\\.views\\.search:/ && !config.gitlens.views.search.avatars", + "group": "1_gitlens@0" + }, + { + "command": "gitlens.views.search.setShowAvatarsOff", + "when": "view =~ /^gitlens\\.views\\.search:/ && config.gitlens.views.search.avatars", + "group": "1_gitlens@0" + }, + { "command": "gitlens.supportGitLens", "when": "view =~ /^gitlens\\.views\\..*:/ && config.gitlens.advanced.messages.suppressSupportGitLensNotification != true && gitlens:views:supportGitLens:hide != true", "group": "navigation@1" diff --git a/src/views/compareView.ts b/src/views/compareView.ts index 984c5fc..86aa12d 100644 --- a/src/views/compareView.ts +++ b/src/views/compareView.ts @@ -59,18 +59,27 @@ export class CompareView extends ViewBase { () => this.setKeepResults(false), this, ); - + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this); + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this); commands.registerCommand(this.getQualifiedCommand('pinComparison'), this.pinComparison, this); commands.registerCommand(this.getQualifiedCommand('unpinComparison'), this.unpinComparison, this); commands.registerCommand(this.getQualifiedCommand('swapComparison'), this.swapComparison, this); - commands.registerCommand(this.getQualifiedCommand('selectForCompare'), this.selectForCompare, this); commands.registerCommand(this.getQualifiedCommand('compareWithSelected'), this.compareWithSelected, this); } protected onConfigurationChanged(e: ConfigurationChangeEvent) { if ( - !configuration.changed(e, 'views') && + !configuration.changed(e, 'views', 'compare') && + !configuration.changed(e, 'views', 'commitFileDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFileFormat') && + !configuration.changed(e, 'views', 'commitDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFormat') && + !configuration.changed(e, 'views', 'defaultItemLimit') && + !configuration.changed(e, 'views', 'pageItemLimit') && + !configuration.changed(e, 'views', 'showRelativeDateMarkers') && + !configuration.changed(e, 'views', 'statusFileDescriptionFormat') && + !configuration.changed(e, 'views', 'statusFileFormat') && !configuration.changed(e, 'defaultDateFormat') && !configuration.changed(e, 'defaultDateSource') && !configuration.changed(e, 'defaultDateStyle') && @@ -174,6 +183,10 @@ export class CompareView extends ViewBase { setCommandContext(CommandContext.ViewsCompareKeepResults, enabled); } + private setShowAvatars(enabled: boolean) { + return configuration.updateEffective('views', 'compare', 'avatars', enabled); + } + private pinComparison(node: ViewNode) { if (!(node instanceof CompareResultsNode)) return undefined; diff --git a/src/views/fileHistoryView.ts b/src/views/fileHistoryView.ts index 988a4cd..65bf112 100644 --- a/src/views/fileHistoryView.ts +++ b/src/views/fileHistoryView.ts @@ -50,11 +50,22 @@ export class FileHistoryView extends ViewBase { () => this.setRenameFollowing(false), this, ); + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this); + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this); } protected onConfigurationChanged(e: ConfigurationChangeEvent) { if ( - !configuration.changed(e, 'views') && + !configuration.changed(e, 'views', 'fileHistory') && + !configuration.changed(e, 'views', 'commitFileDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFileFormat') && + !configuration.changed(e, 'views', 'commitDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFormat') && + !configuration.changed(e, 'views', 'defaultItemLimit') && + !configuration.changed(e, 'views', 'pageItemLimit') && + !configuration.changed(e, 'views', 'showRelativeDateMarkers') && + !configuration.changed(e, 'views', 'statusFileDescriptionFormat') && + !configuration.changed(e, 'views', 'statusFileFormat') && !configuration.changed(e, 'defaultDateFormat') && !configuration.changed(e, 'defaultDateSource') && !configuration.changed(e, 'defaultDateStyle') && @@ -105,4 +116,8 @@ export class FileHistoryView extends ViewBase { private setRenameFollowing(enabled: boolean) { return configuration.updateEffective('advanced', 'fileHistoryFollowsRenames', enabled); } + + private setShowAvatars(enabled: boolean) { + return configuration.updateEffective('views', 'fileHistory', 'avatars', enabled); + } } diff --git a/src/views/lineHistoryView.ts b/src/views/lineHistoryView.ts index 13f3a4b..e127c6b 100644 --- a/src/views/lineHistoryView.ts +++ b/src/views/lineHistoryView.ts @@ -49,11 +49,22 @@ export class LineHistoryView extends ViewBase { () => this.setRenameFollowing(false), this, ); + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this); + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this); } protected onConfigurationChanged(e: ConfigurationChangeEvent) { if ( - !configuration.changed(e, 'views') && + !configuration.changed(e, 'views', 'lineHistory') && + !configuration.changed(e, 'views', 'commitFileDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFileFormat') && + !configuration.changed(e, 'views', 'commitDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFormat') && + !configuration.changed(e, 'views', 'defaultItemLimit') && + !configuration.changed(e, 'views', 'pageItemLimit') && + !configuration.changed(e, 'views', 'showRelativeDateMarkers') && + !configuration.changed(e, 'views', 'statusFileDescriptionFormat') && + !configuration.changed(e, 'views', 'statusFileFormat') && !configuration.changed(e, 'defaultDateFormat') && !configuration.changed(e, 'defaultDateSource') && !configuration.changed(e, 'defaultDateStyle') && @@ -96,4 +107,8 @@ export class LineHistoryView extends ViewBase { private setRenameFollowing(enabled: boolean) { return configuration.updateEffective('advanced', 'fileHistoryFollowsRenames', enabled); } + + private setShowAvatars(enabled: boolean) { + return configuration.updateEffective('views', 'lineHistory', 'avatars', enabled); + } } diff --git a/src/views/repositoriesView.ts b/src/views/repositoriesView.ts index f8f9bc4..af00b3f 100644 --- a/src/views/repositoriesView.ts +++ b/src/views/repositoriesView.ts @@ -88,7 +88,6 @@ export class RepositoriesView extends ViewBase { () => this.setFilesLayout(ViewFilesLayout.Tree), this, ); - commands.registerCommand( this.getQualifiedCommand('setAutoRefreshToOn'), () => this.setAutoRefresh(Container.config.views.repositories.autoRefresh, true), @@ -99,7 +98,8 @@ export class RepositoriesView extends ViewBase { () => this.setAutoRefresh(Container.config.views.repositories.autoRefresh, false), this, ); - + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this); + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this); commands.registerCommand( this.getQualifiedCommand('setBranchComparisonToWorking'), n => this.setBranchComparison(n, ViewShowBranchComparison.Working), @@ -114,7 +114,20 @@ export class RepositoriesView extends ViewBase { protected onConfigurationChanged(e: ConfigurationChangeEvent) { if ( - !configuration.changed(e, 'views') && + !configuration.changed(e, 'views', 'repositories') && + !configuration.changed(e, 'views', 'commitFileDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFileFormat') && + !configuration.changed(e, 'views', 'commitDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFormat') && + !configuration.changed(e, 'views', 'defaultItemLimit') && + !configuration.changed(e, 'views', 'pageItemLimit') && + !configuration.changed(e, 'views', 'showRelativeDateMarkers') && + !configuration.changed(e, 'views', 'stashFileDescriptionFormat') && + !configuration.changed(e, 'views', 'stashFileFormat') && + !configuration.changed(e, 'views', 'stashDescriptionFormat') && + !configuration.changed(e, 'views', 'stashFormat') && + !configuration.changed(e, 'views', 'statusFileDescriptionFormat') && + !configuration.changed(e, 'views', 'statusFileFormat') && !configuration.changed(e, 'defaultDateFormat') && !configuration.changed(e, 'defaultDateSource') && !configuration.changed(e, 'defaultDateStyle') && @@ -560,4 +573,8 @@ export class RepositoriesView extends ViewBase { private setFilesLayout(layout: ViewFilesLayout) { return configuration.updateEffective('views', 'repositories', 'files', 'layout', layout); } + + private setShowAvatars(enabled: boolean) { + return configuration.updateEffective('views', 'repositories', 'avatars', enabled); + } } diff --git a/src/views/searchView.ts b/src/views/searchView.ts index d9f1564..b14adc2 100644 --- a/src/views/searchView.ts +++ b/src/views/searchView.ts @@ -61,11 +61,22 @@ export class SearchView extends ViewBase { () => this.setKeepResults(false), this, ); + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this); + commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this); } protected onConfigurationChanged(e: ConfigurationChangeEvent) { if ( - !configuration.changed(e, 'views') && + !configuration.changed(e, 'views', 'search') && + !configuration.changed(e, 'views', 'commitFileDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFileFormat') && + !configuration.changed(e, 'views', 'commitDescriptionFormat') && + !configuration.changed(e, 'views', 'commitFormat') && + !configuration.changed(e, 'views', 'defaultItemLimit') && + !configuration.changed(e, 'views', 'pageItemLimit') && + !configuration.changed(e, 'views', 'showRelativeDateMarkers') && + !configuration.changed(e, 'views', 'statusFileDescriptionFormat') && + !configuration.changed(e, 'views', 'statusFileFormat') && !configuration.changed(e, 'defaultDateFormat') && !configuration.changed(e, 'defaultDateSource') && !configuration.changed(e, 'defaultDateStyle') && @@ -261,4 +272,8 @@ export class SearchView extends ViewBase { Container.context.workspaceState.update(WorkspaceState.ViewsSearchKeepResults, enabled); setCommandContext(CommandContext.ViewsSearchKeepResults, enabled); } + + private setShowAvatars(enabled: boolean) { + return configuration.updateEffective('views', 'search', 'avatars', enabled); + } }