From a540814a22dfcd1dbb89db089b3c539c51a3313f Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 18 Feb 2022 02:06:34 -0500 Subject: [PATCH] Improves home, welcome, getting started experience Adds links footer to home view when welcome is hidden Polishes welcome/settings page headers Removes links from welcome page Removes old welcome view --- package.json | 75 +++++++------------ src/commands.ts | 2 +- src/commands/closeView.ts | 26 ------- src/commands/getStarted.ts | 22 ++++++ src/commands/showView.ts | 10 +-- src/constants.ts | 4 +- src/extension.ts | 28 ++++---- src/storage.ts | 2 +- src/webviews/apps/premium/home/home.html | 100 ++++++++++++++++++++++---- src/webviews/apps/premium/home/home.scss | 40 ++++++++++- src/webviews/apps/premium/home/home.ts | 28 +++++--- src/webviews/apps/rebase/rebase.ts | 2 + src/webviews/apps/settings/settings.scss | 30 +++++--- src/webviews/apps/settings/settings.ts | 46 ++++-------- src/webviews/apps/shared/appWithConfigBase.ts | 20 ++++++ src/webviews/apps/shared/codicons.scss | 32 +++++++++ src/webviews/apps/welcome/welcome.html | 66 +---------------- src/webviews/apps/welcome/welcome.scss | 31 ++++---- src/webviews/premium/home/homeWebviewView.ts | 14 +++- src/webviews/premium/home/protocol.ts | 2 + src/webviews/protocol.ts | 6 ++ src/webviews/settings/protocol.ts | 6 -- src/webviews/settings/settingsWebview.ts | 20 +----- src/webviews/webviewBase.ts | 3 +- src/webviews/webviewViewBase.ts | 12 +++- src/webviews/webviewWithConfigBase.ts | 30 +++++++- 26 files changed, 376 insertions(+), 281 deletions(-) delete mode 100644 src/commands/closeView.ts create mode 100644 src/commands/getStarted.ts diff --git a/package.json b/package.json index e783854..2287f26 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "onCommand:gitlens.premium.startPreview", "onCommand:gitlens.premium.purchase", "onCommand:gitlens.premium.reset", + "onCommand:gitlens.getStarted", "onCommand:gitlens.showSettingsPage", "onCommand:gitlens.showSettingsPage#views", "onCommand:gitlens.showSettingsPage#branches-view", @@ -89,6 +90,7 @@ "onCommand:gitlens.showCommitsView", "onCommand:gitlens.showContributorsView", "onCommand:gitlens.showFileHistoryView", + "onCommand:gitlens.showHomeView", "onCommand:gitlens.showLineHistoryView", "onCommand:gitlens.showRemotesView", "onCommand:gitlens.showRepositoriesView", @@ -96,8 +98,6 @@ "onCommand:gitlens.showStashesView", "onCommand:gitlens.showTagsView", "onCommand:gitlens.showWorktreesView", - "onCommand:gitlens.showWelcomeView", - "onCommand:gitlens.closeWelcomeView", "onCommand:gitlens.compareWith", "onCommand:gitlens.compareHeadWith", "onCommand:gitlens.compareWorkingWith", @@ -3625,6 +3625,11 @@ "category": "GitLens Premium" }, { + "command": "gitlens.getStarted", + "title": "Get Started", + "category": "GitLens" + }, + { "command": "gitlens.showSettingsPage", "title": "Open Settings", "category": "GitLens", @@ -3728,6 +3733,11 @@ "category": "GitLens" }, { + "command": "gitlens.showHomeView", + "title": "Show Home View", + "category": "GitLens" + }, + { "command": "gitlens.showLineHistoryView", "title": "Show Line History View", "category": "GitLens" @@ -3763,17 +3773,6 @@ "category": "GitLens" }, { - "command": "gitlens.showWelcomeView", - "title": "Show Welcome View", - "category": "GitLens" - }, - { - "command": "gitlens.closeWelcomeView", - "title": "Close", - "category": "GitLens", - "icon": "$(close)" - }, - { "command": "gitlens.compareWith", "title": "Compare References...", "category": "GitLens", @@ -5978,6 +5977,10 @@ "when": "gitlens:enabled" }, { + "command": "gitlens.showHomeView", + "when": "gitlens:enabled" + }, + { "command": "gitlens.showLineHistoryView", "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, @@ -6003,15 +6006,7 @@ }, { "command": "gitlens.showWorktreesView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.showWelcomeView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.closeWelcomeView", - "when": "false" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.compareWith", @@ -7685,14 +7680,19 @@ ], "extension/context": [ { - "command": "gitlens.showWelcomePage", + "command": "gitlens.getStarted", "when": "extension =~ /^eamodio.gitlens(-insiders)?$/ && extensionStatus == installed", "group": "9_gitlens@1" }, { - "command": "gitlens.showSettingsPage", + "command": "gitlens.showWelcomePage", "when": "extension =~ /^eamodio.gitlens(-insiders)?$/ && extensionStatus == installed", "group": "9_gitlens@2" + }, + { + "command": "gitlens.showSettingsPage", + "when": "extension =~ /^eamodio.gitlens(-insiders)?$/ && extensionStatus == installed", + "group": "9_gitlens@3" } ], "git.commit": [ @@ -7790,11 +7790,6 @@ ], "view/title": [ { - "command": "gitlens.closeWelcomeView", - "when": "view == gitlens.views.welcome", - "group": "navigation@1" - }, - { "command": "gitlens.views.switchToAnotherBranch", "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.branches/", "group": "navigation@10" @@ -10530,18 +10525,6 @@ }, "viewsWelcome": [ { - "view": "gitlens.views.welcome", - "contents": "GitLens 11 is powerful, feature rich, and highly customizable to meet your needs. You can use the GitLens Welcome experience to get setup quickly.\n\n[Welcome (Quick Setup)](command:gitlens.showWelcomePage \"Opens the GitLens Welcome (Quick Setup)\")\n\nFor more options, run [GitLens: Open Settings](command:gitlens.showSettingsPage \"Opens the GitLens Interactive Settings\") from the Command Palette to open the interactive GitLens settings editor." - }, - { - "view": "gitlens.views.welcome", - "contents": "[GitLens views](command:gitlens.showSettingsPage%23views) are shown on the Source Control side bar, by default. Run [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") from the Command Palette to switch to an alternate side bar layout, or drag & drop them." - }, - { - "view": "gitlens.views.welcome", - "contents": "[Close](command:gitlens.closeWelcomeView \"Closes the Welcome view\")" - }, - { "view": "gitlens.views.searchAndCompare", "contents": "Search for commits by [message](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22pattern%22%3A%22message%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D), [author](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22pattern%22%3A%22author%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D), [SHA](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22pattern%22%3A%22commit%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D), [file](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22pattern%22%3A%22file%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D), or [changes](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22pattern%22%3A%22change%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D)\n\n[Search Commits...](command:gitlens.views.searchAndCompare.searchCommits)", "when": "!gitlens:hasVirtualFolders" @@ -10597,15 +10580,7 @@ "type": "webview", "id": "gitlens.views.home", "name": "Home", - "-when": "!gitlens:disabled && gitlens:views:home:visible != false", - "contextualTitle": "GitLens", - "icon": "images/gitlens-activitybar.svg", - "visibility": "visible" - }, - { - "id": "gitlens.views.welcome", - "name": "Welcome", - "when": "gitlens:views:welcome:visible != false", + "-when": "!gitlens:disabled", "contextualTitle": "GitLens", "icon": "images/gitlens-activitybar.svg", "visibility": "visible" diff --git a/src/commands.ts b/src/commands.ts index d4bad30..00a6121 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,7 +1,6 @@ export * from './commands/addAuthors'; export * from './commands/browseRepoAtRevision'; export * from './commands/closeUnchangedFiles'; -export * from './commands/closeView'; export * from './commands/compareWith'; export * from './commands/copyCurrentBranch'; export * from './commands/copyMessageToClipboard'; @@ -17,6 +16,7 @@ export * from './commands/diffWithRevision'; export * from './commands/diffWithRevisionFrom'; export * from './commands/diffWithWorking'; export * from './commands/externalDiff'; +export * from './commands/getStarted'; export * from './commands/gitCommands'; export * from './commands/inviteToLiveShare'; export * from './commands/logging'; diff --git a/src/commands/closeView.ts b/src/commands/closeView.ts deleted file mode 100644 index 6d9dc18..0000000 --- a/src/commands/closeView.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Commands, ContextKeys } from '../constants'; -import type { Container } from '../container'; -import { setContext } from '../context'; -import { SyncedStorageKeys } from '../storage'; -import { command } from '../system/command'; -import { Command, CommandContext } from './base'; - -@command() -export class CloseViewCommand extends Command { - constructor(private readonly container: Container) { - super([Commands.CloseWelcomeView]); - } - - protected override preExecute(context: CommandContext) { - return this.execute(context.command as Commands); - } - - async execute(command: Commands) { - switch (command) { - case Commands.CloseWelcomeView: - await this.container.storage.store(SyncedStorageKeys.WelcomeViewVisible, false); - await setContext(ContextKeys.ViewsWelcomeVisible, false); - break; - } - } -} diff --git a/src/commands/getStarted.ts b/src/commands/getStarted.ts new file mode 100644 index 0000000..c7d51fa --- /dev/null +++ b/src/commands/getStarted.ts @@ -0,0 +1,22 @@ +import { Commands, CoreCommands } from '../constants'; +import type { Container } from '../container'; +import { command, executeCoreCommand } from '../system/command'; +import { Command } from './base'; + +@command() +export class GetStartedCommand extends Command { + constructor(private readonly container: Container) { + super(Commands.GetStarted); + } + + execute(step?: string) { + const id = this.container.context.extension.id; + // If the step param is the same as the extension id, then this was run from the extensions view gear menu + if (step === id) { + step = undefined; + } + + // Takes the following params: walkthroughID: string | { category: string, step: string } | undefined, toSide: boolean | undefined + void executeCoreCommand(CoreCommands.OpenWalkthrough, `${id}#${step ?? 'gitlens.welcome'}`, true); + } +} diff --git a/src/commands/showView.ts b/src/commands/showView.ts index 99e6d21..c95c282 100644 --- a/src/commands/showView.ts +++ b/src/commands/showView.ts @@ -1,7 +1,5 @@ -import { Commands, ContextKeys } from '../constants'; +import { Commands } from '../constants'; import type { Container } from '../container'; -import { setContext } from '../context'; -import { SyncedStorageKeys } from '../storage'; import { command, executeCommand } from '../system/command'; import { Command, CommandContext } from './base'; @@ -20,7 +18,6 @@ export class ShowViewCommand extends Command { Commands.ShowStashesView, Commands.ShowTagsView, Commands.ShowWorktreesView, - Commands.ShowWelcomeView, Commands.ShowHomeView, ]); } @@ -53,11 +50,6 @@ export class ShowViewCommand extends Command { return this.container.tagsView.show(); case Commands.ShowWorktreesView: return this.container.worktreesView.show(); - case Commands.ShowWelcomeView: - await setContext(ContextKeys.ViewsWelcomeVisible, true); - void this.container.storage.store(SyncedStorageKeys.WelcomeViewVisible, true); - void (await executeCommand('gitlens.views.welcome.focus')); - break; case Commands.ShowHomeView: void (await executeCommand('gitlens.views.home.focus')); break; diff --git a/src/constants.ts b/src/constants.ts index becf0af..10ff3ec 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -98,6 +98,7 @@ export const enum Commands { ExternalDiff = 'gitlens.externalDiff', ExternalDiffAll = 'gitlens.externalDiffAll', FetchRepositories = 'gitlens.fetchRepositories', + GetStarted = 'gitlens.getStarted', InviteToLiveShare = 'gitlens.inviteToLiveShare', OpenBlamePriorToChange = 'gitlens.openBlamePriorToChange', OpenBranchesOnRemote = 'gitlens.openBranchesOnRemote', @@ -182,7 +183,6 @@ export const enum Commands { ShowTagsView = 'gitlens.showTagsView', ShowWorktreesView = 'gitlens.showWorktreesView', ShowWelcomePage = 'gitlens.showWelcomePage', - ShowWelcomeView = 'gitlens.showWelcomeView', StashApply = 'gitlens.stashApply', StashSave = 'gitlens.stashSave', StashSaveFiles = 'gitlens.stashSaveFiles', @@ -238,7 +238,6 @@ export const enum ContextKeys { ViewsLineHistoryEditorFollowing = 'gitlens:views:lineHistory:editorFollowing', ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh', ViewsSearchAndCompareKeepResults = 'gitlens:views:searchAndCompare:keepResults', - ViewsWelcomeVisible = 'gitlens:views:welcome:visible', Vsls = 'gitlens:vsls', Premium = 'gitlens:premium', @@ -262,6 +261,7 @@ export const enum CoreCommands { Open = 'vscode.open', OpenFolder = 'vscode.openFolder', OpenInTerminal = 'openInTerminal', + OpenWalkthrough = 'workbench.action.openWalkthrough', OpenWith = 'vscode.openWith', NextEditor = 'workbench.action.nextEditor', PreviewHtml = 'vscode.previewHtml', diff --git a/src/extension.ts b/src/extension.ts index fc594e1..def4dd0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -85,18 +85,12 @@ export async function activate(context: ExtensionContext): Promise( - SyncedStorageKeys.WelcomeViewVisible, + SyncedStorageKeys.HomeViewWelcomeVisible, )}`; } if (previousVersion == null) { - void context.globalState.update(SyncedStorageKeys.WelcomeViewVisible, true); - void setContext(ContextKeys.ViewsWelcomeVisible, true); - } else { - void setContext( - ContextKeys.ViewsWelcomeVisible, - context.globalState.get(SyncedStorageKeys.WelcomeViewVisible) ?? false, - ); + void context.globalState.update(SyncedStorageKeys.HomeViewWelcomeVisible, true); } Configuration.configure(context); @@ -165,7 +159,7 @@ function setKeysForSync(context: ExtensionContext, ...keys: (SyncedStorageKeys | return context.globalState?.setKeysForSync([ ...keys, SyncedStorageKeys.Version, - SyncedStorageKeys.WelcomeViewVisible, + SyncedStorageKeys.HomeViewWelcomeVisible, ]); } @@ -204,6 +198,9 @@ function registerBuiltInActionRunners(container: Container): void { async function showWelcomeOrWhatsNew(container: Container, version: string, previousVersion: string | undefined) { if (previousVersion == null) { Logger.log(`GitLens first-time install; window.focused=${window.state.focused}`); + + void executeCommand(Commands.ShowHomeView); + if (container.config.showWelcomeOnInstall === false) return; if (window.state.focused) { @@ -237,16 +234,15 @@ async function showWelcomeOrWhatsNew(container: Container, version: string, prev const [major, minor] = version.split('.').map(v => parseInt(v, 10)); const [prevMajor, prevMinor] = previousVersion.split('.').map(v => parseInt(v, 10)); - if ( - (major === prevMajor && minor === prevMinor) || - // Don't notify on downgrades - major < prevMajor || - (major === prevMajor && minor < prevMinor) - ) { + + // Don't notify on downgrades + if (major === prevMajor || major < prevMajor || (major === prevMajor && minor < prevMinor)) { return; } - if (major !== prevMajor && container.config.showWhatsNewAfterUpgrades) { + void executeCommand(Commands.ShowHomeView); + + if (container.config.showWhatsNewAfterUpgrades) { if (window.state.focused) { await container.storage.delete(StorageKeys.PendingWhatsNewOnFocus); await Messages.showWhatsNewMessage(version); diff --git a/src/storage.ts b/src/storage.ts index 52375d3..0015f55 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -70,7 +70,7 @@ export const enum StorageKeys { export const enum SyncedStorageKeys { Version = 'gitlens:synced:version', - WelcomeViewVisible = 'gitlens:views:welcome:visible', + HomeViewWelcomeVisible = 'gitlens:views:welcome:visible', Deprecated_DisallowConnectionPrefix = 'gitlens:disallow:connection:', } diff --git a/src/webviews/apps/premium/home/home.html b/src/webviews/apps/premium/home/home.html index cdfe2db..6d102e7 100644 --- a/src/webviews/apps/premium/home/home.html +++ b/src/webviews/apps/premium/home/home.html @@ -11,7 +11,7 @@ -
+
@@ -21,8 +21,8 @@ + +