From c9b875a32dcaafb3906dc544bb6d2182814d5b92 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 14 Mar 2018 08:02:23 +0100 Subject: [PATCH] Allow to open notifications center if there are no notifications (fixes #44509) --- .../notifications/notificationsCenter.ts | 26 +++++++++++++------ .../notifications/notificationsStatus.ts | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/browser/parts/notifications/notificationsCenter.ts b/src/vs/workbench/browser/parts/notifications/notificationsCenter.ts index d6baf9a796e..04871674f0d 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsCenter.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsCenter.ts @@ -32,6 +32,7 @@ export class NotificationsCenter extends Themable { private notificationsCenterContainer: HTMLElement; private notificationsCenterHeader: HTMLElement; + private notificationsCenterTitle: HTMLSpanElement; private notificationsList: NotificationsList; private _isVisible: boolean; private workbenchDimensions: Dimension; @@ -71,10 +72,6 @@ export class NotificationsCenter extends Themable { } public show(): void { - if (this.model.notifications.length === 0) { - return; // currently not supporting to show empty (https://github.com/Microsoft/vscode/issues/44509) - } - if (this._isVisible) { this.notificationsList.show(true /* focus */); @@ -86,6 +83,9 @@ export class NotificationsCenter extends Themable { this.create(); } + // Title + this.updateTitle(); + // Make visible this._isVisible = true; addClass(this.notificationsCenterContainer, 'visible'); @@ -110,6 +110,14 @@ export class NotificationsCenter extends Themable { this._onDidChangeVisibility.fire(); } + private updateTitle(): void { + if (this.model.notifications.length === 0) { + this.notificationsCenterTitle.innerText = localize('notificationsEmpty', "No new notifications"); + } else { + this.notificationsCenterTitle.innerText = localize('notifications', "Notifications"); + } + } + private create(): void { // Container @@ -122,10 +130,9 @@ export class NotificationsCenter extends Themable { this.notificationsCenterContainer.appendChild(this.notificationsCenterHeader); // Header Title - const title = document.createElement('span'); - addClass(title, 'notifications-center-header-title'); - title.innerText = localize('notifications', "Notifications"); - this.notificationsCenterHeader.appendChild(title); + this.notificationsCenterTitle = document.createElement('span'); + addClass(this.notificationsCenterTitle, 'notifications-center-header-title'); + this.notificationsCenterHeader.appendChild(this.notificationsCenterTitle); // Header Toolbar const toolbarContainer = document.createElement('div'); @@ -184,6 +191,9 @@ export class NotificationsCenter extends Themable { break; } + // Update title + this.updateTitle(); + // Hide if no more notifications to show if (this.model.notifications.length === 0) { this.hide(); diff --git a/src/vs/workbench/browser/parts/notifications/notificationsStatus.ts b/src/vs/workbench/browser/parts/notifications/notificationsStatus.ts index d8150a058b1..32f884d0fc6 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsStatus.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsStatus.ts @@ -75,7 +75,7 @@ export class NotificationsStatus { // Create new this.statusItem = this.statusbarService.addEntry({ text: this.count === 0 ? '$(bell)' : `$(bell) ${this.count}`, - command: this.isNotificationsCenterVisible ? HIDE_NOTIFICATIONS_CENTER : this.model.notifications.length > 0 ? SHOW_NOTIFICATIONS_CENTER : void 0, + command: this.isNotificationsCenterVisible ? HIDE_NOTIFICATIONS_CENTER : SHOW_NOTIFICATIONS_CENTER, tooltip: this.getTooltip(), showBeak: this.isNotificationsCenterVisible }, StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */); -- GitLab