Path: blob/main/src/vs/workbench/contrib/chat/browser/aiCustomization/embeddedAgentPluginDetail.ts
13406 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as DOM from '../../../../../base/browser/dom.js';6import { Disposable } from '../../../../../base/common/lifecycle.js';7import { localize } from '../../../../../nls.js';8import { AgentPluginItemKind, IAgentPluginItem } from '../agentPluginEditor/agentPluginItems.js';9import { extensionIcon, pluginIcon } from './aiCustomizationIcons.js';1011const $ = DOM.$;1213/**14* Compact detail view for an agent plugin inside the AI Customizations management editor's15* split-pane host. Renders identity (icon + name + source) and description.16*17* Advanced actions (enable / disable / uninstall) remain accessible via the row's existing18* context menu, so this component intentionally stays small.19*/20export class EmbeddedAgentPluginDetail extends Disposable {2122private readonly root: HTMLElement;23private readonly iconEl: HTMLElement;24private readonly nameEl: HTMLElement;25private readonly sourceEl: HTMLElement;26private readonly descriptionEl: HTMLElement;27private readonly emptyEl: HTMLElement;2829private current: IAgentPluginItem | undefined;3031constructor(32parent: HTMLElement,33) {34super();3536this.root = DOM.append(parent, $('.ai-customization-embedded-detail.embedded-plugin-detail'));3738const header = DOM.append(this.root, $('.embedded-detail-header'));39this.iconEl = DOM.append(header, $('.embedded-detail-icon'));40const headerText = DOM.append(header, $('.embedded-detail-header-text'));41this.nameEl = DOM.append(headerText, $('h2.embedded-detail-name'));42this.nameEl.setAttribute('role', 'heading');43this.sourceEl = DOM.append(headerText, $('.embedded-detail-scope'));4445this.descriptionEl = DOM.append(this.root, $('.embedded-detail-description'));4647this.emptyEl = DOM.append(this.root, $('.embedded-detail-empty'));48this.emptyEl.textContent = localize('pluginDetailEmpty', "No plugin selected.");4950this.renderItem();51}5253get element(): HTMLElement {54return this.root;55}5657setInput(item: IAgentPluginItem): void {58this.current = item;59this.renderItem();60}6162clearInput(): void {63this.current = undefined;64this.renderItem();65}6667private renderItem(): void {68const item = this.current;69const hasItem = !!item;70this.emptyEl.style.display = hasItem ? 'none' : '';71this.root.classList.toggle('is-empty', !hasItem);72if (!item) {73this.nameEl.textContent = '';74this.sourceEl.textContent = '';75this.descriptionEl.textContent = '';76this.iconEl.className = 'embedded-detail-icon';77return;78}7980this.nameEl.textContent = item.name;8182const isMarketplace = item.kind === AgentPluginItemKind.Marketplace;83const iconId = isMarketplace ? extensionIcon.id : pluginIcon.id;84this.iconEl.className = `embedded-detail-icon codicon codicon-${iconId}`;8586const sourceLabel = item.marketplace87? (isMarketplace88? localize('pluginSourceMarketplace', "From {0}", item.marketplace)89: localize('pluginSourceInstalled', "Installed from {0}", item.marketplace))90: (isMarketplace91? localize('pluginSourceMarketplaceUnknown', "Marketplace plugin")92: localize('pluginSourceLocal', "Installed plugin"));93const iconSpan = $(`span.codicon.codicon-${iconId}`);94this.sourceEl.replaceChildren(iconSpan, document.createTextNode(' ' + sourceLabel));9596const description = (item.description || '').trim();97this.descriptionEl.textContent = description;98this.descriptionEl.style.display = description ? '' : 'none';99}100}101102103