From 9be0d5ed05ea064568515e455d8488e3d523d0a8 Mon Sep 17 00:00:00 2001 From: Matt Adam Date: Tue, 8 Mar 2022 08:07:15 -0800 Subject: [PATCH] Add badges extension API (#139225) * First attempt at a badges API * Updated badge API to reflect feedback * Update to reflect PR feedback * Address further feedback * Badge -> ViewBadge Co-authored-by: Alex Ross --- .../common/extensionsApiProposals.ts | 1 + src/vscode-dts/vscode.proposed.badges.d.ts | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/vscode-dts/vscode.proposed.badges.d.ts diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 6267489b52d..c4653e81b17 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -7,6 +7,7 @@ export const allApiProposals = Object.freeze({ authSession: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.authSession.d.ts', + badges: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.badges.d.ts', commentsResolvedState: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.commentsResolvedState.d.ts', contribLabelFormatterWorkspaceTooltip: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribLabelFormatterWorkspaceTooltip.d.ts', contribMenuBarHome: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribMenuBarHome.d.ts', diff --git a/src/vscode-dts/vscode.proposed.badges.d.ts b/src/vscode-dts/vscode.proposed.badges.d.ts new file mode 100644 index 00000000000..5aed72b6019 --- /dev/null +++ b/src/vscode-dts/vscode.proposed.badges.d.ts @@ -0,0 +1,41 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + // https://github.com/microsoft/vscode/issues/62783 @matthewjamesadam + + /** + * A badge presenting a value for a view + */ + export interface ViewBadge { + + /** + * A label to present in tooltips for the badge + */ + readonly tooltip: string; + + /** + * The value to present in the badge + */ + readonly value: number; + } + + export interface TreeView { + /** + * The badge to display for this TreeView. + * To remove the badge, set to undefined. + */ + badge?: ViewBadge | undefined; + } + + export interface WebviewView { + /** + * The badge to display for this webview view. + * To remove the badge, set to undefined. + */ + badge?: ViewBadge | undefined; + } +}