From db6c454837c633e4f1b83fe537f7bbb531527c9d Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 24 Jun 2020 11:45:34 +0200 Subject: [PATCH 1/2] Fix merge issue --- customize.dist/src/less2/include/drive.less | 2 -- www/common/drive-ui.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/customize.dist/src/less2/include/drive.less b/customize.dist/src/less2/include/drive.less index 9f569a0f9..c04c0d05b 100644 --- a/customize.dist/src/less2/include/drive.less +++ b/customize.dist/src/less2/include/drive.less @@ -4,7 +4,6 @@ @import (reference) "./limit-bar.less"; @import (reference) "./tokenfield.less"; @import (reference) "./dropdown.less"; -@import (reference) "./buttons.less"; .drive_main() { --LessLoader_require: LessLoader_currentFile(); @@ -935,7 +934,6 @@ .cp-app-drive-button { order: 15; margin: 0 1em; - .buttons_main(); } } diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index d7662b3df..cd375d16a 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1334,7 +1334,7 @@ define([ break; } case 'trash': { - show = ['remove', 'restore', 'properties']; + show = ['remove', 'deleteowned', 'restore', 'properties']; } } From b7794fa31d52a39b16a2073c04d9a598c4a7be79 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 24 Jun 2020 14:53:37 +0200 Subject: [PATCH 2/2] Add 'Delete from server' button in the access modal --- www/common/inner/access.js | 22 ++++++++++++++++++++++ www/common/proxy-manager.js | 22 ++++++++++++++-------- www/common/sframe-common-outer.js | 9 +++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/www/common/inner/access.js b/www/common/inner/access.js index 28dd2863b..668cfcdf3 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -897,6 +897,28 @@ define([ $d.append(changePass); } } + if (owned) { + var deleteOwned = h('button.btn.btn-danger-alt', Messages.fc_delete_owned); + var $deleteOwned; + var spinner = UI.makeSpinner(); + UI.confirmButton(deleteOwned, { + classes: 'btn-danger' + }, function () { + spinner.spin(); + sframeChan.query('Q_DELETE_OWNED', { + teamId: typeof(owned) !== "boolean" ? owned : undefined, + channel: data.channel + }, function (err, obj) { + spinner.done(); + if (err || (obj && obj.error)) { UI.warn(Messages.error); } + }); + }); + $d.append(h('br')); + $d.append(h('div', [ + deleteOwned, + spinner.spinner + ])); + } return $d; }; var drawRight = function () { diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index 49876a8b1..479d93c31 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -795,20 +795,23 @@ define([ // Delete permanently some pads or folders var _deleteOwned = function (Env, data, cb) { data = data || {}; - var resolved = _resolvePaths(Env, data.paths); - if (!resolved.main.length && !Object.keys(resolved.folders).length) { + var resolved = _resolvePaths(Env, data.paths || []); + if (!data.channel && !resolved.main.length && !Object.keys(resolved.folders).length) { return void cb({error: 'E_NOTFOUND'}); } var toDelete = { main: [], folders: {} }; - var todo = function (id, uo, p, _cb) { + var todo = function (channel, uo, p, _cb) { var cb = Util.once(Util.mkAsync(_cb)); - var el = uo.find(p); - if (!uo.isFile(el) && !uo.isSharedFolder(el)) { return; } - var data = uo.isFile(el) ? uo.getFileData(el) : getSharedFolderData(Env, el); - var chan = data.channel; + var chan = channel; + if (!chan && uo) { + var el = uo.find(p); + if (!uo.isFile(el) && !uo.isSharedFolder(el)) { return; } + var data = uo.isFile(el) ? uo.getFileData(el) : getSharedFolderData(Env, el); + chan = data.channel; + } Env.removeOwnedChannel(chan, function (obj) { // If the error is that the file is already removed, nothing to // report, it's a normal behavior (pad expired probably) @@ -840,13 +843,16 @@ define([ }; nThen(function (w) { // Delete owned pads from the server + if (data.channel) { + todo(data.channel, null, null, w()); + } resolved.main.forEach(function (p) { todo(null, Env.user.userObject, p, w()); }); Object.keys(resolved.folders).forEach(function (id) { var uo = Env.folders[id].userObject; resolved.folders[id].forEach(function (p) { - todo(id, uo, p, w()); + todo(null, uo, p, w()); }); }); }).nThen(function () { diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index ef983503c..5d680fcf6 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -793,6 +793,15 @@ define([ Cryptpad.changePadPassword(Cryptget, Crypto, data, cb); }); + sframeChan.on('Q_DELETE_OWNED', function (data, cb) { + Cryptpad.userObjectCommand({ + cmd: 'deleteOwned', + teamId: data.teamId, + data: { + channel: data.channel + } + }, cb); + }); }; addCommonRpc(sframeChan, isSafe);