From 29170415e3a019c7225e0a3a2d5a42591bf7c412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Gonz=C3=A1lez=20Labrador?= Date: Thu, 11 May 2017 14:21:43 +0200 Subject: [PATCH] Cernbox prod 8.2.2 improve share limitation (#118) * Improve user experience when throwing errors * Improve user exp on creating shares --- core/js/share.js | 18 +++++++++++------- core/js/sharedialogshareelistview.js | 7 ++++++- core/js/sharedialogview.js | 6 +++++- core/js/shareitemmodel.js | 8 +++++--- lib/private/shareutil.php | 2 +- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/core/js/share.js b/core/js/share.js index 1932043203ed..b204412de333 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -410,14 +410,15 @@ OC.Share = _.extend(OC.Share || {}, { callback(result.data); } } else { + var msg = t('core', 'Error'); + if (result.data && result.data.message) { + msg = result.data.message; + } + if (_.isUndefined(errorCallback)) { - var msg = t('core', 'Error'); - if (result.data && result.data.message) { - msg = result.data.message; - } - OC.dialogs.alert(msg, t('core', 'Error while sharing')); } else { - errorCallback(result); + OC.dialogs.alert(msg, t('core', 'Error while sharing')); + errorCallback(true); } } } @@ -438,7 +439,7 @@ OC.Share = _.extend(OC.Share || {}, { } }); }, - setPermissions:function(itemType, itemSource, shareType, shareWith, permissions) { + setPermissions:function(itemType, itemSource, shareType, shareWith, permissions, callback) { $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setPermissions', itemType: itemType, itemSource: itemSource, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) { if (!result || result.status !== 'success') { var msg = t('core', 'Error while unsharing'); @@ -446,6 +447,9 @@ OC.Share = _.extend(OC.Share || {}, { msg = result.data.message; } OC.dialogs.alert(msg, t('core', 'Error')); + if(callback) { + callback(true); + } } }); }, diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 74c7bb29fb3f..70dff30267c6 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -263,6 +263,7 @@ var shareWith = $li.attr('data-share-with'); this.model.removeShare(shareType, shareWith); + $loading.addClass('hidden'); return false; }, @@ -297,7 +298,11 @@ permissions |= $(checkbox).data('permissions'); });*/ /** PATCH END */ - this.model.setPermissions(shareType, shareWith, permissions); + this.model.setPermissions(shareType, shareWith, permissions, function(errored) { + if(errored) { + $('input[name="edit"]', $li).attr('checked', !checked); + } + }); }, onCrudsToggle: function(event) { diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 472f0fce6820..c916ebfc126f 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -313,7 +313,11 @@ var options = {}; options.notifyByEmail = _self.$el.find('#shareNotifyByEmail').is(":checked"); - _self.model.addShareList(shareRequestData, options); + _self.model.addShareList(shareRequestData, options, function(errored) { + if(errored) { + _self._toggleLoading(false); + } + }); _self.shareRecipientList.length = 0; _self.$el.find('#recipentList').addClass('hidden'); diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index cc3acdd26438..da7aa1e176ff 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -221,7 +221,7 @@ }, /** CERNBOX SHARE USER LIST PR PATCH */ - addShareList: function(shareWith, options) + addShareList: function(shareWith, options, callback) { var fileName = this.fileInfoModel.get('name'); options = options || {}; @@ -246,6 +246,8 @@ var itemSource = this.get('itemSource'); OC.Share.shareList(itemType, itemSource, null, shareWith, permissions, fileName, options.expiration, options.notifyByEmail, function() { model.fetch(); + }, function(errored) { + callback(errored); }); }, @@ -283,12 +285,12 @@ }); }, - setPermissions: function(shareType, shareWith, permissions) { + setPermissions: function(shareType, shareWith, permissions, callback) { var itemType = this.get('itemType'); var itemSource = this.get('itemSource'); // TODO: in the future, only set the permissions on the model but don't save directly - OC.Share.setPermissions(itemType, itemSource, shareType, shareWith, permissions); + OC.Share.setPermissions(itemType, itemSource, shareType, shareWith, permissions, callback); }, removeShare: function(shareType, shareWith) { diff --git a/lib/private/shareutil.php b/lib/private/shareutil.php index 92b57193fbda..6a60c4f953ef 100644 --- a/lib/private/shareutil.php +++ b/lib/private/shareutil.php @@ -71,7 +71,7 @@ public static function checkParentDirShared(array $eosMeta, $isShareByLink) { $sharedFolderPath = self::childrenFoldersHaveBeenShared($allPaths, $currentPath); if ($sharedFolderPath) { - $msg = "Unable to modify share information because it will cause the lost of share information in the already shared folder '$sharedFolderPath'"; + $msg = "Currently not allowed. See KB at http://cern.ch/go/R7np"; throw new \Exception($msg); } }