Skip to content

Commit

Permalink
Fixes many more issues w/welcome blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Nov 12, 2024
1 parent ac1633c commit d07e231
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 109 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19159,6 +19159,16 @@
]
},
"viewsWelcome": [
{
"view": "gitlens.views.scm.grouped",
"contents": "GitLens groups many related views—Commits, Branches, Stashes, etc—here for easier view management.\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.\n\n[Continue](command:gitlens.views.scm.grouped.welcome.dismiss)",
"when": "!gitlens:views:scm:grouped:welcome:dismissed && gitlens:newInstall"
},
{
"view": "gitlens.views.scm.grouped",
"contents": "In GitLens 16, we've grouped many related views—Commits, Branches, Stashes, etc—here for easier view management.\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.\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)",
"when": "!gitlens:views:scm:grouped:welcome:dismissed && !gitlens:newInstall"
},
{
"view": "gitlens.views.searchAndCompare",
"contents": "Search for commits by [message](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22query%22%3A%22message%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D), [author](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22query%22%3A%22author%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D), [SHA](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22query%22%3A%22commit%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D), [file](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22query%22%3A%22file%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D), or [changes](command:gitlens.views.searchAndCompare.searchCommits?%7B%22search%22%3A%7B%22query%22%3A%22change%3A%22%7D%2C%22prefillOnly%22%3Atrue%7D)\n\n[Search Commits...](command:gitlens.views.searchAndCompare.searchCommits)",
Expand Down Expand Up @@ -19441,16 +19451,6 @@
"view": "gitlens.views.scm.grouped",
"contents": "Pro feature — requires a paid plan for use on privately-hosted repos.",
"when": "gitlens:views:scm:grouped:view == worktrees"
},
{
"view": "gitlens.views.scm.grouped",
"contents": "GitLens groups many related views—Commits, Branches, Stashes, etc—here for easier view management.\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.\n\n[Continue](command:gitlens.views.scm.grouped.welcome.dismiss)",
"when": "!gitlens:views:scm:grouped:welcome:dismissed && gitlens:newInstall"
},
{
"view": "gitlens.views.scm.grouped",
"contents": "In GitLens 16, we've grouped many related views—Commits, Branches, Stashes, etc—here for easier view management.\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.\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)",
"when": "!gitlens:views:scm:grouped:welcome:dismissed && !gitlens:newInstall"
}
],
"views": {
Expand Down
28 changes: 14 additions & 14 deletions src/commands/showView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,41 +45,41 @@ export class ShowViewCommand extends Command {
...([{ focusAccount: true }, ...args] as HomeWebviewShowingArgs),
);
case Commands.ShowBranchesView:
return this.container.views.branches.show();
return this.container.views.showView('branches');
case Commands.ShowCommitDetailsView:
return this.container.views.commitDetails.show();
case Commands.ShowCommitsView:
return this.container.views.commits.show();
return this.container.views.showView('commits');
case Commands.ShowContributorsView:
return this.container.views.contributors.show();
return this.container.views.showView('contributors');
case Commands.ShowDraftsView:
return this.container.views.drafts.show();
return this.container.views.showView('drafts');
case Commands.ShowFileHistoryView:
return this.container.views.fileHistory.show();
return this.container.views.showView('fileHistory');
case Commands.ShowGraphView:
return this.container.views.graph.show(undefined, ...(args as GraphWebviewShowingArgs));
case Commands.ShowHomeView:
return this.container.views.home.show(undefined, ...(args as HomeWebviewShowingArgs));
case Commands.ShowLaunchpadView:
return this.container.views.launchpad.show();
return this.container.views.showView('launchpad');
case Commands.ShowLineHistoryView:
return this.container.views.lineHistory.show();
return this.container.views.showView('lineHistory');
case Commands.ShowRemotesView:
return this.container.views.remotes.show();
return this.container.views.showView('remotes');
case Commands.ShowRepositoriesView:
return this.container.views.repositories.show();
return this.container.views.showView('repositories');
case Commands.ShowSearchAndCompareView:
return this.container.views.searchAndCompare.show();
return this.container.views.showView('searchAndCompare');
case Commands.ShowStashesView:
return this.container.views.stashes.show();
return this.container.views.showView('stashes');
case Commands.ShowTagsView:
return this.container.views.tags.show();
return this.container.views.showView('tags');
case Commands.ShowTimelineView:
return this.container.views.timeline.show();
case Commands.ShowWorktreesView:
return this.container.views.worktrees.show();
return this.container.views.showView('worktrees');
case Commands.ShowWorkspacesView:
return this.container.views.workspaces.show();
return this.container.views.showView('workspaces');
}

return Promise.resolve(undefined);
Expand Down
32 changes: 7 additions & 25 deletions src/views/scmGroupedView.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Disposable } from 'vscode';
import type { Commands } from '../constants.commands';
import type { Disposable } from 'vscode';
import type { GroupableTreeViewTypes } from '../constants.views';
import type { Container } from '../container';
import { first } from '../system/iterable';
import { executeCommand, registerCommand } from '../system/vscode/command';
import { BranchesView } from './branchesView';
import { CommitsView } from './commitsView';
import { ContributorsView } from './contributorsView';
Expand All @@ -18,42 +16,26 @@ import type { Views } from './views';
import { WorktreesView } from './worktreesView';

export class ScmGroupedView implements Disposable {
private _disposable: Disposable;
private _view: TreeViewByType[GroupableTreeViewTypes] | undefined;

constructor(
private readonly container: Container,
private views: Views,
) {
this._disposable = Disposable.from(
registerCommand('gitlens.views.scm.grouped.refresh', () => {
if (this._view == null) return;

executeCommand(`gitlens.views.${this._view.type}.refresh` as Commands);
}),
registerCommand('gitlens.views.scm.grouped.branches', () => this.setView('branches', true)),
registerCommand('gitlens.views.scm.grouped.commits', () => this.setView('commits', true)),
registerCommand('gitlens.views.scm.grouped.contributors', () => this.setView('contributors', true)),
registerCommand('gitlens.views.scm.grouped.launchpad', () => this.setView('launchpad', true)),
registerCommand('gitlens.views.scm.grouped.remotes', () => this.setView('remotes', true)),
registerCommand('gitlens.views.scm.grouped.repositories', () => this.setView('repositories', true)),
registerCommand('gitlens.views.scm.grouped.searchAndCompare', () => this.setView('searchAndCompare', true)),
registerCommand('gitlens.views.scm.grouped.stashes', () => this.setView('stashes', true)),
registerCommand('gitlens.views.scm.grouped.tags', () => this.setView('tags', true)),
registerCommand('gitlens.views.scm.grouped.worktrees', () => this.setView('worktrees', true)),
);

this._view = this.setView(this.views.lastSelectedScmGroupedView!);
}

dispose() {
this._disposable.dispose();
this._view?.dispose();
}

get view() {
return this._view;
}

setView<T extends GroupableTreeViewTypes>(type: T, focus?: boolean): TreeViewByType[T] {
if (!this.views.scmGroupedViews.has(type)) {
type = first(this.views.scmGroupedViews) as T;
if (!this.views.scmGroupedViews?.has(type)) {
type = this.views.scmGroupedViews?.size ? (first(this.views.scmGroupedViews) as T) : undefined!;
}

if (this._view?.type === type) {
Expand Down
19 changes: 18 additions & 1 deletion src/views/viewBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import type {
import { viewsCommonConfigKeys, viewsConfigKeys } from '../config';
import type { TreeViewCommandSuffixesByViewType } from '../constants.commands';
import type { TrackedUsageFeatures } from '../constants.telemetry';
import type { TreeViewIds, TreeViewTypes } from '../constants.views';
import type { TreeViewIds, TreeViewTypes, WebviewViewTypes } from '../constants.views';
import type { Container } from '../container';
import { debug, log } from '../system/decorators/log';
import { once } from '../system/event';
Expand Down Expand Up @@ -113,6 +113,23 @@ export type TreeViewByType = {
: View;
};

// prettier-ignore
export type WebviewViewByType = {
[T in WebviewViewTypes]: T extends 'commitDetails'
? CommitsView
: T extends 'graph'
? CommitsView
: T extends 'graphDetails'
? CommitsView
: T extends 'home'
? CommitsView
: T extends 'patchDetails'
? CommitsView
: T extends 'timeline'
? CommitsView
: View;
};

export type ViewsWithBranches = BranchesView | CommitsView | RemotesView | RepositoriesView | WorkspacesView;
export type ViewsWithBranchesNode = BranchesView | RepositoriesView | WorkspacesView;
export type ViewsWithCommits = Exclude<View, LineHistoryView | StashesView>;
Expand Down
Loading

0 comments on commit d07e231

Please sign in to comment.