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) {
});
};
/**
* 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.
*/
......
......@@ -1147,11 +1147,18 @@ FileManager.prototype = /** @struct */ {
this.metadataModel_,
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.
this.taskController_ = new TaskController(
this.dialogType, this.volumeManager_, this.ui_, this.metadataModel_,
this.directoryModel_, this.selectionHandler_,
this.metadataUpdateController_, assert(this.crostini_));
this.metadataUpdateController_, this.namingController_,
assert(this.crostini_));
// Create search controller.
this.searchController_ = new SearchController(
......@@ -1161,18 +1168,6 @@ FileManager.prototype = /** @struct */ {
this.volumeManager_,
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.
this.directoryTreeNamingController_ = new DirectoryTreeNamingController(
this.directoryModel_,
......
......@@ -15,13 +15,14 @@
* @param {!Array<!chrome.fileManagerPrivate.FileTask>} tasks
* @param {chrome.fileManagerPrivate.FileTask} defaultTask
* @param {!TaskHistory} taskHistory
* @param {!NamingController} namingController
* @param {!Crostini} crostini
* @constructor
* @struct
*/
function FileTasks(
volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes, tasks,
defaultTask, taskHistory, crostini) {
defaultTask, taskHistory, namingController, crostini) {
/**
* @private {!VolumeManager}
* @const
......@@ -76,6 +77,12 @@ function FileTasks(
*/
this.taskHistory_ = taskHistory;
/**
* @private {!NamingController}
* @const
*/
this.namingController_ = namingController;
/**
* @private {!Crostini}
* @const
......@@ -162,12 +169,13 @@ FileTasks.TaskPickerType = {
* @param {!Array<!Entry>} entries
* @param {!Array<?string>} mimeTypes
* @param {!TaskHistory} taskHistory
* @param {!NamingController} namingController
* @param {!Crostini} crostini
* @return {!Promise<!FileTasks>}
*/
FileTasks.create = function(
volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes,
taskHistory, crostini) {
taskHistory, namingController, crostini) {
var tasksPromise = new Promise(function(fulfill) {
// getFileTasks supports only native entries.
entries = entries.filter(util.isNativeEntry);
......@@ -220,7 +228,7 @@ FileTasks.create = function(
return Promise.all([tasksPromise, defaultTaskPromise]).then(function(args) {
return new FileTasks(
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) {
.create(
this.volumeManager_, this.metadataModel_,
this.directoryModel_, this.ui_, this.entries_,
this.mimeTypes_, this.taskHistory_, this.crostini_)
this.mimeTypes_, this.taskHistory_, this.namingController_,
this.crostini_)
.then(
function(tasks) {
tasks.executeDefault();
......@@ -1071,7 +1080,9 @@ FileTasks.prototype.updateShareMenuButton_ = function(shareMenuButton, tasks) {
var driveShareCommandSeparator =
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
// one other share actions.
......
......@@ -78,8 +78,7 @@ function getMockFileManager() {
}
},
ui: {
alertDialog:
{showHtml: function(title, text, onOk, onCancel, onShow) {}}
alertDialog: {showHtml: function(title, text, onOk, onCancel, onShow) {}}
},
metadataModel: {},
directoryModel: {
......@@ -87,6 +86,7 @@ function getMockFileManager() {
return null;
}
},
namingController: {},
crostini: new Crostini(),
};
result.crostini.init(result.volumeManager);
......@@ -116,7 +116,7 @@ function showHtmlOfAlertDialogIsCalled(entries, expectedTitle, expectedText) {
.create(
fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, entries, [null],
mockTaskHistory, fileManager.crostini)
mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) {
tasks.executeDefault();
});
......@@ -143,7 +143,7 @@ function openSuggestAppsDialogIsCalled(entries, mimeTypes) {
.create(
fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, entries, mimeTypes,
mockTaskHistory, fileManager.crostini)
mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) {
tasks.executeDefault();
});
......@@ -171,7 +171,7 @@ function showDefaultTaskDialogCalled(entries, mimeTypes) {
.create(
fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, entries, mimeTypes,
mockTaskHistory, fileManager.crostini)
mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) {
tasks.executeDefault();
});
......@@ -236,7 +236,8 @@ function testOpenSuggestAppsDialogWithMetadata(callback) {
}
}
},
[entry], ['application/rtf'], mockTaskHistory, fileManager.crostini)
[entry], ['application/rtf'], mockTaskHistory,
fileManager.namingController, fileManager.crostini)
.then(function(tasks) {
tasks.openSuggestAppsDialog(
function() {}, function() {}, function() {});
......@@ -261,7 +262,7 @@ function testOpenSuggestAppsDialogFailure(callback) {
.create(
fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, [entry], [null],
mockTaskHistory, fileManager.crostini)
mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) {
tasks.openSuggestAppsDialog(function() {}, function() {}, resolve);
});
......@@ -366,7 +367,7 @@ function testOpenWithMostRecentlyExecuted(callback) {
.create(
fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, [mockEntry], [null],
taskHistory, fileManager.crostini)
taskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) {
tasks.executeDefault();
assertEquals(latestTaskId, executedTask);
......@@ -431,7 +432,7 @@ function testOpenZipWithZipArchiver(callback) {
.create(
fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, [mockEntry], [null],
taskHistory, fileManager.crostini)
taskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) {
tasks.executeDefault();
assertEquals(zipArchiverTaskId, executedTask);
......@@ -475,7 +476,7 @@ function testOpenInstallLinuxPackageDialog(callback) {
.create(
fileManager.volumeManager, fileManager.metadataModel,
fileManager.directoryModel, fileManager.ui, [mockEntry], [null],
mockTaskHistory, fileManager.crostini)
mockTaskHistory, fileManager.namingController, fileManager.crostini)
.then(function(tasks) {
tasks.executeDefault();
});
......
......@@ -10,13 +10,14 @@
* @param {!DirectoryModel} directoryModel
* @param {!FileSelectionHandler} selectionHandler
* @param {!MetadataUpdateController} metadataUpdateController
* @param {!NamingController} namingController
* @param {!Crostini} crostini
* @constructor
* @struct
*/
function TaskController(
dialogType, volumeManager, ui, metadataModel, directoryModel,
selectionHandler, metadataUpdateController, crostini) {
selectionHandler, metadataUpdateController, namingController, crostini) {
/**
* @private {DialogType}
* @const
......@@ -60,6 +61,12 @@ function TaskController(
*/
this.metadataUpdateController_ = metadataUpdateController;
/**
* @private {!NamingController}
* @const
*/
this.namingController_ = namingController;
/**
* @type {!Crostini}
* @const
......@@ -384,7 +391,7 @@ TaskController.prototype.getFileTasks = function() {
.create(
this.volumeManager_, this.metadataModel_, this.directoryModel_,
this.ui_, selection.entries, assert(selection.mimeTypes),
this.taskHistory_, this.crostini_)
this.taskHistory_, this.namingController_, this.crostini_)
.then(function(tasks) {
if (this.selectionHandler_.selection !== selection) {
if (util.isSameEntries(this.tasksEntries_, selection.entries))
......@@ -475,7 +482,7 @@ TaskController.prototype.executeEntryTask = function(entry) {
.create(
this.volumeManager_, this.metadataModel_, this.directoryModel_,
this.ui_, [entry], [props[0].contentMimeType || null],
this.taskHistory_, this.crostini_)
this.taskHistory_, this.namingController_, this.crostini_)
.then(function(tasks) {
tasks.executeDefault();
});
......
......@@ -80,15 +80,14 @@ function testExecuteEntryTask(callback) {
{
taskMenuButton: document.createElement('button'),
shareMenuButton: {menu: document.createElement('div')},
fileContextMenu:
{defaultActionMenuItem: document.createElement('div')}
fileContextMenu: {defaultActionMenuItem: document.createElement('div')}
},
new MockMetadataModel({}), {
getCurrentRootType: function() {
return null;
}
},
new cr.EventTarget(), null, createCrostini());
new cr.EventTarget(), null, null, createCrostini());
controller.executeEntryTask(fileSystem.entries['/test.png']);
reportPromise(new Promise(function(fulfill) {
......@@ -149,15 +148,14 @@ function createTaskController(selectionHandler) {
{
taskMenuButton: document.createElement('button'),
shareMenuButton: {menu: document.createElement('div')},
fileContextMenu:
{defaultActionMenuItem: document.createElement('div')}
fileContextMenu: {defaultActionMenuItem: document.createElement('div')}
},
new MockMetadataModel({}), {
getCurrentRootType: function() {
return null;
}
},
selectionHandler, null, createCrostini());
selectionHandler, null, null, createCrostini());
}
// 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