Commit ec2e0231 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

FilesApp: Stop blinking of share icon when creating a new drive folder

MockEntry.deleteRecursively added to help debugging in browser.

Bug: 571355
Change-Id: I74422501b0e69380d8d5ff05c796ef1d42c68992
Reviewed-on: https://chromium-review.googlesource.com/c/1345951
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609970}
parent 892936ea
...@@ -226,6 +226,23 @@ MockEntry.prototype.remove = function(onSuccess, onError) { ...@@ -226,6 +226,23 @@ MockEntry.prototype.remove = function(onSuccess, onError) {
}); });
}; };
/**
* Removes the entry and any children.
*
* @param {function()} onSuccess Success callback.
* @param {function(!FileError)=} onError Callback invoked with an error object.
*/
MockEntry.prototype.removeRecursively = function(onSuccess, onError) {
this.removed_ = true;
Promise.resolve().then(() => {
for (let path in this.filesystem.entries) {
if (path.startsWith(this.fullPath))
delete this.filesystem.entries[path];
}
onSuccess();
});
};
/** /**
* Asserts that the entry was removed. * Asserts that the entry was removed.
*/ */
......
...@@ -1147,11 +1147,18 @@ FileManager.prototype = /** @struct */ { ...@@ -1147,11 +1147,18 @@ FileManager.prototype = /** @struct */ {
this.metadataModel_, this.metadataModel_,
this.fileMetadataFormatter_); this.fileMetadataFormatter_);
// Create naming controller.
this.namingController_ = new NamingController(
this.ui_.listContainer, assert(this.ui_.alertDialog),
assert(this.ui_.confirmDialog), this.directoryModel_,
assert(this.fileFilter_), this.selectionHandler_);
// Create task controller. // Create task controller.
this.taskController_ = new TaskController( this.taskController_ = new TaskController(
this.dialogType, this.volumeManager_, this.ui_, this.metadataModel_, this.dialogType, this.volumeManager_, this.ui_, this.metadataModel_,
this.directoryModel_, this.selectionHandler_, this.directoryModel_, this.selectionHandler_,
this.metadataUpdateController_, assert(this.crostini_)); this.metadataUpdateController_, this.namingController_,
assert(this.crostini_));
// Create search controller. // Create search controller.
this.searchController_ = new SearchController( this.searchController_ = new SearchController(
...@@ -1161,18 +1168,6 @@ FileManager.prototype = /** @struct */ { ...@@ -1161,18 +1168,6 @@ FileManager.prototype = /** @struct */ {
this.volumeManager_, this.volumeManager_,
assert(this.taskController_)); assert(this.taskController_));
// Create naming controller.
assert(this.ui_.alertDialog);
assert(this.ui_.confirmDialog);
assert(this.fileFilter_);
this.namingController_ = new NamingController(
this.ui_.listContainer,
this.ui_.alertDialog,
this.ui_.confirmDialog,
this.directoryModel_,
this.fileFilter_,
this.selectionHandler_);
// Create directory tree naming controller. // Create directory tree naming controller.
this.directoryTreeNamingController_ = new DirectoryTreeNamingController( this.directoryTreeNamingController_ = new DirectoryTreeNamingController(
this.directoryModel_, this.directoryModel_,
......
...@@ -15,13 +15,14 @@ ...@@ -15,13 +15,14 @@
* @param {!Array<!chrome.fileManagerPrivate.FileTask>} tasks * @param {!Array<!chrome.fileManagerPrivate.FileTask>} tasks
* @param {chrome.fileManagerPrivate.FileTask} defaultTask * @param {chrome.fileManagerPrivate.FileTask} defaultTask
* @param {!TaskHistory} taskHistory * @param {!TaskHistory} taskHistory
* @param {!NamingController} namingController
* @param {!Crostini} crostini * @param {!Crostini} crostini
* @constructor * @constructor
* @struct * @struct
*/ */
function FileTasks( function FileTasks(
volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes, tasks, volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes, tasks,
defaultTask, taskHistory, crostini) { defaultTask, taskHistory, namingController, crostini) {
/** /**
* @private {!VolumeManager} * @private {!VolumeManager}
* @const * @const
...@@ -76,6 +77,12 @@ function FileTasks( ...@@ -76,6 +77,12 @@ function FileTasks(
*/ */
this.taskHistory_ = taskHistory; this.taskHistory_ = taskHistory;
/**
* @private {!NamingController}
* @const
*/
this.namingController_ = namingController;
/** /**
* @private {!Crostini} * @private {!Crostini}
* @const * @const
...@@ -162,12 +169,13 @@ FileTasks.TaskPickerType = { ...@@ -162,12 +169,13 @@ FileTasks.TaskPickerType = {
* @param {!Array<!Entry>} entries * @param {!Array<!Entry>} entries
* @param {!Array<?string>} mimeTypes * @param {!Array<?string>} mimeTypes
* @param {!TaskHistory} taskHistory * @param {!TaskHistory} taskHistory
* @param {!NamingController} namingController
* @param {!Crostini} crostini * @param {!Crostini} crostini
* @return {!Promise<!FileTasks>} * @return {!Promise<!FileTasks>}
*/ */
FileTasks.create = function( FileTasks.create = function(
volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes, volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes,
taskHistory, crostini) { taskHistory, namingController, crostini) {
var tasksPromise = new Promise(function(fulfill) { var tasksPromise = new Promise(function(fulfill) {
// getFileTasks supports only native entries. // getFileTasks supports only native entries.
entries = entries.filter(util.isNativeEntry); entries = entries.filter(util.isNativeEntry);
...@@ -220,7 +228,7 @@ FileTasks.create = function( ...@@ -220,7 +228,7 @@ FileTasks.create = function(
return Promise.all([tasksPromise, defaultTaskPromise]).then(function(args) { return Promise.all([tasksPromise, defaultTaskPromise]).then(function(args) {
return new FileTasks( return new FileTasks(
volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes, volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes,
args[0], args[1], taskHistory, crostini); args[0], args[1], taskHistory, namingController, crostini);
}); });
}; };
...@@ -739,7 +747,8 @@ FileTasks.prototype.executeDefaultInternal_ = function(opt_callback) { ...@@ -739,7 +747,8 @@ FileTasks.prototype.executeDefaultInternal_ = function(opt_callback) {
.create( .create(
this.volumeManager_, this.metadataModel_, this.volumeManager_, this.metadataModel_,
this.directoryModel_, this.ui_, this.entries_, this.directoryModel_, this.ui_, this.entries_,
this.mimeTypes_, this.taskHistory_, this.crostini_) this.mimeTypes_, this.taskHistory_, this.namingController_,
this.crostini_)
.then( .then(
function(tasks) { function(tasks) {
tasks.executeDefault(); tasks.executeDefault();
...@@ -1071,7 +1080,9 @@ FileTasks.prototype.updateShareMenuButton_ = function(shareMenuButton, tasks) { ...@@ -1071,7 +1080,9 @@ FileTasks.prototype.updateShareMenuButton_ = function(shareMenuButton, tasks) {
var driveShareCommandSeparator = var driveShareCommandSeparator =
shareMenuButton.menu.querySelector('#drive-share-separator'); shareMenuButton.menu.querySelector('#drive-share-separator');
shareMenuButton.hidden = driveShareCommand.disabled && tasks.length == 0; // Hide share icon for New Folder creation. See https://crbug.com/571355.
shareMenuButton.hidden = (driveShareCommand.disabled && tasks.length == 0) ||
this.namingController_.isRenamingInProgress();
// Show the separator if Drive share command is enabled and there is at least // Show the separator if Drive share command is enabled and there is at least
// one other share actions. // one other share actions.
......
...@@ -78,8 +78,7 @@ function getMockFileManager() { ...@@ -78,8 +78,7 @@ function getMockFileManager() {
} }
}, },
ui: { ui: {
alertDialog: alertDialog: {showHtml: function(title, text, onOk, onCancel, onShow) {}}
{showHtml: function(title, text, onOk, onCancel, onShow) {}}
}, },
metadataModel: {}, metadataModel: {},
directoryModel: { directoryModel: {
...@@ -87,6 +86,7 @@ function getMockFileManager() { ...@@ -87,6 +86,7 @@ function getMockFileManager() {
return null; return null;
} }
}, },
namingController: {},
crostini: new Crostini(), crostini: new Crostini(),
}; };
result.crostini.init(result.volumeManager); result.crostini.init(result.volumeManager);
...@@ -116,7 +116,7 @@ function showHtmlOfAlertDialogIsCalled(entries, expectedTitle, expectedText) { ...@@ -116,7 +116,7 @@ function showHtmlOfAlertDialogIsCalled(entries, expectedTitle, expectedText) {
.create( .create(
fileManager.volumeManager, fileManager.metadataModel, fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, entries, [null], fileManager.directoryModel, fileManager.ui, entries, [null],
mockTaskHistory, fileManager.crostini) mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) { .then(function(tasks) {
tasks.executeDefault(); tasks.executeDefault();
}); });
...@@ -143,7 +143,7 @@ function openSuggestAppsDialogIsCalled(entries, mimeTypes) { ...@@ -143,7 +143,7 @@ function openSuggestAppsDialogIsCalled(entries, mimeTypes) {
.create( .create(
fileManager.volumeManager, fileManager.metadataModel, fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, entries, mimeTypes, fileManager.directoryModel, fileManager.ui, entries, mimeTypes,
mockTaskHistory, fileManager.crostini) mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) { .then(function(tasks) {
tasks.executeDefault(); tasks.executeDefault();
}); });
...@@ -171,7 +171,7 @@ function showDefaultTaskDialogCalled(entries, mimeTypes) { ...@@ -171,7 +171,7 @@ function showDefaultTaskDialogCalled(entries, mimeTypes) {
.create( .create(
fileManager.volumeManager, fileManager.metadataModel, fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, entries, mimeTypes, fileManager.directoryModel, fileManager.ui, entries, mimeTypes,
mockTaskHistory, fileManager.crostini) mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) { .then(function(tasks) {
tasks.executeDefault(); tasks.executeDefault();
}); });
...@@ -236,7 +236,8 @@ function testOpenSuggestAppsDialogWithMetadata(callback) { ...@@ -236,7 +236,8 @@ function testOpenSuggestAppsDialogWithMetadata(callback) {
} }
} }
}, },
[entry], ['application/rtf'], mockTaskHistory, fileManager.crostini) [entry], ['application/rtf'], mockTaskHistory,
fileManager.namingController, fileManager.crostini)
.then(function(tasks) { .then(function(tasks) {
tasks.openSuggestAppsDialog( tasks.openSuggestAppsDialog(
function() {}, function() {}, function() {}); function() {}, function() {}, function() {});
...@@ -261,7 +262,7 @@ function testOpenSuggestAppsDialogFailure(callback) { ...@@ -261,7 +262,7 @@ function testOpenSuggestAppsDialogFailure(callback) {
.create( .create(
fileManager.volumeManager, fileManager.metadataModel, fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, [entry], [null], fileManager.directoryModel, fileManager.ui, [entry], [null],
mockTaskHistory, fileManager.crostini) mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) { .then(function(tasks) {
tasks.openSuggestAppsDialog(function() {}, function() {}, resolve); tasks.openSuggestAppsDialog(function() {}, function() {}, resolve);
}); });
...@@ -366,7 +367,7 @@ function testOpenWithMostRecentlyExecuted(callback) { ...@@ -366,7 +367,7 @@ function testOpenWithMostRecentlyExecuted(callback) {
.create( .create(
fileManager.volumeManager, fileManager.metadataModel, fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, [mockEntry], [null], fileManager.directoryModel, fileManager.ui, [mockEntry], [null],
taskHistory, fileManager.crostini) taskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) { .then(function(tasks) {
tasks.executeDefault(); tasks.executeDefault();
assertEquals(latestTaskId, executedTask); assertEquals(latestTaskId, executedTask);
...@@ -431,7 +432,7 @@ function testOpenZipWithZipArchiver(callback) { ...@@ -431,7 +432,7 @@ function testOpenZipWithZipArchiver(callback) {
.create( .create(
fileManager.volumeManager, fileManager.metadataModel, fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, [mockEntry], [null], fileManager.directoryModel, fileManager.ui, [mockEntry], [null],
taskHistory, fileManager.crostini) taskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) { .then(function(tasks) {
tasks.executeDefault(); tasks.executeDefault();
assertEquals(zipArchiverTaskId, executedTask); assertEquals(zipArchiverTaskId, executedTask);
...@@ -475,7 +476,7 @@ function testOpenInstallLinuxPackageDialog(callback) { ...@@ -475,7 +476,7 @@ function testOpenInstallLinuxPackageDialog(callback) {
.create( .create(
fileManager.volumeManager, fileManager.metadataModel, fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, [mockEntry], [null], fileManager.directoryModel, fileManager.ui, [mockEntry], [null],
mockTaskHistory, fileManager.crostini) mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) { .then(function(tasks) {
tasks.executeDefault(); tasks.executeDefault();
}); });
......
...@@ -10,13 +10,14 @@ ...@@ -10,13 +10,14 @@
* @param {!DirectoryModel} directoryModel * @param {!DirectoryModel} directoryModel
* @param {!FileSelectionHandler} selectionHandler * @param {!FileSelectionHandler} selectionHandler
* @param {!MetadataUpdateController} metadataUpdateController * @param {!MetadataUpdateController} metadataUpdateController
* @param {!NamingController} namingController
* @param {!Crostini} crostini * @param {!Crostini} crostini
* @constructor * @constructor
* @struct * @struct
*/ */
function TaskController( function TaskController(
dialogType, volumeManager, ui, metadataModel, directoryModel, dialogType, volumeManager, ui, metadataModel, directoryModel,
selectionHandler, metadataUpdateController, crostini) { selectionHandler, metadataUpdateController, namingController, crostini) {
/** /**
* @private {DialogType} * @private {DialogType}
* @const * @const
...@@ -60,6 +61,12 @@ function TaskController( ...@@ -60,6 +61,12 @@ function TaskController(
*/ */
this.metadataUpdateController_ = metadataUpdateController; this.metadataUpdateController_ = metadataUpdateController;
/**
* @private {!NamingController}
* @const
*/
this.namingController_ = namingController;
/** /**
* @type {!Crostini} * @type {!Crostini}
* @const * @const
...@@ -384,7 +391,7 @@ TaskController.prototype.getFileTasks = function() { ...@@ -384,7 +391,7 @@ TaskController.prototype.getFileTasks = function() {
.create( .create(
this.volumeManager_, this.metadataModel_, this.directoryModel_, this.volumeManager_, this.metadataModel_, this.directoryModel_,
this.ui_, selection.entries, assert(selection.mimeTypes), this.ui_, selection.entries, assert(selection.mimeTypes),
this.taskHistory_, this.crostini_) this.taskHistory_, this.namingController_, this.crostini_)
.then(function(tasks) { .then(function(tasks) {
if (this.selectionHandler_.selection !== selection) { if (this.selectionHandler_.selection !== selection) {
if (util.isSameEntries(this.tasksEntries_, selection.entries)) if (util.isSameEntries(this.tasksEntries_, selection.entries))
...@@ -475,7 +482,7 @@ TaskController.prototype.executeEntryTask = function(entry) { ...@@ -475,7 +482,7 @@ TaskController.prototype.executeEntryTask = function(entry) {
.create( .create(
this.volumeManager_, this.metadataModel_, this.directoryModel_, this.volumeManager_, this.metadataModel_, this.directoryModel_,
this.ui_, [entry], [props[0].contentMimeType || null], this.ui_, [entry], [props[0].contentMimeType || null],
this.taskHistory_, this.crostini_) this.taskHistory_, this.namingController_, this.crostini_)
.then(function(tasks) { .then(function(tasks) {
tasks.executeDefault(); tasks.executeDefault();
}); });
......
...@@ -80,15 +80,14 @@ function testExecuteEntryTask(callback) { ...@@ -80,15 +80,14 @@ function testExecuteEntryTask(callback) {
{ {
taskMenuButton: document.createElement('button'), taskMenuButton: document.createElement('button'),
shareMenuButton: {menu: document.createElement('div')}, shareMenuButton: {menu: document.createElement('div')},
fileContextMenu: fileContextMenu: {defaultActionMenuItem: document.createElement('div')}
{defaultActionMenuItem: document.createElement('div')}
}, },
new MockMetadataModel({}), { new MockMetadataModel({}), {
getCurrentRootType: function() { getCurrentRootType: function() {
return null; return null;
} }
}, },
new cr.EventTarget(), null, createCrostini()); new cr.EventTarget(), null, null, createCrostini());
controller.executeEntryTask(fileSystem.entries['/test.png']); controller.executeEntryTask(fileSystem.entries['/test.png']);
reportPromise(new Promise(function(fulfill) { reportPromise(new Promise(function(fulfill) {
...@@ -149,15 +148,14 @@ function createTaskController(selectionHandler) { ...@@ -149,15 +148,14 @@ function createTaskController(selectionHandler) {
{ {
taskMenuButton: document.createElement('button'), taskMenuButton: document.createElement('button'),
shareMenuButton: {menu: document.createElement('div')}, shareMenuButton: {menu: document.createElement('div')},
fileContextMenu: fileContextMenu: {defaultActionMenuItem: document.createElement('div')}
{defaultActionMenuItem: document.createElement('div')}
}, },
new MockMetadataModel({}), { new MockMetadataModel({}), {
getCurrentRootType: function() { getCurrentRootType: function() {
return null; return null;
} }
}, },
selectionHandler, null, createCrostini()); selectionHandler, null, null, createCrostini());
} }
// TaskController.getFileTasks should not call fileManagerPrivate.getFileTasks // TaskController.getFileTasks should not call fileManagerPrivate.getFileTasks
......
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