]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix share dropdown when links are not allowed
authorVincent Petry <pvince81@owncloud.com>
Thu, 21 Aug 2014 11:49:02 +0000 (13:49 +0200)
committerVincent Petry <pvince81@owncloud.com>
Thu, 21 Aug 2014 11:49:02 +0000 (13:49 +0200)
When links are not allowed, the email field does not exist and
autocomplete returns null. This causes Javascript errors.

The fix prevents entering the bogus block when links aren't allowed, as
it doesn't make sense to enter it in such cases anyway.

core/js/share.js
core/js/tests/specs/shareSpec.js

index 99a767b47f24428b82d26d5fddc48b2bc681dac7..f1652370d352ea2ddcc89e0f19734f1ab658c12e 100644 (file)
@@ -503,7 +503,7 @@ OC.Share={
                                        .append( insert )
                                        .appendTo( ul );
                        };
-                       if (link) {
+                       if (link && linksAllowed) {
                                $('#email').autocomplete({
                                        minLength: 1,
                                        source: function (search, response) {
index 1fd36dfff04d66945c1e0d587a01a0d0b6a7dfc6..06c4b98df2a95cdf41ad5636f4466c7447708a8a 100644 (file)
@@ -44,6 +44,12 @@ describe('OC.Share tests', function() {
 
                        autocompleteStub = sinon.stub($.fn, 'autocomplete', function() {
                                // dummy container with the expected attributes
+                               if (!$(this).length) {
+                                       // simulate the real autocomplete that returns
+                                       // nothing at all when no element is specified
+                                       // (and potentially break stuff)
+                                       return null;
+                               }
                                var $el = $('<div></div>').data('ui-autocomplete', {});
                                return $el;
                        });
@@ -60,7 +66,7 @@ describe('OC.Share tests', function() {
                                'file',
                                123,
                                $container,
-                               'http://localhost/dummylink',
+                               true,
                                31,
                                'shared_file_name.txt'
                        );
@@ -73,7 +79,7 @@ describe('OC.Share tests', function() {
                                'file',
                                123,
                                $container,
-                               'http://localhost/dummylink',
+                               true,
                                31,
                                'shared_file_name.txt'
                        );
@@ -92,7 +98,7 @@ describe('OC.Share tests', function() {
                                        'file',
                                        123,
                                        $container,
-                                       'http://localhost/dummylink',
+                                       true,           
                                        31,
                                        'shared_file_name.txt'
                                );
@@ -104,7 +110,7 @@ describe('OC.Share tests', function() {
                                        'file',
                                        123,
                                        $container,
-                                       'http://localhost/dummylink',
+                                       true,           
                                        31,
                                        'shared_file_name.txt'
                                );
@@ -138,7 +144,7 @@ describe('OC.Share tests', function() {
                                        'file',
                                        123,
                                        $container,
-                                       'http://localhost/dummylink',
+                                       true,
                                        31,
                                        'folder'
                                );
@@ -176,7 +182,7 @@ describe('OC.Share tests', function() {
                                        'file',
                                        456, // another file
                                        $container,
-                                       'http://localhost/dummylink',
+                                       true,
                                        31,
                                        'folder'
                                );
@@ -230,7 +236,7 @@ describe('OC.Share tests', function() {
                                        'folder',
                                        123,
                                        $container,
-                                       'http://localhost/dummylink',
+                                       true,
                                        31,
                                        'folder'
                                );
@@ -245,7 +251,7 @@ describe('OC.Share tests', function() {
                                        'file',
                                        456,
                                        $container,
-                                       'http://localhost/dummylink',
+                                       true,
                                        31,
                                        'file_in_folder.txt'
                                );
@@ -266,7 +272,7 @@ describe('OC.Share tests', function() {
                                                'file',
                                                123,
                                                $container,
-                                               'http://localhost/dummylink',
+                                               true,
                                                31,
                                                'folder'
                                        );
@@ -407,7 +413,7 @@ describe('OC.Share tests', function() {
                                        'file',
                                        123,
                                        $container,
-                                       'http://localhost/dummylink',
+                                       true,
                                        31,
                                        'shared_file_name.txt'
                                );