extensionsViewlet.ts 18.1 KB
Newer Older
J
Joao Moreno 已提交
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

J
Joao Moreno 已提交
8
import 'vs/css!./media/extensionsViewlet';
J
Joao Moreno 已提交
9 10
import { localize } from 'vs/nls';
import { ThrottledDelayer, always } from 'vs/base/common/async';
J
Joao Moreno 已提交
11
import { TPromise } from 'vs/base/common/winjs.base';
12
import { isPromiseCanceledError, onUnexpectedError, create as createError } from 'vs/base/common/errors';
J
Joao Moreno 已提交
13
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
J
Joao Moreno 已提交
14 15
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { Builder, Dimension } from 'vs/base/browser/builder';
16
import { assign } from 'vs/base/common/objects';
J
Joao Moreno 已提交
17
import EventOf, { mapEvent, chain } from 'vs/base/common/event';
18
import { IAction } from 'vs/base/common/actions';
J
Joao Moreno 已提交
19
import { domEvent } from 'vs/base/browser/event';
J
Joao Moreno 已提交
20
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
J
Joao Moreno 已提交
21 22
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
J
Joao Moreno 已提交
23
import { Viewlet } from 'vs/workbench/browser/viewlet';
24 25
import { IViewlet } from 'vs/workbench/common/viewlet';
import { IViewletService } from 'vs/workbench/services/viewlet/common/viewletService';
J
Joao Moreno 已提交
26
import { append, $, addStandardDisposableListener, EventType, addClass, removeClass, toggleClass } from 'vs/base/browser/dom';
J
Joao Moreno 已提交
27
import { PagedModel, IPagedModel } from 'vs/base/common/paging';
J
Joao Moreno 已提交
28
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
J
Joao Moreno 已提交
29 30
import { PagedList } from 'vs/base/browser/ui/list/listPaging';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
J
Joao Moreno 已提交
31
import { Delegate, Renderer } from './extensionsList';
32
import { IExtensionsWorkbenchService, IExtension, IExtensionsViewlet, VIEWLET_ID, ExtensionState } from '../common/extensions';
33 34 35 36 37
import {
	ShowRecommendedExtensionsAction, ShowWorkspaceRecommendedExtensionsAction, ShowPopularExtensionsAction, ShowInstalledExtensionsAction, ShowDisabledExtensionsAction,
	ShowOutdatedExtensionsAction, ClearExtensionsInputAction, ChangeSortAction, UpdateAllAction, InstallVSIXAction, ConfigureWorkspaceRecommendedExtensionsAction,
	EnableAllAction, EnableAllWorkpsaceAction, DisableAllAction, DisableAllWorkpsaceAction
} from './extensionsActions';
J
Joao Moreno 已提交
38
import { IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService, SortBy, SortOrder, IQueryOptions, LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement';
39
import { ExtensionsInput } from './extensionsInput';
J
Joao Moreno 已提交
40
import { Query } from '../common/extensionQuery';
J
Joao Moreno 已提交
41
import { OpenGlobalSettingsAction } from 'vs/workbench/browser/actions/openSettings';
J
Joao Moreno 已提交
42
import { IProgressService } from 'vs/platform/progress/common/progress';
J
Joao Moreno 已提交
43
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
44
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
J
Joao Moreno 已提交
45 46
import { IMessageService, CloseAction } from 'vs/platform/message/common/message';
import Severity from 'vs/base/common/severity';
J
Joao Moreno 已提交
47
import { IActivityService, ProgressBadge, NumberBadge } from 'vs/workbench/services/activity/common/activityService';
J
Joao Moreno 已提交
48

49 50 51 52
interface SearchInputEvent extends Event {
	target: HTMLInputElement;
	immediate?: boolean;
}
J
Joao Moreno 已提交
53

54
export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
J
Joao Moreno 已提交
55

56
	private onSearchChange: EventOf<string>;
J
Joao Moreno 已提交
57
	private searchDelayer: ThrottledDelayer<any>;
J
Joao Moreno 已提交
58
	private root: HTMLElement;
J
Joao Moreno 已提交
59 60
	private searchBox: HTMLInputElement;
	private extensionsBox: HTMLElement;
J
Joao Moreno 已提交
61
	private messageBox: HTMLElement;
J
Joao Moreno 已提交
62
	private list: PagedList<IExtension>;
J
Joao Moreno 已提交
63 64
	private primaryActions: IAction[];
	private secondaryActions: IAction[];
J
Joao Moreno 已提交
65
	private disposables: IDisposable[] = [];
J
Joao Moreno 已提交
66

J
Joao Moreno 已提交
67 68
	constructor(
		@ITelemetryService telemetryService: ITelemetryService,
69
		@IExtensionGalleryService private galleryService: IExtensionGalleryService,
J
Joao Moreno 已提交
70
		@IExtensionManagementService private extensionService: IExtensionManagementService,
J
Joao Moreno 已提交
71
		@IProgressService private progressService: IProgressService,
J
Joao Moreno 已提交
72
		@IInstantiationService private instantiationService: IInstantiationService,
73
		@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
74
		@IEditorGroupService private editorInputService: IEditorGroupService,
J
Joao Moreno 已提交
75
		@IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService,
J
Joao Moreno 已提交
76
		@IExtensionTipsService private tipsService: IExtensionTipsService,
77 78
		@IMessageService private messageService: IMessageService,
		@IViewletService private viewletService: IViewletService
J
Joao Moreno 已提交
79
	) {
J
Joao Moreno 已提交
80
		super(VIEWLET_ID, telemetryService);
J
Joao Moreno 已提交
81
		this.searchDelayer = new ThrottledDelayer(500);
J
Joao Moreno 已提交
82

83
		this.disposables.push(viewletService.onDidViewletOpen(this.onViewletOpen, this, this.disposables));
J
Joao Moreno 已提交
84 85 86 87
	}

	create(parent: Builder): TPromise<void> {
		super.create(parent);
J
Joao Moreno 已提交
88 89 90
		parent.addClass('extensions-viewlet');
		this.root = parent.getHTMLElement();

J
Joao Moreno 已提交
91 92 93 94
		const header = append(this.root, $('.header'));

		this.searchBox = append(header, $<HTMLInputElement>('input.search-box'));
		this.searchBox.placeholder = localize('searchExtensions', "Search Extensions in Marketplace");
I
isidor 已提交
95 96
		this.disposables.push(addStandardDisposableListener(this.searchBox, EventType.FOCUS, () => addClass(this.searchBox, 'synthetic-focus')));
		this.disposables.push(addStandardDisposableListener(this.searchBox, EventType.BLUR, () => removeClass(this.searchBox, 'synthetic-focus')));
J
Joao Moreno 已提交
97

J
Joao Moreno 已提交
98
		this.extensionsBox = append(this.root, $('.extensions'));
J
Joao Moreno 已提交
99
		this.messageBox = append(this.root, $('.message'));
J
Joao Moreno 已提交
100 101

		const delegate = new Delegate();
102
		const renderer = this.instantiationService.createInstance(Renderer);
J
Joao Moreno 已提交
103
		this.list = new PagedList(this.extensionsBox, delegate, [renderer]);
J
Joao Moreno 已提交
104

J
Joao Moreno 已提交
105 106 107 108 109 110 111 112 113
		const onKeyDown = chain(domEvent(this.searchBox, 'keydown'))
			.map(e => new StandardKeyboardEvent(e));

		onKeyDown.filter(e => e.keyCode === KeyCode.Enter).on(this.onEnter, this, this.disposables);
		onKeyDown.filter(e => e.keyCode === KeyCode.Escape).on(this.onEscape, this, this.disposables);
		onKeyDown.filter(e => e.keyCode === KeyCode.UpArrow).on(this.onUpArrow, this, this.disposables);
		onKeyDown.filter(e => e.keyCode === KeyCode.DownArrow).on(this.onDownArrow, this, this.disposables);
		onKeyDown.filter(e => e.keyCode === KeyCode.PageUp).on(this.onPageUpArrow, this, this.disposables);
		onKeyDown.filter(e => e.keyCode === KeyCode.PageDown).on(this.onPageDownArrow, this, this.disposables);
J
Joao Moreno 已提交
114

115 116 117 118
		const onSearchInput = domEvent(this.searchBox, 'input') as EventOf<SearchInputEvent>;
		onSearchInput(e => this.triggerSearch(e.target.value, e.immediate), null, this.disposables);

		this.onSearchChange = mapEvent(onSearchInput, e => e.target.value);
J
Joao Moreno 已提交
119

J
Joao Moreno 已提交
120 121 122
		chain(this.list.onSelectionChange)
			.map(e => e.elements[0])
			.filter(e => !!e)
123
			.on(this.openExtension, this, this.disposables);
J
Joao Moreno 已提交
124

J
Joao Moreno 已提交
125 126 127
		return TPromise.as(null);
	}

J
Johannes Rieken 已提交
128
	setVisible(visible: boolean): TPromise<void> {
J
Joao Moreno 已提交
129 130
		return super.setVisible(visible).then(() => {
			if (visible) {
J
Joao Moreno 已提交
131
				this.searchBox.focus();
132 133
				this.searchBox.setSelectionRange(0, this.searchBox.value.length);
				this.triggerSearch(this.searchBox.value, true, true);
J
Joao Moreno 已提交
134
			} else {
J
Joao Moreno 已提交
135
				this.setModel(new PagedModel([]));
J
Joao Moreno 已提交
136 137
			}
		});
J
Joao Moreno 已提交
138 139 140
	}

	focus(): void {
J
Joao Moreno 已提交
141
		this.searchBox.focus();
J
Joao Moreno 已提交
142 143
	}

J
Johannes Rieken 已提交
144
	layout({ height, width }: Dimension): void {
J
Joao Moreno 已提交
145
		this.list.layout(height - 38);
J
Joao Moreno 已提交
146 147 148 149 150
		toggleClass(this.root, 'narrow', width <= 300);
	}

	getOptimalWidth(): number {
		return 400;
J
Joao Moreno 已提交
151 152
	}

J
Joao Moreno 已提交
153
	getActions(): IAction[] {
J
Joao Moreno 已提交
154 155 156 157
		if (!this.primaryActions) {
			this.primaryActions = [
				this.instantiationService.createInstance(ClearExtensionsInputAction, ClearExtensionsInputAction.ID, ClearExtensionsInputAction.LABEL, this.onSearchChange)
			];
158 159
		}

J
Joao Moreno 已提交
160
		return this.primaryActions;
J
Joao Moreno 已提交
161 162
	}

163
	getSecondaryActions(): IAction[] {
J
Joao Moreno 已提交
164 165
		if (!this.secondaryActions) {
			this.secondaryActions = [
166
				this.instantiationService.createInstance(UpdateAllAction, UpdateAllAction.ID, UpdateAllAction.LABEL),
J
Joao Moreno 已提交
167
				new Separator(),
J
Joao Moreno 已提交
168 169
				this.instantiationService.createInstance(ShowInstalledExtensionsAction, ShowInstalledExtensionsAction.ID, ShowInstalledExtensionsAction.LABEL),
				this.instantiationService.createInstance(ShowOutdatedExtensionsAction, ShowOutdatedExtensionsAction.ID, ShowOutdatedExtensionsAction.LABEL),
170
				this.instantiationService.createInstance(ShowDisabledExtensionsAction, ShowDisabledExtensionsAction.ID, ShowDisabledExtensionsAction.LABEL),
J
Joao Moreno 已提交
171
				this.instantiationService.createInstance(ShowRecommendedExtensionsAction, ShowRecommendedExtensionsAction.ID, ShowRecommendedExtensionsAction.LABEL),
S
Sandeep Somavarapu 已提交
172
				this.instantiationService.createInstance(ShowWorkspaceRecommendedExtensionsAction, ShowWorkspaceRecommendedExtensionsAction.ID, ShowWorkspaceRecommendedExtensionsAction.LABEL),
J
Joao Moreno 已提交
173 174
				this.instantiationService.createInstance(ShowPopularExtensionsAction, ShowPopularExtensionsAction.ID, ShowPopularExtensionsAction.LABEL),
				new Separator(),
J
Joao Moreno 已提交
175 176
				this.instantiationService.createInstance(ChangeSortAction, 'extensions.sort.install', localize('sort by installs', "Sort By: Install Count"), this.onSearchChange, 'installs', undefined),
				this.instantiationService.createInstance(ChangeSortAction, 'extensions.sort.rating', localize('sort by rating', "Sort By: Rating"), this.onSearchChange, 'rating', undefined),
J
Joao Moreno 已提交
177
				new Separator(),
J
Joao Moreno 已提交
178
				this.instantiationService.createInstance(ChangeSortAction, 'extensions.sort..asc', localize('ascending', "Sort Order: ↑"), this.onSearchChange, undefined, 'asc'),
J
Joao Moreno 已提交
179 180
				this.instantiationService.createInstance(ChangeSortAction, 'extensions.sort..desc', localize('descending', "Sort Order: ↓"), this.onSearchChange, undefined, 'desc'),
				new Separator(),
181 182 183 184 185 186
				this.instantiationService.createInstance(DisableAllAction, DisableAllAction.ID, DisableAllAction.LABEL),
				this.instantiationService.createInstance(DisableAllWorkpsaceAction, DisableAllWorkpsaceAction.ID, DisableAllWorkpsaceAction.LABEL),
				new Separator(),
				this.instantiationService.createInstance(EnableAllAction, EnableAllAction.ID, EnableAllAction.LABEL),
				this.instantiationService.createInstance(EnableAllWorkpsaceAction, EnableAllWorkpsaceAction.ID, EnableAllWorkpsaceAction.LABEL),
				new Separator(),
187 188
				this.instantiationService.createInstance(InstallVSIXAction, InstallVSIXAction.ID, InstallVSIXAction.LABEL),
				this.instantiationService.createInstance(ConfigureWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceRecommendedExtensionsAction.ID, ConfigureWorkspaceRecommendedExtensionsAction.LABEL)
J
Joao Moreno 已提交
189 190 191 192
			];
		}

		return this.secondaryActions;
193 194
	}

J
Joao Moreno 已提交
195 196 197 198 199 200 201 202 203 204 205 206 207 208
	private setModel(model: IPagedModel<IExtension>) {
		this.list.model = model;
		this.list.scrollTop = 0;

		toggleClass(this.extensionsBox, 'hidden', model.length === 0);
		toggleClass(this.messageBox, 'hidden', model.length > 0);

		if (model.length === 0 && this.isVisible()) {
			this.messageBox.textContent = localize('no extensions found', "No extensions found.");
		} else {
			this.messageBox.textContent = '';
		}
	}

209
	search(value: string): void {
210
		const event = new Event('input', { bubbles: true }) as SearchInputEvent;
211
		event.immediate = true;
212 213 214

		this.searchBox.value = value;
		this.searchBox.dispatchEvent(event);
J
Joao Moreno 已提交
215 216
	}

217
	private triggerSearch(value: string, immediate = false, suggestPopular = false): void {
J
Joao Moreno 已提交
218 219
		this.searchDelayer.trigger(() => this.doSearch(value, suggestPopular), immediate || !value ? 0 : 500)
			.done(null, err => this.onError(err));
J
Joao Moreno 已提交
220 221
	}

222
	private doSearch(value: string = '', suggestPopular = false): TPromise<any> {
223 224 225
		return this.progress(this.query(value))
			.then(model => {
				if (!value && model.length === 0 && suggestPopular) {
226
					return this.search('@sort:installs');
227 228
				}

J
Joao Moreno 已提交
229
				this.setModel(model);
230 231 232
			});
	}

J
Joao Moreno 已提交
233
	private query(value: string): TPromise<IPagedModel<IExtension>> {
234 235 236
		if (!value) {
			// Show installed extensions
			return this.extensionsWorkbenchService.queryLocal()
237
				.then(result => result.sort((e1, e2) => e1.displayName.localeCompare(e2.displayName)))
238 239 240
				.then(result => result.filter(e => e.type === LocalExtensionType.User))
				.then(result => new PagedModel(result));
		}
241

242 243
		if (/@outdated/i.test(value)) {
			return this.extensionsWorkbenchService.queryLocal()
244
				.then(extensions => extensions.filter(extension => extension.outdated))
245
				.then(result => new PagedModel(result));
246
		}
247

248 249
		if (/@disabled/i.test(value)) {
			return this.extensionsWorkbenchService.queryLocal()
250
				.then(result => result.filter(e => e.state === ExtensionState.Disabled))
251 252 253
				.then(result => new PagedModel(result));
		}

J
Joao Moreno 已提交
254
		const query = Query.parse(value);
255 256
		let options: IQueryOptions = {};

J
Johannes Rieken 已提交
257
		switch (query.sortBy) {
J
Joao Moreno 已提交
258 259 260 261 262 263 264 265 266
			case 'installs': options = assign(options, { sortBy: SortBy.InstallCount }); break;
			case 'rating': options = assign(options, { sortBy: SortBy.AverageRating }); break;
		}

		switch (query.sortOrder) {
			case 'asc': options = assign(options, { sortOrder: SortOrder.Ascending }); break;
			case 'desc': options = assign(options, { sortOrder: SortOrder.Descending }); break;
		}

S
Sandeep Somavarapu 已提交
267
		if (/@recommended:workspace/i.test(query.value)) {
268 269 270
			return this.getWorkspaceRecommendationsModel(query, options);
		} else if (/@recommended/i.test(query.value)) {
			return this.getRecommendationsModel(query, options);
J
Joao Moreno 已提交
271 272
		}

J
Joao Moreno 已提交
273
		if (query.value) {
274
			options = assign(options, { text: query.value.substr(0, 200) });
J
Joao Moreno 已提交
275
		}
276 277 278

		return this.extensionsWorkbenchService.queryGallery(options)
			.then(result => new PagedModel(result));
J
Joao Moreno 已提交
279 280
	}

J
Joao Moreno 已提交
281
	private getRecommendationsModel(query: Query, options: IQueryOptions): TPromise<IPagedModel<IExtension>> {
282 283 284 285 286 287
		const value = query.value.replace(/@recommended/g, '').trim().toLowerCase();

		return this.extensionsWorkbenchService.queryLocal()
			.then(result => result.filter(e => e.type === LocalExtensionType.User))
			.then(local => {
				const names = this.tipsService.getRecommendations()
J
Johannes Rieken 已提交
288
					.filter(name => local.every(ext => `${ext.publisher}.${ext.name}` !== name))
289 290 291 292 293
					.filter(name => name.toLowerCase().indexOf(value) > -1);

				this.telemetryService.publicLog('extensionRecommendations:open', { count: names.length });

				if (!names.length) {
J
Joao Moreno 已提交
294
					return TPromise.as(new PagedModel([]));
295 296 297 298 299 300 301
				}

				return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }))
					.then(result => new PagedModel(result));
			});
	}

J
Joao Moreno 已提交
302
	private getWorkspaceRecommendationsModel(query: Query, options: IQueryOptions): TPromise<IPagedModel<IExtension>> {
303 304 305
		const value = query.value.replace(/@recommended:workspace/g, '').trim().toLowerCase();
		const names = this.tipsService.getWorkspaceRecommendations()
			.filter(name => name.toLowerCase().indexOf(value) > -1);
306 307 308

		this.telemetryService.publicLog('extensionWorkspaceRecommendations:open', { count: names.length });

S
Sandeep Somavarapu 已提交
309 310 311
		if (!names.length) {
			return TPromise.as(new PagedModel([]));
		}
312 313 314

		return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }))
			.then(result => new PagedModel(result));
S
Sandeep Somavarapu 已提交
315 316
	}

317 318 319 320
	private openExtension(extension: IExtension): void {
		this.extensionsWorkbenchService.open(extension).done(null, err => this.onError(err));
	}

J
Joao Moreno 已提交
321 322 323 324 325
	private onEnter(): void {
		this.list.setSelection(...this.list.getFocus());
	}

	private onEscape(): void {
326
		this.search('');
J
Joao Moreno 已提交
327 328 329 330
	}

	private onUpArrow(): void {
		this.list.focusPrevious();
J
Joao Moreno 已提交
331
		this.list.reveal(this.list.getFocus()[0]);
J
Joao Moreno 已提交
332 333 334 335
	}

	private onDownArrow(): void {
		this.list.focusNext();
J
Joao Moreno 已提交
336
		this.list.reveal(this.list.getFocus()[0]);
J
Joao Moreno 已提交
337 338
	}

J
Joao Moreno 已提交
339 340 341 342 343 344 345 346 347 348
	private onPageUpArrow(): void {
		this.list.focusPreviousPage();
		this.list.reveal(this.list.getFocus()[0]);
	}

	private onPageDownArrow(): void {
		this.list.focusNextPage();
		this.list.reveal(this.list.getFocus()[0]);
	}

349 350 351 352 353
	private progress<T>(promise: TPromise<T>): TPromise<T> {
		const progressRunner = this.progressService.show(true);
		return always(promise, () => progressRunner.done());
	}

354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
	private onViewletOpen(viewlet: IViewlet): void {
		if (!viewlet || viewlet.getId() === VIEWLET_ID) {
			return;
		}

		const model = this.editorInputService.getStacksModel();

		const promises = model.groups.map(group => {
			const position = model.positionOfGroup(group);
			const inputs = group.getEditors().filter(input => input instanceof ExtensionsInput);
			const promises = inputs.map(input => this.editorService.closeEditor(position, input));

			return TPromise.join(promises);
		});

		TPromise.join(promises).done(null, onUnexpectedError);
	}

J
Joao Moreno 已提交
372 373 374 375 376 377 378
	private onError(err: any): void {
		if (isPromiseCanceledError(err)) {
			return;
		}

		const message = err && err.message || '';

J
Joao Moreno 已提交
379
		if (/ECONNREFUSED/.test(message)) {
J
Joao Moreno 已提交
380 381
			const error = createError(localize('suggestProxyError', "Marketplace returned 'ECONNREFUSED'. Please check the 'http.proxy' setting."), {
				actions: [
382 383
					this.instantiationService.createInstance(OpenGlobalSettingsAction, OpenGlobalSettingsAction.ID, OpenGlobalSettingsAction.LABEL),
					CloseAction
J
Joao Moreno 已提交
384 385 386 387 388 389 390 391 392 393
				]
			});

			this.messageService.show(Severity.Error, error);
			return;
		}

		this.messageService.show(Severity.Error, err);
	}

J
Joao Moreno 已提交
394
	dispose(): void {
J
Joao Moreno 已提交
395
		this.disposables = dispose(this.disposables);
J
Joao Moreno 已提交
396 397 398
		super.dispose();
	}
}
J
Joao Moreno 已提交
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420

export class StatusUpdater implements IWorkbenchContribution {

	private disposables: IDisposable[];

	constructor(
		@IActivityService private activityService: IActivityService,
		@IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService
	) {
		extensionsWorkbenchService.onChange(this.onServiceChange, this, this.disposables);
	}

	getId(): string {
		return 'vs.extensions.statusupdater';
	}

	private onServiceChange(): void {
		if (this.extensionsWorkbenchService.local.some(e => e.state === ExtensionState.Installing)) {
			this.activityService.showActivity(VIEWLET_ID, new ProgressBadge(() => localize('extensions', 'Extensions')), 'extensions-badge progress-badge');
			return;
		}

421 422 423 424 425 426 427
		const outdated = this.extensionsWorkbenchService.local.reduce((r, e) => r + (e.outdated ? 1 : 0), 0);
		if (outdated > 0) {
			const badge = new NumberBadge(outdated, n => localize('outdatedExtensions', '{0} Outdated Extensions', n));
			this.activityService.showActivity(VIEWLET_ID, badge, 'extensions-badge count-badge');
		} else {
			this.activityService.showActivity(VIEWLET_ID, null, 'extensions-badge');
		}
J
Joao Moreno 已提交
428 429 430 431 432 433
	}

	dispose(): void {
		this.disposables = dispose(this.disposables);
	}
}