diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-11-02 22:36:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-02 22:36:05 +0100 |
commit | 39573e602d5e38e4b71b3d197d08798dd9558659 (patch) | |
tree | 1a4045bda8e05ad3537a9bf974834e1731a1e2cd /core | |
parent | 178d7f5bfa49bcf54d85ce788268ba592608627a (diff) | |
parent | 7d17b42f4df2322c1078c99840a9d35415ffd7aa (diff) | |
download | nextcloud-server-39573e602d5e38e4b71b3d197d08798dd9558659.tar.gz nextcloud-server-39573e602d5e38e4b71b3d197d08798dd9558659.zip |
Merge pull request #1978 from nextcloud/remove-send-mail-option
Remove send mail option
Diffstat (limited to 'core')
-rw-r--r-- | core/js/core.json | 1 | ||||
-rw-r--r-- | core/js/shareconfigmodel.js | 14 | ||||
-rw-r--r-- | core/js/sharedialoglinkshareview.js | 1 | ||||
-rw-r--r-- | core/js/sharedialogmailview.js | 178 | ||||
-rw-r--r-- | core/js/sharedialogshareelistview.js | 2 | ||||
-rw-r--r-- | core/js/sharedialogview.js | 10 | ||||
-rw-r--r-- | core/js/shareitemmodel.js | 43 | ||||
-rw-r--r-- | core/js/tests/specs/sharedialogshareelistview.js | 2 | ||||
-rw-r--r-- | core/js/tests/specs/sharedialogviewSpec.js | 72 | ||||
-rw-r--r-- | core/js/tests/specs/shareitemmodelSpec.js | 104 |
10 files changed, 4 insertions, 423 deletions
diff --git a/core/js/core.json b/core/js/core.json index 7e72234aaa4..d589208c828 100644 --- a/core/js/core.json +++ b/core/js/core.json @@ -33,7 +33,6 @@ "sharedialogview.js", "sharedialogexpirationview.js", "sharedialoglinkshareview.js", - "sharedialogmailview.js", "sharedialogresharerinfoview.js", "sharedialogshareelistview.js", "octemplate.js", diff --git a/core/js/shareconfigmodel.js b/core/js/shareconfigmodel.js index 24922d62636..7c92853f682 100644 --- a/core/js/shareconfigmodel.js +++ b/core/js/shareconfigmodel.js @@ -49,20 +49,6 @@ /** * @returns {boolean} */ - isMailPublicNotificationEnabled: function() { - return $('input:hidden[name=mailPublicNotificationEnabled]').val() === 'yes'; - }, - - /** - * @returns {boolean} - */ - isMailNotificationEnabled: function() { - return $('input:hidden[name=mailNotificationEnabled]').val() === 'yes'; - }, - - /** - * @returns {boolean} - */ isShareWithLinkAllowed: function() { return $('#allowShareWithLink').val() === 'yes'; }, diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index 1d6a0f03d4d..bbc8f1b4547 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -332,7 +332,6 @@ hideFileListChecked: hideFileListChecked, publicUploadLabel: t('core', 'Allow upload and editing'), hideFileListLabel: t('core', 'Hide file listing'), - mailPublicNotificationEnabled: isLinkShare && this.configModel.isMailPublicNotificationEnabled(), mailPrivatePlaceholder: t('core', 'Email link to person'), mailButtonText: t('core', 'Send') })); diff --git a/core/js/sharedialogmailview.js b/core/js/sharedialogmailview.js deleted file mode 100644 index ce0893cb25c..00000000000 --- a/core/js/sharedialogmailview.js +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2016 - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ - -/* globals escapeHTML, Handlebars */ - -(function() { - if (!OC.Share) { - OC.Share = {}; - } - - var TEMPLATE = - '{{#if shareAllowed}}' + - ' {{#if mailPublicNotificationEnabled}}' + - '<form id="emailPrivateLink" class="emailPrivateLinkForm oneline">' + - ' <input id="email" class="emailField" value="{{email}}" placeholder="{{mailPrivatePlaceholder}}" type="text" />' + - ' <a id="emailButton" class="icon icon-mail hasTooltip" title="Send e-mail"></a>' + - '</form>' + - ' {{/if}}' + - '{{/if}}' - ; - - /** - * @class OCA.Share.ShareDialogMailView - * @member {OC.Share.ShareItemModel} model - * @member {jQuery} $el - * @memberof OCA.Sharing - * @classdesc - * - * Represents the GUI of the share dialogue - * - */ - var ShareDialogMailView = OC.Backbone.View.extend({ - /** @type {string} **/ - id: 'shareDialogMailView', - - /** @type {OC.Share.ShareConfigModel} **/ - configModel: undefined, - - /** @type {Function} **/ - _template: undefined, - - /** @type {boolean} **/ - showLink: true, - - events: { - 'click #emailButton': '_onEmailPrivateLink' - }, - - initialize: function(options) { - var view = this; - - this.model.on('change:linkShare', function() { - view.render(); - }); - - if(!_.isUndefined(options.configModel)) { - this.configModel = options.configModel; - } else { - throw 'missing OC.Share.ShareConfigModel'; - } - - _.bindAll( - this, - '_onEmailPrivateLink' - ); - }, - - _onEmailPrivateLink: function(event) { - event.preventDefault(); - - var $emailField = this.$el.find('.emailField'); - var $emailButton = this.$el.find('.emailButton'); - var email = $emailField.val(); - if (email !== '') { - $emailField.prop('disabled', true); - $emailButton.prop('disabled', true); - $emailField.val(t('core', 'Sending ...')); - this.model.sendEmailPrivateLink(email).done(function() { - $emailField.css('font-weight', 'bold').val(t('core','Email sent')); - setTimeout(function() { - $emailField.val(''); - $emailField.css('font-weight', 'normal'); - $emailField.prop('disabled', false); - $emailButton.prop('disabled', false); - }, 2000); - }).fail(function() { - $emailField.val(email); - $emailField.css('font-weight', 'normal'); - $emailField.prop('disabled', false); - $emailButton.prop('disabled', false); - }); - } - return false; - }, - - render: function() { - var linkShareTemplate = this.template(); - var resharingAllowed = this.model.sharePermissionPossible(); - var email = this.$el.find('.emailField').val(); - - if(!resharingAllowed - || !this.showLink - || !this.configModel.isShareWithLinkAllowed()) - { - var templateData = {shareAllowed: false}; - if (!resharingAllowed) { - // add message - templateData.noSharingPlaceholder = t('core', 'Resharing is not allowed'); - } - this.$el.html(linkShareTemplate(templateData)); - return this; - } - - var isLinkShare = this.model.get('linkShare').isLinkShare; - - this.$el.html(linkShareTemplate({ - cid: this.cid, - shareAllowed: true, - mailPublicNotificationEnabled: isLinkShare && this.configModel.isMailPublicNotificationEnabled(), - mailPrivatePlaceholder: t('core', 'Email link to person'), - mailButtonText: t('core', 'Send link via email'), - email: email - })); - - var $emailField = this.$el.find('.emailField'); - if (isLinkShare && $emailField.length !== 0) { - $emailField.autocomplete({ - minLength: 1, - source: function (search, response) { - $.get( - OC.generateUrl('core/ajax/share.php'), { - fetch: 'getShareWithEmail', - search: search.term - }, function(result) { - if (result.status === 'success' && result.data.length > 0) { - response(result.data); - } - }); - }, - select: function( event, item ) { - $emailField.val(item.item.email); - return false; - } - }) - .data("ui-autocomplete")._renderItem = function( ul, item ) { - return $('<li>') - .append('<a>' + escapeHTML(item.displayname) + "<br>" + escapeHTML(item.email) + '</a>' ) - .appendTo( ul ); - }; - } - this.delegateEvents(); - - return this; - }, - - /** - * @returns {Function} from Handlebars - * @private - */ - template: function () { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template; - } - - }); - - OC.Share.ShareDialogMailView = ShareDialogMailView; - -})(); diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 775eaa554b0..f532d27c4b6 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -173,7 +173,6 @@ hasCreatePermission: this.model.hasCreatePermission(shareIndex), hasUpdatePermission: this.model.hasUpdatePermission(shareIndex), hasDeletePermission: this.model.hasDeletePermission(shareIndex), - wasMailSent: this.model.notificationMailWasSent(shareIndex), shareWith: shareWith, shareWithDisplayName: shareWithDisplayName, shareWithTitle: shareWithTitle, @@ -189,7 +188,6 @@ getShareeList: function() { var universal = { avatarEnabled: this.configModel.areAvatarsEnabled(), - notifyByMailLabel: t('core', 'notify by email'), unshareLabel: t('core', 'Unshare'), canShareLabel: t('core', 'can reshare'), canEditLabel: t('core', 'can edit'), diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 3b2a7480c47..b277a1226c7 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -28,7 +28,6 @@ '<div class="shareeListView subView"></div>' + '<div class="linkShareView subView"></div>' + '<div class="expirationView subView"></div>' + - '<div class="mailView subView"></div>' + '<div class="loading hidden" style="height: 50px"></div>'; var TEMPLATE_REMOTE_SHARE_INFO = @@ -70,9 +69,6 @@ /** @type {object} **/ shareeListView: undefined, - /** @type {object} **/ - mailView: undefined, - events: { 'input .shareWithField': 'onShareWithFieldChanged' }, @@ -109,8 +105,7 @@ resharerInfoView: 'ShareDialogResharerInfoView', linkShareView: 'ShareDialogLinkShareView', expirationView: 'ShareDialogExpirationView', - shareeListView: 'ShareDialogShareeListView', - mailView: 'ShareDialogMailView' + shareeListView: 'ShareDialogShareeListView' }; for(var name in subViews) { @@ -383,9 +378,6 @@ this.shareeListView.$el = this.$el.find('.shareeListView'); this.shareeListView.render(); - this.mailView.$el = this.$el.find('.mailView'); - this.mailView.render(); - this.$el.find('.hasTooltip').tooltip(); return this; diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index ecc75ab147c..a784f59f67f 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -417,49 +417,6 @@ return (share.permissions & permission) === permission; }, - notificationMailWasSent: function(shareIndex) { - /** @type OC.Share.Types.ShareInfo **/ - var share = this.get('shares')[shareIndex]; - if(!_.isObject(share)) { - throw "Unknown Share"; - } - return share.mail_send === 1; - }, - - /** - * Send the link share information by email - * - * @param {string} recipientEmail recipient email address - */ - sendEmailPrivateLink: function(recipientEmail) { - var deferred = $.Deferred(); - var itemType = this.get('itemType'); - var itemSource = this.get('itemSource'); - var linkShare = this.get('linkShare'); - - $.post( - OC.generateUrl('core/ajax/share.php'), { - action: 'email', - toaddress: recipientEmail, - link: linkShare.link, - itemType: itemType, - itemSource: itemSource, - file: this.fileInfoModel.get('name'), - expiration: linkShare.expiration || '' - }, - function(result) { - if (!result || result.status !== 'success') { - // FIXME: a model should not show dialogs - OC.dialogs.alert(result.data.message, t('core', 'Error while sending notification')); - deferred.reject(); - } else { - deferred.resolve(); - } - }); - - return deferred.promise(); - }, - /** * @returns {boolean} */ diff --git a/core/js/tests/specs/sharedialogshareelistview.js b/core/js/tests/specs/sharedialogshareelistview.js index 699e2e58d7b..bcc596a1386 100644 --- a/core/js/tests/specs/sharedialogshareelistview.js +++ b/core/js/tests/specs/sharedialogshareelistview.js @@ -34,8 +34,6 @@ describe('OC.Share.ShareDialogShareeListView', function () { oldAppConfig = _.extend({}, oc_appconfig.core); oc_appconfig.core.enforcePasswordForPublicLink = false; - $('#testArea').append('<input id="mailNotificationEnabled" name="mailNotificationEnabled" type="hidden" value="yes">'); - fileInfoModel = new OCA.Files.FileInfoModel({ id: 123, name: 'shared_file_name.txt', diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js index f0e027d9fb9..6e86cb8eff7 100644 --- a/core/js/tests/specs/sharedialogviewSpec.js +++ b/core/js/tests/specs/sharedialogviewSpec.js @@ -41,7 +41,6 @@ describe('OC.Share.ShareDialogView', function() { beforeEach(function() { // horrible parameters $('#testArea').append('<input id="allowShareWithLink" type="hidden" value="yes">'); - $('#testArea').append('<input id="mailPublicNotificationEnabled" name="mailPublicNotificationEnabled" type="hidden" value="yes">'); $container = $('#shareContainer'); /* jshint camelcase:false */ oldAppConfig = _.extend({}, oc_appconfig.core); @@ -247,7 +246,7 @@ describe('OC.Share.ShareDialogView', function() { expect(slideToggleStub.callCount).toEqual(1); expect(slideToggleStub.getCall(0).thisValue.eq(0).attr('id')).toEqual('linkPass'); expect(fakeServer.requests.length).toEqual(0); - + // Now untoggle share by link dialog.$el.find('.linkCheckbox').click(); dialog.render(); @@ -402,76 +401,7 @@ describe('OC.Share.ShareDialogView', function() { expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0)); }); }); - describe('send link by email', function() { - var sendEmailPrivateLinkStub; - var clock; - - beforeEach(function() { - configModel.set({ - isMailPublicNotificationEnabled: true - }); - - shareModel.set('linkShare', { - isLinkShare: true, - token: 'tehtoken', - permissions: OC.PERMISSION_READ, - expiration: null - }); - - sendEmailPrivateLinkStub = sinon.stub(dialog.model, "sendEmailPrivateLink"); - clock = sinon.useFakeTimers(); - }); - afterEach(function() { - sendEmailPrivateLinkStub.restore(); - clock.restore(); - }); - it('displays form when sending emails is enabled', function() { - $('input[name=mailPublicNotificationEnabled]').val('yes'); - dialog.render(); - expect(dialog.$('.emailPrivateLinkForm').length).toEqual(1); - }); - it('form not rendered when sending emails is disabled', function() { - $('input[name=mailPublicNotificationEnabled]').val('no'); - dialog.render(); - expect(dialog.$('.emailPrivateLinkForm').length).toEqual(0); - }); - it('input cleared on success', function() { - var defer = $.Deferred(); - sendEmailPrivateLinkStub.returns(defer.promise()); - - $('input[name=mailPublicNotificationEnabled]').val('yes'); - dialog.render(); - - dialog.$el.find('.emailPrivateLinkForm .emailField').val('a@b.c'); - dialog.$el.find('#emailButton').trigger('click'); - - expect(sendEmailPrivateLinkStub.callCount).toEqual(1); - expect(dialog.$el.find('.emailPrivateLinkForm .emailField').val()).toEqual('Sending ...'); - - defer.resolve(); - expect(dialog.$el.find('.emailPrivateLinkForm .emailField').val()).toEqual('Email sent'); - - clock.tick(2000); - expect(dialog.$el.find('.emailPrivateLinkForm .emailField').val()).toEqual(''); - }); - it('input not cleared on failure', function() { - var defer = $.Deferred(); - sendEmailPrivateLinkStub.returns(defer.promise()); - - $('input[name=mailPublicNotificationEnabled]').val('yes'); - dialog.render(); - - dialog.$el.find('.emailPrivateLinkForm .emailField').val('a@b.c'); - dialog.$el.find('#emailButton').trigger('click'); - - expect(sendEmailPrivateLinkStub.callCount).toEqual(1); - expect(dialog.$el.find('.emailPrivateLinkForm .emailField').val()).toEqual('Sending ...'); - - defer.reject(); - expect(dialog.$el.find('.emailPrivateLinkForm .emailField').val()).toEqual('a@b.c'); - }); - }); }); describe('check for avatar', function() { beforeEach(function() { diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js index 9d9001dc9e8..1cddcb2acaa 100644 --- a/core/js/tests/specs/shareitemmodelSpec.js +++ b/core/js/tests/specs/shareitemmodelSpec.js @@ -464,107 +464,7 @@ describe('OC.Share.ShareItemModel', function() { }); }); - describe('sendEmailPrivateLink', function() { - it('succeeds', function() { - /* jshint camelcase: false */ - fetchReshareDeferred.resolve(makeOcsResponse([])); - fetchSharesDeferred.resolve(makeOcsResponse([{ - displayname_owner: 'root', - expiration: null, - file_source: 123, - file_target: '/folder', - id: 20, - item_source: '123', - item_type: 'folder', - mail_send: '0', - parent: null, - path: '/folder', - permissions: OC.PERMISSION_READ, - share_type: OC.Share.SHARE_TYPE_LINK, - share_with: null, - stime: 1403884258, - storage: 1, - token: 'tehtoken', - uid_owner: 'root' - }])); - OC.currentUser = 'root'; - model.fetch(); - - var res = model.sendEmailPrivateLink('foo@bar.com'); - - expect(res.state()).toEqual('pending'); - expect(fakeServer.requests.length).toEqual(1); - expect(fakeServer.requests[0].url).toEqual(OC.generateUrl('core/ajax/share.php')); - expect(OC.parseQueryString(fakeServer.requests[0].requestBody)).toEqual( - { - action: 'email', - toaddress: 'foo@bar.com', - link: model.get('linkShare').link, - itemType: 'file', - itemSource: '123', - file: 'shared_file_name.txt', - expiration: '' - } - ) - - fakeServer.requests[0].respond( - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify({status: 'success'}) - ); - expect(res.state()).toEqual('resolved'); - }); - - it('fails', function() { - /* jshint camelcase: false */ - fetchReshareDeferred.resolve(makeOcsResponse([])); - fetchSharesDeferred.resolve(makeOcsResponse([{ - displayname_owner: 'root', - expiration: null, - file_source: 123, - file_target: '/folder', - id: 20, - item_source: '123', - item_type: 'folder', - mail_send: '0', - parent: null, - path: '/folder', - permissions: OC.PERMISSION_READ, - share_type: OC.Share.SHARE_TYPE_LINK, - share_with: null, - stime: 1403884258, - storage: 1, - token: 'tehtoken', - uid_owner: 'root' - }])); - OC.currentUser = 'root'; - model.fetch(); - - var res = model.sendEmailPrivateLink('foo@bar.com'); - - expect(res.state()).toEqual('pending'); - expect(fakeServer.requests.length).toEqual(1); - expect(fakeServer.requests[0].url).toEqual(OC.generateUrl('core/ajax/share.php')); - expect(OC.parseQueryString(fakeServer.requests[0].requestBody)).toEqual( - { - action: 'email', - toaddress: 'foo@bar.com', - link: model.get('linkShare').link, - itemType: 'file', - itemSource: '123', - file: 'shared_file_name.txt', - expiration: '' - } - ) - - fakeServer.requests[0].respond( - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify({data: {message: 'fail'}, status: 'error'}) - ); - expect(res.state()).toEqual('rejected'); - }); - }); + describe('share permissions', function() { beforeEach(function() { oc_appconfig.core.resharingAllowed = true; @@ -635,7 +535,7 @@ describe('OC.Share.ShareItemModel', function() { addShareStub = sinon.stub(model, 'addShare'); updateShareStub = sinon.stub(model, 'updateShare'); }); - afterEach(function() { + afterEach(function() { addShareStub.restore(); updateShareStub.restore(); }); |