From 8957bbd7821c7caabfe16898f753fbea705db185 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 27 Aug 2019 10:53:41 +0200 Subject: [PATCH] Ability to set ownership and password when sharing a folder --- www/common/common-interface.js | 10 ++++++++++ www/common/proxy-manager.js | 10 ++++++---- www/common/sframe-common-file.js | 9 +-------- www/drive/inner.js | 22 +++++++++++++++++++--- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 6f70d15c3..cb5f9903a 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -592,6 +592,16 @@ define([ ]); }; + UI.createHelper = function (href, text) { + var q = h('a.fa.fa-question-circle', { + style: 'text-decoration: none !important;', + title: text, + href: href, + target: "_blank", + 'data-tippy-placement': "right" + }); + return q; + }; /* * spinner diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index d7c943893..4bed6a1a2 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -492,8 +492,8 @@ define([ _addSharedFolder(Env, { path: parentPath, name: folderName, - owned: true, // XXX FIXME hardcoded preference - password: '', // XXX FIXME hardcoded preference + owned: data.owned, // XXX FIXME hardcoded preference + password: data.password || '', // XXX FIXME hardcoded preference }, waitFor(function (id) { // _addSharedFolder can be an id or an error if (typeof(id) === 'object' && id && id.error) { @@ -1012,11 +1012,13 @@ define([ } }, cb); }; - var convertFolderToSharedFolderInner = function (Env, path, cb) { + var convertFolderToSharedFolderInner = function (Env, path, owned, password, cb) { return void Env.sframeChan.query("Q_DRIVE_USEROBJECT", { cmd: "convertFolderToSharedFolder", data: { - path: path + path: path, + owned: owned, + password: password } }, cb); }; diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index fc30f8831..868279717 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -257,14 +257,7 @@ define([ store: true }; var createHelper = function (href, text) { - var q = h('a.fa.fa-question-circle', { - style: 'text-decoration: none !important;', - title: text, - href: origin + href, - target: "_blank", - 'data-tippy-placement': "right" - }); - return q; + return UI.createHelper(origin + href, text); }; var createManualStore = function (isFolderUpload) { var privateData = common.getMetadataMgr().getPrivateData(); diff --git a/www/drive/inner.js b/www/drive/inner.js index be0a60f36..987eeb16d 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -3940,12 +3940,28 @@ define([ else if (manager.hasSubSharedFolder(el)) { return void UI.alert(Messages.convertFolderToSF_SFChildren); } + // if root + else if (paths[0].path.length <= 1) { + return void UI.warn(Messages.error); + } // if folder does not contains SF else { - return void UI.confirm(Messages.convertFolderToSF_confirm, function(res) { + var convertContent = h('div', [ + h('p', Messages.convertFolderToSF_confirm), + h('label', {for: 'cp-upload-password'}, Messages.creation_passwordValue), + UI.passwordInput({id: 'cp-upload-password'}), + h('span', { + style: 'display:flex;align-items:center;justify-content:space-between' + }, [ + UI.createCheckbox('cp-upload-owned', Messages.sharedFolders_create_owned, true), + UI.createHelper(APP.origin + '/faq.html#keywords-owned', Messages.creation_owned1) + ]), + ]); + return void UI.confirm(convertContent, function(res) { if (!res) { return; } - if (paths[0].path.length <= 1) { return; } // if root - manager.convertFolderToSharedFolder(paths[0].path, refresh); + var password = $(convertContent).find('#cp-upload-password').val() || undefined; + var owned = Util.isChecked($(convertContent).find('#cp-upload-owned')); + manager.convertFolderToSharedFolder(paths[0].path, owned, password, refresh); }); } } else { // File