From 329868aa818b8424d837503f2de0809b76aa0ff1 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 14 Feb 2018 15:28:45 +0100 Subject: [PATCH] notifications - :lipstick: --- .../parts/notifications/notificationsAlerts.ts | 8 ++++++++ src/vs/workbench/common/notifications.ts | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/browser/parts/notifications/notificationsAlerts.ts b/src/vs/workbench/browser/parts/notifications/notificationsAlerts.ts index 9375d36ad0d..84c98c310eb 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsAlerts.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsAlerts.ts @@ -10,6 +10,7 @@ import { localize } from 'vs/nls'; import { Severity } from 'vs/platform/message/common/message'; import { INotificationViewItem, INotificationsModel, NotificationChangeType, INotificationChangeEvent } from 'vs/workbench/common/notifications'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { toErrorMessage } from 'vs/base/common/errorMessage'; export class NotificationsAlerts { @@ -30,7 +31,14 @@ export class NotificationsAlerts { private onDidNotificationChange(e: INotificationChangeEvent): void { if (e.kind === NotificationChangeType.ADD) { + + // ARIA alert for screen readers this.ariaAlert(e.item); + + // Always log errors to console with full details + if (e.item.severity === Severity.Error) { + console.error(toErrorMessage(e.item.message.value, true)); + } } } diff --git a/src/vs/workbench/common/notifications.ts b/src/vs/workbench/common/notifications.ts index a9c654c595d..0add9539fde 100644 --- a/src/vs/workbench/common/notifications.ts +++ b/src/vs/workbench/common/notifications.ts @@ -13,6 +13,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage'; import { localize } from 'vs/nls'; import Event, { Emitter, once } from 'vs/base/common/event'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { isPromiseCanceledError } from 'vs/base/common/errors'; export interface INotificationsModel { @@ -139,10 +140,17 @@ export class NotificationViewItem implements INotificationViewItem { private _onDidDispose: Emitter; public static create(notification: INotification): INotificationViewItem { - if (!notification || !notification.message) { + if (!notification || !notification.message || isPromiseCanceledError(notification.message)) { return null; // we need a message to show } + let severity: Severity; + if (typeof notification.severity === 'number') { + severity = notification.severity; + } else { + severity = Severity.Info; + } + let message: IMarkdownString; if (notification.message instanceof Error) { message = { value: toErrorMessage(notification.message, false), isTrusted: true }; @@ -156,7 +164,7 @@ export class NotificationViewItem implements INotificationViewItem { return null; // we need a message to show } - return new NotificationViewItem(notification.severity, message, notification.source || NotificationViewItem.DEFAULT_SOURCE, notification.actions || []); + return new NotificationViewItem(severity, message, notification.source || NotificationViewItem.DEFAULT_SOURCE, notification.actions || []); } private constructor(private _severity: Severity, private _message: IMarkdownString, private _source: string, private _actions: IAction[]) { -- GitLab