mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Apply extension to all profiles (#187767)
Apply extension to all profiles #157492
This commit is contained in:
committed by
GitHub
parent
4bacd64925
commit
3881831877
@@ -1442,6 +1442,24 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
|
||||
}
|
||||
});
|
||||
|
||||
this.registerExtensionAction({
|
||||
id: 'workbench.extensions.action.toggleApplyToAllProfiles',
|
||||
title: { value: localize('workbench.extensions.action.toggleApplyToAllProfiles', "Apply this Extension to all Profiles"), original: `Apply this Extension to all Profiles` },
|
||||
toggled: ContextKeyExpr.has('isApplicationScopedExtension'),
|
||||
menu: {
|
||||
id: MenuId.ExtensionContext,
|
||||
group: '2_configure',
|
||||
when: ContextKeyExpr.and(ContextKeyExpr.equals('extensionStatus', 'installed'), ContextKeyExpr.has('isDefaultApplicationScopedExtension').negate()),
|
||||
order: 4
|
||||
},
|
||||
run: async (accessor: ServicesAccessor, id: string) => {
|
||||
const extension = this.extensionsWorkbenchService.local.find(e => areSameExtensions({ id }, e.identifier));
|
||||
if (extension) {
|
||||
return this.extensionsWorkbenchService.toggleApplyExtensionToAllProfiles(extension);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.registerExtensionAction({
|
||||
id: 'workbench.extensions.action.ignoreRecommendation',
|
||||
title: { value: localize('workbench.extensions.action.ignoreRecommendation', "Ignore Recommendation"), original: `Ignore Recommendation` },
|
||||
|
||||
@@ -18,7 +18,7 @@ import { IGalleryExtension, IExtensionGalleryService, ILocalExtension, InstallOp
|
||||
import { IWorkbenchExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionRecommendationReason, IExtensionIgnoredRecommendationsService, IExtensionRecommendationsService } from 'vs/workbench/services/extensionRecommendations/common/extensionRecommendations';
|
||||
import { areSameExtensions, getExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { ExtensionType, ExtensionIdentifier, IExtensionDescription, IExtensionManifest, isLanguagePackExtension, getWorkspaceSupportTypeMessage, TargetPlatform } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtensionType, ExtensionIdentifier, IExtensionDescription, IExtensionManifest, isLanguagePackExtension, getWorkspaceSupportTypeMessage, TargetPlatform, isApplicationScopedExtension } from 'vs/platform/extensions/common/extensions';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IFileService, IFileContent } from 'vs/platform/files/common/files';
|
||||
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
@@ -1010,6 +1010,8 @@ async function getContextMenuActionsGroups(extension: IExtension | undefined | n
|
||||
if (extension) {
|
||||
cksOverlay.push(['extension', extension.identifier.id]);
|
||||
cksOverlay.push(['isBuiltinExtension', extension.isBuiltin]);
|
||||
cksOverlay.push(['isDefaultApplicationScopedExtension', extension.local && isApplicationScopedExtension(extension.local.manifest)]);
|
||||
cksOverlay.push(['isApplicationScopedExtension', extension.local && extension.local.isApplicationScoped]);
|
||||
cksOverlay.push(['extensionHasConfiguration', extension.local && !!extension.local.manifest.contributes && !!extension.local.manifest.contributes.configuration]);
|
||||
cksOverlay.push(['extensionHasKeybindings', extension.local && !!extension.local.manifest.contributes && !!extension.local.manifest.contributes.keybindings]);
|
||||
cksOverlay.push(['extensionHasCommands', extension.local && !!extension.local.manifest.contributes && !!extension.local.manifest.contributes?.commands]);
|
||||
@@ -1179,6 +1181,8 @@ export class MenuItemExtensionAction extends ExtensionAction {
|
||||
}
|
||||
if (this.action.id === TOGGLE_IGNORE_EXTENSION_ACTION_ID) {
|
||||
this.checked = !this.extensionsWorkbenchService.isExtensionIgnoredToSync(this.extension);
|
||||
} else {
|
||||
this.checked = this.action.checked;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import * as resources from 'vs/base/common/resources';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IExtensionManifest, ExtensionType, IExtension as IPlatformExtension, TargetPlatform, ExtensionIdentifier, IExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { IExtensionManifest, ExtensionType, IExtension as IPlatformExtension, TargetPlatform, ExtensionIdentifier, IExtensionIdentifier, IExtensionDescription, isApplicationScopedExtension } from 'vs/platform/extensions/common/extensions';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
@@ -50,6 +50,7 @@ import { getLocale } from 'vs/platform/languagePacks/common/languagePacks';
|
||||
import { ILocaleService } from 'vs/workbench/services/localization/common/locale';
|
||||
import { TelemetryTrustedValue } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
|
||||
|
||||
interface IExtensionStateProvider<T> {
|
||||
(extension: Extension): T;
|
||||
@@ -774,6 +775,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
@ILocaleService private readonly localeService: ILocaleService,
|
||||
@ILifecycleService private readonly lifecycleService: ILifecycleService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
|
||||
) {
|
||||
super();
|
||||
const preferPreReleasesValue = configurationService.getValue('_extensions.preferPreReleases');
|
||||
@@ -1619,6 +1621,12 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
await this.userDataAutoSyncService.triggerSync(['IgnoredExtensionsUpdated'], false, false);
|
||||
}
|
||||
|
||||
async toggleApplyExtensionToAllProfiles(extension: IExtension): Promise<void> {
|
||||
if (extension.local && !isApplicationScopedExtension(extension.local.manifest)) {
|
||||
await this.extensionManagementService.updateMetadata(extension.local, { isApplicationScoped: !extension.local.isApplicationScoped }, this.userDataProfilesService.defaultProfile.extensionsResource);
|
||||
}
|
||||
}
|
||||
|
||||
private isInstalledExtensionSynced(extension: ILocalExtension): boolean {
|
||||
if (extension.isMachineScoped) {
|
||||
return false;
|
||||
|
||||
@@ -120,6 +120,7 @@ export interface IExtensionsWorkbenchService {
|
||||
// Sync APIs
|
||||
isExtensionIgnoredToSync(extension: IExtension): boolean;
|
||||
toggleExtensionIgnoredToSync(extension: IExtension): Promise<void>;
|
||||
toggleApplyExtensionToAllProfiles(extension: IExtension): Promise<void>;
|
||||
}
|
||||
|
||||
export const enum ExtensionEditorTab {
|
||||
|
||||
@@ -153,10 +153,10 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
|
||||
return Promise.reject(`Invalid location ${extension.location.toString()}`);
|
||||
}
|
||||
|
||||
updateMetadata(extension: ILocalExtension, metadata: Partial<Metadata>): Promise<ILocalExtension> {
|
||||
updateMetadata(extension: ILocalExtension, metadata: Partial<Metadata>, profileLocation?: URI): Promise<ILocalExtension> {
|
||||
const server = this.getServer(extension);
|
||||
if (server) {
|
||||
return server.extensionManagementService.updateMetadata(extension, metadata);
|
||||
return server.extensionManagementService.updateMetadata(extension, metadata, profileLocation);
|
||||
}
|
||||
return Promise.reject(`Invalid location ${extension.location.toString()}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user