Skip to content

Commit

Permalink
Adds grouping support for launchpad view
Browse files Browse the repository at this point in the history
  • Loading branch information
axosoft-ramint authored and eamodio committed Nov 11, 2024
1 parent aa129ab commit 219d620
Show file tree
Hide file tree
Showing 14 changed files with 276 additions and 33 deletions.
1 change: 1 addition & 0 deletions images/icons/launchpad-view-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/launchpad-view.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/icons/template/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@
"search-view-filled": 61755,
"stashes-view-filled": 61756,
"tags-view-filled": 61757,
"worktrees-view-filled": 61758
"worktrees-view-filled": 61758,
"launchpad-view": 61759,
"launchpad-view-filled": 61760
}
236 changes: 218 additions & 18 deletions package.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/constants.views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type GroupableTreeViewTypes = Extract<
| 'branches'
| 'commits'
| 'contributors'
| 'launchpad'
| 'remotes'
| 'repositories'
| 'searchAndCompare'
Expand Down
17 changes: 13 additions & 4 deletions src/views/launchpadView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ConfigurationChangeEvent, TreeViewVisibilityChangeEvent } from 'vs
import { Disposable, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode';
import type { OpenWalkthroughCommandArgs } from '../commands/walkthroughs';
import type { LaunchpadViewConfig, ViewFilesLayout } from '../config';
import { proBadge } from '../constants';
import { Commands } from '../constants.commands';
import type { Container } from '../container';
import { AuthenticationRequiredError } from '../errors';
Expand Down Expand Up @@ -152,14 +153,17 @@ export class LaunchpadViewNode extends CacheableChildrenViewNode<
}

async getChildren(): Promise<(GroupingNode | LaunchpadItemNode)[]> {
this.view.description = this.view.grouped
? `${this.view.name.toLocaleLowerCase()}\u00a0\u2022\u00a0 ${proBadge}`
: proBadge;
this.view.message = undefined;

if (this.children == null) {
const access = await this.view.container.git.access(PlusFeatures.Launchpad);
if (!access.allowed) return [];

const children: (GroupingNode | LaunchpadItemNode)[] = [];

this.view.message = undefined;

const hasIntegrations = await this.view.container.launchpad.hasConnectedIntegration();
if (!hasIntegrations) {
return [];
Expand Down Expand Up @@ -220,15 +224,20 @@ export class LaunchpadView extends ViewBase<'launchpad', LaunchpadViewNode, Laun
protected readonly configKey = 'launchpad';
private _disposable: Disposable | undefined;

constructor(container: Container) {
super(container, 'launchpad', 'Launchpad', 'launchpadView');
constructor(container: Container, grouped?: boolean) {
super(container, 'launchpad', 'Launchpad', 'launchpadView', grouped);
}

override dispose() {
this._disposable?.dispose();
super.dispose();
}

override getViewDescription(count?: number): string {
const description = super.getViewDescription(count);
return description ? `${description} \u00a0\u2022\u00a0 ${proBadge}` : proBadge;
}

protected getRoot() {
return new LaunchpadViewNode(this);
}
Expand Down
4 changes: 4 additions & 0 deletions src/views/scmGroupedView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { executeCommand, registerCommand } from '../system/vscode/command';
import { BranchesView } from './branchesView';
import { CommitsView } from './commitsView';
import { ContributorsView } from './contributorsView';
import { LaunchpadView } from './launchpadView';
import { RemotesView } from './remotesView';
import { RepositoriesView } from './repositoriesView';
import { SearchAndCompareView } from './searchAndCompareView';
Expand All @@ -33,6 +34,7 @@ export class ScmGroupedView implements Disposable {
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)),
Expand Down Expand Up @@ -77,6 +79,8 @@ export class ScmGroupedView implements Disposable {
return new CommitsView(this.container, true);
case 'contributors':
return new ContributorsView(this.container, true);
case 'launchpad':
return new LaunchpadView(this.container, true);
case 'remotes':
return new RemotesView(this.container, true);
case 'repositories':
Expand Down
27 changes: 23 additions & 4 deletions src/views/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class Views implements Disposable {
this._branchesView?.dispose();
this._commitsView?.dispose();
this._contributorsView?.dispose();
this._launchpadView?.dispose();
this._remotesView?.dispose();
this._repositoriesView?.dispose();
this._searchAndCompareView?.dispose();
Expand Down Expand Up @@ -151,6 +152,16 @@ export class Views implements Disposable {
registerCommand('gitlens.views.scm.grouped.contributors.setAsDefault', () =>
this.setAsScmGroupedDefaultView('contributors'),
),
registerCommand('gitlens.views.launchpad.regroup', () => this.toggleScmViewGrouping('launchpad', true)),
registerCommand('gitlens.views.scm.grouped.launchpad.detach', () =>
this.toggleScmViewGrouping('launchpad', false),
),
registerCommand('gitlens.views.scm.grouped.launchpad.regroup', () =>
this.toggleScmViewGrouping('launchpad', true),
),
registerCommand('gitlens.views.scm.grouped.launchpad.setAsDefault', () =>
this.setAsScmGroupedDefaultView('launchpad'),
),
registerCommand('gitlens.views.remotes.regroup', () => this.toggleScmViewGrouping('remotes', true)),
registerCommand('gitlens.views.scm.grouped.remotes.detach', () =>
this.toggleScmViewGrouping('remotes', false),
Expand Down Expand Up @@ -218,7 +229,6 @@ export class Views implements Disposable {
return [
(this._draftsView = new DraftsView(this.container)),
(this._fileHistoryView = new FileHistoryView(this.container)),
(this._launchpadView = new LaunchpadView(this.container)),
(this._lineHistoryView = new LineHistoryView(this.container)),
(this._pullRequestView = new PullRequestView(this.container)),
(this._workspacesView = new WorkspacesView(this.container)),
Expand Down Expand Up @@ -303,6 +313,13 @@ export class Views implements Disposable {
this._contributorsView = undefined;
}

if (!groupingEnabled || !this._scmGroupedViews.has('launchpad')) {
this._launchpadView ??= new LaunchpadView(this.container);
} else {
this._launchpadView?.dispose();
this._launchpadView = undefined;
}

if (!groupingEnabled || !this._scmGroupedViews.has('remotes')) {
this._remotesView ??= new RemotesView(this.container);
} else {
Expand Down Expand Up @@ -398,9 +415,9 @@ export class Views implements Disposable {
return this._homeView;
}

private _launchpadView!: LaunchpadView;
private _launchpadView!: LaunchpadView | undefined;
get launchpad(): LaunchpadView {
return this._launchpadView;
return this._launchpadView ?? this._scmGroupedView.setView('launchpad');
}

private _lineHistoryView!: LineHistoryView;
Expand Down Expand Up @@ -595,8 +612,9 @@ const defaultScmGroupedViews: Record<GroupableTreeViewTypes, boolean> = Object.f
tags: true,
worktrees: true,
contributors: true,
repositories: true,
repositories: false,
searchAndCompare: true,
launchpad: false,
});

function getScmGroupedViewsFromConfig() {
Expand All @@ -622,5 +640,6 @@ async function updateScmGroupedViewsInConfig(groupedViews: Set<GroupableTreeView
contributors: groupedViews.has('contributors'),
repositories: groupedViews.has('repositories'),
searchAndCompare: groupedViews.has('searchAndCompare'),
launchpad: groupedViews.has('launchpad'),
});
}
2 changes: 1 addition & 1 deletion src/webviews/apps/commitDetails/commitDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@font-face {
font-family: 'glicons';
font-display: block;
src: url('#{root}/dist/glicons.woff2?526ab4b01522255557001d936894ca47') format('woff2');
src: url('#{root}/dist/glicons.woff2?888557bf00e2cc234c92d4643f1f0051') format('woff2');
}
</style>
</head>
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/apps/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@font-face {
font-family: 'glicons';
font-display: block;
src: url('#{root}/dist/glicons.woff2?526ab4b01522255557001d936894ca47') format('woff2');
src: url('#{root}/dist/glicons.woff2?888557bf00e2cc234c92d4643f1f0051') format('woff2');
}
</style>
</head>
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/apps/plus/graph/graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@font-face {
font-family: 'glicons';
font-display: block;
src: url('#{root}/dist/glicons.woff2?526ab4b01522255557001d936894ca47') format('woff2');
src: url('#{root}/dist/glicons.woff2?888557bf00e2cc234c92d4643f1f0051') format('woff2');
}
</style>
<script type="application/javascript" nonce="#{cspNonce}">
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/apps/plus/patchDetails/patchDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@font-face {
font-family: 'glicons';
font-display: block;
src: url('#{root}/dist/glicons.woff2?526ab4b01522255557001d936894ca47') format('woff2');
src: url('#{root}/dist/glicons.woff2?888557bf00e2cc234c92d4643f1f0051') format('woff2');
}
</style>
</head>
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/apps/plus/timeline/timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@font-face {
font-family: 'glicons';
font-display: block;
src: url('#{root}/dist/glicons.woff2?526ab4b01522255557001d936894ca47') format('woff2');
src: url('#{root}/dist/glicons.woff2?888557bf00e2cc234c92d4643f1f0051') format('woff2');
}
</style>
<script type="application/javascript" nonce="#{cspNonce}">
Expand Down
8 changes: 7 additions & 1 deletion src/webviews/apps/shared/glicons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Must be placed at the end of body in the HTML file of any webview that needs it
@font-face {
font-family: 'glicons';
font-display: block;
src: url("#{root}/dist/glicons.woff2?526ab4b01522255557001d936894ca47") format("woff2");
src: url("#{root}/dist/glicons.woff2?888557bf00e2cc234c92d4643f1f0051") format("woff2");
}
</style>
*/
Expand Down Expand Up @@ -251,3 +251,9 @@ Must be placed at the end of body in the HTML file of any webview that needs it
.glicon-worktrees-view-filled:before {
content: '\f13e';
}
.glicon-launchpad-view:before {
content: '\f13f';
}
.glicon-launchpad-view-filled:before {
content: '\f140';
}

0 comments on commit 219d620

Please sign in to comment.