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

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

Issue 2839863002: Add Team Drive subtree to the directory list view. (Closed)
Patch Set: Fix FileManagerJsTest.{NavigationListModelTest,ProvidersModel}. Created 3 years, 8 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
Index: ui/file_manager/file_manager/foreground/js/ui/location_line.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/location_line.js b/ui/file_manager/file_manager/foreground/js/ui/location_line.js
index d838a01139c03f13a82d449d5f015993e793b341..85955cd5bbbb9282251e71f05650f3d615d23a98 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/location_line.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/location_line.js
@@ -35,6 +35,22 @@ LocationLine.prototype.show = function(entry) {
};
/**
+ * Replace the root directory name at the end of a url.
+ * The input, |url| is a displayRoot URL of a Drive volume like
+ * filesystem:chrome-extension://....foo.com-hash/root
+ * The output is like:
+ * filesystem:chrome-extension://....foo.com-hash/other
+ *
+ * @param {string} url which points to a volume display root
+ * @param {string} newRoot new root directory name
+ * @return {string} new URL with the new root directory name
+ * @private
+ */
+LocationLine.prototype.replaceRootName_ = function(url, newRoot) {
+ return url.slice(0, url.length - '/root'.length) + newRoot;
+};
+
+/**
* Get components for the path of entry.
* @param {!Entry|!FakeEntry} entry An entry.
* @return {!Array<!LocationLine.PathComponent>} Components.
@@ -59,15 +75,19 @@ LocationLine.prototype.getComponents_ = function(entry) {
var displayRootFullPath = locationInfo.volumeInfo.displayRoot.fullPath;
if (locationInfo.rootType === VolumeManagerCommon.RootType.DRIVE_OTHER) {
// When target path is a shared directory, volume should be shared with me.
- displayRootUrl = displayRootUrl.slice(
- 0, displayRootUrl.length - '/root'.length) + '/other';
- displayRootFullPath = '/other';
+ displayRootUrl = this.replaceRootName_(displayRootUrl, '/other');
var sharedWithMeFakeEntry = locationInfo.volumeInfo.fakeEntries[
VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME];
components.push(new LocationLine.PathComponent(
str('DRIVE_SHARED_WITH_ME_COLLECTION_LABEL'),
sharedWithMeFakeEntry.toURL(),
sharedWithMeFakeEntry));
+ } else if (
+ locationInfo.rootType === VolumeManagerCommon.RootType.TEAM_DRIVES) {
+ displayRootUrl = this.replaceRootName_(
+ displayRootUrl, VolumeManagerCommon.TEAM_DRIVES_DIRECTORY_PATH);
+ components.push(new LocationLine.PathComponent(
+ util.getRootTypeLabel(locationInfo), displayRootUrl));
} else {
components.push(new LocationLine.PathComponent(
util.getRootTypeLabel(locationInfo), displayRootUrl));
@@ -75,6 +95,11 @@ LocationLine.prototype.getComponents_ = function(entry) {
// Get relative path to display root (e.g. /root/foo/bar -> foo/bar).
var relativePath = entry.fullPath.slice(displayRootFullPath.length);
+ if (entry.fullPath.startsWith(
+ VolumeManagerCommon.TEAM_DRIVES_DIRECTORY_PATH)) {
+ relativePath = entry.fullPath.slice(
+ VolumeManagerCommon.TEAM_DRIVES_DIRECTORY_PATH.length);
+ }
if (relativePath.indexOf('/') === 0) {
relativePath = relativePath.slice(1);
}

Powered by Google App Engine
This is Rietveld 408576698