From 673110f56c9eda21b1e318e85ad9810cb8e8fc31 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 21 Oct 2020 00:53:38 -0400 Subject: [PATCH] Reworks close view command --- package.json | 15 +++++++++++++++ src/commands.ts | 2 +- src/commands/closeView.ts | 22 ++++++++++++++++++++++ src/commands/closeWelcomeView.ts | 14 -------------- 4 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 src/commands/closeView.ts delete mode 100644 src/commands/closeWelcomeView.ts diff --git a/package.json b/package.json index 0e2e9a3..8afd396 100644 --- a/package.json +++ b/package.json @@ -2531,6 +2531,12 @@ "category": "GitLens" }, { + "command": "gitlens.closeWelcomeView", + "title": "Close", + "category": "GitLens", + "icon": "$(close)" + }, + { "command": "gitlens.diffDirectory", "title": "Directory Compare Working Tree with...", "category": "GitLens" @@ -4328,6 +4334,10 @@ "when": "gitlens:enabled" }, { + "command": "gitlens.closeWelcomeView", + "when": "false" + }, + { "command": "gitlens.diffDirectory", "when": "gitlens:enabled" }, @@ -5802,6 +5812,11 @@ ], "view/title": [ { + "command": "gitlens.closeWelcomeView", + "when": "view == gitlens.views.welcome", + "group": "navigation@1" + }, + { "command": "gitlens.pushRepositories", "when": "gitlens:hasRemotes && !gitlens:readonly && view =~ /^gitlens\\.views\\.(repositories|commits)/", "group": "navigation@1" diff --git a/src/commands.ts b/src/commands.ts index 9a0baa5..3b92867 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -3,7 +3,7 @@ export * from './commands/addAuthors'; export * from './commands/browseRepoAtRevision'; export * from './commands/closeUnchangedFiles'; -export * from './commands/closeWelcomeView'; +export * from './commands/closeView'; export * from './commands/common'; export * from './commands/copyMessageToClipboard'; export * from './commands/copyShaToClipboard'; diff --git a/src/commands/closeView.ts b/src/commands/closeView.ts new file mode 100644 index 0000000..1d75f27 --- /dev/null +++ b/src/commands/closeView.ts @@ -0,0 +1,22 @@ +'use strict'; +import { configuration } from '../configuration'; +import { command, Command, CommandContext, Commands } from './common'; + +@command() +export class CloseViewCommand extends Command { + constructor() { + super(Commands.CloseWelcomeView); + } + + protected preExecute(context: CommandContext) { + return this.execute(context.command as Commands); + } + + async execute(command: Commands) { + switch (command) { + case Commands.CloseWelcomeView: + void (await configuration.updateEffective('views', 'welcome', 'enabled', false)); + break; + } + } +} diff --git a/src/commands/closeWelcomeView.ts b/src/commands/closeWelcomeView.ts deleted file mode 100644 index 57308e7..0000000 --- a/src/commands/closeWelcomeView.ts +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; -import { configuration } from '../configuration'; -import { command, Command, Commands } from './common'; - -@command() -export class CloseWelcomeViewCommand extends Command { - constructor() { - super(Commands.CloseWelcomeView); - } - - async execute() { - void (await configuration.updateEffective('views', 'welcome', 'enabled', false)); - } -}