Skip to content

Commit 9fd45fc

Browse files
committed
Expands GL view on upgrade
1 parent b779add commit 9fd45fc

File tree

6 files changed

+39
-24
lines changed

6 files changed

+39
-24
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18913,12 +18913,12 @@
1891318913
{
1891418914
"view": "gitlens.views.scm.grouped",
1891518915
"contents": "GitLens groups many related views—Commits, Branches, Stashes, etc—here for easier view management.\n\n[Continue](command:gitlens.views.scm.grouped.welcome.dismiss)\n\nUse the tabs above to navigate, or detach the views you want to keep separated. You can regroup them anytime using the 'x' in the view header.",
18916-
"when": "gitlens:views:scm:grouped:welcome && gitlens:newInstall"
18916+
"when": "gitlens:views:scm:grouped:welcome && gitlens:install:new"
1891718917
},
1891818918
{
1891918919
"view": "gitlens.views.scm.grouped",
1892018920
"contents": "In GitLens 16, we've grouped many related views—Commits, Branches, Stashes, etc—here for easier view management.\n\n[Continue](command:gitlens.views.scm.grouped.welcome.dismiss)\n\nPrefer them separate? [Restore views to previous locations](command:gitlens.views.scm.grouped.welcome.restore)\n\nUse the tabs above to navigate, or detach the views you want to keep separated. You can regroup them anytime using the 'x' in the view header.",
18921-
"when": "gitlens:views:scm:grouped:welcome && !gitlens:newInstall"
18921+
"when": "gitlens:views:scm:grouped:welcome && !gitlens:install:new"
1892218922
},
1892318923
{
1892418924
"view": "gitlens.views.searchAndCompare",

src/constants.context.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export type ContextKeys = {
1515
'gitlens:gk:organization:drafts:enabled': boolean;
1616
'gitlens:hasVirtualFolders': boolean;
1717
'gitlens:launchpad:connect': boolean;
18-
/** Indicates that this is a new install of GitLens (on this machine) */
19-
'gitlens:newInstall': boolean;
20-
/** Indicates that this is a new install of GitLens (anywhere for this user -- if synced settings is on) */
21-
'gitlens:newUserInstall': boolean;
18+
/** Indicates that this is the first run of a new install of GitLens */
19+
'gitlens:install:new': boolean;
20+
/** Indicates that this is the first run after an upgrade of GitLens */
21+
'gitlens:install:upgradedFrom': string;
2222
'gitlens:plus': Exclude<SubscriptionPlanId, SubscriptionPlanId.Community>;
2323
'gitlens:plus:disallowedRepos': string[];
2424
'gitlens:plus:enabled': boolean;

src/extension.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,11 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
147147
previousVersion = localVersion;
148148
}
149149

150-
// If there is no local previous version, this is a new install on this machine
151-
if (localVersion == null) {
152-
void setContext('gitlens:newInstall', true);
153-
}
154-
// If there is no local or synced previous version, this is a new install for this user
155-
if (previousVersion == null) {
156-
void setContext('gitlens:newUserInstall', true);
150+
// If there is no local or synced previous version, this is a new install
151+
if (localVersion == null || previousVersion == null) {
152+
void setContext('gitlens:install:new', true);
153+
} else if (gitlensVersion !== previousVersion && compare(gitlensVersion, previousVersion) === 1) {
154+
void setContext('gitlens:install:upgradedFrom', previousVersion);
157155
}
158156

159157
let exitMessage;

src/messages.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ export function showIntegrationRequestTimedOutWarningMessage(providerName: strin
230230
);
231231
}
232232

233-
export async function showWhatsNewMessage(version: string) {
233+
export async function showWhatsNewMessage(majorVersion: string) {
234234
const confirm = { title: 'OK', isCloseAffordance: true };
235235
const releaseNotes = { title: 'View Release Notes' };
236236
const result = await showMessage(
237237
'info',
238-
`Upgraded to GitLens ${version}${
239-
version === '16'
238+
`Upgraded to GitLens ${majorVersion}${
239+
majorVersion === '16'
240240
? ` with an all new [Home view](${createMarkdownCommandLink(Commands.ShowHomeView, {
241241
source: 'whatsnew',
242-
})} "Show Home view") reimagined as a hub for your current, future, and recent work, consolidated Source Control views, and much more.`
242+
})} "Show Home view") reimagined as a hub for your current, future, and recent work, [consolidated Source Control views](command:gitlens.views.scm.grouped.focus "Show GitLens view"), and much more.`
243243
: " — see what's new."
244244
}`,
245245
undefined,

src/views/views.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import type { PatchDetailsWebviewShowingArgs } from '../plus/webviews/patchDetai
1818
import { registerPatchDetailsWebviewView } from '../plus/webviews/patchDetails/registration';
1919
import type { TimelineWebviewShowingArgs } from '../plus/webviews/timeline/registration';
2020
import { registerTimelineWebviewView } from '../plus/webviews/timeline/registration';
21+
import { once } from '../system/function';
2122
import { first } from '../system/iterable';
23+
import { compare } from '../system/version';
2224
import { executeCommand, executeCoreCommand, registerCommand } from '../system/vscode/command';
2325
import { configuration } from '../system/vscode/configuration';
2426
import { getContext, setContext } from '../system/vscode/context';
@@ -108,12 +110,27 @@ export class Views implements Disposable {
108110
configuration.get('views.scm.grouped.default'),
109111
);
110112
this.updateScmGroupedViewsRegistration();
113+
111114
// If this is a new install, expand the GitLens view and show the home view by default
112-
if (getContext('gitlens:newInstall', false)) {
113-
setTimeout(() => {
114-
executeCoreCommand(`gitlens.views.scm.grouped.focus`, { preserveFocus: true });
115-
executeCoreCommand(`gitlens.views.home.focus`, { preserveFocus: true });
116-
}, 250);
115+
const newInstall = getContext('gitlens:install:new', false);
116+
let showGitLensView = newInstall;
117+
if (!showGitLensView) {
118+
const upgradedFrom = getContext('gitlens:install:upgradedFrom');
119+
if (upgradedFrom && compare(upgradedFrom, '16.0.2') === -1) {
120+
showGitLensView = !container.storage.get('views:scm:grouped:welcome:dismissed', false);
121+
}
122+
}
123+
124+
if (showGitLensView) {
125+
const disposable = once(container.onReady)(() => {
126+
disposable?.dispose();
127+
setTimeout(() => {
128+
executeCoreCommand(`gitlens.views.scm.grouped.focus`, { preserveFocus: true });
129+
if (newInstall) {
130+
executeCoreCommand(`gitlens.views.home.focus`, { preserveFocus: true });
131+
}
132+
}, 0);
133+
});
117134
}
118135
}
119136

@@ -410,7 +427,7 @@ export class Views implements Disposable {
410427
private async showWelcomeNotification() {
411428
this._welcomeDismissed = true;
412429

413-
const newInstall = getContext('gitlens:newInstall', false);
430+
const newInstall = getContext('gitlens:install:new', false);
414431

415432
const confirm: MessageItem = { title: 'OK', isCloseAffordance: true };
416433
const Restore: MessageItem = { title: 'Restore Previous Locations' };

src/webviews/home/homeWebview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
437437
},
438438
showWalkthroughProgress: !this.getWalkthroughDismissed(),
439439
previewEnabled: this.getPreviewEnabled(),
440-
newInstall: getContext('gitlens:newInstall', false),
440+
newInstall: getContext('gitlens:install:new', false),
441441
};
442442
}
443443

0 commit comments

Comments
 (0)