Commit acc8c131 authored by Sasha Morrissey's avatar Sasha Morrissey Committed by Commit Bot

Fix context menu for Team Drives in Files.app

Fix the context menu for Team Drives in Files.app to show all available
options, but greyed out. Later, these will become available if the user
has the necessary permissions for that team drive.

This also fixes a bug where selecting 'New Folder' for a Team Drive
would not target the name of the new folder for editing. Now, creating
a new folder under a team drive using the context menu correctly focuses
the name text area for the new folder.

Bug: 825725
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I785e381369c892caa48a1a9141d296c8e7888d44
Reviewed-on: https://chromium-review.googlesource.com/996832
Commit-Queue: Sasha Morrissey <sashab@chromium.org>
Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550516}
parent 02a37b8b
...@@ -659,10 +659,12 @@ util.isFakeEntry = function(entry) { ...@@ -659,10 +659,12 @@ util.isFakeEntry = function(entry) {
/** /**
* Obtains whether an entry is the root directory of a Team Drive. * Obtains whether an entry is the root directory of a Team Drive.
* @param {(!Entry|!FakeEntry)} entry Entry or a fake entry. * @param {(!Entry|!FakeEntry)|null} entry Entry or a fake entry.
* @return {boolean} True if the given entry is root of a Team Drive. * @return {boolean} True if the given entry is root of a Team Drive.
*/ */
util.isTeamDriveRoot = function(entry) { util.isTeamDriveRoot = function(entry) {
if (entry === null)
return false;
if (!entry.fullPath) if (!entry.fullPath)
return false; return false;
var tree = entry.fullPath.split('/'); var tree = entry.fullPath.split('/');
......
...@@ -35,6 +35,12 @@ DirectoryItemTreeBaseMethods.getItemByEntry = function(entry) { ...@@ -35,6 +35,12 @@ DirectoryItemTreeBaseMethods.getItemByEntry = function(entry) {
return item; return item;
} }
// Team drives are descendants of the Drive root volume item "Google Drive".
// When we looking for an item in team drives, recursively search inside the
// "Google Drive" root item.
if (util.isTeamDriveEntry(entry) && item instanceof DriveVolumeItem)
return item.getItemByEntry(entry);
if (util.isDescendantEntry(item.entry, entry)) if (util.isDescendantEntry(item.entry, entry))
return item.getItemByEntry(entry); return item.getItemByEntry(entry);
} }
...@@ -473,7 +479,7 @@ function SubDirectoryItem(label, dirEntry, parentDirItem, tree) { ...@@ -473,7 +479,7 @@ function SubDirectoryItem(label, dirEntry, parentDirItem, tree) {
} }
// Sets up context menu of the item. // Sets up context menu of the item.
if (tree.contextMenuForSubitems) if (tree.contextMenuForSubitems && !util.isTeamDriveRoot(dirEntry))
cr.ui.contextMenuHandler.setContextMenu(item, tree.contextMenuForSubitems); cr.ui.contextMenuHandler.setContextMenu(item, tree.contextMenuForSubitems);
// Populates children now if needed. // Populates children now if needed.
...@@ -702,7 +708,7 @@ VolumeItem.prototype.setupRenamePlaceholder_ = function(rowElement) { ...@@ -702,7 +708,7 @@ VolumeItem.prototype.setupRenamePlaceholder_ = function(rowElement) {
/** /**
* A TreeItem which represents a Drive volume. Drive volume has fake entries * A TreeItem which represents a Drive volume. Drive volume has fake entries
* such as Recent, Shared with me, and Offline in it. * such as Team Drives, Shared with me, and Offline in it.
* *
* @param {!NavigationModelVolumeItem} modelItem NavigationModelItem of this * @param {!NavigationModelVolumeItem} modelItem NavigationModelItem of this
* volume. * volume.
......
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