提交 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 {
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();
......
......@@ -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 */);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册