feat:插件侧边栏'Kylin-IDE推荐插件'列表视图标题中添加筛选和清除筛选按钮.

This commit is contained in:
chriswang521 2024-06-13 15:33:42 +08:00 committed by wangpenglong
parent d5a0761e1f
commit 6263df6635
1 changed files with 45 additions and 2 deletions

View File

@ -13,7 +13,7 @@ import { EnablementState, IExtensionManagementServerService, IWorkbenchExtension
import { IExtensionIgnoredRecommendationsService, IExtensionRecommendationsService } from 'vs/workbench/services/extensionRecommendations/common/extensionRecommendations';
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, UPDATE_ACTIONS_GROUP } from 'vs/workbench/contrib/extensions/common/extensions';
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, UPDATE_ACTIONS_GROUP, WORKSPACE_KYLINIDETEAM_VIEW_ID, IWorkspaceKylinIDETeamExtensionsView } from 'vs/workbench/contrib/extensions/common/extensions';
import { ReinstallAction, InstallSpecificVersionOfExtensionAction, ConfigureWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction, PromptExtensionInstallFailureAction, SearchExtensionsAction, SwitchToPreReleaseVersionAction, SwitchToReleasedVersionAction, SetColorThemeAction, SetFileIconThemeAction, SetProductIconThemeAction, ClearLanguageAction, ToggleAutoUpdateForExtensionAction, ToggleAutoUpdatesForPublisherAction } 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';
@ -57,7 +57,7 @@ import { IWorkspaceExtensionsConfigService } from 'vs/workbench/services/extensi
import { Schemas } from 'vs/base/common/network';
import { ShowRuntimeExtensionsAction } from 'vs/workbench/contrib/extensions/browser/abstractRuntimeExtensionsEditor';
import { ExtensionEnablementWorkspaceTrustTransitionParticipant } from 'vs/workbench/contrib/extensions/browser/extensionEnablementWorkspaceTrustTransitionParticipant';
import { clearSearchResultsIcon, configureRecommendedIcon, extensionsViewIcon, filterIcon, installWorkspaceRecommendedIcon, refreshIcon } from 'vs/workbench/contrib/extensions/browser/extensionsIcons';
import { clearSearchResultsIcon, configureRecommendedIcon, extensionsViewIcon, filterIcon, installWorkspaceRecommendedIcon, kylinIdeExtensionsFilterIcon, kylinIdeExtensionsResetIcon, refreshIcon } from 'vs/workbench/contrib/extensions/browser/extensionsIcons';
import { EXTENSION_CATEGORIES } from 'vs/platform/extensions/common/extensions';
import { Disposable, DisposableStore, IDisposable, isDisposable } from 'vs/base/common/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@ -1259,6 +1259,49 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
// }
// });
const kylinIdeExtensionsFilterSubMenu = new MenuId('kylinIdeExtensionsFilterSubMenu');
MenuRegistry.appendMenuItem(MenuId.ViewTitle, <ISubmenuItem>{
submenu: kylinIdeExtensionsFilterSubMenu,
title: localize('filterExtensions', "Filter Extensions..."),
when: ContextKeyExpr.equals('view', WORKSPACE_KYLINIDETEAM_VIEW_ID),
group: 'navigation',
order: 2,
icon: kylinIdeExtensionsFilterIcon,
});
Object.entries(extensionKylinCategories).forEach(([categoryKey, category], index) => {
this.registerExtensionAction({
id: `extensions.actions.kylinIdeExtensionsByCategory.${categoryKey}`,
title: category,
menu: [{
id: kylinIdeExtensionsFilterSubMenu,
when: CONTEXT_HAS_GALLERY,
order: index,
}],
run: async (accessor: ServicesAccessor) => {
const view = accessor.get(IViewsService).getActiveViewWithId(WORKSPACE_KYLINIDETEAM_VIEW_ID) as IWorkspaceKylinIDETeamExtensionsView;
view.filterKylinIdeTeamExtensions(`@kylinIDETeam:"${categoryKey.toLowerCase()}"`, category);
}
});
});
this.registerExtensionAction({
id: `extensions.actions.kylinIdeExtensions.reset`,
title: localize('kylinIdeExtensionsReset', "Clear Extensions Filter"),
icon: kylinIdeExtensionsResetIcon,
menu: {
id: MenuId.ViewTitle,
when: ContextKeyExpr.equals('view', WORKSPACE_KYLINIDETEAM_VIEW_ID),
group: 'navigation',
order: 1
},
run: async (accessor: ServicesAccessor) => {
const defaultQuery = '@kylinIDETeam:"kylinidedev kylinidedevcooperator"';
const view = accessor.get(IViewsService).getActiveViewWithId(WORKSPACE_KYLINIDETEAM_VIEW_ID) as IWorkspaceKylinIDETeamExtensionsView;
view.filterKylinIdeTeamExtensions(defaultQuery, '');
}
});
this.registerExtensionAction({
id: 'workbench.extensions.action.installWorkspaceRecommendedExtensions',
title: localize('installWorkspaceRecommendedExtensions', "Install Workspace Recommended Extensions"),