Fix share dropdown when links are not allowed

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.
remotes/origin/fix-10825
Vincent Petry 12 years ago
parent 36c88e2830
commit 98d06094e7
  1. 2
      core/js/share.js
  2. 26
      core/js/tests/specs/shareSpec.js

@ -503,7 +503,7 @@ OC.Share={
.append( insert ) .append( insert )
.appendTo( ul ); .appendTo( ul );
}; };
if (link) { if (link && linksAllowed) {
$('#email').autocomplete({ $('#email').autocomplete({
minLength: 1, minLength: 1,
source: function (search, response) { source: function (search, response) {

@ -44,6 +44,12 @@ describe('OC.Share tests', function() {
autocompleteStub = sinon.stub($.fn, 'autocomplete', function() { autocompleteStub = sinon.stub($.fn, 'autocomplete', function() {
// dummy container with the expected attributes // 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', {}); var $el = $('<div></div>').data('ui-autocomplete', {});
return $el; return $el;
}); });
@ -60,7 +66,7 @@ describe('OC.Share tests', function() {
'file', 'file',
123, 123,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'shared_file_name.txt' 'shared_file_name.txt'
); );
@ -73,7 +79,7 @@ describe('OC.Share tests', function() {
'file', 'file',
123, 123,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'shared_file_name.txt' 'shared_file_name.txt'
); );
@ -92,7 +98,7 @@ describe('OC.Share tests', function() {
'file', 'file',
123, 123,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'shared_file_name.txt' 'shared_file_name.txt'
); );
@ -104,7 +110,7 @@ describe('OC.Share tests', function() {
'file', 'file',
123, 123,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'shared_file_name.txt' 'shared_file_name.txt'
); );
@ -138,7 +144,7 @@ describe('OC.Share tests', function() {
'file', 'file',
123, 123,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'folder' 'folder'
); );
@ -176,7 +182,7 @@ describe('OC.Share tests', function() {
'file', 'file',
456, // another file 456, // another file
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'folder' 'folder'
); );
@ -230,7 +236,7 @@ describe('OC.Share tests', function() {
'folder', 'folder',
123, 123,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'folder' 'folder'
); );
@ -245,7 +251,7 @@ describe('OC.Share tests', function() {
'file', 'file',
456, 456,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'file_in_folder.txt' 'file_in_folder.txt'
); );
@ -266,7 +272,7 @@ describe('OC.Share tests', function() {
'file', 'file',
123, 123,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'folder' 'folder'
); );
@ -407,7 +413,7 @@ describe('OC.Share tests', function() {
'file', 'file',
123, 123,
$container, $container,
'http://localhost/dummylink', true,
31, 31,
'shared_file_name.txt' 'shared_file_name.txt'
); );

Loading…
Cancel
Save