feat:插件侧边栏新增Kylin-IDE推荐插件列表视图,列表单元格显示插件能够安装卸载等.

This commit is contained in:
chriswang521 2024-06-13 15:20:54 +08:00 committed by wangpenglong
parent 53a365cad3
commit d5a0761e1f
4 changed files with 116 additions and 4 deletions

View File

@ -38,3 +38,6 @@ export const infoIcon = registerIcon('extensions-info-message', Codicon.info, lo
export const trustIcon = registerIcon('extension-workspace-trust', Codicon.shield, localize('trustIcon', 'Icon shown with a workspace trust message in the extension editor.'));
export const activationTimeIcon = registerIcon('extension-activation-time', Codicon.history, localize('activationtimeIcon', 'Icon shown with a activation time message in the extension editor.'));
export const kylinIdeExtensionsFilterIcon = registerIcon('kylinide-extensions-filter', Codicon.listFilter, localize('kylinIdeExtensionsFilterIcon', 'Icon for the \'Filter\' action in the extensions view.'));
export const kylinIdeExtensionsResetIcon = registerIcon('kylinide-extensions-reset', Codicon.debugRestartFrame, localize('kylinIdeExtensionsResetIcon', 'Icon for the \'Reset\' action in the extensions view.'));

View File

@ -16,12 +16,12 @@ import { append, $, Dimension, hide, show, DragAndDropObserver, trackFocus } fro
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IExtensionsWorkbenchService, IExtensionsViewPaneContainer, VIEWLET_ID, CloseExtensionDetailsOnViewChangeKey, INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, WORKSPACE_RECOMMENDATIONS_VIEW_ID, AutoCheckUpdatesConfigurationKey, OUTDATED_EXTENSIONS_VIEW_ID, CONTEXT_HAS_GALLERY, extensionsSearchActionsMenu } from '../common/extensions';
import { IExtensionsWorkbenchService, IExtensionsViewPaneContainer, VIEWLET_ID, CloseExtensionDetailsOnViewChangeKey, INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, WORKSPACE_RECOMMENDATIONS_VIEW_ID, AutoCheckUpdatesConfigurationKey, OUTDATED_EXTENSIONS_VIEW_ID, CONTEXT_HAS_GALLERY, extensionsSearchActionsMenu, WORKSPACE_KYLINIDETEAM_VIEW_ID } from '../common/extensions';
import { InstallLocalExtensionsInRemoteAction, InstallRemoteExtensionsInLocalAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IWorkbenchExtensionEnablementService, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
import { ExtensionsInput } from 'vs/workbench/contrib/extensions/common/extensionsInput';
import { ExtensionsListView, EnabledExtensionsView, DisabledExtensionsView, RecommendedExtensionsView, WorkspaceRecommendedExtensionsView, BuiltInFeatureExtensionsView, BuiltInThemesExtensionsView, BuiltInProgrammingLanguageExtensionsView, ServerInstalledExtensionsView, DefaultRecommendedExtensionsView, UntrustedWorkspaceUnsupportedExtensionsView, UntrustedWorkspacePartiallySupportedExtensionsView, VirtualWorkspaceUnsupportedExtensionsView, VirtualWorkspacePartiallySupportedExtensionsView, DefaultPopularExtensionsView, DeprecatedExtensionsView, SearchMarketplaceExtensionsView, RecentlyUpdatedExtensionsView, OutdatedExtensionsView } from 'vs/workbench/contrib/extensions/browser/extensionsViews';
import { ExtensionsListView, EnabledExtensionsView, DisabledExtensionsView, RecommendedExtensionsView, WorkspaceRecommendedExtensionsView, BuiltInFeatureExtensionsView, BuiltInThemesExtensionsView, BuiltInProgrammingLanguageExtensionsView, ServerInstalledExtensionsView, DefaultRecommendedExtensionsView, UntrustedWorkspaceUnsupportedExtensionsView, UntrustedWorkspacePartiallySupportedExtensionsView, VirtualWorkspaceUnsupportedExtensionsView, VirtualWorkspacePartiallySupportedExtensionsView, DefaultPopularExtensionsView, DeprecatedExtensionsView, SearchMarketplaceExtensionsView, RecentlyUpdatedExtensionsView, OutdatedExtensionsView, DefaultKylinIDETeamExtensionsView, DefaultKylinIDETeamExtensionsViewTitle } from 'vs/workbench/contrib/extensions/browser/extensionsViews';
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import Severity from 'vs/base/common/severity';
@ -229,6 +229,22 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
canToggleVisibility: false
});
/*
* Default kylinIdeTeam extensions view
* When user has installed extensions, this is shown along with the views for enabled & disabled extensions
* When user has no installed extensions, this is shown along with the view for kylinIdeTeam extensions
*/
viewDescriptors.push({
id: WORKSPACE_KYLINIDETEAM_VIEW_ID,
name: DefaultKylinIDETeamExtensionsViewTitle,
ctorDescriptor: new SyncDescriptor(DefaultKylinIDETeamExtensionsView, [{ flexibleHeight: true }]),
when: ContextKeyExpr.and(DefaultViewsContext, CONTEXT_HAS_GALLERY),
hideByDefault: false,
weight: 60,
order: 2,
canToggleVisibility: true
});
/*
* Default recommended extensions view
* When user has installed extensions, this is shown along with the views for enabled & disabled extensions

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { localize, localize2 } from 'vs/nls';
import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
import { Event, Emitter } from 'vs/base/common/event';
import { isCancellationError, getErrorMessage } from 'vs/base/common/errors';
@ -18,7 +18,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { append, $ } from 'vs/base/browser/dom';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Delegate, Renderer, IExtensionsViewState } from 'vs/workbench/contrib/extensions/browser/extensionsList';
import { ExtensionState, IExtension, IExtensionsWorkbenchService, IWorkspaceRecommendedExtensionsView } from 'vs/workbench/contrib/extensions/common/extensions';
import { ExtensionState, IExtension, IExtensionsWorkbenchService, IWorkspaceKylinIDETeamExtensionsView, IWorkspaceRecommendedExtensionsView } from 'vs/workbench/contrib/extensions/common/extensions';
import { Query } from 'vs/workbench/contrib/extensions/common/extensionQuery';
import { IExtensionService, toExtension } from 'vs/workbench/services/extensions/common/extensions';
import { IThemeService } from 'vs/platform/theme/common/themeService';
@ -55,6 +55,7 @@ import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import { ILogService } from 'vs/platform/log/common/log';
import { isOfflineError } from 'vs/base/parts/request/common/request';
import { defaultCountBadgeStyles } from 'vs/platform/theme/browser/defaultStyles';
import { ILocalizedString } from 'vs/platform/action/common/action';
// Extensions that are automatically classified as Programming Language extensions, but should be Feature extensions
const FORCE_FEATURE_EXTENSIONS = ['vscode.git', 'vscode.git-base', 'vscode.search-result'];
@ -352,6 +353,10 @@ export class ExtensionsListView extends ViewPane {
query.value = query.value.replace('@recentlyPublished', '');
options.sortBy = !options.sortBy ? GallerySortBy.PublishedDate : options.sortBy;
}
else if (ExtensionsListView.isSearchKylinIDETeamQuery(query.value)) {
query.value = query.value.replace('@kylinIDETeam', '');
options.sortBy = !options.sortBy ? GallerySortBy.InstallCount : options.sortBy;
}
const galleryQueryOptions: IGalleryQueryOptions = { ...options, sortBy: isLocalSortBy(options.sortBy) ? undefined : options.sortBy };
const model = await this.queryGallery(query, galleryQueryOptions, token);
@ -1183,6 +1188,10 @@ export class ExtensionsListView extends ViewPane {
return /@sort:updateDate/i.test(query);
}
static isSearchKylinIDETeamQuery(query: string): boolean {
return /@kylinIDETeam:/i.test(query);
}
override focus(): void {
super.focus();
if (!this.list) {
@ -1347,6 +1356,84 @@ export class SearchMarketplaceExtensionsView extends ExtensionsListView {
}
}
export const DefaultKylinIDETeamExtensionsViewTitle: ILocalizedString = localize2('kylinIdeTeamExtensions', "Kylin-Code Recommended");
export class DefaultKylinIDETeamExtensionsView extends ExtensionsListView implements IWorkspaceKylinIDETeamExtensionsView {
private readonly kylinIDETeamExtensionsQuery = '@kylinIDETeam:"kylinidedev kylinidedevcooperator"';
private kylinIdeTeamExtensions: IExtension[] = [];
private category: string = '';
protected override renderBody(container: HTMLElement): void {
super.renderBody(container);
}
override async show(query: string, refresh?: boolean): Promise<IPagedModel<IExtension>> {
//query is include @sort,then reset query
let flag = false;
if (query && query.trim().startsWith('@sort')) {
flag = true;
}
// title
if ((!query && flag) || refresh || !this.category) {
super.updateTitle(DefaultKylinIDETeamExtensionsViewTitle.value);
} else {
super.updateTitle(`${DefaultKylinIDETeamExtensionsViewTitle.value}:${this.category}`);
}
// search
let queryString: string = '';
if (query && query.trim().startsWith('@sort')) {
queryString = this.kylinIDETeamExtensionsQuery + ' ' + query.trim();
} else if (query && query.trim().startsWith('@kylinIDETeam')) {
queryString = query.trim();
} else {
queryString = this.kylinIDETeamExtensionsQuery;
}
// const queryString = (query && !flag) ? query.trim() : this.kylinIDETeamExtensionsQuery;
const model = await super.show(queryString);
// Expanded
// if (!this.extensionsWorkbenchService.local.some(e => !e.isBuiltin)) {
// this.setExpanded(model.length > 0);
// }
// this.kylinIdeTeamExtensions assign
// if (model.length > 0) {
// this.kylinIdeTeamExtensions.length = 0;
// for (let i = 0; i < model.length; i++) {
// this.kylinIdeTeamExtensions.push(model.get(i));
// }
// }
this.category = '';
return model;
}
//filter kylinideTeamExtension
filterKylinIdeTeamExtensions(query: string, category: string): void {
this.category = category;
this.show(query);
}
//install kylinIdeTeamExtensions
private async getInstallableKylinIdeTeamExtensions() {
const installed = (await this.extensionsWorkbenchService.queryLocal())
.filter(l => l.enablementState !== EnablementState.DisabledByExtensionKind); // Filter extensions disabled by kind
return this.kylinIdeTeamExtensions.filter(item => installed.every(local => !areSameExtensions(item.identifier, local.identifier)));
}
async installKylinIdeTeamExtensions(): Promise<void> {
const installableKylinIdeTeamExtensions = await this.getInstallableKylinIdeTeamExtensions();
if (installableKylinIdeTeamExtensions.length) {
await this.extensionManagementService.installGalleryExtensions(installableKylinIdeTeamExtensions.map(i => ({ extension: i.gallery!, options: {} })));
} else {
this.notificationService.notify({
severity: Severity.Info,
message: localize('no local extensions', "There are no extensions to install.")
});
}
}
}
export class DefaultRecommendedExtensionsView extends ExtensionsListView {
private readonly recommendedExtensionsQuery = '@recommended:all';

View File

@ -32,6 +32,11 @@ export interface IWorkspaceRecommendedExtensionsView extends IView {
installWorkspaceRecommendations(): Promise<void>;
}
export interface IWorkspaceKylinIDETeamExtensionsView extends IView {
installKylinIdeTeamExtensions(): Promise<void>;
filterKylinIdeTeamExtensions(query: string, category: string): void;
}
export const enum ExtensionState {
Installing,
Installed,
@ -190,6 +195,7 @@ export class ExtensionContainers extends Disposable {
}
}
export const WORKSPACE_KYLINIDETEAM_VIEW_ID = 'workbench.views.extensions.kylinIdeTeam';
export const WORKSPACE_RECOMMENDATIONS_VIEW_ID = 'workbench.views.extensions.workspaceRecommendations';
export const OUTDATED_EXTENSIONS_VIEW_ID = 'workbench.views.extensions.searchOutdated';
export const TOGGLE_IGNORE_EXTENSION_ACTION_ID = 'workbench.extensions.action.toggleIgnoreExtension';