Commit 83d39859 authored by Klemen Kozjek's avatar Klemen Kozjek Committed by Commit Bot

Files App: Add notifications for renaming

This CL adds notification messages for renaming process for events:
PENDING, SUCCESS, and FAILURE. In addition to notification this CL also
adds strings required by notifications. As a result, when renaming is invoked
you ought to see notification that reports the current status of
renaming.

BUG=274041
TEST=browser_tests FileManagerJsTest.DeviceHandler*

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I000bdb58ca93c7f61c8bdf111397d495fc89316e
Reviewed-on: https://chromium-review.googlesource.com/615105
Commit-Queue: Klemen Kozjek <klemenko@google.com>
Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496555}
parent 031ae100
......@@ -3269,6 +3269,26 @@ Battery full
Aw, Snap! There was an error during formatting.
</message>
<!-- Renaming device notifications -->
<message name="IDS_RENAMING_OF_DEVICE_PENDING_TITLE" desc="Title of notification message which is shown when renaming process of some device is in progress">
Renaming...
</message>
<message name="IDS_RENAMING_OF_DEVICE_FINISHED_TITLE" desc="Title of notification message which is shown when renaming process finshes">
Renaming finished
</message>
<message name="IDS_RENAMING_OF_DEVICE_FAILED_TITLE" desc="Title of notification message which is shown when renaming process fails">
Renaming failed
</message>
<message name="IDS_RENAMING_OF_DEVICE_PENDING_MESSAGE" desc="Text of notification message which is shown when renaming process of some device is in progress">
The renaming process can take a couple of seconds. Please wait.
</message>
<message name="IDS_RENAMING_OF_DEVICE_FINISHED_SUCCESS_MESSAGE" desc="Text of notification message which is shown when renaming finishes without any errors.">
Renaming finished successfully!
</message>
<message name="IDS_RENAMING_OF_DEVICE_FINISHED_FAILURE_MESSAGE" desc="Text of notification message which is shown when there are some errors while renaming.">
Aw, Snap! There was an error during renaming.
</message>
<!-- ChromeOS GData synchronization notifications -->
<message name="IDS_CHROMEOS_GDATA_SYNC_TITLE" desc="Title text of notification message which is shown when gdata sync is on progress.">
Syncing
......
......@@ -497,6 +497,18 @@ ExtensionFunction::ResponseAction FileManagerPrivateGetStringsFunction::Run() {
SET_STRING("FORMATTING_OF_DEVICE_PENDING_TITLE",
IDS_FORMATTING_OF_DEVICE_PENDING_TITLE);
SET_STRING("FORMATTING_WARNING", IDS_FILE_BROWSER_FORMATTING_WARNING);
SET_STRING("RENAMING_OF_DEVICE_FINISHED_FAILURE_MESSAGE",
IDS_RENAMING_OF_DEVICE_FINISHED_FAILURE_MESSAGE);
SET_STRING("RENAMING_OF_DEVICE_FINISHED_SUCCESS_MESSAGE",
IDS_RENAMING_OF_DEVICE_FINISHED_SUCCESS_MESSAGE);
SET_STRING("RENAMING_OF_DEVICE_FAILED_TITLE",
IDS_RENAMING_OF_DEVICE_FAILED_TITLE);
SET_STRING("RENAMING_OF_DEVICE_FINISHED_TITLE",
IDS_RENAMING_OF_DEVICE_FINISHED_TITLE);
SET_STRING("RENAMING_OF_DEVICE_PENDING_MESSAGE",
IDS_RENAMING_OF_DEVICE_PENDING_MESSAGE);
SET_STRING("RENAMING_OF_DEVICE_PENDING_TITLE",
IDS_RENAMING_OF_DEVICE_PENDING_TITLE);
SET_STRING("FORMAT_DEVICE_BUTTON_LABEL",
IDS_FILE_BROWSER_FORMAT_DEVICE_BUTTON_LABEL);
SET_STRING("SHARE_BUTTON_TOOLTIP", IDS_FILE_BROWSER_SHARE_BUTTON_TOOLTIP);
......
......@@ -198,6 +198,30 @@ DeviceHandler.Notification.FORMAT_FAIL = new DeviceHandler.Notification(
'FORMATTING_OF_DEVICE_FAILED_TITLE',
'FORMATTING_FINISHED_FAILURE_MESSAGE');
/**
* @type {DeviceHandler.Notification}
* @const
*/
DeviceHandler.Notification.RENAME_START = new DeviceHandler.Notification(
'renameStart', 'RENAMING_OF_DEVICE_PENDING_TITLE',
'RENAMING_OF_DEVICE_PENDING_MESSAGE');
/**
* @type {DeviceHandler.Notification}
* @const
*/
DeviceHandler.Notification.RENAME_SUCCESS = new DeviceHandler.Notification(
'renameSuccess', 'RENAMING_OF_DEVICE_FINISHED_TITLE',
'RENAMING_OF_DEVICE_FINISHED_SUCCESS_MESSAGE');
/**
* @type {DeviceHandler.Notification}
* @const
*/
DeviceHandler.Notification.RENAME_FAIL = new DeviceHandler.Notification(
'renameFail', 'RENAMING_OF_DEVICE_FAILED_TITLE',
'RENAMING_OF_DEVICE_FINISHED_FAILURE_MESSAGE');
/**
* Shows the notification for the device path.
* @param {string} devicePath Device path.
......@@ -307,6 +331,17 @@ DeviceHandler.prototype.onDeviceChanged_ = function(event) {
DeviceHandler.Notification.FORMAT_START.hide(event.devicePath);
DeviceHandler.Notification.FORMAT_FAIL.show(event.devicePath);
break;
case 'rename_start':
DeviceHandler.Notification.RENAME_START.show(event.devicePath);
break;
case 'rename_success':
DeviceHandler.Notification.RENAME_START.hide(event.devicePath);
DeviceHandler.Notification.RENAME_SUCCESS.show(event.devicePath);
break;
case 'rename_fail':
DeviceHandler.Notification.RENAME_START.hide(event.devicePath);
DeviceHandler.Notification.RENAME_FAIL.show(event.devicePath);
break;
default:
console.error('Unknown event type: ' + event.type);
break;
......
......@@ -42,7 +42,15 @@ loadTimeData.data = {
FORMATTING_OF_DEVICE_FINISHED_TITLE: 'FORMATTING_OF_DEVICE_FINISHED_TITLE',
FORMATTING_FINISHED_SUCCESS_MESSAGE: 'FORMATTING_FINISHED_SUCCESS',
FORMATTING_OF_DEVICE_FAILED_TITLE: 'FORMATTING_OF_DEVICE_FAILED_TITLE',
FORMATTING_FINISHED_FAILURE_MESSAGE: 'FORMATTING_FINISHED_FAILURE'
FORMATTING_FINISHED_FAILURE_MESSAGE: 'FORMATTING_FINISHED_FAILURE',
RENAMING_OF_DEVICE_PENDING_TITLE: 'RENAMING_OF_DEVICE_PENDING_TITLE',
RENAMING_OF_DEVICE_PENDING_MESSAGE: 'RENAMING_OF_DEVICE_PENDING',
RENAMING_OF_DEVICE_FINISHED_TITLE: 'RENAMING_OF_DEVICE_FINISHED_TITLE',
RENAMING_OF_DEVICE_FINISHED_SUCCESS_MESSAGE:
'RENAMING_OF_DEVICE_FINISHED_SUCCESS',
RENAMING_OF_DEVICE_FAILED_TITLE: 'RENAMING_OF_DEVICE_FAILED_TITLE',
RENAMING_OF_DEVICE_FINISHED_FAILURE_MESSAGE:
'RENAMING_OF_DEVICE_FINISHED_FAILURE',
};
// Set up the test components.
......@@ -591,6 +599,38 @@ function testFormatFailed() {
chrome.notifications.items['formatFail:/device/path'].message);
}
function testRenameSucceeded() {
chrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'rename_start', devicePath: '/device/path'});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
'RENAMING_OF_DEVICE_PENDING',
chrome.notifications.items['renameStart:/device/path'].message);
chrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'rename_success', devicePath: '/device/path'});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
'RENAMING_OF_DEVICE_FINISHED_SUCCESS',
chrome.notifications.items['renameSuccess:/device/path'].message);
}
function testRenameFailed() {
chrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'rename_start', devicePath: '/device/path'});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
'RENAMING_OF_DEVICE_PENDING',
chrome.notifications.items['renameStart:/device/path'].message);
chrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'rename_fail', devicePath: '/device/path'});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
'RENAMING_OF_DEVICE_FINISHED_FAILURE',
chrome.notifications.items['renameFail:/device/path'].message);
}
function testDeviceHardUnplugged() {
chrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'hard_unplugged',
......
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