Skip to content

Commit

Permalink
Add a new preference to silence notifications
Browse files Browse the repository at this point in the history
Resolves #5942

Signed-off-by: Gareth Whittaker <[email protected]>
  • Loading branch information
garethwhittaker authored and vince-fugnitto committed Mar 6, 2020
1 parent 42b73d5 commit 796a592
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/browser/core-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
}
}
};
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<NotificationUpdateEvent, Exclude<keyof NotificationUpdateEvent, 'notifications'>>;
Expand All @@ -40,6 +42,7 @@ export class NotificationToastsComponent extends React.Component<NotificationToa
async componentDidMount(): Promise<void> {
this.toDisposeOnUnmount.push(
this.props.manager.onUpdated(({ toasts, visibilityState }) => {
visibilityState = this.props.corePreferences['workbench.silentNotifications'] ? 'hidden' : visibilityState;
this.setState({
toasts: toasts.slice(-3),
visibilityState
Expand Down
7 changes: 5 additions & 2 deletions packages/messages/src/browser/notifications-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand All @@ -48,7 +51,7 @@ export class NotificationsRenderer {

protected render(): void {
ReactDOM.render(<div>
<NotificationToastsComponent manager={this.manager} />
<NotificationToastsComponent manager={this.manager} corePreferences={this.corePreferences} />
<NotificationCenterComponent manager={this.manager} />
</div>, this.container);
}
Expand Down

0 comments on commit 796a592

Please sign in to comment.