Procházet zdrojové kódy

Fixes #738 - honors whats new setting

Opens Welcome for v10
main
Eric Amodio před 5 roky
rodič
revize
9cd1877890
2 změnil soubory, kde provedl 28 přidání a 67 odebrání
  1. +25
    -29
      src/extension.ts
  2. +3
    -38
      src/messages.ts

+ 25
- 29
src/extension.ts Zobrazit soubor

@ -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);
@ -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);
}
}

+ 3
- 38
src/messages.ts Zobrazit soubor

@ -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',
@ -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: '❤' }];
@ -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]) {

Načítá se…
Zrušit
Uložit