Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/directory_tree.js

Issue 2897973002: Hide Team Drives when user don't have membership of any Team Drive. (Closed)
Patch Set: revise comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js b/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
index bacf7d54c40d0e0d92ee341705f04155e58b3b7f..0b4d3eb070ccd05ae7f816606d107b83230a6d97 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
@@ -740,17 +740,37 @@ DriveVolumeItem.prototype.handleClick = function(e) {
};
/**
+ * Checks whether the Team Drives grand root should be shown.
+ * @param {function(boolean)} callback to receive the result. The paramter is
+ * true if the Files app. should show the Team Drives grand root and its
+ * subtree.
+ * @private
+ */
+DriveVolumeItem.prototype.shouldShowTeamDrives_ = function(callback) {
+ var teamDriveEntry = this.volumeInfo_.teamDriveDisplayRoot;
+ if (!teamDriveEntry) {
+ callback(false);
+ } else {
+ var reader = teamDriveEntry.createReader();
+ reader.readEntries(function(results) {
+ callback(results.length > 0);
+ });
+ }
+};
+
+/**
* Retrieves the latest subdirectories and update them on the tree.
* @param {boolean} recursive True if the update is recursively.
* @override
*/
DriveVolumeItem.prototype.updateSubDirectories = function(recursive) {
- // Drive volume has children including fake entries (offline, recent, etc...).
- if (this.entry && !this.hasChildren) {
+ if (!this.entry || this.hasChildren)
+ return;
+ this.shouldShowTeamDrives_(function(shouldShowTeamDrives) {
var entries = [this.entry];
- var teamDriveEntry = this.volumeInfo_.teamDriveDisplayRoot;
- if (teamDriveEntry)
- entries.push(teamDriveEntry);
+ if (shouldShowTeamDrives)
+ entries.push(this.volumeInfo_.teamDriveDisplayRoot);
+ // Drive volume has children including fake entries (offline, recent, ...)
var fakeEntries = [];
if (this.parentTree_.fakeEntriesVisible_) {
for (var key in this.volumeInfo_.fakeEntries)
@@ -774,7 +794,7 @@ DriveVolumeItem.prototype.updateSubDirectories = function(recursive) {
item.updateSubDirectories(false);
}
this.expanded = true;
- }
+ }.bind(this));
};
/**
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698