Skip to content

Commit

Permalink
Fixes #738 - honors whats new setting
Browse files Browse the repository at this point in the history
Opens Welcome for v10
  • Loading branch information
eamodio committed Aug 31, 2019
1 parent 5e71238 commit 9cd1877
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 67 deletions.
54 changes: 25 additions & 29 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function activate(context: ExtensionContext) {
// Telemetry.setContext(telemetryContext);

notifyOnUnsupportedGitVersion(gitVersion);
void showWelcomePage(gitlensVersion, previousVersion);
void showWelcomeOrWhatsNew(gitlensVersion, previousVersion);

context.globalState.update(GlobalState.GitLensVersion, gitlensVersion);

Expand Down Expand Up @@ -157,38 +157,34 @@ function notifyOnUnsupportedGitVersion(version: string) {
void Messages.showGitVersionUnsupportedErrorMessage(version);
}

async function showWelcomePage(version: string, previousVersion: string | undefined) {
try {
if (previousVersion === undefined) {
Logger.log('GitLens first-time install');
async function showWelcomeOrWhatsNew(version: string, previousVersion: string | undefined) {
if (previousVersion === undefined) {
Logger.log('GitLens first-time install');
await commands.executeCommand(Commands.ShowWelcomePage);

if (Container.config.showWhatsNewAfterUpgrades) {
await commands.executeCommand(Commands.ShowWelcomePage);
}
return;
}

return;
}
if (previousVersion !== version) {
Logger.log(`GitLens upgraded from v${previousVersion} to v${version}`);
}

if (previousVersion !== version) {
Logger.log(`GitLens upgraded from v${previousVersion} to v${version}`);
}
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))
) {
return;
}

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))
) {
return;
}
// Show the Welcome for v10 since its all new
if (major !== prevMajor && major === 10) {
await commands.executeCommand(Commands.ShowWelcomePage);
}

if (Container.config.showWhatsNewAfterUpgrades && major !== prevMajor) {
await commands.executeCommand(Commands.ShowWelcomePage);
} else {
await Messages.showWhatsNewMessage(version);
}
} finally {
void (await Messages.showSetupViewLayoutMessage(previousVersion));
if (Container.config.showWhatsNewAfterUpgrades && major !== prevMajor) {
await Messages.showWhatsNewMessage(version);
}
}
41 changes: 3 additions & 38 deletions src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
'use strict';
import { commands, ConfigurationTarget, env, MessageItem, Uri, window } from 'vscode';
import { Commands } from './commands';
import { configuration, ViewLocation } from './configuration';
import { ConfigurationTarget, env, MessageItem, Uri, window } from 'vscode';
import { configuration } from './configuration';
import { CommandContext, setCommandContext } from './constants';
import { GitCommit } from './git/gitService';
import { Logger } from './logger';
import { Versions } from './system';
import { Container } from './container';

export enum SuppressedMessages {
CommitHasNoPreviousCommitWarning = 'suppressCommitHasNoPreviousCommitWarning',
Expand Down Expand Up @@ -132,38 +129,6 @@ export class Messages {
}
}

static async showSetupViewLayoutMessage(previousVersion: string | undefined) {
if (
Container.config.views.repositories.location !== ViewLocation.GitLens ||
Container.config.views.fileHistory.location !== ViewLocation.GitLens ||
Container.config.views.lineHistory.location !== ViewLocation.GitLens ||
Container.config.views.search.location !== ViewLocation.GitLens ||
Container.config.views.compare.location !== ViewLocation.GitLens
) {
return;
}

if (
previousVersion !== undefined &&
Versions.compare(Versions.fromString(previousVersion), Versions.from(9, 6, 3)) === 1
) {
return;
}

const actions: MessageItem[] = [{ title: 'Customize...' }, { title: 'Use Defaults' }];
const result = await Messages.showMessage(
'info',
'GitLens views can be configured to be shown in different side bar layouts to best match your workflow. You can easily change the default layout (where all views are shown together on the GitLens side bar) below.',
undefined,
null,
...actions
);

if (result != null && result === actions[0]) {
await commands.executeCommand(Commands.ShowSettingsPage, 'views-layout');
}
}

static async showWhatsNewMessage(version: string) {
const actions: MessageItem[] = [{ title: "What's New" }, { title: 'Release Notes' }, { title: '❤' }];

Expand All @@ -177,7 +142,7 @@ export class Messages {

if (result != null) {
if (result === actions[0]) {
await commands.executeCommand(Commands.ShowWelcomePage);
await env.openExternal(Uri.parse('https://gitlens.amod.io/#whats-new'));
} else if (result === actions[1]) {
await env.openExternal(Uri.parse('https://github.com/eamodio/vscode-gitlens/blob/master/CHANGELOG.md'));
} else if (result === actions[2]) {
Expand Down

0 comments on commit 9cd1877

Please sign in to comment.