diff --git a/src/vs/workbench/parts/extensions/browser/extensionsActions.ts b/src/vs/workbench/parts/extensions/browser/extensionsActions.ts index 853830a99a433..15e3b882403a7 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionsActions.ts @@ -1020,10 +1020,6 @@ export class ShowOutdatedExtensionsAction extends Action { viewlet.focus(); }); } - - protected isEnabled(): boolean { - return true; - } } export class ShowPopularExtensionsAction extends Action { @@ -1047,10 +1043,6 @@ export class ShowPopularExtensionsAction extends Action { viewlet.focus(); }); } - - protected isEnabled(): boolean { - return true; - } } export class ShowRecommendedExtensionsAction extends Action { @@ -1074,10 +1066,6 @@ export class ShowRecommendedExtensionsAction extends Action { viewlet.focus(); }); } - - protected isEnabled(): boolean { - return true; - } } export class InstallWorkspaceRecommendedExtensionsAction extends Action { @@ -1151,10 +1139,6 @@ export class InstallWorkspaceRecommendedExtensionsAction extends Action { }); } - protected isEnabled(): boolean { - return this.enabled; - } - dispose(): void { this.disposables = dispose(this.disposables); super.dispose(); @@ -1167,6 +1151,7 @@ export class InstallRecommendedExtensionAction extends Action { static LABEL = localize('installRecommendedExtension', "Install Recommended Extension"); private extensionId: string; + private disposables: IDisposable[] = []; constructor( extensionId: string, @@ -1176,6 +1161,11 @@ export class InstallRecommendedExtensionAction extends Action { ) { super(InstallRecommendedExtensionAction.ID, InstallRecommendedExtensionAction.LABEL, null); this.extensionId = extensionId; + this.extensionsWorkbenchService.onChange(() => this.update(), this, this.disposables); + } + + private update(): void { + this.enabled = !this.extensionsWorkbenchService.local.some(x => x.id.toLowerCase() === this.extensionId.toLowerCase()); } run(): TPromise { @@ -1198,11 +1188,8 @@ export class InstallRecommendedExtensionAction extends Action { }); } - protected isEnabled(): boolean { - return !this.extensionsWorkbenchService.local.some(x => x.id.toLowerCase() === this.extensionId.toLowerCase()); - } - dispose(): void { + this.disposables = dispose(this.disposables); super.dispose(); } } @@ -1211,7 +1198,6 @@ export class InstallRecommendedExtensionAction extends Action { export class ShowRecommendedKeymapExtensionsAction extends Action { static ID = 'workbench.extensions.action.showRecommendedKeymapExtensions'; - static LABEL = localize('showRecommendedKeymapExtensions', "Show Recommended Keymaps"); static SHORT_LABEL = localize('showRecommendedKeymapExtensionsShort', "Keymaps"); constructor( @@ -1230,16 +1216,11 @@ export class ShowRecommendedKeymapExtensionsAction extends Action { viewlet.focus(); }); } - - protected isEnabled(): boolean { - return true; - } } export class ShowLanguageExtensionsAction extends Action { static ID = 'workbench.extensions.action.showLanguageExtensions'; - static LABEL = localize('showLanguageExtensions', "Show Language Extensions"); static SHORT_LABEL = localize('showLanguageExtensionsShort', "Language Extensions"); constructor( @@ -1258,16 +1239,11 @@ export class ShowLanguageExtensionsAction extends Action { viewlet.focus(); }); } - - protected isEnabled(): boolean { - return true; - } } export class ShowAzureExtensionsAction extends Action { static ID = 'workbench.extensions.action.showAzureExtensions'; - static LABEL = localize('showAzureExtensions', "Show Azure Extensions"); static SHORT_LABEL = localize('showAzureExtensionsShort', "Azure Extensions"); constructor( @@ -1286,10 +1262,6 @@ export class ShowAzureExtensionsAction extends Action { viewlet.focus(); }); } - - protected isEnabled(): boolean { - return true; - } } export class ChangeSortAction extends Action { @@ -1329,10 +1301,6 @@ export class ChangeSortAction extends Action { viewlet.focus(); }); } - - protected isEnabled(): boolean { - return true; - } } interface IExtensionsContent {