Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCM - Source Control Repositories view to use scm.providerCountBadge #194696

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/scm/browser/scm.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
localize('scm.providerCountBadge.auto', "Only show count badge for Source Control Provider when non-zero."),
localize('scm.providerCountBadge.visible', "Show Source Control Provider count badges.")
],
description: localize('scm.providerCountBadge', "Controls the count badges on Source Control Provider headers. These headers only appear when there is more than one provider."),
markdownDescription: localize('scm.providerCountBadge', "Controls the count badges on Source Control Provider headers. These headers appear in the \"Source Control\", and \"Source Control Sync\" views when there is more than one provider or when the {0} setting is enabled, as well as in the \"Source Control Repositories\" view.", '\`#scm.alwaysShowRepositories#\`'),
default: 'hidden'
},
'scm.defaultViewMode': {
Expand Down
16 changes: 16 additions & 0 deletions src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import 'vs/css!./media/scm';
import { localize } from 'vs/nls';
import { Event } from 'vs/base/common/event';
import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPane';
import { append, $ } from 'vs/base/browser/dom';
import { IListVirtualDelegate, IListContextMenuEvent, IListEvent } from 'vs/base/browser/ui/list/list';
Expand All @@ -24,6 +25,7 @@ import { RepositoryRenderer } from 'vs/workbench/contrib/scm/browser/scmReposito
import { collectContextMenuActions, getActionViewItemProvider } from 'vs/workbench/contrib/scm/browser/util';
import { Orientation } from 'vs/base/browser/ui/sash/sash';
import { Iterable } from 'vs/base/common/iterator';
import { DisposableStore } from 'vs/base/common/lifecycle';

class ListDelegate implements IListVirtualDelegate<ISCMRepository> {

Expand All @@ -39,6 +41,7 @@ class ListDelegate implements IListVirtualDelegate<ISCMRepository> {
export class SCMRepositoriesViewPane extends ViewPane {

private list!: WorkbenchList<ISCMRepository>;
private readonly disposables = new DisposableStore();

constructor(
options: IViewPaneOptions,
Expand All @@ -61,6 +64,14 @@ export class SCMRepositoriesViewPane extends ViewPane {

const listContainer = append(container, $('.scm-view.scm-repositories-view'));

const updateProviderCountVisibility = () => {
const value = this.configurationService.getValue<'hidden' | 'auto' | 'visible'>('scm.providerCountBadge');
listContainer.classList.toggle('hide-provider-counts', value === 'hidden');
listContainer.classList.toggle('auto-provider-counts', value === 'auto');
};
this._register(Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.providerCountBadge'), this.disposables)(updateProviderCountVisibility));
updateProviderCountVisibility();

const delegate = new ListDelegate();
const renderer = this.instantiationService.createInstance(RepositoryRenderer, getActionViewItemProvider(this.instantiationService));
const identityProvider = { getId: (r: ISCMRepository) => r.provider.id };
Expand Down Expand Up @@ -179,4 +190,9 @@ export class SCMRepositoriesViewPane extends ViewPane {
this.list.setFocus([selection[0]]);
}
}

override dispose(): void {
this.disposables.dispose();
super.dispose();
}
}