From 8dd42e3e8c771672393314e5e48617b8253ff48a Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 8 Oct 2021 15:58:54 +0200 Subject: [PATCH] Only display current shared folder with embed link --- customize.dist/src/less2/include/drive.less | 15 +++++++++--- www/common/drive-ui.js | 26 ++++++++++++++++----- www/common/proxy-manager.js | 2 ++ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/customize.dist/src/less2/include/drive.less b/customize.dist/src/less2/include/drive.less index d287951b5..5feb22ca3 100644 --- a/customize.dist/src/less2/include/drive.less +++ b/customize.dist/src/less2/include/drive.less @@ -286,7 +286,9 @@ display: none; } input { - width: ~"calc(100% - 30px)"; + //width: ~"calc(100% - 30px)"; + flex: 1; + min-width: 0; padding: 0 10px; border: 0; height: auto; @@ -298,8 +300,9 @@ .leftside-menu-category_main(); width: ~"calc(100% + 5px)"; margin: 0; - margin-bottom: -6px; - display: inline-block; + //margin-bottom: -6px; + display: flex; + align-items: center; cursor: pointer; margin-left: -5px; padding-left: 5px; @@ -309,6 +312,12 @@ width: 25px; margin-right: 0px; } + .cp-app-drive-element { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + } } } } diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index d2f76ef8d..aeace766a 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -625,7 +625,7 @@ define([ // DRIVE var currentPath = APP.currentPath = LS.getLastOpenedFolder(); if (APP.newSharedFolder) { - var newSFPaths = manager.findFile(APP.newSharedFolder); + var newSFPaths = manager.findFile(Number(APP.newSharedFolder)); if (newSFPaths.length) { currentPath = newSFPaths[0]; } @@ -654,6 +654,8 @@ define([ displayedCategories = [FILES_DATA]; currentPath = [FILES_DATA]; } + } else if (priv.isEmbed && APP.newSharedFolder) { + displayedCategories = [ROOT, TRASH]; } APP.editable = !APP.readOnly; @@ -2354,6 +2356,7 @@ define([ path.forEach(function (p, idx) { if (isTrash && [2,3].indexOf(idx) !== -1) { return; } if (skipNext) { skipNext = false; return; } + if (APP.newSharedFolder && priv.isEmbed && p === ROOT && !idx) { return; } var name = p; if (manager.isFile(el) && isInTrashRoot && idx === 1) { @@ -2394,7 +2397,7 @@ define([ addDragAndDropHandlers($span, path.slice(0, idx), true, true); if (idx === 0) { name = p === SHARED_FOLDER ? name : getPrettyName(p); } - else { + else if (!(APP.newSharedFolder && priv.isEmbed && idx === 1)) { var $span2 = $('', { 'class': 'cp-app-drive-path-element cp-app-drive-path-separator' }).text(' / '); @@ -4062,17 +4065,28 @@ define([ var createTree = function ($container, path) { var root = manager.find(path); + var isRoot = manager.comparePath([ROOT], path); + var rootName = ROOT_NAME; + if (APP.newSharedFolder && priv.isEmbed && isRoot) { + var newSFPaths = manager.findFile(Number(APP.newSharedFolder)); + if (newSFPaths.length) { + path = newSFPaths[0]; + path.push(ROOT); + root = manager.find(path); + rootName = manager.getSharedFolderData(APP.newSharedFolder).title; + } + } + // don't try to display what doesn't exist if (!root) { return; } // Display the root element in the tree - var displayingRoot = manager.comparePath([ROOT], path); - if (displayingRoot) { - var isRootOpened = manager.comparePath([ROOT], currentPath); + if (isRoot) { + var isRootOpened = manager.comparePath(path.slice(), currentPath); var $rootIcon = manager.isFolderEmpty(files[ROOT]) ? (isRootOpened ? $folderOpenedEmptyIcon : $folderEmptyIcon) : (isRootOpened ? $folderOpenedIcon : $folderIcon); - var $rootElement = createTreeElement(ROOT_NAME, $rootIcon.clone(), [ROOT], false, true, true, isRootOpened); + var $rootElement = createTreeElement(rootName, $rootIcon.clone(), path.slice(), false, true, true, isRootOpened); if (!manager.hasSubfolder(root)) { $rootElement.find('.cp-app-drive-icon-expcol').css('visibility', 'hidden'); } diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index d87572d7e..5cf44b467 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -548,6 +548,8 @@ define([ var secret = Hash.getSecrets('drive', parsed.hash, folderData.password); SF.upgrade(secret.channel, secret); Env.folders[folderId].userObject.setReadOnly(false, secret.keys.secondaryKey); + waitFor.abort(); + return void cb(folderId); } if (err) { waitFor.abort();