提交 c9b875a3 编写于 作者: B Benjamin Pasero

Allow to open notifications center if there are no notifications (fixes #44509)

上级 ec3c0834
...@@ -32,6 +32,7 @@ export class NotificationsCenter extends Themable { ...@@ -32,6 +32,7 @@ export class NotificationsCenter extends Themable {
private notificationsCenterContainer: HTMLElement; private notificationsCenterContainer: HTMLElement;
private notificationsCenterHeader: HTMLElement; private notificationsCenterHeader: HTMLElement;
private notificationsCenterTitle: HTMLSpanElement;
private notificationsList: NotificationsList; private notificationsList: NotificationsList;
private _isVisible: boolean; private _isVisible: boolean;
private workbenchDimensions: Dimension; private workbenchDimensions: Dimension;
...@@ -71,10 +72,6 @@ export class NotificationsCenter extends Themable { ...@@ -71,10 +72,6 @@ export class NotificationsCenter extends Themable {
} }
public show(): void { 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) { if (this._isVisible) {
this.notificationsList.show(true /* focus */); this.notificationsList.show(true /* focus */);
...@@ -86,6 +83,9 @@ export class NotificationsCenter extends Themable { ...@@ -86,6 +83,9 @@ export class NotificationsCenter extends Themable {
this.create(); this.create();
} }
// Title
this.updateTitle();
// Make visible // Make visible
this._isVisible = true; this._isVisible = true;
addClass(this.notificationsCenterContainer, 'visible'); addClass(this.notificationsCenterContainer, 'visible');
...@@ -110,6 +110,14 @@ export class NotificationsCenter extends Themable { ...@@ -110,6 +110,14 @@ export class NotificationsCenter extends Themable {
this._onDidChangeVisibility.fire(); 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 { private create(): void {
// Container // Container
...@@ -122,10 +130,9 @@ export class NotificationsCenter extends Themable { ...@@ -122,10 +130,9 @@ export class NotificationsCenter extends Themable {
this.notificationsCenterContainer.appendChild(this.notificationsCenterHeader); this.notificationsCenterContainer.appendChild(this.notificationsCenterHeader);
// Header Title // Header Title
const title = document.createElement('span'); this.notificationsCenterTitle = document.createElement('span');
addClass(title, 'notifications-center-header-title'); addClass(this.notificationsCenterTitle, 'notifications-center-header-title');
title.innerText = localize('notifications', "Notifications"); this.notificationsCenterHeader.appendChild(this.notificationsCenterTitle);
this.notificationsCenterHeader.appendChild(title);
// Header Toolbar // Header Toolbar
const toolbarContainer = document.createElement('div'); const toolbarContainer = document.createElement('div');
...@@ -184,6 +191,9 @@ export class NotificationsCenter extends Themable { ...@@ -184,6 +191,9 @@ export class NotificationsCenter extends Themable {
break; break;
} }
// Update title
this.updateTitle();
// Hide if no more notifications to show // Hide if no more notifications to show
if (this.model.notifications.length === 0) { if (this.model.notifications.length === 0) {
this.hide(); this.hide();
......
...@@ -75,7 +75,7 @@ export class NotificationsStatus { ...@@ -75,7 +75,7 @@ export class NotificationsStatus {
// Create new // Create new
this.statusItem = this.statusbarService.addEntry({ this.statusItem = this.statusbarService.addEntry({
text: this.count === 0 ? '$(bell)' : `$(bell) ${this.count}`, 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(), tooltip: this.getTooltip(),
showBeak: this.isNotificationsCenterVisible showBeak: this.isNotificationsCenterVisible
}, StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */); }, StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册