Skip to content

Commit

Permalink
Dont update disabled extensions (microsoft#58723)
Browse files Browse the repository at this point in the history
* Dont update disabled extensions microsoft#22461

* Include disabled extensions in update notification and the update button

* Show same msg for badge and check extension updates cmd

* Refactor

* Revert "Refactor"

This reverts commit a68f83f.

* Revert "Show same msg for badge and check extension updates cmd"

This reverts commit 62faecd.
  • Loading branch information
ramya-rao-a authored Sep 20, 2018
1 parent b1dd70f commit 96033fe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -810,15 +810,31 @@ export class CheckForUpdatesAction extends Action {
private checkUpdatesAndNotify(): void {
this.extensionsWorkbenchService.queryLocal().then(
extensions => {
const outdatedCount = extensions.filter(ext => ext.outdated === true).length;
let msgAvailableExtensions = localize('noUpdatesAvailable', "All Extensions are up to date.");
if (outdatedCount > 0) {
msgAvailableExtensions = outdatedCount === 1 ? localize('updateAvailable', "An Extension update is available.")
: localize('updatesAvailable', "{0} extensions updates are available.", outdatedCount);
this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => viewlet.search(''));
const outdatedExtensions = extensions.filter(ext => ext.outdated === true);
if (!outdatedExtensions.length) {
this.notificationService.notify({ severity: severity.Info, message: localize('noUpdatesAvailable', "All Extensions are up to date.") });
return;
}

let msgAvailableExtensions = outdatedExtensions.length === 1 ? localize('singleUpdateAvailable', "An extension update is available.") : localize('updatesAvailable', "{0} extension updates are available.", outdatedExtensions.length);

const disabledExtensionsCount = outdatedExtensions.filter(ext => ext.enablementState === EnablementState.Disabled || ext.enablementState === EnablementState.WorkspaceDisabled).length;
if (disabledExtensionsCount) {
if (outdatedExtensions.length === 1) {
msgAvailableExtensions = localize('singleDisabledUpdateAvailable', "An update to an extension which is disabled is available.");
} else if (disabledExtensionsCount === 1) {
msgAvailableExtensions = localize('updatesAvailableOneDisabled', "{0} extension updates are available. One of them is for a disabled extension.", outdatedExtensions.length);
} else if (disabledExtensionsCount === outdatedExtensions.length) {
msgAvailableExtensions = localize('updatesAvailableAllDisabled', "{0} extension updates are available. All of them are for disabled extensions.", outdatedExtensions.length);
} else {
msgAvailableExtensions = localize('updatesAvailableIncludingDisabled', "{0} extension updates are available. {1} of them are for disabled extensions.", outdatedExtensions.length, disabledExtensionsCount);
}
}

this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => viewlet.search(''));

this.notificationService.notify({ severity: severity.Info, message: msgAvailableExtensions });
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ShowOutdatedExtensionsAction, ClearExtensionsInputAction, ChangeSortAction, UpdateAllAction, CheckForUpdatesAction, DisableAllAction, EnableAllAction,
EnableAutoUpdateAction, DisableAutoUpdateAction, ShowBuiltInExtensionsAction, InstallVSIXAction, ChangeGroupAction
} from 'vs/workbench/parts/extensions/electron-browser/extensionsActions';
import { LocalExtensionType, IExtensionManagementService, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/platform/extensionManagement/common/extensionManagement';
import { LocalExtensionType, IExtensionManagementService, IExtensionManagementServerService, IExtensionManagementServer, EnablementState } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
import { ExtensionsListView, EnabledExtensionsView, DisabledExtensionsView, RecommendedExtensionsView, WorkspaceRecommendedExtensionsView, BuiltInExtensionsView, BuiltInThemesExtensionsView, BuiltInBasicsExtensionsView, GroupByServerExtensionsView, DefaultRecommendedExtensionsView } from './extensionsViews';
import { OpenGlobalSettingsAction } from 'vs/workbench/parts/preferences/browser/preferencesActions';
Expand Down Expand Up @@ -537,7 +537,7 @@ export class StatusUpdater implements IWorkbenchContribution {
return;
}

const outdated = this.extensionsWorkbenchService.local.reduce((r, e) => r + (e.outdated ? 1 : 0), 0);
const outdated = this.extensionsWorkbenchService.local.reduce((r, e) => r + (e.outdated && e.enablementState !== EnablementState.Disabled && e.enablementState !== EnablementState.WorkspaceDisabled ? 1 : 0), 0);
if (outdated > 0) {
const badge = new NumberBadge(outdated, n => localize('outdatedExtensions', '{0} Outdated Extensions', n));
this.badgeHandle = this.activityService.showActivity(VIEWLET_ID, badge, 'extensions-badge count-badge');
Expand Down

0 comments on commit 96033fe

Please sign in to comment.