Browse Source

Adds view badge support to base models

main
Eric Amodio 1 year ago
parent
commit
168f746bf8
2 changed files with 23 additions and 1 deletions
  1. +11
    -0
      src/views/viewBase.ts
  2. +12
    -1
      src/webviews/webviewController.ts

+ 11
- 0
src/views/viewBase.ts View File

@ -8,6 +8,7 @@ import type {
TreeViewExpansionEvent,
TreeViewSelectionChangeEvent,
TreeViewVisibilityChangeEvent,
ViewBadge,
} from 'vscode';
import { Disposable, EventEmitter, MarkdownString, TreeItemCollapsibleState, window } from 'vscode';
import type {
@ -213,6 +214,16 @@ export abstract class ViewBase<
return false;
}
get badge(): ViewBadge | undefined {
return this.tree?.badge;
}
set badge(value: ViewBadge | undefined) {
if (this.tree != null) {
this.tree.badge = value;
}
}
private _title: string | undefined;
get title(): string | undefined {
return this._title;

+ 12
- 1
src/webviews/webviewController.ts View File

@ -1,4 +1,4 @@
import type { Webview, WebviewPanel, WebviewView, WindowState } from 'vscode';
import type { ViewBadge, Webview, WebviewPanel, WebviewView, WindowState } from 'vscode';
import { Disposable, EventEmitter, Uri, ViewColumn, window, workspace } from 'vscode';
import { getNonce } from '@env/crypto';
import type { Commands, CustomEditorIds, WebviewIds, WebviewViewIds } from '../constants';
@ -194,6 +194,17 @@ export class WebviewController<
return !this._isEditor;
}
get badge(): ViewBadge | undefined {
return 'badge' in this.parent ? this.parent.badge : undefined;
}
set badge(value: ViewBadge | undefined) {
if ('badge' in this.parent) {
this.parent.badge = value;
} else {
throw new Error("The 'badge' property not supported on Webview parent");
}
}
private _description: string | undefined;
get description(): string | undefined {
if ('description' in this.parent) {

Loading…
Cancel
Save