@theia/messages 1.47.1 → 1.48.1

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.
Files changed (37) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/messages-frontend-module.d.ts +4 -4
  3. package/lib/browser/messages-frontend-module.js +41 -41
  4. package/lib/browser/notification-center-component.d.ts +18 -18
  5. package/lib/browser/notification-center-component.js +67 -67
  6. package/lib/browser/notification-component.d.ts +15 -15
  7. package/lib/browser/notification-component.js +88 -88
  8. package/lib/browser/notification-content-renderer.d.ts +5 -5
  9. package/lib/browser/notification-content-renderer.js +35 -35
  10. package/lib/browser/notification-content-renderer.spec.d.ts +1 -1
  11. package/lib/browser/notification-content-renderer.spec.js +41 -41
  12. package/lib/browser/notification-preferences.d.ts +11 -11
  13. package/lib/browser/notification-preferences.js +46 -46
  14. package/lib/browser/notification-toasts-component.d.ts +18 -18
  15. package/lib/browser/notification-toasts-component.js +48 -48
  16. package/lib/browser/notifications-commands.d.ts +7 -7
  17. package/lib/browser/notifications-commands.js +47 -47
  18. package/lib/browser/notifications-contribution.d.ts +21 -21
  19. package/lib/browser/notifications-contribution.js +203 -203
  20. package/lib/browser/notifications-manager.d.ts +71 -71
  21. package/lib/browser/notifications-manager.js +274 -274
  22. package/lib/browser/notifications-renderer.d.ts +13 -13
  23. package/lib/browser/notifications-renderer.js +67 -67
  24. package/package.json +4 -4
  25. package/src/browser/messages-frontend-module.ts +42 -42
  26. package/src/browser/notification-center-component.tsx +95 -95
  27. package/src/browser/notification-component.tsx +128 -128
  28. package/src/browser/notification-content-renderer.spec.ts +73 -73
  29. package/src/browser/notification-content-renderer.ts +31 -31
  30. package/src/browser/notification-preferences.ts +58 -58
  31. package/src/browser/notification-toasts-component.tsx +67 -67
  32. package/src/browser/notifications-commands.ts +50 -50
  33. package/src/browser/notifications-contribution.ts +218 -218
  34. package/src/browser/notifications-manager.ts +305 -305
  35. package/src/browser/notifications-renderer.tsx +61 -61
  36. package/src/browser/style/index.css +17 -17
  37. package/src/browser/style/notifications.css +283 -283
package/README.md CHANGED
@@ -1,30 +1,30 @@
1
- <div align='center'>
2
-
3
- <br />
4
-
5
- <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
-
7
- <h2>ECLIPSE THEIA - MESSAGES EXTENSION</h2>
8
-
9
- <hr />
10
-
11
- </div>
12
-
13
- ## Description
14
-
15
- The `@theia/messages` extension provides the ability to display user notifications in the application.
16
-
17
- ## Additional Information
18
-
19
- - [API documentation for `@theia/messages`](https://eclipse-theia.github.io/theia/docs/next/modules/messages.html)
20
- - [Theia - GitHub](https://github.com/eclipse-theia/theia)
21
- - [Theia - Website](https://theia-ide.org/)
22
-
23
- ## License
24
-
25
- - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
26
- - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
27
-
28
- ## Trademark
29
- "Theia" is a trademark of the Eclipse Foundation
30
- https://www.eclipse.org/theia
1
+ <div align='center'>
2
+
3
+ <br />
4
+
5
+ <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
+
7
+ <h2>ECLIPSE THEIA - MESSAGES EXTENSION</h2>
8
+
9
+ <hr />
10
+
11
+ </div>
12
+
13
+ ## Description
14
+
15
+ The `@theia/messages` extension provides the ability to display user notifications in the application.
16
+
17
+ ## Additional Information
18
+
19
+ - [API documentation for `@theia/messages`](https://eclipse-theia.github.io/theia/docs/next/modules/messages.html)
20
+ - [Theia - GitHub](https://github.com/eclipse-theia/theia)
21
+ - [Theia - Website](https://theia-ide.org/)
22
+
23
+ ## License
24
+
25
+ - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
26
+ - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
27
+
28
+ ## Trademark
29
+ "Theia" is a trademark of the Eclipse Foundation
30
+ https://www.eclipse.org/theia
@@ -1,5 +1,5 @@
1
- import '../../src/browser/style/index.css';
2
- import { ContainerModule } from '@theia/core/shared/inversify';
3
- declare const _default: ContainerModule;
4
- export default _default;
1
+ import '../../src/browser/style/index.css';
2
+ import { ContainerModule } from '@theia/core/shared/inversify';
3
+ declare const _default: ContainerModule;
4
+ export default _default;
5
5
  //# sourceMappingURL=messages-frontend-module.d.ts.map
@@ -1,42 +1,42 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 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
- require("../../src/browser/style/index.css");
19
- const inversify_1 = require("@theia/core/shared/inversify");
20
- const common_1 = require("@theia/core/lib/common");
21
- const notifications_manager_1 = require("./notifications-manager");
22
- const notification_preferences_1 = require("./notification-preferences");
23
- const notifications_renderer_1 = require("./notifications-renderer");
24
- const notifications_contribution_1 = require("./notifications-contribution");
25
- const browser_1 = require("@theia/core/lib/browser");
26
- const core_1 = require("@theia/core");
27
- const color_application_contribution_1 = require("@theia/core/lib/browser/color-application-contribution");
28
- const notification_content_renderer_1 = require("./notification-content-renderer");
29
- exports.default = new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
30
- bind(notification_content_renderer_1.NotificationContentRenderer).toSelf().inSingletonScope();
31
- bind(notifications_renderer_1.NotificationsRenderer).toSelf().inSingletonScope();
32
- bind(notifications_contribution_1.NotificationsContribution).toSelf().inSingletonScope();
33
- bind(browser_1.FrontendApplicationContribution).toService(notifications_contribution_1.NotificationsContribution);
34
- bind(core_1.CommandContribution).toService(notifications_contribution_1.NotificationsContribution);
35
- bind(browser_1.KeybindingContribution).toService(notifications_contribution_1.NotificationsContribution);
36
- bind(color_application_contribution_1.ColorContribution).toService(notifications_contribution_1.NotificationsContribution);
37
- bind(browser_1.StylingParticipant).toService(notifications_contribution_1.NotificationsContribution);
38
- bind(notifications_manager_1.NotificationManager).toSelf().inSingletonScope();
39
- rebind(common_1.MessageClient).toService(notifications_manager_1.NotificationManager);
40
- (0, notification_preferences_1.bindNotificationPreferences)(bind);
41
- });
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 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
+ require("../../src/browser/style/index.css");
19
+ const inversify_1 = require("@theia/core/shared/inversify");
20
+ const common_1 = require("@theia/core/lib/common");
21
+ const notifications_manager_1 = require("./notifications-manager");
22
+ const notification_preferences_1 = require("./notification-preferences");
23
+ const notifications_renderer_1 = require("./notifications-renderer");
24
+ const notifications_contribution_1 = require("./notifications-contribution");
25
+ const browser_1 = require("@theia/core/lib/browser");
26
+ const core_1 = require("@theia/core");
27
+ const color_application_contribution_1 = require("@theia/core/lib/browser/color-application-contribution");
28
+ const notification_content_renderer_1 = require("./notification-content-renderer");
29
+ exports.default = new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
30
+ bind(notification_content_renderer_1.NotificationContentRenderer).toSelf().inSingletonScope();
31
+ bind(notifications_renderer_1.NotificationsRenderer).toSelf().inSingletonScope();
32
+ bind(notifications_contribution_1.NotificationsContribution).toSelf().inSingletonScope();
33
+ bind(browser_1.FrontendApplicationContribution).toService(notifications_contribution_1.NotificationsContribution);
34
+ bind(core_1.CommandContribution).toService(notifications_contribution_1.NotificationsContribution);
35
+ bind(browser_1.KeybindingContribution).toService(notifications_contribution_1.NotificationsContribution);
36
+ bind(color_application_contribution_1.ColorContribution).toService(notifications_contribution_1.NotificationsContribution);
37
+ bind(browser_1.StylingParticipant).toService(notifications_contribution_1.NotificationsContribution);
38
+ bind(notifications_manager_1.NotificationManager).toSelf().inSingletonScope();
39
+ rebind(common_1.MessageClient).toService(notifications_manager_1.NotificationManager);
40
+ (0, notification_preferences_1.bindNotificationPreferences)(bind);
41
+ });
42
42
  //# sourceMappingURL=messages-frontend-module.js.map
@@ -1,19 +1,19 @@
1
- /// <reference types="react" />
2
- import * as React from '@theia/core/shared/react';
3
- import { DisposableCollection } from '@theia/core';
4
- import { NotificationManager, NotificationUpdateEvent } from './notifications-manager';
5
- export interface NotificationCenterComponentProps {
6
- readonly manager: NotificationManager;
7
- }
8
- declare type NotificationCenterComponentState = Pick<NotificationUpdateEvent, Exclude<keyof NotificationUpdateEvent, 'toasts'>>;
9
- export declare class NotificationCenterComponent extends React.Component<NotificationCenterComponentProps, NotificationCenterComponentState> {
10
- constructor(props: NotificationCenterComponentProps);
11
- protected readonly toDisposeOnUnmount: DisposableCollection;
12
- componentDidMount(): Promise<void>;
13
- componentWillUnmount(): void;
14
- render(): React.ReactNode;
15
- protected onHide: () => void;
16
- protected onClearAll: () => void;
17
- }
18
- export {};
1
+ /// <reference types="react" />
2
+ import * as React from '@theia/core/shared/react';
3
+ import { DisposableCollection } from '@theia/core';
4
+ import { NotificationManager, NotificationUpdateEvent } from './notifications-manager';
5
+ export interface NotificationCenterComponentProps {
6
+ readonly manager: NotificationManager;
7
+ }
8
+ declare type NotificationCenterComponentState = Pick<NotificationUpdateEvent, Exclude<keyof NotificationUpdateEvent, 'toasts'>>;
9
+ export declare class NotificationCenterComponent extends React.Component<NotificationCenterComponentProps, NotificationCenterComponentState> {
10
+ constructor(props: NotificationCenterComponentProps);
11
+ protected readonly toDisposeOnUnmount: DisposableCollection;
12
+ componentDidMount(): Promise<void>;
13
+ componentWillUnmount(): void;
14
+ render(): React.ReactNode;
15
+ protected onHide: () => void;
16
+ protected onClearAll: () => void;
17
+ }
18
+ export {};
19
19
  //# sourceMappingURL=notification-center-component.d.ts.map
@@ -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.NotificationCenterComponent = void 0;
19
- const React = require("@theia/core/shared/react");
20
- const core_1 = require("@theia/core");
21
- const notification_component_1 = require("./notification-component");
22
- const browser_1 = require("@theia/core/lib/browser");
23
- const nls_1 = require("@theia/core/lib/common/nls");
24
- const PerfectScrollbar = require('react-perfect-scrollbar');
25
- class NotificationCenterComponent extends React.Component {
26
- constructor(props) {
27
- super(props);
28
- this.toDisposeOnUnmount = new core_1.DisposableCollection();
29
- this.onHide = () => {
30
- this.props.manager.hideCenter();
31
- };
32
- this.onClearAll = () => {
33
- this.props.manager.clearAll();
34
- };
35
- this.state = {
36
- notifications: [],
37
- visibilityState: 'hidden'
38
- };
39
- }
40
- async componentDidMount() {
41
- this.toDisposeOnUnmount.push(this.props.manager.onUpdated(({ notifications, visibilityState }) => {
42
- this.setState({
43
- notifications: notifications,
44
- visibilityState
45
- });
46
- }));
47
- }
48
- componentWillUnmount() {
49
- this.toDisposeOnUnmount.dispose();
50
- }
51
- render() {
52
- const empty = this.state.notifications.length === 0;
53
- const title = empty
54
- ? nls_1.nls.localizeByDefault('No New Notifications')
55
- : nls_1.nls.localizeByDefault('Notifications');
56
- return (React.createElement("div", { className: `theia-notifications-container theia-notification-center ${this.state.visibilityState === 'center' ? 'open' : 'closed'}` },
57
- React.createElement("div", { className: 'theia-notification-center-header' },
58
- React.createElement("div", { className: 'theia-notification-center-header-title' }, title),
59
- React.createElement("div", { className: 'theia-notification-center-header-actions' },
60
- React.createElement("ul", { className: 'theia-notification-actions' },
61
- React.createElement("li", { className: (0, browser_1.codicon)('clear-all', true), title: nls_1.nls.localizeByDefault('Clear All Notifications'), onClick: this.onClearAll }),
62
- React.createElement("li", { className: (0, browser_1.codicon)('chevron-down', true), title: nls_1.nls.localizeByDefault('Hide Notifications'), onClick: this.onHide })))),
63
- React.createElement(PerfectScrollbar, { className: 'theia-notification-list-scroll-container' },
64
- React.createElement("div", { className: 'theia-notification-list' }, this.state.notifications.map(notification => React.createElement(notification_component_1.NotificationComponent, { key: notification.messageId, notification: notification, manager: this.props.manager }))))));
65
- }
66
- }
67
- exports.NotificationCenterComponent = NotificationCenterComponent;
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.NotificationCenterComponent = void 0;
19
+ const React = require("@theia/core/shared/react");
20
+ const core_1 = require("@theia/core");
21
+ const notification_component_1 = require("./notification-component");
22
+ const browser_1 = require("@theia/core/lib/browser");
23
+ const nls_1 = require("@theia/core/lib/common/nls");
24
+ const PerfectScrollbar = require('react-perfect-scrollbar');
25
+ class NotificationCenterComponent extends React.Component {
26
+ constructor(props) {
27
+ super(props);
28
+ this.toDisposeOnUnmount = new core_1.DisposableCollection();
29
+ this.onHide = () => {
30
+ this.props.manager.hideCenter();
31
+ };
32
+ this.onClearAll = () => {
33
+ this.props.manager.clearAll();
34
+ };
35
+ this.state = {
36
+ notifications: [],
37
+ visibilityState: 'hidden'
38
+ };
39
+ }
40
+ async componentDidMount() {
41
+ this.toDisposeOnUnmount.push(this.props.manager.onUpdated(({ notifications, visibilityState }) => {
42
+ this.setState({
43
+ notifications: notifications,
44
+ visibilityState
45
+ });
46
+ }));
47
+ }
48
+ componentWillUnmount() {
49
+ this.toDisposeOnUnmount.dispose();
50
+ }
51
+ render() {
52
+ const empty = this.state.notifications.length === 0;
53
+ const title = empty
54
+ ? nls_1.nls.localizeByDefault('No New Notifications')
55
+ : nls_1.nls.localizeByDefault('Notifications');
56
+ return (React.createElement("div", { className: `theia-notifications-container theia-notification-center ${this.state.visibilityState === 'center' ? 'open' : 'closed'}` },
57
+ React.createElement("div", { className: 'theia-notification-center-header' },
58
+ React.createElement("div", { className: 'theia-notification-center-header-title' }, title),
59
+ React.createElement("div", { className: 'theia-notification-center-header-actions' },
60
+ React.createElement("ul", { className: 'theia-notification-actions' },
61
+ React.createElement("li", { className: (0, browser_1.codicon)('clear-all', true), title: nls_1.nls.localizeByDefault('Clear All Notifications'), onClick: this.onClearAll }),
62
+ React.createElement("li", { className: (0, browser_1.codicon)('chevron-down', true), title: nls_1.nls.localizeByDefault('Hide Notifications'), onClick: this.onHide })))),
63
+ React.createElement(PerfectScrollbar, { className: 'theia-notification-list-scroll-container' },
64
+ React.createElement("div", { className: 'theia-notification-list' }, this.state.notifications.map(notification => React.createElement(notification_component_1.NotificationComponent, { key: notification.messageId, notification: notification, manager: this.props.manager }))))));
65
+ }
66
+ }
67
+ exports.NotificationCenterComponent = NotificationCenterComponent;
68
68
  //# sourceMappingURL=notification-center-component.js.map
@@ -1,16 +1,16 @@
1
- /// <reference types="react" />
2
- import * as React from '@theia/core/shared/react';
3
- import { NotificationManager, Notification } from './notifications-manager';
4
- export interface NotificationComponentProps {
5
- readonly manager: NotificationManager;
6
- readonly notification: Notification;
7
- }
8
- export declare class NotificationComponent extends React.Component<NotificationComponentProps> {
9
- constructor(props: NotificationComponentProps);
10
- protected onClear: (event: React.MouseEvent) => void;
11
- protected onToggleExpansion: (event: React.MouseEvent) => void;
12
- protected onAction: (event: React.MouseEvent) => void;
13
- protected onMessageClick: (event: React.MouseEvent) => void;
14
- render(): React.ReactNode;
15
- }
1
+ /// <reference types="react" />
2
+ import * as React from '@theia/core/shared/react';
3
+ import { NotificationManager, Notification } from './notifications-manager';
4
+ export interface NotificationComponentProps {
5
+ readonly manager: NotificationManager;
6
+ readonly notification: Notification;
7
+ }
8
+ export declare class NotificationComponent extends React.Component<NotificationComponentProps> {
9
+ constructor(props: NotificationComponentProps);
10
+ protected onClear: (event: React.MouseEvent) => void;
11
+ protected onToggleExpansion: (event: React.MouseEvent) => void;
12
+ protected onAction: (event: React.MouseEvent) => void;
13
+ protected onMessageClick: (event: React.MouseEvent) => void;
14
+ render(): React.ReactNode;
15
+ }
16
16
  //# sourceMappingURL=notification-component.d.ts.map
@@ -1,89 +1,89 @@
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.NotificationComponent = void 0;
19
- const React = require("@theia/core/shared/react");
20
- const DOMPurify = require("@theia/core/shared/dompurify");
21
- const browser_1 = require("@theia/core/lib/browser");
22
- const nls_1 = require("@theia/core/lib/common/nls");
23
- class NotificationComponent extends React.Component {
24
- constructor(props) {
25
- super(props);
26
- this.onClear = (event) => {
27
- if (event.target instanceof HTMLElement) {
28
- const messageId = event.target.dataset.messageId;
29
- if (messageId) {
30
- this.props.manager.clear(messageId);
31
- }
32
- }
33
- };
34
- this.onToggleExpansion = (event) => {
35
- if (event.target instanceof HTMLElement) {
36
- const messageId = event.target.dataset.messageId;
37
- if (messageId) {
38
- this.props.manager.toggleExpansion(messageId);
39
- }
40
- }
41
- };
42
- this.onAction = (event) => {
43
- if (event.target instanceof HTMLElement) {
44
- const messageId = event.target.dataset.messageId;
45
- const action = event.target.dataset.action;
46
- if (messageId && action) {
47
- this.props.manager.accept(messageId, action);
48
- }
49
- }
50
- };
51
- this.onMessageClick = (event) => {
52
- if (event.target instanceof HTMLAnchorElement) {
53
- event.stopPropagation();
54
- event.preventDefault();
55
- const link = event.target.href;
56
- this.props.manager.openLink(link);
57
- }
58
- };
59
- this.state = {};
60
- }
61
- render() {
62
- const { messageId, message, type, progress, collapsed, expandable, source, actions } = this.props.notification;
63
- const isProgress = type === 'progress' || typeof progress === 'number';
64
- const icon = type === 'progress' ? 'info' : type;
65
- return (React.createElement("div", { key: messageId, className: 'theia-notification-list-item-container' },
66
- React.createElement("div", { className: 'theia-notification-list-item', tabIndex: 0 },
67
- React.createElement("div", { className: `theia-notification-list-item-content ${collapsed ? 'collapsed' : ''}` },
68
- React.createElement("div", { className: 'theia-notification-list-item-content-main' },
69
- React.createElement("div", { className: `theia-notification-icon ${(0, browser_1.codicon)(icon)} ${icon}` }),
70
- React.createElement("div", { className: 'theia-notification-message' },
71
- React.createElement("span", {
72
- // eslint-disable-next-line react/no-danger
73
- dangerouslySetInnerHTML: {
74
- __html: DOMPurify.sanitize(message, {
75
- ALLOW_UNKNOWN_PROTOCOLS: true // DOMPurify usually strips non http(s) links from hrefs
76
- })
77
- }, onClick: this.onMessageClick })),
78
- React.createElement("ul", { className: 'theia-notification-actions' },
79
- expandable && (React.createElement("li", { className: (0, browser_1.codicon)('chevron-down', true) + (collapsed ? ' expand' : ' collapse'), title: collapsed ? 'Expand' : 'Collapse', "data-message-id": messageId, onClick: this.onToggleExpansion })),
80
- !isProgress && (React.createElement("li", { className: (0, browser_1.codicon)('close', true), title: nls_1.nls.localizeByDefault('Clear'), "data-message-id": messageId, onClick: this.onClear })))),
81
- (source || !!actions.length) && (React.createElement("div", { className: 'theia-notification-list-item-content-bottom' },
82
- React.createElement("div", { className: 'theia-notification-source' }, source && (React.createElement("span", null, source))),
83
- React.createElement("div", { className: 'theia-notification-buttons' }, actions && actions.map((action, index) => (React.createElement("button", { key: messageId + `-action-${index}`, className: 'theia-button', "data-message-id": messageId, "data-action": action, onClick: this.onAction }, action))))))),
84
- isProgress && (React.createElement("div", { className: 'theia-notification-item-progress' },
85
- React.createElement("div", { className: `theia-notification-item-progressbar ${progress ? 'determinate' : 'indeterminate'}`, style: { width: `${progress !== null && progress !== void 0 ? progress : '100'}%` } }))))));
86
- }
87
- }
88
- exports.NotificationComponent = NotificationComponent;
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.NotificationComponent = void 0;
19
+ const React = require("@theia/core/shared/react");
20
+ const DOMPurify = require("@theia/core/shared/dompurify");
21
+ const browser_1 = require("@theia/core/lib/browser");
22
+ const nls_1 = require("@theia/core/lib/common/nls");
23
+ class NotificationComponent extends React.Component {
24
+ constructor(props) {
25
+ super(props);
26
+ this.onClear = (event) => {
27
+ if (event.target instanceof HTMLElement) {
28
+ const messageId = event.target.dataset.messageId;
29
+ if (messageId) {
30
+ this.props.manager.clear(messageId);
31
+ }
32
+ }
33
+ };
34
+ this.onToggleExpansion = (event) => {
35
+ if (event.target instanceof HTMLElement) {
36
+ const messageId = event.target.dataset.messageId;
37
+ if (messageId) {
38
+ this.props.manager.toggleExpansion(messageId);
39
+ }
40
+ }
41
+ };
42
+ this.onAction = (event) => {
43
+ if (event.target instanceof HTMLElement) {
44
+ const messageId = event.target.dataset.messageId;
45
+ const action = event.target.dataset.action;
46
+ if (messageId && action) {
47
+ this.props.manager.accept(messageId, action);
48
+ }
49
+ }
50
+ };
51
+ this.onMessageClick = (event) => {
52
+ if (event.target instanceof HTMLAnchorElement) {
53
+ event.stopPropagation();
54
+ event.preventDefault();
55
+ const link = event.target.href;
56
+ this.props.manager.openLink(link);
57
+ }
58
+ };
59
+ this.state = {};
60
+ }
61
+ render() {
62
+ const { messageId, message, type, progress, collapsed, expandable, source, actions } = this.props.notification;
63
+ const isProgress = type === 'progress' || typeof progress === 'number';
64
+ const icon = type === 'progress' ? 'info' : type;
65
+ return (React.createElement("div", { key: messageId, className: 'theia-notification-list-item-container' },
66
+ React.createElement("div", { className: 'theia-notification-list-item', tabIndex: 0 },
67
+ React.createElement("div", { className: `theia-notification-list-item-content ${collapsed ? 'collapsed' : ''}` },
68
+ React.createElement("div", { className: 'theia-notification-list-item-content-main' },
69
+ React.createElement("div", { className: `theia-notification-icon ${(0, browser_1.codicon)(icon)} ${icon}` }),
70
+ React.createElement("div", { className: 'theia-notification-message' },
71
+ React.createElement("span", {
72
+ // eslint-disable-next-line react/no-danger
73
+ dangerouslySetInnerHTML: {
74
+ __html: DOMPurify.sanitize(message, {
75
+ ALLOW_UNKNOWN_PROTOCOLS: true // DOMPurify usually strips non http(s) links from hrefs
76
+ })
77
+ }, onClick: this.onMessageClick })),
78
+ React.createElement("ul", { className: 'theia-notification-actions' },
79
+ expandable && (React.createElement("li", { className: (0, browser_1.codicon)('chevron-down', true) + (collapsed ? ' expand' : ' collapse'), title: collapsed ? 'Expand' : 'Collapse', "data-message-id": messageId, onClick: this.onToggleExpansion })),
80
+ !isProgress && (React.createElement("li", { className: (0, browser_1.codicon)('close', true), title: nls_1.nls.localizeByDefault('Clear'), "data-message-id": messageId, onClick: this.onClear })))),
81
+ (source || !!actions.length) && (React.createElement("div", { className: 'theia-notification-list-item-content-bottom' },
82
+ React.createElement("div", { className: 'theia-notification-source' }, source && (React.createElement("span", null, source))),
83
+ React.createElement("div", { className: 'theia-notification-buttons' }, actions && actions.map((action, index) => (React.createElement("button", { key: messageId + `-action-${index}`, className: 'theia-button', "data-message-id": messageId, "data-action": action, onClick: this.onAction }, action))))))),
84
+ isProgress && (React.createElement("div", { className: 'theia-notification-item-progress' },
85
+ React.createElement("div", { className: `theia-notification-item-progressbar ${progress ? 'determinate' : 'indeterminate'}`, style: { width: `${progress !== null && progress !== void 0 ? progress : '100'}%` } }))))));
86
+ }
87
+ }
88
+ exports.NotificationComponent = NotificationComponent;
89
89
  //# sourceMappingURL=notification-component.js.map
@@ -1,6 +1,6 @@
1
- import * as markdownit from '@theia/core/shared/markdown-it';
2
- export declare class NotificationContentRenderer {
3
- protected readonly mdEngine: markdownit;
4
- renderMessage(content: string): string;
5
- }
1
+ import * as markdownit from '@theia/core/shared/markdown-it';
2
+ export declare class NotificationContentRenderer {
3
+ protected readonly mdEngine: markdownit;
4
+ renderMessage(content: string): string;
5
+ }
6
6
  //# sourceMappingURL=notification-content-renderer.d.ts.map