command to browse marketplace color themes (#192269)

This commit is contained in:
Martin Aeschlimann
2023-09-06 10:57:28 +02:00
committed by GitHub
parent b737d8f860
commit 4adde92102
@@ -662,6 +662,55 @@ registerAction2(class extends Action2 {
}
});
const browseColorThemesInMarketplaceCommandId = 'workbench.action.browseColorThemesInMarketplace';
registerAction2(class extends Action2 {
constructor() {
super({
id: browseColorThemesInMarketplaceCommandId,
title: { value: localize('browseColorThemeInMarketPlace.label', "Browse Color Themes in Marketplace"), original: 'Browse Color Themes in Marketplace' },
category: Categories.Preferences,
f1: true,
});
}
override async run(accessor: ServicesAccessor) {
const marketplaceTag = 'category:themes';
const themeService = accessor.get(IWorkbenchThemeService);
const extensionGalleryService = accessor.get(IExtensionGalleryService);
const extensionResourceLoaderService = accessor.get(IExtensionResourceLoaderService);
const instantiationService = accessor.get(IInstantiationService);
if (!extensionGalleryService.isEnabled() || !extensionResourceLoaderService.supportsExtensionGalleryResources) {
return;
}
const currentTheme = themeService.getColorTheme();
const getMarketplaceColorThemes = (publisher: string, name: string, version: string) => themeService.getMarketplaceColorThemes(publisher, name, version);
let selectThemeTimeout: number | undefined;
const selectTheme = (theme: IWorkbenchTheme | undefined, applyTheme: boolean) => {
if (selectThemeTimeout) {
clearTimeout(selectThemeTimeout);
}
selectThemeTimeout = window.setTimeout(() => {
selectThemeTimeout = undefined;
const newTheme = (theme ?? currentTheme) as IWorkbenchTheme;
themeService.setColorTheme(newTheme as IWorkbenchColorTheme, applyTheme ? 'auto' : 'preview').then(undefined,
err => {
onUnexpectedError(err);
themeService.setColorTheme(currentTheme, undefined);
}
);
}, applyTheme ? 0 : 200);
};
const marketplaceThemePicker = instantiationService.createInstance(MarketplaceThemesPicker, getMarketplaceColorThemes, marketplaceTag);
await marketplaceThemePicker.openQuickPick('', themeService.getColorTheme(), selectTheme).then(undefined, onUnexpectedError);
}
});
const ThemesSubMenu = new MenuId('ThemesSubMenu');
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, <ISubmenuItem>{
title: localize('themes', "Themes"),