diff --git a/CHANGELOG.md b/CHANGELOG.md index c9b2139fcd5e4..31cb971f0aaee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## v0.17.0 +- [preferences] add a new preference to silence notifications [#7195](https://github.com/eclipse-theia/theia/pull/7195) + Breaking changes: - [scm][git] the History view (GitHistoryWidget) has moved from the git package to a new package, scm-extra, and diff --git a/packages/core/src/browser/core-preferences.ts b/packages/core/src/browser/core-preferences.ts index e8f5e43e23fa3..7ec11247c3649 100644 --- a/packages/core/src/browser/core-preferences.ts +++ b/packages/core/src/browser/core-preferences.ts @@ -57,6 +57,11 @@ export const corePreferenceSchema: PreferenceSchema = { 'workbench.iconTheme': { type: ['string', 'null'], description: "Specifies the icon theme used in the workbench or 'null' to not show any file icons." + }, + 'workbench.silentNotifications': { + type: 'boolean', + default: false, + description: 'Controls whether to suppress notification popups.' } } }; @@ -68,6 +73,7 @@ export interface CoreConfiguration { 'workbench.editor.highlightModifiedTabs': boolean; 'workbench.colorTheme'?: string; 'workbench.iconTheme'?: string | null; + 'workbench.silentNotifications': boolean; } export const CorePreferences = Symbol('CorePreferences'); diff --git a/packages/messages/src/browser/notification-toasts-component.tsx b/packages/messages/src/browser/notification-toasts-component.tsx index f277b1fe6b01e..1bc8a8ee9ebc9 100644 --- a/packages/messages/src/browser/notification-toasts-component.tsx +++ b/packages/messages/src/browser/notification-toasts-component.tsx @@ -18,9 +18,11 @@ import * as React from 'react'; import { DisposableCollection } from '@theia/core'; import { NotificationManager, NotificationUpdateEvent } from './notifications-manager'; import { NotificationComponent } from './notification-component'; +import { CorePreferences } from '@theia/core/lib/browser'; export interface NotificationToastsComponentProps { readonly manager: NotificationManager; + readonly corePreferences: CorePreferences; } type NotificationToastsComponentState = Pick>; @@ -40,6 +42,7 @@ export class NotificationToastsComponent extends React.Component { this.toDisposeOnUnmount.push( this.props.manager.onUpdated(({ toasts, visibilityState }) => { + visibilityState = this.props.corePreferences['workbench.silentNotifications'] ? 'hidden' : visibilityState; this.setState({ toasts: toasts.slice(-3), visibilityState diff --git a/packages/messages/src/browser/notifications-renderer.tsx b/packages/messages/src/browser/notifications-renderer.tsx index b76b8232fdfd9..479b2e5760b64 100644 --- a/packages/messages/src/browser/notifications-renderer.tsx +++ b/packages/messages/src/browser/notifications-renderer.tsx @@ -17,7 +17,7 @@ import * as ReactDOM from 'react-dom'; import * as React from 'react'; import { injectable, inject, postConstruct } from 'inversify'; -import { ApplicationShell } from '@theia/core/lib/browser'; +import { ApplicationShell, CorePreferences } from '@theia/core/lib/browser'; import { NotificationManager } from './notifications-manager'; import { NotificationCenterComponent } from './notification-center-component'; import { NotificationToastsComponent } from './notification-toasts-component'; @@ -31,6 +31,9 @@ export class NotificationsRenderer { @inject(NotificationManager) protected readonly manager: NotificationManager; + @inject(CorePreferences) + protected readonly corePreferences: CorePreferences; + @postConstruct() protected init(): void { this.createOverlayContainer(); @@ -48,7 +51,7 @@ export class NotificationsRenderer { protected render(): void { ReactDOM.render(
- +
, this.container); }