Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new preference to silence notifications #7195

Merged
merged 1 commit into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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