Skip to content

Commit

Permalink
#194188 enable skip updates action on all installed extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Nov 21, 2023
1 parent 633efd8 commit bd434ab
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ export class InstallGalleryExtensionTask extends InstallExtensionTask {
updated: !!existingExtension,
isPreReleaseVersion: this.gallery.properties.isPreReleaseVersion,
installedTimestamp: Date.now(),
pinned: this.options.installGivenVersion ? true : undefined,
pinned: this.options.installGivenVersion ? true : existingExtension?.pinned,
preRelease: this.gallery.properties.isPreReleaseVersion ||
(isBoolean(this.options.installPreReleaseVersion)
? this.options.installPreReleaseVersion /* Respect the passed flag */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { IExtensionIgnoredRecommendationsService, IExtensionRecommendationsServi
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { VIEWLET_ID, IExtensionsWorkbenchService, IExtensionsViewPaneContainer, TOGGLE_IGNORE_EXTENSION_ACTION_ID, INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, WORKSPACE_RECOMMENDATIONS_VIEW_ID, IWorkspaceRecommendedExtensionsView, AutoUpdateConfigurationKey, HasOutdatedExtensionsContext, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID, ExtensionEditorTab, THEME_ACTIONS_GROUP, INSTALL_ACTIONS_GROUP, OUTDATED_EXTENSIONS_VIEW_ID, CONTEXT_HAS_GALLERY, IExtension, extensionsSearchActionsMenu } from 'vs/workbench/contrib/extensions/common/extensions';
import { ReinstallAction, InstallSpecificVersionOfExtensionAction, ConfigureWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction, PromptExtensionInstallFailureAction, SearchExtensionsAction, SwitchToPreReleaseVersionAction, SwitchToReleasedVersionAction, SetColorThemeAction, SetFileIconThemeAction, SetProductIconThemeAction, ClearLanguageAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { ReinstallAction, InstallSpecificVersionOfExtensionAction, ConfigureWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction, PromptExtensionInstallFailureAction, SearchExtensionsAction, SwitchToPreReleaseVersionAction, SwitchToReleasedVersionAction, SetColorThemeAction, SetFileIconThemeAction, SetProductIconThemeAction, ClearLanguageAction, SkipUpdateAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { ExtensionsInput } from 'vs/workbench/contrib/extensions/common/extensionsInput';
import { ExtensionEditor } from 'vs/workbench/contrib/extensions/browser/extensionEditor';
import { StatusUpdater, MaliciousExtensionChecker, ExtensionsViewletViewsContribution, ExtensionsViewPaneContainer, BuiltInExtensionsContext, SearchMarketplaceExtensionsContext, RecommendedExtensionsContext, DefaultViewsContext, ExtensionsSortByContext, SearchHasTextContext } from 'vs/workbench/contrib/extensions/browser/extensionsViewlet';
Expand All @@ -35,7 +35,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { IViewContainersRegistry, ViewContainerLocation, Extensions as ViewContainerExtensions, IViewsService } from 'vs/workbench/common/views';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { ContextKeyExpr, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { ContextKeyDefinedExpr, ContextKeyExpr, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IQuickAccessRegistry, Extensions } from 'vs/platform/quickinput/common/quickAccess';
import { InstallExtensionQuickAccessProvider, ManageExtensionsQuickAccessProvider } from 'vs/workbench/contrib/extensions/browser/extensionsQuickAccess';
import { ExtensionRecommendationsService } from 'vs/workbench/contrib/extensions/browser/extensionRecommendationsService';
Expand Down Expand Up @@ -1297,6 +1297,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
extensionWorkbenchService.open(extension, { showPreReleaseVersion: true });
}
});

this.registerExtensionAction({
id: 'workbench.extensions.action.showReleasedVersion',
title: { value: localize('show released version', "Show Release Version"), original: 'Show Release Version' },
Expand All @@ -1312,6 +1313,30 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
extensionWorkbenchService.open(extension, { showPreReleaseVersion: false });
}
});

this.registerExtensionAction({
id: SkipUpdateAction.ID,
title: { value: SkipUpdateAction.LABEL, original: 'Ignore Updates' },
category: ExtensionsLocalizedLabel,
toggled: ContextKeyDefinedExpr.create('isExtensionPinned'),
menu: {
id: MenuId.ExtensionContext,
group: INSTALL_ACTIONS_GROUP,
order: 2,
when: ContextKeyExpr.and(ContextKeyExpr.equals('extensionStatus', 'installed'), ContextKeyExpr.not('isBuiltinExtension'))
},
run: async (accessor: ServicesAccessor, id: string) => {
const instantiationService = accessor.get(IInstantiationService);
const extensionWorkbenchService = accessor.get(IExtensionsWorkbenchService);
const extension = extensionWorkbenchService.local.find(e => areSameExtensions(e.identifier, { id }));
if (extension) {
const action = instantiationService.createInstance(SkipUpdateAction);
action.extension = extension;
return action.run();
}
}
});

this.registerExtensionAction({
id: SwitchToPreReleaseVersionAction.ID,
title: SwitchToPreReleaseVersionAction.TITLE,
Expand All @@ -1330,6 +1355,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
}
}
});

this.registerExtensionAction({
id: SwitchToReleasedVersionAction.ID,
title: SwitchToReleasedVersionAction.TITLE,
Expand All @@ -1348,6 +1374,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
}
}
});

this.registerExtensionAction({
id: ClearLanguageAction.ID,
title: ClearLanguageAction.TITLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,13 @@ export class UpdateAction extends AbstractUpdateAction {

export class SkipUpdateAction extends AbstractUpdateAction {

static readonly ID = 'workbench.extensions.action.ignoreUpdates';
static readonly LABEL = localize('ignoreUpdates', "Ignore Updates");

constructor(
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService
) {
super(`extensions.ignoreUpdates`, localize('ignoreUpdates', "Ignore Updates"), extensionsWorkbenchService);
super(SkipUpdateAction.ID, SkipUpdateAction.LABEL, extensionsWorkbenchService);
}

override update() {
Expand Down Expand Up @@ -1010,6 +1013,7 @@ async function getContextMenuActionsGroups(extension: IExtension | undefined | n
cksOverlay.push(['galleryExtensionIsPreReleaseVersion', !!extension.gallery?.properties.isPreReleaseVersion]);
cksOverlay.push(['extensionHasPreReleaseVersion', extension.hasPreReleaseVersion]);
cksOverlay.push(['extensionHasReleaseVersion', extension.hasReleaseVersion]);
cksOverlay.push(['isExtensionPinned', extension.pinned]);

const [colorThemes, fileIconThemes, productIconThemes] = await Promise.all([workbenchThemeService.getColorThemes(), workbenchThemeService.getFileIconThemes(), workbenchThemeService.getProductIconThemes()]);
cksOverlay.push(['extensionHasColorThemes', colorThemes.some(theme => isThemeFromExtension(theme, extension))]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class InstallExtensionTask extends AbstractExtensionTask<ILocalExtension> implem
? this.options.installPreReleaseVersion /* Respect the passed flag */
: metadata?.preRelease /* Respect the existing pre-release flag if it was set */);
}
metadata.pinned = this.options.installGivenVersion ? true : undefined;
metadata.pinned = this.options.installGivenVersion ? true : metadata.pinned;

this._profileLocation = metadata.isApplicationScoped ? this.userDataProfilesService.defaultProfile.extensionsResource : this.options.profileLocation;
const scannedExtension = URI.isUri(this.extension) ? await this.webExtensionsScannerService.addExtension(this.extension, metadata, this.profileLocation)
Expand Down

0 comments on commit bd434ab

Please sign in to comment.