Commit d08c79e4 authored by Alex Danilo's avatar Alex Danilo Committed by Commit Bot

Add support for showing errors on file operations

Adds support for the 'error' status returned from file operations in
progress. Also allows the error panel item to be dismissed.

The error message can be too long to show on one line with the maximum
width of the panels, so it's split into 2 lines using regexps. This will
need an integration test to make sure translations fit in the maximum
width without generating ellipsis.

Bug: 947388, 979374
Change-Id: I3d33a5ab821c574cc454fb3520089cd949898e4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692422Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676234}
parent 76447a5d
...@@ -37,7 +37,8 @@ class PanelButton extends HTMLElement { ...@@ -37,7 +37,8 @@ class PanelButton extends HTMLElement {
background: url(../images/files/ui/pause.svg) no-repeat center; background: url(../images/files/ui/pause.svg) no-repeat center;
} }
:host([data-category='cancel']) { :host([data-category='cancel']),
:host([data-category='dismiss']) {
background: url(../images/files/ui/cancel.svg) no-repeat center; background: url(../images/files/ui/cancel.svg) no-repeat center;
} }
......
...@@ -212,7 +212,7 @@ class PanelItem extends HTMLElement { ...@@ -212,7 +212,7 @@ class PanelItem extends HTMLElement {
secondaryButton = document.createElement('xf-button'); secondaryButton = document.createElement('xf-button');
secondaryButton.id = 'secondary-action'; secondaryButton.id = 'secondary-action';
secondaryButton.onclick = this.onclick; secondaryButton.onclick = this.onclick;
secondaryButton.dataset.category = 'retry'; secondaryButton.dataset.category = 'dismiss';
buttonSpacer.insertAdjacentElement('afterend', secondaryButton); buttonSpacer.insertAdjacentElement('afterend', secondaryButton);
break; break;
case this.panelTypeInfo: case this.panelTypeInfo:
......
...@@ -338,12 +338,25 @@ class ProgressCenterPanel { ...@@ -338,12 +338,25 @@ class ProgressCenterPanel {
if (signal === 'cancel' && item.cancelCallback) { if (signal === 'cancel' && item.cancelCallback) {
item.cancelCallback(); item.cancelCallback();
} }
if (signal === 'dismiss') {
this.feedbackHost_.removePanelItem(panelItem);
}
}; };
panelItem.progress = item.progressRateInPercent.toString(); panelItem.progress = item.progressRateInPercent.toString();
// Remove the feedback panel when complete, and create switch (item.state) {
// an activity complete panel. case 'completed':
if (item.state == 'completed') { case 'canceled':
this.feedbackHost_.removePanelItem(panelItem); // Remove the feedback panel when complete, and TODO(create
// an activity complete panel).
this.feedbackHost_.removePanelItem(panelItem);
break;
case 'error':
panelItem.panelType = panelItem.panelTypeError;
panelItem.setAttribute(
'primary-text', item.message.replace(/\. .*/, '.'));
panelItem.setAttribute(
'secondary-text', item.message.replace(/.*\. /, ''));
break;
} }
} else if (panelItem) { } else if (panelItem) {
this.feedbackHost_.removePanelItem(panelItem); this.feedbackHost_.removePanelItem(panelItem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment