summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-04-23 00:18:23 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-04-23 00:18:23 +0200
commit37a5b62abbc0574d2591c26002ae6937a9a37cdb (patch)
treed861aefb149952f68363df2683d5faafa1aa6d6e
parent59161774e48781de1f93d9e6896a1029f5a9688a (diff)
parentb9710296520940609bb70a4a29df0cc52fa22940 (diff)
downloadnextcloud-server-37a5b62abbc0574d2591c26002ae6937a9a37cdb.tar.gz
nextcloud-server-37a5b62abbc0574d2591c26002ae6937a9a37cdb.zip
Merge pull request #15639 from rullzer/fix_15368
Reset sharedialog values
-rw-r--r--core/js/share.js7
-rw-r--r--core/js/tests/specs/shareSpec.js94
2 files changed, 99 insertions, 2 deletions
diff --git a/core/js/share.js b/core/js/share.js
index 2eae6fa49a2..45873ca870e 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -982,6 +982,10 @@ $(document).ready(function() {
}
if (this.checked) {
+ // Reset password placeholder
+ $('#linkPassText').attr('placeholder', t('core', 'Choose a password for the public link'));
+ // Reset link
+ $('#linkText').val('');
var expireDateString = '';
if (oc_appconfig.core.defaultExpireDateEnabled) {
var date = new Date().getTime();
@@ -1009,7 +1013,7 @@ $(document).ready(function() {
} else {
$('#linkPass').slideToggle(OC.menuSpeed);
// TODO drop with IE8 drop
- if(html.hasClass('ie8')) {
+ if($('html').hasClass('ie8')) {
$('#linkPassText').attr('placeholder', null);
$('#linkPassText').val('');
}
@@ -1116,7 +1120,6 @@ $(document).ready(function() {
$(document).on('focusout keyup', '#dropdown #linkPassText', function(event) {
var linkPassText = $('#linkPassText');
if ( linkPassText.val() != '' && (event.type == 'focusout' || event.keyCode == 13) ) {
-
var allowPublicUpload = $('#sharingDialogAllowPublicUpload').is(':checked');
var dropDown = $('#dropdown');
var itemType = dropDown.data('item-type');
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js
index 4a2da645029..a16358b55c5 100644
--- a/core/js/tests/specs/shareSpec.js
+++ b/core/js/tests/specs/shareSpec.js
@@ -129,6 +129,100 @@ describe('OC.Share tests', function() {
);
expect($('#dropdown #linkCheckbox').length).toEqual(0);
});
+ it('Reset link when password is enforced and link is toggled', function() {
+ var old = oc_appconfig.core.enforcePasswordForPublicLink;
+ oc_appconfig.core.enforcePasswordForPublicLink = true;
+ $('#allowShareWithLink').val('yes');
+
+ OC.Share.showDropDown(
+ 'file',
+ 123,
+ $container,
+ true,
+ 31,
+ 'shared_file_name.txt'
+ );
+
+ // Toggle linkshare
+ $('#dropdown [name=linkCheckbox]').click();
+ expect($('#dropdown #linkText').val()).toEqual('');
+
+ // Set password
+ $('#dropdown #linkPassText').val('foo');
+ $('#dropdown #linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+
+ // Remove link
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[1].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({status: 'success'})
+ );
+
+ /*
+ * Try to share again
+ * The linkText should be emptied
+ */
+ $('#dropdown [name=linkCheckbox]').click();
+ expect($('#dropdown #linkText').val()).toEqual('');
+
+ /*
+ * Do not set password but untoggle
+ * Since there is no share this should not result in another request to the server
+ */
+ $('#dropdown [name=linkCheckbox]').click();
+ expect(fakeServer.requests.length).toEqual(2);
+
+ oc_appconfig.core.enforcePasswordForPublicLink = old;
+ });
+
+ it('Reset password placeholder when password is enforced and link is toggled', function() {
+ var old = oc_appconfig.core.enforcePasswordForPublicLink;
+ oc_appconfig.core.enforcePasswordForPublicLink = true;
+ $('#allowShareWithLink').val('yes');
+
+ OC.Share.showDropDown(
+ 'file',
+ 123,
+ $container,
+ true,
+ 31,
+ 'shared_file_name.txt'
+ );
+
+ // Toggle linkshare
+ $('#dropdown [name=linkCheckbox]').click();
+ expect($('#dropdown #linkPassText').attr('placeholder')).toEqual('Choose a password for the public link');
+
+ // Set password
+ $('#dropdown #linkPassText').val('foo');
+ $('#dropdown #linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+ expect($('#dropdown #linkPassText').attr('placeholder')).toEqual('**********');
+
+ // Remove link
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[1].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({status: 'success'})
+ );
+
+ // Try to share again
+ $('#dropdown [name=linkCheckbox]').click();
+ expect($('#dropdown #linkPassText').attr('placeholder')).toEqual('Choose a password for the public link');
+
+ oc_appconfig.core.enforcePasswordForPublicLink = old;
+ });
it('shows populated link share when a link share exists', function() {
loadItemStub.returns({
reshare: [],