From e73b4a11317b7c5bea329a27695b087cae4429c0 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 22 Feb 2017 11:15:29 +0100 Subject: [PATCH 1/3] Don't display 'All files' in the menu --- customize.dist/translations/messages.fr.js | 1 + customize.dist/translations/messages.js | 1 + www/drive/file.css | 2 +- www/drive/file.less | 2 +- www/drive/main.js | 22 +++++++++++++--------- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 344a1839f..0be7452f5 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -162,6 +162,7 @@ define(function () { out.fm_unknownFolderError = "Le dossier sélectionné ou le dernier dossier visité n'existe plus. Ouverture du dossier parent..."; out.fm_contextMenuError = "Impossible d'ouvrir le menu contextuel pour cet élément. Si le problème persiste, essayez de rechercher la page."; out.fm_selectError = "Impossible de sélectionner l'élément ciblé. Si le problème persiste, essayez de recharger la page."; + out.fm_categoryError = "Impossible d'afficher la catégorie sélectionnée, affichage de Documents"; out.fm_info_root = "Créez ici autant de dossiers que vous le souhaitez pour trier vos fichiers."; out.fm_info_unsorted = 'Contient tous les documents que vous avez ouvert et qui ne sont pas triés dans "Documents" ou déplacés vers la "Corbeille".'; // "My Documents" should match with the "out.fm_rootName" key, and "Trash" with "out.fm_trashName" out.fm_info_template = "Contient tous les fichiers que vous avez sauvés en tant que modèle afin de les réutiliser lors de la création d'un nouveau document."; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 85853b84d..85ac47340 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -165,6 +165,7 @@ define(function () { out.fm_unknownFolderError = "The selected or last visited directory no longer exist. Opening the parent folder..."; out.fm_contextMenuError = "Unable to open the context menu for that element. If the problem persist, try to reload the page."; out.fm_selectError = "Unable to select the targetted element. If the problem persist, try to reload the page."; + out.fm_categoryError = "Unable to open the selected category, displaying root."; out.fm_info_root = "Create as many nested folders here as you want to sort your files."; out.fm_info_unsorted = 'Contains all the files you\'ve visited that are not yet sorted in "Documents" or moved to the "Trash".'; // "My Documents" should match with the "out.fm_rootName" key, and "Trash" with "out.fm_trashName" out.fm_info_template = 'Contains all the pads stored as templates and that you can re-use when you create a new document.'; diff --git a/www/drive/file.css b/www/drive/file.css index 46295d95d..461a4658f 100644 --- a/www/drive/file.css +++ b/www/drive/file.css @@ -94,7 +94,7 @@ span.fa-folder-open { background: #fff; overflow: auto; resize: horizontal; - width: 250px; + width: auto; white-space: nowrap; max-width: 500px; min-width: 200px; diff --git a/www/drive/file.less b/www/drive/file.less index 0b6a52cc9..ade482e58 100644 --- a/www/drive/file.less +++ b/www/drive/file.less @@ -128,7 +128,7 @@ span { background: @tree-bg; overflow: auto; resize: horizontal; - width: 250px; + width: auto; white-space: nowrap; max-width: 500px; min-width: 200px; diff --git a/www/drive/main.js b/www/drive/main.js index 1d0b3eade..b52c1b0dd 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -202,6 +202,12 @@ define([ // FILE MANAGER // _WORKGROUP_ and other people drive : display Documents as main page var currentPath = module.currentPath = isOwnDrive() ? getLastOpenedFolder() : [ROOT]; + + // Categories dislayed in the menu + // _WORKGROUP_ : do not display unsorted + var displayedCategories = [ROOT, UNSORTED, TRASH]; + if (isWorkgroup()) { displayedCategory = [ROOT, TRASH]; } + var lastSelectTime; var selectedElement; @@ -1284,8 +1290,8 @@ define([ if (!APP.editable) { debug("Read-only mode"); } if (!appStatus.isReady && !force) { return; } // Only Trash and Root are available in not-owned files manager - if (isWorkgroup() && !filesOp.isPathInTrash(path) && !filesOp.isPathInRoot(path)) { - log("Unable to open the selected category, displaying root"); //TODO translate + if (displayedCategories.indexOf(path[0]) === -1) { + log(Messages.categoryError); currentPath = [ROOT]; displayDirectory(currentPath); return; @@ -1532,13 +1538,11 @@ define([ var resetTree = module.resetTree = function () { $tree.html(''); - createTree($tree, [ROOT]); - if (!isWorkgroup()) { - createUnsorted($tree, [UNSORTED]); - //createTemplate($tree, [TEMPLATE]); - createAllFiles($tree, [FILES_DATA]); - } - createTrash($tree, [TRASH]); + if (displayedCategories.indexOf(ROOT) !== -1) { createTree($tree, [ROOT]); } + if (displayedCategories.indexOf(UNSORTED) !== -1) { createUnsorted($tree, [UNSORTED]); } + if (displayedCategories.indexOf(TEMPLATE) !== -1) { createTemplate($tree, [TEMPLATE]); } + if (displayedCategories.indexOf(FILES_DATA) !== -1) { createAllFiles($tree, [FILES_DATA]); } + if (displayedCategories.indexOf(TRASH) !== -1) { createTrash($tree, [TRASH]); } }; var hideMenu = module.hideMenu = function () { From 0ce17ebbad56b5deb94070d07cdd5727e0e5921b Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 22 Feb 2017 12:25:29 +0100 Subject: [PATCH 2/3] CryptDrive usability improvements (new file in drive + context menu) --- customize.dist/translations/messages.fr.js | 2 + customize.dist/translations/messages.js | 2 + www/common/cryptpad-common.js | 1 + www/common/fileObject.js | 23 +++++++++ www/drive/file.css | 1 + www/drive/file.less | 1 + www/drive/inner.html | 1 + www/drive/main.js | 55 ++++++++++------------ www/pad/main.js | 2 +- www/poll/main.js | 1 + 10 files changed, 58 insertions(+), 31 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 0be7452f5..1ad5e907d 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -142,12 +142,14 @@ define(function () { out.fm_templateName = "Modèles"; out.fm_newButton = "Nouveau"; out.fm_newFolder = "Nouveau dossier"; + out.fm_newFile = "Nouveau document"; out.fm_folder = "Dossier"; out.fm_folderName = "Nom du dossier"; out.fm_numberOfFolders = "# de dossiers"; out.fm_numberOfFiles = "# de fichiers"; out.fm_fileName = "Nom du fichier"; out.fm_title = "Titre"; + out.fm_type = "Type"; out.fm_lastAccess = "Dernier accès"; out.fm_creation = "Création"; out.fm_forbidden = "Action interdite"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 85ac47340..30b051634 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -145,12 +145,14 @@ define(function () { out.fm_templateName = "Templates"; out.fm_newButton = "New"; out.fm_newFolder = "New folder"; + out.fm_newFile = "New document"; out.fm_folder = "Folder"; out.fm_folderName = "Folder name"; out.fm_numberOfFolders = "# of folders"; out.fm_numberOfFiles = "# of files"; out.fm_fileName = "File name"; out.fm_title = "Title"; + out.fm_type = "Type"; out.fm_lastAccess = "Last access"; out.fm_creation = "Creation"; out.fm_forbidden = "Forbidden action"; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index c03664036..b98c947f4 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -706,6 +706,7 @@ define([ common.initialName = sessionStorage[newPadNameKey]; delete sessionStorage[newPadNameKey]; } + // Deprecated if (sessionStorage[newPadPathKey]) { common.initialPath = sessionStorage[newPadPathKey]; delete sessionStorage[newPadPathKey]; diff --git a/www/common/fileObject.js b/www/common/fileObject.js index 4986c1a57..272517ec8 100644 --- a/www/common/fileObject.js +++ b/www/common/fileObject.js @@ -17,6 +17,7 @@ define([ var FILES_DATA = Cryptpad.storageKey; var NEW_FOLDER_NAME = Messages.fm_newFolder; + var NEW_FILE_NAME = Messages.fm_newFile; var DEBUG = config.DEBUG || false; var logging = function () { @@ -579,6 +580,28 @@ define([ }); }; + var pushNewFileData = function (href, title) { + files[FILES_DATA].push({ + href: href, + title: title, + atime: new Date().toISOString(), + ctime: new Date().toISOString() + }); + }; + var createNewFile = exp.createNewFile = function (filePath, name, type, cb) { + var parentEl = findElement(files, filePath); + var fileName = getAvailableName(parentEl, name || NEW_FILE_NAME); + var href = '/' + type + '/#' + Cryptpad.createRandomHash(); + parentEl[fileName] = href; + + pushNewFileData(href, fileName); + + var newPath = filePath.slice(); + newPath.push(fileName); + cb({ + newPath: newPath + }); + }; // Remove an element from the trash root var removeFromTrashArray = function (element, name) { diff --git a/www/drive/file.css b/www/drive/file.css index 461a4658f..bc9755009 100644 --- a/www/drive/file.css +++ b/www/drive/file.css @@ -229,6 +229,7 @@ span.fa-folder-open { width: 140px; text-align: center; vertical-align: top; + overflow: hidden; } #content div.grid li .name { width: 100%; diff --git a/www/drive/file.less b/www/drive/file.less index ade482e58..f2f3a5ea6 100644 --- a/www/drive/file.less +++ b/www/drive/file.less @@ -274,6 +274,7 @@ span { width: 140px; text-align: center; vertical-align: top; + overflow: hidden; .name { width: 100%; diff --git a/www/drive/inner.html b/www/drive/inner.html index 1b54746e8..9f337f5ff 100644 --- a/www/drive/inner.html +++ b/www/drive/inner.html @@ -39,6 +39,7 @@