Improve notification APIs #44121
Labels
api
*out-of-scope
Posted issue is not in scope of VS Code
under-discussion
Issue is under discussion for relevance, priority, approach
workbench-notifications
Notification widget issues
Summary
The current notification API does not currently provide a distinction between notifications (these don't require user interaction) and prompts (these do require user interaction) or implement the required functionality for additional notification features that have been requested. This also results in instances where the wrong UI element is used, which hinders the workflow of some users.
Proposal
Add a notification manager containing related notification methods to the
window
object.Ex:
window.notifications.addError('Something bad happened.');
The manager would provide the following methods and events:
addInfo()
: accepts a message and options parameters, returns a notification objectaddWarning()
: accepts a message and options parameters, returns a notification objectaddError()
: accepts a message and options parameters, returns a notification objectgetNotifications()
: returns a list of notificationsonDidAddNotification
: event that invokes a callback that receives a notification objectremoveNotification()
: accepts a notification, tag, or extension idThe
NotificationOptions
object would also contain the following properties:title
: stringdetails
/source
: markup?buttons
: arraytag
/group
: stringisExpanded
: boolean (for backward-compatibility)The
Notification
object contains information about the added notification and anonDismiss
event. This object would also be required for other features, such as #44122.Add a generic
showDialog
method to thewindow
object.// TODO: This method would... accept simple message parameters, or an object that implements an abstract
Dialog
class? Could these dialogs also show custom markup?Backwards compatibility
The current APIs should be marked deprecated.
If desired, an "adapter" class or service could also redirect deprecated API calls to the most appropriate (notification or dialog box) action, thereby allowing use of updated UI elements by deprecated code in most cases.
The text was updated successfully, but these errors were encountered: