chat - allow to override status icon too (#235715)

pull/232244/head
Benjamin Pasero 2024-12-10 11:18:17 +01:00 committed by GitHub
parent 21c52a4a3a
commit 373cd3886f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 21 deletions

View File

@ -9,7 +9,7 @@ import { Disposable, DisposableStore, disposeIfDisposable, IDisposable, MutableD
import { MultiWindowParts, Part } from '../../part.js';
import { EventType as TouchEventType, Gesture, GestureEvent } from '../../../../base/browser/touch.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { StatusbarAlignment, IStatusbarService, IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarStyleOverride, isStatusbarEntryLocation, IStatusbarEntryLocation, isStatusbarEntryPriority, IStatusbarEntryPriority, IStatusbarEntryOverride } from '../../../services/statusbar/browser/statusbar.js';
import { StatusbarAlignment, IStatusbarService, IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarStyleOverride, isStatusbarEntryLocation, IStatusbarEntryLocation, isStatusbarEntryPriority, IStatusbarEntryPriority } from '../../../services/statusbar/browser/statusbar.js';
import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js';
import { IAction, Separator, toAction } from '../../../../base/common/actions.js';
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
@ -76,10 +76,9 @@ export interface IStatusbarEntryContainer extends IDisposable {
updateEntryVisibility(id: string, visible: boolean): void;
/**
* Allows to override the appearance of an entry with the provided ID. Only a subset
* of properties is allowed to be overridden.
* Allows to override the appearance of an entry with the provided ID.
*/
overrideEntry(id: string, override: IStatusbarEntryOverride): IDisposable;
overrideEntry(id: string, override: Partial<IStatusbarEntry>): IDisposable;
/**
* Focused the status bar. If one of the status bar entries was focused, focuses it directly.
@ -141,7 +140,7 @@ class StatusbarPart extends Part implements IStatusbarEntryContainer {
readonly onWillDispose = this._onWillDispose.event;
private readonly onDidOverrideEntry = this._register(new Emitter<string>());
private readonly entryOverrides = new Map<string, IStatusbarEntryOverride>();
private readonly entryOverrides = new Map<string, Partial<IStatusbarEntry>>();
private leftItemsContainer: HTMLElement | undefined;
private rightItemsContainer: HTMLElement | undefined;
@ -182,7 +181,7 @@ class StatusbarPart extends Part implements IStatusbarEntryContainer {
this._register(this.contextService.onDidChangeWorkbenchState(() => this.updateStyles()));
}
overrideEntry(id: string, override: IStatusbarEntryOverride): IDisposable {
overrideEntry(id: string, override: Partial<IStatusbarEntry>): IDisposable {
this.entryOverrides.set(id, override);
this.onDidOverrideEntry.fire(id);
@ -834,7 +833,7 @@ export class StatusbarService extends MultiWindowParts<StatusbarPart> implements
}
}
overrideEntry(id: string, override: IStatusbarEntryOverride): IDisposable {
overrideEntry(id: string, override: Partial<IStatusbarEntry>): IDisposable {
const disposables = new DisposableStore();
for (const part of this.parts) {
@ -910,7 +909,7 @@ export class ScopedStatusbarService extends Disposable implements IStatusbarServ
this.statusbarEntryContainer.updateEntryVisibility(id, visible);
}
overrideEntry(id: string, override: IStatusbarEntryOverride): IDisposable {
overrideEntry(id: string, override: Partial<IStatusbarEntry>): IDisposable {
return this.statusbarEntryContainer.overrideEntry(id, override);
}

View File

@ -261,7 +261,11 @@ export class ChatQuotasStatusBarEntry extends Disposable implements IWorkbenchCo
compact: isCopilotStatusVisible
}));
this.entry.add(this.statusbarService.overrideEntry(ChatQuotasStatusBarEntry.COPILOT_STATUS_ID, { kind: 'prominent' }));
this.entry.add(this.statusbarService.overrideEntry(ChatQuotasStatusBarEntry.COPILOT_STATUS_ID, {
text: '$(copilot-warning)',
ariaLabel: text,
kind: 'prominent'
}));
}
}
}

View File

@ -197,15 +197,3 @@ export interface IStatusbarEntryAccessor extends IDisposable {
*/
update(properties: IStatusbarEntry): void;
}
/**
* A way to override a status bar entry appearance. Only a subset of
* properties are currently allowed to override.
*/
export interface IStatusbarEntryOverride {
/**
* The kind of status bar entry. This applies different colors to the entry.
*/
readonly kind?: StatusbarEntryKind;
}