@theia/messages 1.48.1 → 1.48.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/lib/browser/messages-frontend-module.d.ts +4 -4
- package/lib/browser/messages-frontend-module.js +41 -41
- package/lib/browser/notification-center-component.d.ts +18 -18
- package/lib/browser/notification-center-component.js +67 -67
- package/lib/browser/notification-component.d.ts +15 -15
- package/lib/browser/notification-component.js +88 -88
- package/lib/browser/notification-content-renderer.d.ts +5 -5
- package/lib/browser/notification-content-renderer.js +35 -35
- package/lib/browser/notification-content-renderer.spec.d.ts +1 -1
- package/lib/browser/notification-content-renderer.spec.js +41 -41
- package/lib/browser/notification-preferences.d.ts +11 -11
- package/lib/browser/notification-preferences.js +46 -46
- package/lib/browser/notification-toasts-component.d.ts +18 -18
- package/lib/browser/notification-toasts-component.js +48 -48
- package/lib/browser/notifications-commands.d.ts +7 -7
- package/lib/browser/notifications-commands.js +47 -47
- package/lib/browser/notifications-contribution.d.ts +21 -21
- package/lib/browser/notifications-contribution.js +203 -203
- package/lib/browser/notifications-manager.d.ts +71 -71
- package/lib/browser/notifications-manager.js +274 -274
- package/lib/browser/notifications-renderer.d.ts +13 -13
- package/lib/browser/notifications-renderer.js +67 -67
- package/package.json +4 -4
- package/src/browser/messages-frontend-module.ts +42 -42
- package/src/browser/notification-center-component.tsx +95 -95
- package/src/browser/notification-component.tsx +128 -128
- package/src/browser/notification-content-renderer.spec.ts +73 -73
- package/src/browser/notification-content-renderer.ts +31 -31
- package/src/browser/notification-preferences.ts +58 -58
- package/src/browser/notification-toasts-component.tsx +67 -67
- package/src/browser/notifications-commands.ts +50 -50
- package/src/browser/notifications-contribution.ts +218 -218
- package/src/browser/notifications-manager.ts +305 -305
- package/src/browser/notifications-renderer.tsx +61 -61
- package/src/browser/style/index.css +17 -17
- package/src/browser/style/notifications.css +283 -283
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2019 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.NotificationsRenderer = void 0;
|
|
19
|
-
const tslib_1 = require("tslib");
|
|
20
|
-
const React = require("@theia/core/shared/react");
|
|
21
|
-
const client_1 = require("@theia/core/shared/react-dom/client");
|
|
22
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
23
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
24
|
-
const notifications_manager_1 = require("./notifications-manager");
|
|
25
|
-
const notification_center_component_1 = require("./notification-center-component");
|
|
26
|
-
const notification_toasts_component_1 = require("./notification-toasts-component");
|
|
27
|
-
let NotificationsRenderer = class NotificationsRenderer {
|
|
28
|
-
init() {
|
|
29
|
-
this.createOverlayContainer();
|
|
30
|
-
this.render();
|
|
31
|
-
}
|
|
32
|
-
createOverlayContainer() {
|
|
33
|
-
this.container = window.document.createElement('div');
|
|
34
|
-
this.container.className = 'theia-notifications-overlay';
|
|
35
|
-
if (window.document.body) {
|
|
36
|
-
window.document.body.appendChild(this.container);
|
|
37
|
-
}
|
|
38
|
-
this.containerRoot = (0, client_1.createRoot)(this.container);
|
|
39
|
-
}
|
|
40
|
-
render() {
|
|
41
|
-
this.containerRoot.render(React.createElement("div", null,
|
|
42
|
-
React.createElement(notification_toasts_component_1.NotificationToastsComponent, { manager: this.manager, corePreferences: this.corePreferences }),
|
|
43
|
-
React.createElement(notification_center_component_1.NotificationCenterComponent, { manager: this.manager })));
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
(0, tslib_1.__decorate)([
|
|
47
|
-
(0, inversify_1.inject)(browser_1.ApplicationShell),
|
|
48
|
-
(0, tslib_1.__metadata)("design:type", browser_1.ApplicationShell)
|
|
49
|
-
], NotificationsRenderer.prototype, "shell", void 0);
|
|
50
|
-
(0, tslib_1.__decorate)([
|
|
51
|
-
(0, inversify_1.inject)(notifications_manager_1.NotificationManager),
|
|
52
|
-
(0, tslib_1.__metadata)("design:type", notifications_manager_1.NotificationManager)
|
|
53
|
-
], NotificationsRenderer.prototype, "manager", void 0);
|
|
54
|
-
(0, tslib_1.__decorate)([
|
|
55
|
-
(0, inversify_1.inject)(browser_1.CorePreferences),
|
|
56
|
-
(0, tslib_1.__metadata)("design:type", Object)
|
|
57
|
-
], NotificationsRenderer.prototype, "corePreferences", void 0);
|
|
58
|
-
(0, tslib_1.__decorate)([
|
|
59
|
-
(0, inversify_1.postConstruct)(),
|
|
60
|
-
(0, tslib_1.__metadata)("design:type", Function),
|
|
61
|
-
(0, tslib_1.__metadata)("design:paramtypes", []),
|
|
62
|
-
(0, tslib_1.__metadata)("design:returntype", void 0)
|
|
63
|
-
], NotificationsRenderer.prototype, "init", null);
|
|
64
|
-
NotificationsRenderer = (0, tslib_1.__decorate)([
|
|
65
|
-
(0, inversify_1.injectable)()
|
|
66
|
-
], NotificationsRenderer);
|
|
67
|
-
exports.NotificationsRenderer = NotificationsRenderer;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2019 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.NotificationsRenderer = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const React = require("@theia/core/shared/react");
|
|
21
|
+
const client_1 = require("@theia/core/shared/react-dom/client");
|
|
22
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
23
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
24
|
+
const notifications_manager_1 = require("./notifications-manager");
|
|
25
|
+
const notification_center_component_1 = require("./notification-center-component");
|
|
26
|
+
const notification_toasts_component_1 = require("./notification-toasts-component");
|
|
27
|
+
let NotificationsRenderer = class NotificationsRenderer {
|
|
28
|
+
init() {
|
|
29
|
+
this.createOverlayContainer();
|
|
30
|
+
this.render();
|
|
31
|
+
}
|
|
32
|
+
createOverlayContainer() {
|
|
33
|
+
this.container = window.document.createElement('div');
|
|
34
|
+
this.container.className = 'theia-notifications-overlay';
|
|
35
|
+
if (window.document.body) {
|
|
36
|
+
window.document.body.appendChild(this.container);
|
|
37
|
+
}
|
|
38
|
+
this.containerRoot = (0, client_1.createRoot)(this.container);
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
this.containerRoot.render(React.createElement("div", null,
|
|
42
|
+
React.createElement(notification_toasts_component_1.NotificationToastsComponent, { manager: this.manager, corePreferences: this.corePreferences }),
|
|
43
|
+
React.createElement(notification_center_component_1.NotificationCenterComponent, { manager: this.manager })));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
(0, tslib_1.__decorate)([
|
|
47
|
+
(0, inversify_1.inject)(browser_1.ApplicationShell),
|
|
48
|
+
(0, tslib_1.__metadata)("design:type", browser_1.ApplicationShell)
|
|
49
|
+
], NotificationsRenderer.prototype, "shell", void 0);
|
|
50
|
+
(0, tslib_1.__decorate)([
|
|
51
|
+
(0, inversify_1.inject)(notifications_manager_1.NotificationManager),
|
|
52
|
+
(0, tslib_1.__metadata)("design:type", notifications_manager_1.NotificationManager)
|
|
53
|
+
], NotificationsRenderer.prototype, "manager", void 0);
|
|
54
|
+
(0, tslib_1.__decorate)([
|
|
55
|
+
(0, inversify_1.inject)(browser_1.CorePreferences),
|
|
56
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
57
|
+
], NotificationsRenderer.prototype, "corePreferences", void 0);
|
|
58
|
+
(0, tslib_1.__decorate)([
|
|
59
|
+
(0, inversify_1.postConstruct)(),
|
|
60
|
+
(0, tslib_1.__metadata)("design:type", Function),
|
|
61
|
+
(0, tslib_1.__metadata)("design:paramtypes", []),
|
|
62
|
+
(0, tslib_1.__metadata)("design:returntype", void 0)
|
|
63
|
+
], NotificationsRenderer.prototype, "init", null);
|
|
64
|
+
NotificationsRenderer = (0, tslib_1.__decorate)([
|
|
65
|
+
(0, inversify_1.injectable)()
|
|
66
|
+
], NotificationsRenderer);
|
|
67
|
+
exports.NotificationsRenderer = NotificationsRenderer;
|
|
68
68
|
//# sourceMappingURL=notifications-renderer.js.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/messages",
|
|
3
|
-
"version": "1.48.
|
|
3
|
+
"version": "1.48.3",
|
|
4
4
|
"description": "Theia - Messages Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.48.
|
|
6
|
+
"@theia/core": "1.48.3",
|
|
7
7
|
"react-perfect-scrollbar": "^1.5.3",
|
|
8
8
|
"ts-md5": "^1.2.2",
|
|
9
9
|
"tslib": "^2.6.2"
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"watch": "theiaext watch"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@theia/ext-scripts": "1.48.
|
|
44
|
+
"@theia/ext-scripts": "1.48.3"
|
|
45
45
|
},
|
|
46
46
|
"nyc": {
|
|
47
47
|
"extends": "../../configs/nyc.json"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "49e167c6d7deaa68060e12e8f33d35b31b1230a0"
|
|
50
50
|
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import '../../src/browser/style/index.css';
|
|
18
|
-
|
|
19
|
-
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
20
|
-
import { MessageClient } from '@theia/core/lib/common';
|
|
21
|
-
import { NotificationManager } from './notifications-manager';
|
|
22
|
-
import { bindNotificationPreferences } from './notification-preferences';
|
|
23
|
-
import { NotificationsRenderer } from './notifications-renderer';
|
|
24
|
-
import { NotificationsContribution } from './notifications-contribution';
|
|
25
|
-
import { FrontendApplicationContribution, KeybindingContribution, StylingParticipant } from '@theia/core/lib/browser';
|
|
26
|
-
import { CommandContribution } from '@theia/core';
|
|
27
|
-
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
28
|
-
import { NotificationContentRenderer } from './notification-content-renderer';
|
|
29
|
-
|
|
30
|
-
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
31
|
-
bind(NotificationContentRenderer).toSelf().inSingletonScope();
|
|
32
|
-
bind(NotificationsRenderer).toSelf().inSingletonScope();
|
|
33
|
-
bind(NotificationsContribution).toSelf().inSingletonScope();
|
|
34
|
-
bind(FrontendApplicationContribution).toService(NotificationsContribution);
|
|
35
|
-
bind(CommandContribution).toService(NotificationsContribution);
|
|
36
|
-
bind(KeybindingContribution).toService(NotificationsContribution);
|
|
37
|
-
bind(ColorContribution).toService(NotificationsContribution);
|
|
38
|
-
bind(StylingParticipant).toService(NotificationsContribution);
|
|
39
|
-
bind(NotificationManager).toSelf().inSingletonScope();
|
|
40
|
-
rebind(MessageClient).toService(NotificationManager);
|
|
41
|
-
bindNotificationPreferences(bind);
|
|
42
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import '../../src/browser/style/index.css';
|
|
18
|
+
|
|
19
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
20
|
+
import { MessageClient } from '@theia/core/lib/common';
|
|
21
|
+
import { NotificationManager } from './notifications-manager';
|
|
22
|
+
import { bindNotificationPreferences } from './notification-preferences';
|
|
23
|
+
import { NotificationsRenderer } from './notifications-renderer';
|
|
24
|
+
import { NotificationsContribution } from './notifications-contribution';
|
|
25
|
+
import { FrontendApplicationContribution, KeybindingContribution, StylingParticipant } from '@theia/core/lib/browser';
|
|
26
|
+
import { CommandContribution } from '@theia/core';
|
|
27
|
+
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
28
|
+
import { NotificationContentRenderer } from './notification-content-renderer';
|
|
29
|
+
|
|
30
|
+
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
31
|
+
bind(NotificationContentRenderer).toSelf().inSingletonScope();
|
|
32
|
+
bind(NotificationsRenderer).toSelf().inSingletonScope();
|
|
33
|
+
bind(NotificationsContribution).toSelf().inSingletonScope();
|
|
34
|
+
bind(FrontendApplicationContribution).toService(NotificationsContribution);
|
|
35
|
+
bind(CommandContribution).toService(NotificationsContribution);
|
|
36
|
+
bind(KeybindingContribution).toService(NotificationsContribution);
|
|
37
|
+
bind(ColorContribution).toService(NotificationsContribution);
|
|
38
|
+
bind(StylingParticipant).toService(NotificationsContribution);
|
|
39
|
+
bind(NotificationManager).toSelf().inSingletonScope();
|
|
40
|
+
rebind(MessageClient).toService(NotificationManager);
|
|
41
|
+
bindNotificationPreferences(bind);
|
|
42
|
+
});
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import * as React from '@theia/core/shared/react';
|
|
18
|
-
import { DisposableCollection } from '@theia/core';
|
|
19
|
-
import { NotificationManager, NotificationUpdateEvent } from './notifications-manager';
|
|
20
|
-
import { NotificationComponent } from './notification-component';
|
|
21
|
-
import { codicon } from '@theia/core/lib/browser';
|
|
22
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
23
|
-
|
|
24
|
-
const PerfectScrollbar = require('react-perfect-scrollbar');
|
|
25
|
-
|
|
26
|
-
export interface NotificationCenterComponentProps {
|
|
27
|
-
readonly manager: NotificationManager;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type NotificationCenterComponentState = Pick<NotificationUpdateEvent, Exclude<keyof NotificationUpdateEvent, 'toasts'>>;
|
|
31
|
-
|
|
32
|
-
export class NotificationCenterComponent extends React.Component<NotificationCenterComponentProps, NotificationCenterComponentState> {
|
|
33
|
-
|
|
34
|
-
constructor(props: NotificationCenterComponentProps) {
|
|
35
|
-
super(props);
|
|
36
|
-
this.state = {
|
|
37
|
-
notifications: [],
|
|
38
|
-
visibilityState: 'hidden'
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected readonly toDisposeOnUnmount = new DisposableCollection();
|
|
43
|
-
|
|
44
|
-
override async componentDidMount(): Promise<void> {
|
|
45
|
-
this.toDisposeOnUnmount.push(
|
|
46
|
-
this.props.manager.onUpdated(({ notifications, visibilityState }) => {
|
|
47
|
-
this.setState({
|
|
48
|
-
notifications: notifications,
|
|
49
|
-
visibilityState
|
|
50
|
-
});
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
override componentWillUnmount(): void {
|
|
55
|
-
this.toDisposeOnUnmount.dispose();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
override render(): React.ReactNode {
|
|
59
|
-
const empty = this.state.notifications.length === 0;
|
|
60
|
-
const title = empty
|
|
61
|
-
? nls.localizeByDefault('No New Notifications')
|
|
62
|
-
: nls.localizeByDefault('Notifications');
|
|
63
|
-
return (
|
|
64
|
-
<div className={`theia-notifications-container theia-notification-center ${this.state.visibilityState === 'center' ? 'open' : 'closed'}`}>
|
|
65
|
-
<div className='theia-notification-center-header'>
|
|
66
|
-
<div className='theia-notification-center-header-title'>{title}</div>
|
|
67
|
-
<div className='theia-notification-center-header-actions'>
|
|
68
|
-
<ul className='theia-notification-actions'>
|
|
69
|
-
<li className={codicon('clear-all', true)} title={nls.localizeByDefault('Clear All Notifications')}
|
|
70
|
-
onClick={this.onClearAll} />
|
|
71
|
-
<li className={codicon('chevron-down', true)} title={nls.localizeByDefault('Hide Notifications')}
|
|
72
|
-
onClick={this.onHide} />
|
|
73
|
-
</ul>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
<PerfectScrollbar className='theia-notification-list-scroll-container'>
|
|
77
|
-
<div className='theia-notification-list'>
|
|
78
|
-
{this.state.notifications.map(notification =>
|
|
79
|
-
<NotificationComponent key={notification.messageId} notification={notification} manager={this.props.manager} />
|
|
80
|
-
)}
|
|
81
|
-
</div>
|
|
82
|
-
</PerfectScrollbar>
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
protected onHide = () => {
|
|
88
|
-
this.props.manager.hideCenter();
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
protected onClearAll = () => {
|
|
92
|
-
this.props.manager.clearAll();
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as React from '@theia/core/shared/react';
|
|
18
|
+
import { DisposableCollection } from '@theia/core';
|
|
19
|
+
import { NotificationManager, NotificationUpdateEvent } from './notifications-manager';
|
|
20
|
+
import { NotificationComponent } from './notification-component';
|
|
21
|
+
import { codicon } from '@theia/core/lib/browser';
|
|
22
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
23
|
+
|
|
24
|
+
const PerfectScrollbar = require('react-perfect-scrollbar');
|
|
25
|
+
|
|
26
|
+
export interface NotificationCenterComponentProps {
|
|
27
|
+
readonly manager: NotificationManager;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type NotificationCenterComponentState = Pick<NotificationUpdateEvent, Exclude<keyof NotificationUpdateEvent, 'toasts'>>;
|
|
31
|
+
|
|
32
|
+
export class NotificationCenterComponent extends React.Component<NotificationCenterComponentProps, NotificationCenterComponentState> {
|
|
33
|
+
|
|
34
|
+
constructor(props: NotificationCenterComponentProps) {
|
|
35
|
+
super(props);
|
|
36
|
+
this.state = {
|
|
37
|
+
notifications: [],
|
|
38
|
+
visibilityState: 'hidden'
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected readonly toDisposeOnUnmount = new DisposableCollection();
|
|
43
|
+
|
|
44
|
+
override async componentDidMount(): Promise<void> {
|
|
45
|
+
this.toDisposeOnUnmount.push(
|
|
46
|
+
this.props.manager.onUpdated(({ notifications, visibilityState }) => {
|
|
47
|
+
this.setState({
|
|
48
|
+
notifications: notifications,
|
|
49
|
+
visibilityState
|
|
50
|
+
});
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
override componentWillUnmount(): void {
|
|
55
|
+
this.toDisposeOnUnmount.dispose();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override render(): React.ReactNode {
|
|
59
|
+
const empty = this.state.notifications.length === 0;
|
|
60
|
+
const title = empty
|
|
61
|
+
? nls.localizeByDefault('No New Notifications')
|
|
62
|
+
: nls.localizeByDefault('Notifications');
|
|
63
|
+
return (
|
|
64
|
+
<div className={`theia-notifications-container theia-notification-center ${this.state.visibilityState === 'center' ? 'open' : 'closed'}`}>
|
|
65
|
+
<div className='theia-notification-center-header'>
|
|
66
|
+
<div className='theia-notification-center-header-title'>{title}</div>
|
|
67
|
+
<div className='theia-notification-center-header-actions'>
|
|
68
|
+
<ul className='theia-notification-actions'>
|
|
69
|
+
<li className={codicon('clear-all', true)} title={nls.localizeByDefault('Clear All Notifications')}
|
|
70
|
+
onClick={this.onClearAll} />
|
|
71
|
+
<li className={codicon('chevron-down', true)} title={nls.localizeByDefault('Hide Notifications')}
|
|
72
|
+
onClick={this.onHide} />
|
|
73
|
+
</ul>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
<PerfectScrollbar className='theia-notification-list-scroll-container'>
|
|
77
|
+
<div className='theia-notification-list'>
|
|
78
|
+
{this.state.notifications.map(notification =>
|
|
79
|
+
<NotificationComponent key={notification.messageId} notification={notification} manager={this.props.manager} />
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
</PerfectScrollbar>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
protected onHide = () => {
|
|
88
|
+
this.props.manager.hideCenter();
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
protected onClearAll = () => {
|
|
92
|
+
this.props.manager.clearAll();
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
}
|