From 96968f2076ccad930dbf5070850ccb2833fcd07a Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Oct 2019 12:24:44 +0100 Subject: [PATCH] Disable 'forget' button for pads in read-only teams --- www/common/common-ui-elements.js | 8 ++++++-- www/common/outer/async-store.js | 8 +++++++- www/common/proxy-manager.js | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index a8bea348b..1ee5a9608 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1528,8 +1528,12 @@ define([ } UI.confirm(msg, function (yes) { if (!yes) { return; } - sframeChan.query('Q_MOVE_TO_TRASH', null, function (err) { - if (err) { return void callback(err); } + sframeChan.query('Q_MOVE_TO_TRASH', null, function (err, obj) { + err = err || (obj && obj.error); + if (err) { + callback(err); + return void UI.warn(Messages.fm_forbidden); + } var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted; var msg = common.fixLinks($('
').html(cMsg)); UI.alert(msg); diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 86c9229dc..d2f0d7258 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -986,17 +986,23 @@ define([ }; Store.moveToTrash = function (clientId, data, cb) { var href = Hash.getRelativeHref(data.href); + var allErrors = true; nThen(function (waitFor) { getAllStores().forEach(function (s) { var deleted = s.userObject.forget(href); if (!deleted) { return; } + allErrors = false; var send = s.id ? s.sendEvent : sendDriveEvent; send('DRIVE_CHANGE', { path: ['drive', UserObject.FILES_DATA] }, clientId); onSync(s.id, waitFor()); }); - }).nThen(cb); + }).nThen(function () { + cb({ + error: allErrors ? 'FORBIDDEN' : undefined + }); + }); }; Store.setPadTitle = function (clientId, data, cb) { var title = data.title; diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index 49463c805..4c5e2d2e4 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -124,7 +124,7 @@ define([ var data = Env.user.proxy[UserObject.SHARED_FOLDERS][id]; if (data && !editable) { data = JSON.parse(JSON.stringify(data)); } // If it's not a shared folder, check the pads - if (!data) { Env.user.userObject.getFileData(id, editable); } + if (!data) { data = Env.user.userObject.getFileData(id, editable); } ret.push({ data: data, userObject: Env.user.userObject