Skip to content

Commit f77b5e8

Browse files
Gavin WilliamsChromium LUCI CQ
authored andcommitted
scanning: Show cancel scan succeeded toast
Show toast when scan is canceled. http://screen/A6FWUDiuK9pdp8T Bug: 1059779 Change-Id: Icae5c87cf2ff27e8fbf76ae3d97e48548275855c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2558967 Commit-Queue: Gavin Williams <[email protected]> Reviewed-by: Jesse Schettler <[email protected]> Cr-Commit-Position: refs/heads/master@{#832235}
1 parent c8e82c9 commit f77b5e8

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

chrome/test/data/webui/chromeos/scanning/scanning_app_test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,14 @@ export function scanningAppTest() {
561561
// enabled, and the cancel button shouldn't be visible.
562562
assertTrue(isVisible(scanButton));
563563
assertFalse(isVisible(cancelButton));
564+
assertTrue(scanningApp.$$('#toast').open);
565+
assertFalse(isVisible(
566+
/** @type {!HTMLElement} */ (scanningApp.$$('#infoIcon'))));
567+
assertFalse(isVisible(
568+
/** @type {!HTMLElement} */ (scanningApp.$$('#getHelpLink'))));
569+
assertEquals(
570+
scanningApp.i18n('scanCanceledToastText'),
571+
scanningApp.$$('#toastText').textContent.trim());
564572
});
565573
});
566574

@@ -608,6 +616,10 @@ export function scanningAppTest() {
608616
.then(() => {
609617
// After canceling fails, the error toast should pop up.
610618
assertTrue(scanningApp.$$('#toast').open);
619+
assertTrue(isVisible(
620+
/** @type {!HTMLElement} */ (scanningApp.$$('#infoIcon'))));
621+
assertTrue(isVisible(
622+
/** @type {!HTMLElement} */ (scanningApp.$$('#getHelpLink'))));
611623
assertEquals(
612624
scanningApp.i18n('cancelFailedToastText'),
613625
scanningApp.$$('#toastText').textContent.trim());
@@ -649,6 +661,10 @@ export function scanningAppTest() {
649661
})
650662
.then(() => {
651663
assertTrue(scanningApp.$$('#toast').open);
664+
assertTrue(isVisible(
665+
/** @type {!HTMLElement} */ (scanningApp.$$('#infoIcon'))));
666+
assertTrue(isVisible(
667+
/** @type {!HTMLElement} */ (scanningApp.$$('#getHelpLink'))));
652668
assertEquals(
653669
scanningApp.i18n('startScanFailedToast'),
654670
scanningApp.$$('#toastText').textContent.trim());

chromeos/chromeos_strings.grd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@ Try tapping the mic to ask me anything.
585585
<message name="IDS_SCANNING_APP_CANCEL_FAILED_TOAST_TEXT" desc="The error message displayed when a user attempts to cancel a scan job but the cancel request fails.">
586586
Couldn't cancel scanning
587587
</message>
588+
<message name="IDS_SCANNING_APP_SCAN_CANCELED_TOAST_TEXT" desc="The message displayed when a scan job is successfully canceled.">
589+
Scanning has been canceled
590+
</message>
588591

589592
<!-- Diagnostics App -->
590593
<!-- TODO(michaelcheco): Update with finalized copies of the strings -->
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
90b295e3dd019d9bab0ddee82c11c290284d157f

chromeos/components/scanning/resources/scanning_app.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,13 @@ <h1 id="appTitle">[[i18n('appTitle')]]</h1>
180180
</div>
181181
<cr-toast id="toast" duration="5000">
182182
<div id="toastDiv">
183-
<iron-icon id="infoIcon" icon="cr:info-outline"></iron-icon>
183+
<iron-icon id="infoIcon" icon="cr:info-outline"
184+
hidden="[[!showToastInfoIcon_]]"></iron-icon>
184185
<span id="toastText">[[i18n(toastMessageKey_)]]</span>
185186
<!-- TODO(gavinwill): Add href to the help link when available -->
186187
<div id="getHelpDiv">
187-
<a id="getHelpLink" href="#">[[i18n('getHelpLinkText')]]</a>
188+
<a id="getHelpLink" href="#" hidden="[[!showToastHelpLink_]]">
189+
[[i18n('getHelpLinkText')]]</a>
188190
</div>
189191
</div>
190192
</cr-toast>

chromeos/components/scanning/resources/scanning_app.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,22 @@ Polymer({
185185
* The key to retrieve the appropriate string to display in the toast.
186186
* @private {string}
187187
*/
188-
toastMessageKey_: String,
188+
toastMessageKey_: {
189+
type: String,
190+
observer: 'onToastMessageKeyChange_',
191+
},
192+
193+
/** @private {boolean} */
194+
showToastInfoIcon_: {
195+
type: Boolean,
196+
value: false,
197+
},
198+
199+
/** @private {boolean} */
200+
showToastHelpLink_: {
201+
type: Boolean,
202+
value: false,
203+
},
189204
},
190205

191206
/** @override */
@@ -267,6 +282,7 @@ Polymer({
267282
return;
268283
}
269284

285+
this.showToast_('scanCanceledToastText');
270286
this.setAppState_(AppState.READY);
271287
},
272288

@@ -494,4 +510,10 @@ Polymer({
494510
this.toastMessageKey_ = toastMessageKey;
495511
this.$.toast.show();
496512
},
513+
514+
/** @private */
515+
onToastMessageKeyChange_() {
516+
this.showToastInfoIcon_ = this.toastMessageKey_ !== 'scanCanceledToastText';
517+
this.showToastHelpLink_ = this.toastMessageKey_ !== 'scanCanceledToastText';
518+
},
497519
});

chromeos/components/scanning/scanning_ui.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void AddScanningAppStrings(content::WebUIDataSource* html_source) {
8484
{"resolutionDropdownLabel", IDS_SCANNING_APP_RESOLUTION_DROPDOWN_LABEL},
8585
{"resolutionOptionText", IDS_SCANNING_APP_RESOLUTION_OPTION_TEXT},
8686
{"scanButtonText", IDS_SCANNING_APP_SCAN_BUTTON_TEXT},
87+
{"scanCanceledToastText", IDS_SCANNING_APP_SCAN_CANCELED_TOAST_TEXT},
8788
{"scanPreviewHelperText", IDS_SCANNING_APP_SCAN_PREVIEW_HELPER_TEXT},
8889
{"scanPreviewProgressText", IDS_SCANNING_APP_SCAN_PREVIEW_PROGRESS_TEXT},
8990
{"scanToDropdownLabel", IDS_SCANNING_APP_SCAN_TO_DROPDOWN_LABEL},

0 commit comments

Comments
 (0)