Skip to content

Commit

Permalink
update all extensions
Browse files Browse the repository at this point in the history
fixes #8124
  • Loading branch information
joaomoreno committed Aug 26, 2016
1 parent dcab6a6 commit 7e65ae6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,40 @@ export class EnableAction extends Action {
}
}

export class UpdateAllAction extends Action {

private disposables: IDisposable[] = [];

constructor(
@IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService
) {
super('extensions.update-all', localize('updateAll', "Update All Extensions"), '', false);

this.disposables.push(this.extensionsWorkbenchService.onChange(() => this.update()));
this.update();
}

private get outdated(): IExtension[] {
return this.extensionsWorkbenchService.local
.filter(e => this.extensionsWorkbenchService.canInstall(e)
&& (e.state === ExtensionState.Installed || e.state === ExtensionState.NeedsRestart)
&& e.outdated);
}

private update(): void {
this.enabled = this.outdated.length > 0;
}

run(): TPromise<any> {
return TPromise.join(this.outdated.map(e => this.extensionsWorkbenchService.install(e)));
}

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

export class OpenExtensionsViewletAction extends ToggleViewletAction {

static ID = VIEWLET_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { PagedList } from 'vs/base/browser/ui/list/listPaging';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Delegate, Renderer } from './extensionsList';
import { IExtensionsWorkbenchService, IExtension, IExtensionsViewlet, VIEWLET_ID } from './extensions';
import { ShowRecommendedExtensionsAction, ShowPopularExtensionsAction, ShowInstalledExtensionsAction, ShowOutdatedExtensionsAction, ClearExtensionsInputAction, ChangeSortAction } from './extensionsActions';
import { ShowRecommendedExtensionsAction, ShowPopularExtensionsAction, ShowInstalledExtensionsAction, ShowOutdatedExtensionsAction, ClearExtensionsInputAction, ChangeSortAction, UpdateAllAction } from './extensionsActions';
import { IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService, SortBy, SortOrder, IQueryOptions } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionsInput } from './extensionsInput';
import { Query } from '../common/extensionQuery';
Expand Down Expand Up @@ -153,6 +153,8 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
getSecondaryActions(): IAction[] {
if (!this.secondaryActions) {
this.secondaryActions = [
this.instantiationService.createInstance(UpdateAllAction),
new Separator(),
this.instantiationService.createInstance(ShowInstalledExtensionsAction, ShowInstalledExtensionsAction.ID, ShowInstalledExtensionsAction.LABEL),
this.instantiationService.createInstance(ShowOutdatedExtensionsAction, ShowOutdatedExtensionsAction.ID, ShowOutdatedExtensionsAction.LABEL),
this.instantiationService.createInstance(ShowRecommendedExtensionsAction, ShowRecommendedExtensionsAction.ID, ShowRecommendedExtensionsAction.LABEL),
Expand Down

0 comments on commit 7e65ae6

Please sign in to comment.