]> source.dussan.org Git - nextcloud-server.git/commitdiff
Unlock sharee input field when sharing fails
authorRoeland Jago Douma <rullzer@owncloud.com>
Tue, 16 Feb 2016 18:40:44 +0000 (19:40 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Wed, 17 Feb 2016 08:21:12 +0000 (09:21 +0100)
Fixes #22441

When addShares fails (for whatever reason) we should unlock the sharee
input field so the user does not have to reload the page.

core/js/sharedialogview.js
core/js/tests/specs/sharedialogviewSpec.js

index e7435877cb36a22c494182f10fc20606cdf0965f..b406299a075dfb9d42f5c893cc1443737917b997 100644 (file)
                                        .attr('disabled', false);
                                $loading.addClass('hidden')
                                        .removeClass('inlineblock');
+                       }, error: function(obj, msg) {
+                               OC.Notification.showTemporary(msg);
+                               $(e.target).val('')
+                                       .attr('disabled', false);
+                               $loading.addClass('hidden')
+                                       .removeClass('inlineblock');
                        }});
                },
 
index 3a94379789a47bc748e4f2bad328a3d109e4d621..23214a7fe86a333fdb7689e74f52076520cd369c 100644 (file)
@@ -990,6 +990,43 @@ describe('OC.Share.ShareDialogView', function() {
 
                        addShareStub.restore();
                });
+
+               it('calls addShare after selection and fail to share', function() {
+                       dialog.render();
+
+                       var shareWith = $('.shareWithField')[0];
+                       var $shareWith = $(shareWith);
+                       var addShareStub = sinon.stub(shareModel, 'addShare');
+                       var autocompleteOptions = autocompleteStub.getCall(0).args[0];
+                       autocompleteOptions.select(new $.Event('select', {target: shareWith}), {
+                               item: {
+                                       label: 'User Two',
+                                       value: {
+                                               shareType: OC.Share.SHARE_TYPE_USER,
+                                               shareWith: 'user2'
+                                       }
+                               }
+                       });
+
+                       expect(addShareStub.calledOnce).toEqual(true);
+                       expect(addShareStub.firstCall.args[0]).toEqual({
+                               shareType: OC.Share.SHARE_TYPE_USER,
+                               shareWith: 'user2'
+                       });
+
+                       //Input is locked
+                       expect($shareWith.val()).toEqual('User Two');
+                       expect($shareWith.attr('disabled')).toEqual('disabled');
+
+                       //Callback is called
+                       addShareStub.firstCall.args[1].error();
+
+                       //Input is unlocked
+                       expect($shareWith.val()).toEqual('User Two');
+                       expect($shareWith.attr('disabled')).toEqual(undefined);
+
+                       addShareStub.restore();
+               });
        });
        describe('reshare permissions', function() {
                it('does not show sharing options when sharing not allowed', function() {