Skip to content

Commit

Permalink
Fix progress notification issues
Browse files Browse the repository at this point in the history
Signed-off-by: Doron Nahari <doron.nahari@sap.com>
  • Loading branch information
DoroNahari committed Oct 4, 2020
1 parent 57b4b67 commit 3caa1da
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<a name="breaking_changes_1.7.0">[Breaking Changes:](#breaking_changes_1.7.0)</a>

- [plugin-metrics] renamed `AnalyticsFromRequests.succesfulResponses` to `AnalyticsFromRequests.successfulResponses` []()
- [core] change progress notification cancelable property default from true to false [#8479](https://github.com/eclipse-theia/theia/pull/8479)
- [messages] empty notifications and progress notifications will not be shown [#8479](https://github.com/eclipse-theia/theia/pull/8479)

## v1.6.0 - 24/09/2020

Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/common/message-service-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export interface ProgressMessage extends Message {
export namespace ProgressMessage {
export const Cancel = 'Cancel';
export function isCancelable(message: ProgressMessage): boolean {
return !message.options
|| message.options.cancelable === undefined
|| message.options.cancelable === true;
return !!message.options?.cancelable;
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/messages/src/browser/notification-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class NotificationComponent extends React.Component<NotificationComponent

render(): React.ReactNode {
const { messageId, message, type, progress, collapsed, expandable, source, actions } = this.props.notification;
const isProgress = typeof progress === 'number';
return (<div key={messageId} className='theia-notification-list-item'>
<div className={`theia-notification-list-item-content ${collapsed ? 'collapsed' : ''}`}>
<div className='theia-notification-list-item-content-main'>
Expand All @@ -80,7 +81,7 @@ export class NotificationComponent extends React.Component<NotificationComponent
<li className={collapsed ? 'expand' : 'collapse'} title={collapsed ? 'Expand' : 'Collapse'}
data-message-id={messageId} onClick={this.onToggleExpansion} />
)}
<li className='clear' title='Clear' data-message-id={messageId} onClick={this.onClear} />
{ !isProgress && (<li className='clear' title='Clear' data-message-id={messageId} onClick={this.onClear} />)}
</ul>
</div>
{(source || !!actions.length) && (
Expand All @@ -100,7 +101,7 @@ export class NotificationComponent extends React.Component<NotificationComponent
</div>
)}
</div>
{typeof progress === 'number' && (
{ isProgress && (
<div className='theia-notification-item-progress'>
<div className='theia-notification-item-progressbar' style={{ width: `${progress}%` }} />
</div>
Expand Down
13 changes: 9 additions & 4 deletions packages/messages/src/browser/notifications-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ export class NotificationManager extends MessageClient {
protected readonly onUpdatedEmitter = new Emitter<NotificationUpdateEvent>();
readonly onUpdated = this.onUpdatedEmitter.event;
protected readonly fireUpdatedEvent = throttle(() => {
const notifications = deepClone(Array.from(this.notifications.values()));
const toasts = deepClone(Array.from(this.toasts.values()));
const notifications = deepClone(Array.from(this.notifications.values()).filter((notification: Notification) =>
notification.message
));
const toasts = deepClone(Array.from(this.toasts.values()).filter((toast: Notification) =>
toast.message
));
const visibilityState = this.visibilityState;
this.onUpdatedEmitter.fire({ notifications, toasts, visibilityState });
}, 250, { leading: true, trailing: true });
Expand Down Expand Up @@ -269,8 +273,9 @@ export class NotificationManager extends MessageClient {
if (cancellationToken.isCancellationRequested) {
this.clear(messageId);
} else {
notification.message = update.message ? `${originalMessage.text}: ${update.message}` : originalMessage.text;
notification.progress = this.toPlainProgress(update);
notification.message = originalMessage.text && update.message ? `${originalMessage.text}: ${update.message}` :
originalMessage.text || update?.message || notification.message;
notification.progress = this.toPlainProgress(update) || notification.progress;
}
this.fireUpdatedEvent();
}
Expand Down

0 comments on commit 3caa1da

Please sign in to comment.