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

[visual signals] Fix messages for empty destination

Feedback panels display operations in progress with the source and
destination visible. In cases where the destination string is empty
(e.g. copying to a USB drive with " " as its name), the feedback message
should be grammatically correct.

Adds new strings for display when there is no destination string.

Changes the string generation code to detect empty destination string
and use the appropriate string for formatting.

Bug: 1076312
Tests: Manually tested for all cases, with transfer progress as well.
Change-Id: I72a162d8e0a18a4415d043501bee3cb53b802b36
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409560Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807678}
parent 43bec4c0
......@@ -446,6 +446,7 @@ std::unique_ptr<base::DictionaryValue> GetFileManagerStrings() {
IDS_FILE_BROWSER_CONFLICT_DIALOG_MESSAGE);
SET_STRING("CONFLICT_DIALOG_REPLACE",
IDS_FILE_BROWSER_CONFLICT_DIALOG_REPLACE);
SET_STRING("COPIED", IDS_FILE_BROWSER_COPIED);
SET_STRING("COPIED_TO", IDS_FILE_BROWSER_COPIED_TO);
SET_STRING("COPY_BUTTON_LABEL", IDS_FILE_BROWSER_COPY_BUTTON_LABEL);
SET_STRING("COPY_FILESYSTEM_ERROR", IDS_FILE_BROWSER_COPY_FILESYSTEM_ERROR);
......@@ -531,7 +532,11 @@ std::unique_ptr<base::DictionaryValue> GetFileManagerStrings() {
SET_STRING("FAILED_SPACE_INFO", IDS_FILE_BROWSER_FAILED_SPACE_INFO);
SET_STRING("FILENAME_LABEL", IDS_FILE_BROWSER_FILENAME_LABEL);
SET_STRING("FILE_ALREADY_EXISTS", IDS_FILE_BROWSER_FILE_ALREADY_EXISTS);
SET_STRING("FILE_COPIED", IDS_FILE_BROWSER_FILE_COPIED);
SET_STRING("FILE_ITEMS", IDS_FILE_BROWSER_FILE_ITEMS);
SET_STRING("FILE_ITEMS_COPIED", IDS_FILE_BROWSER_FILE_ITEMS_COPIED);
SET_STRING("FILE_ITEMS_MOVED", IDS_FILE_BROWSER_FILE_ITEMS_MOVED);
SET_STRING("FILE_MOVED", IDS_FILE_BROWSER_FILE_MOVED);
SET_STRING("FOLDER_SHARED_WITH_CROSTINI",
IDS_FILE_BROWSER_FOLDER_SHARED_WITH_CROSTINI);
SET_STRING("FOLDER_SHARED_WITH_CROSTINI_PLURAL",
......@@ -683,6 +688,7 @@ std::unique_ptr<base::DictionaryValue> GetFileManagerStrings() {
IDS_FILE_BROWSER_METADATA_BOX_YEAR_RECORDED);
SET_STRING("MOUNT_ARCHIVE", IDS_FILE_BROWSER_MOUNT_ARCHIVE);
SET_STRING("MOVE_FILESYSTEM_ERROR", IDS_FILE_BROWSER_MOVE_FILESYSTEM_ERROR);
SET_STRING("MOVED", IDS_FILE_BROWSER_MOVED);
SET_STRING("MOVED_TO", IDS_FILE_BROWSER_MOVED_TO);
// TODO (crbug/1093603): Clean up after FilesTransferDetails launch.
SET_STRING("MOVE_FILE_NAME", IDS_FILE_BROWSER_MOVE_FILE_NAME);
......
......@@ -721,6 +721,9 @@
<message name="IDS_FILE_BROWSER_CLOUD_IMPORT_ITEMS_REMAINING" desc="File Manager status message.">
Importing <ph name="FILE_COUNT">$1<ex>5</ex></ph> files...
</message>
<message name="IDS_FILE_BROWSER_COPIED" desc="File Manager status message.">
Copied.
</message>
<message name="IDS_FILE_BROWSER_COPIED_TO" desc="File Manager status message.">
Copied to <ph name="FOLDER_NAME">$1<ex>images</ex></ph>.
</message>
......@@ -758,8 +761,20 @@
<message name="IDS_FILE_BROWSER_COPY_UNEXPECTED_ERROR" desc="File Manager error message.">
Copy operation failed, unexpected error: <ph name="ERROR_MESSAGE">$1<ex>Could not copy</ex></ph>
</message>
<message name="IDS_FILE_BROWSER_FILE_COPIED" desc="File Manager status message. 'Item' is used here as a generic term for file or directory.">
<ph name="NUMBER_OF_ITEMS">$1<ex>3</ex></ph> copied.
</message>
<message name="IDS_FILE_BROWSER_FILE_ITEMS" desc="File Manager status message. 'Item' is used here as a generic term for file or directory.">
<ph name="NUMBER_OF_ITEMS">$1<ex>3</ex></ph> items
</message>
<message name="IDS_FILE_BROWSER_FILE_ITEMS_COPIED" desc="File Manager status message. 'Item' is used here as a generic term for file or directory.">
<ph name="NUMBER_OF_ITEMS">$1<ex>3</ex></ph> items copied.
</message>
<message name="IDS_FILE_BROWSER_FILE_ITEMS_MOVED" desc="File Manager status message. 'Item' is used here as a generic term for file or directory.">
<ph name="NUMBER_OF_ITEMS">$1<ex>3</ex></ph> items moved.
</message>
<message name="IDS_FILE_BROWSER_FILE_MOVED" desc="File Manager status message. 'Item' is used here as a generic term for file or directory.">
<ph name="NUMBER_OF_ITEMS">$1<ex>3</ex></ph> moved.
</message>
<!-- TODO (crbug/1093603): Clean up after FilesTransferDetails launch. -->
<message name="IDS_FILE_BROWSER_MOVE_FILE_NAME" desc="File Manager status message.">
......@@ -787,6 +802,9 @@
<message name="IDS_FILE_BROWSER_MOVE_UNEXPECTED_ERROR" desc="File Manager error message.">
Move failed, unexpected error: <ph name="ERROR_MESSAGE">$1<ex>Could not move</ex></ph>
</message>
<message name="IDS_FILE_BROWSER_MOVED" desc="File Manager status message.">
Moved.
</message>
<message name="IDS_FILE_BROWSER_MOVED_TO" desc="File Manager status message.">
Moved to <ph name="FOLDER_NAME">$1<ex>images</ex></ph>.
</message>
......
5eca46944ee40bc7d3a7697113763a49dee4318f
\ No newline at end of file
d0218c6981c069857eba06ad3f94bf373dc40573
\ No newline at end of file
f75e3bc891729672f4b4f4550c02e250b549adb3
\ No newline at end of file
9f09e98f8669816fbebf05fc1f7e005c939f2086
\ No newline at end of file
6cb05b5c6046c76d4cec2360f28df27c93c37c66
\ No newline at end of file
72034fcb299c4592b43bf720ea43a72e4a6f0855
\ No newline at end of file
......@@ -381,6 +381,18 @@ class ProgressCenterPanel {
return '';
}
/**
* Test if we have an empty or all whitespace string.
* @param {string} candidate String we're checking.
* @return {boolean} true if there's content in the candidate.
*/
isNonEmptyString_(candidate) {
if (!candidate || candidate.trim().length === 0) {
return false;
}
return true;
}
/**
* Generate destination string for display on the feedback panel.
* @param {!ProgressCenterItem} item Item we're generating a message for.
......@@ -388,14 +400,26 @@ class ProgressCenterPanel {
* @return {string} String formatted based on the item state.
*/
generateDestinationString_(item, info) {
const hasDestination = this.isNonEmptyString_(info['destination']);
switch (item.state) {
case 'progressing':
return strf('TO_FOLDER_NAME', info['destination']);
if (hasDestination) {
return strf('TO_FOLDER_NAME', info['destination']);
}
break;
case 'completed':
if (item.type === ProgressItemType.COPY) {
return strf('COPIED_TO', info['destination']);
if (hasDestination) {
return strf('COPIED_TO', info['destination']);
} else {
return str('COPIED');
}
} else if (item.type === ProgressItemType.MOVE) {
return strf('MOVED_TO', info['destination']);
if (hasDestination) {
return strf('MOVED_TO', info['destination']);
} else {
return str('MOVED');
}
}
break;
case 'error':
......@@ -417,28 +441,50 @@ class ProgressCenterPanel {
* @return {string} String formatted based on the item state.
*/
generatePrimaryString_(item, info) {
const hasDestination = this.isNonEmptyString_(info['destination']);
switch (item.state) {
case 'progressing':
// Source and primary string are the same for missing destination.
if (!hasDestination) {
return this.generateSourceString_(item, info);
}
// fall through
case 'completed':
if (item.itemCount === 1) {
if (item.type === ProgressItemType.COPY) {
return strf(
'COPY_FILE_NAME_LONG', info['source'], info['destination']);
if (hasDestination) {
return strf(
'COPY_FILE_NAME_LONG', info['source'], info['destination']);
} else {
return strf('FILE_COPIED', info['source']);
}
} else if (item.type === ProgressItemType.MOVE) {
return strf(
'MOVE_FILE_NAME_LONG', info['source'], info['destination']);
if (hasDestination) {
return strf(
'MOVE_FILE_NAME_LONG', info['source'], info['destination']);
} else {
return strf('FILE_MOVED', info['source']);
}
} else {
return item.message;
}
} else {
if (item.type === ProgressItemType.COPY) {
return strf(
'COPY_ITEMS_REMAINING_LONG', info['source'],
info['destination']);
if (hasDestination) {
return strf(
'COPY_ITEMS_REMAINING_LONG', info['source'],
info['destination']);
} else {
return strf('FILE_ITEMS_COPIED', info['source']);
}
} else if (item.type === ProgressItemType.MOVE) {
return strf(
'MOVE_ITEMS_REMAINING_LONG', info['source'],
info['destination']);
if (hasDestination) {
return strf(
'MOVE_ITEMS_REMAINING_LONG', info['source'],
info['destination']);
} else {
return strf('FILE_ITEMS_MOVED', info['source']);
}
} else {
return item.message;
}
......
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