From cca33942aa01542c7b9920c80c66e3becd3a0d9c Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 27 Jan 2016 18:28:55 +0100 Subject: [PATCH 01/13] Comments GUI --- .gitignore | 1 + apps/comments/appinfo/app.php | 34 ++++++ apps/comments/appinfo/info.xml | 16 +++ apps/comments/js/app.js | 20 ++++ apps/comments/js/commentcollection.js | 82 +++++++++++++ apps/comments/js/commentmodel.js | 47 ++++++++ apps/comments/js/commentstabview.js | 166 ++++++++++++++++++++++++++ apps/comments/js/filesplugin.js | 41 +++++++ core/shipped.json | 1 + 9 files changed, 408 insertions(+) create mode 100644 apps/comments/appinfo/app.php create mode 100644 apps/comments/appinfo/info.xml create mode 100644 apps/comments/js/app.js create mode 100644 apps/comments/js/commentcollection.js create mode 100644 apps/comments/js/commentmodel.js create mode 100644 apps/comments/js/commentstabview.js create mode 100644 apps/comments/js/filesplugin.js diff --git a/.gitignore b/.gitignore index 237f0f44e81..2e42105ad83 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ # ignore all apps except core ones /apps*/* +!/apps/comments !/apps/dav !/apps/files !/apps/federation diff --git a/apps/comments/appinfo/app.php b/apps/comments/appinfo/app.php new file mode 100644 index 00000000000..c6f36567c51 --- /dev/null +++ b/apps/comments/appinfo/app.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +$eventDispatcher = \OC::$server->getEventDispatcher(); +$eventDispatcher->addListener( + 'OCA\Files::loadAdditionalScripts', + function() { + \OCP\Util::addScript('oc-backbone-webdav'); + \OCP\Util::addScript('comments', 'app'); + \OCP\Util::addScript('comments', 'commentmodel'); + \OCP\Util::addScript('comments', 'commentcollection'); + \OCP\Util::addScript('comments', 'commentstabview'); + \OCP\Util::addScript('comments', 'filesplugin'); + \OCP\Util::addStyle('comments', 'comments'); + } +); diff --git a/apps/comments/appinfo/info.xml b/apps/comments/appinfo/info.xml new file mode 100644 index 00000000000..550c79448cf --- /dev/null +++ b/apps/comments/appinfo/info.xml @@ -0,0 +1,16 @@ + + + comments + Comments + Files app plugin to add comments to files + AGPL + Arthur Shiwon, Vincent Petry + + 0.1 + + + + + user-comments + + diff --git a/apps/comments/js/app.js b/apps/comments/js/app.js new file mode 100644 index 00000000000..547059393a5 --- /dev/null +++ b/apps/comments/js/app.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2016 Vincent Petry + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function() { + if (!OCA.Comments) { + /** + * @namespace + */ + OCA.Comments = {}; + } + +})(); + diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js new file mode 100644 index 00000000000..61b5adb7da7 --- /dev/null +++ b/apps/comments/js/commentcollection.js @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function(OC, OCA) { + + function filterFunction(model, term) { + return model.get('name').substr(0, term.length) === term; + } + + /** + * @class OCA.Comments.CommentsCollection + * @classdesc + * + * Collection of comments assigned to a file + * + */ + var CommentsCollection = OC.Backbone.Collection.extend( + /** @lends OCA.Comments.CommentsCollection.prototype */ { + + sync: OC.Backbone.davSync, + + model: OCA.Comments.CommentModel, + + _objectType: 'files', + _objectId: null, + + _endReached: false, + _currentIndex: 0, + + initialize: function(models, options) { + options = options || {}; + if (options.objectType) { + this._objectType = options.objectType; + } + if (options.objectId) { + this._objectId = options.objectId; + } + }, + + url: function() { + return OC.linkToRemote('dav') + '/comments/' + + encodeURIComponent(this._objectType) + '/' + + encodeURIComponent(this._objectId) + '/'; + }, + + setObjectId: function(objectId) { + this._objectId = objectId; + }, + + hasMoreResults: function() { + return !this._endReached; + }, + + /** + * Fetch the next set of results + */ + fetchNext: function() { + if (!this.hasMoreResults()) { + return null; + } + if (this._currentIndex === 0) { + return this.fetch(); + } + return this.fetch({remove: false}); + }, + + reset: function() { + this._currentIndex = 0; + OC.Backbone.Collection.prototype.reset.apply(this, arguments); + } + }); + + OCA.Comments.CommentsCollection = CommentsCollection; +})(OC, OCA); + diff --git a/apps/comments/js/commentmodel.js b/apps/comments/js/commentmodel.js new file mode 100644 index 00000000000..8771bd2d0f4 --- /dev/null +++ b/apps/comments/js/commentmodel.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function(OC, OCA) { + var NS_OWNCLOUD = 'http://owncloud.org/ns'; + /** + * @class OCA.Comments.CommentModel + * @classdesc + * + * Comment + * + */ + var CommentModel = OC.Backbone.Model.extend( + /** @lends OCA.Comments.CommentModel.prototype */ { + sync: OC.Backbone.davSync, + + defaults: { + // TODO + }, + + davProperties: { + 'id': '{' + NS_OWNCLOUD + '}id', + 'message': '{' + NS_OWNCLOUD + '}message', + 'actorType': '{' + NS_OWNCLOUD + '}actorType', + 'actorId': '{' + NS_OWNCLOUD + '}actorId', + 'actorDisplayName': '{' + NS_OWNCLOUD + '}actorDisplayName', + 'creationDateTime': '{' + NS_OWNCLOUD + '}creationDateTime', + 'objectType': '{' + NS_OWNCLOUD + '}objectType', + 'objectId': '{' + NS_OWNCLOUD + '}objectId' + }, + + parse: function(data) { + // TODO: parse non-string values + return data; + } + }); + + OCA.Comments.CommentModel = CommentModel; +})(OC, OCA); + diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js new file mode 100644 index 00000000000..cccb400dd68 --- /dev/null +++ b/apps/comments/js/commentstabview.js @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2016 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function() { + var TEMPLATE = + '
' + + '
' + + ' ' + + ' ' + + '
' + + '
    ' + + '
' + + '
' + + '' + + /* + '' + + */ + ''; + + var COMMENT_TEMPLATE = + '
  • ' + + '
    ' + + '
    ' + + ' {{actorDisplayName}}' + + ' {{creationDateTime}}' + + '
    ' + + '
    {{message}}
    ' + + '
  • '; + + /** + * @memberof OCA.Comments + */ + var CommentsTabView = OCA.Files.DetailTabView.extend( + /** @lends OCA.Comments.CommentsTabView.prototype */ { + id: 'commentsTabView', + className: 'tab commentsTabView', + + events: { + 'submit .newCommentForm': '_onSubmitComment' + }, + + initialize: function() { + OCA.Files.DetailTabView.prototype.initialize.apply(this, arguments); + this.collection = new OCA.Comments.CommentsCollection(); + this.collection.on('request', this._onRequest, this); + this.collection.on('sync', this._onEndRequest, this); + this.collection.on('add', this._onAddModel, this); + // TODO: error handling + _.bindAll(this, '_onSubmitComment'); + }, + + template: function(params) { + if (!this._template) { + this._template = Handlebars.compile(TEMPLATE); + } + return this._template(_.extend({ + submitText: t('comments', 'Submit comment') + }, params)); + }, + + commentTemplate: function(params) { + if (!this._commentTemplate) { + this._commentTemplate = Handlebars.compile(COMMENT_TEMPLATE); + } + return this._commentTemplate(params); + }, + + getLabel: function() { + return t('comments', 'Comments'); + }, + + setFileInfo: function(fileInfo) { + if (fileInfo) { + this.render(); + this.collection.setObjectId(fileInfo.id); + // reset to first page + this.collection.reset([], {silent: true}); + this.nextPage(); + } else { + this.render(); + this.collection.reset(); + } + }, + + render: function() { + this.$el.html(this.template({ + emptyResultLabel: t('comments', 'No other comments available'), + moreLabel: t('comments', 'More comments...') + })); + this.$el.find('.has-tooltip').tooltip(); + this.$container = this.$el.find('ul.comments'); + this.delegateEvents(); + }, + + _formatItem: function(commentModel) { + // TODO: format + return commentModel.attributes; + }, + + _toggleLoading: function(state) { + this._loading = state; + this.$el.find('.loading').toggleClass('hidden', !state); + }, + + _onRequest: function() { + this._toggleLoading(true); + this.$el.find('.showMore').addClass('hidden'); + }, + + _onEndRequest: function() { + this._toggleLoading(false); + this.$el.find('.empty').toggleClass('hidden', !!this.collection.length); + this.$el.find('.showMore').toggleClass('hidden', !this.collection.hasMoreResults()); + }, + + _onAddModel: function(model, collection, options) { + var $el = $(this.commentTemplate(this._formatItem(model))); + if (!_.isUndefined(options.at) && collection.length > 1) { + this.$container.find('li').eq(options.at).before($el); + } else { + this.$container.append($el); + } + }, + + nextPage: function() { + if (this._loading || !this.collection.hasMoreResults()) { + return; + } + + this.collection.fetchNext(); + }, + + _onClickShowMoreVersions: function(ev) { + ev.preventDefault(); + this.nextPage(); + }, + + _onSubmitComment: function(e) { + var $textArea = $(e.target).find('textarea'); + e.preventDefault(); + this.collection.create({ + actorId: OC.currentUser, + // FIXME: how to get current user's display name ? + actorDisplayName: OC.currentUser, + actorType: 'users', + verb: 'comment', + message: $textArea.val() + }, {at: 0}); + + // TODO: spinner/disable field? + $textArea.val(''); + return false; + } + }); + + OCA.Comments.CommentsTabView = CommentsTabView; +})(); + diff --git a/apps/comments/js/filesplugin.js b/apps/comments/js/filesplugin.js new file mode 100644 index 00000000000..c8d91e0ede3 --- /dev/null +++ b/apps/comments/js/filesplugin.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016 Vincent Petry + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function() { + OCA.Comments = _.extend({}, OCA.Comments); + if (!OCA.Comments) { + /** + * @namespace + */ + OCA.Comments = {}; + } + + /** + * @namespace + */ + OCA.Comments.FilesPlugin = { + allowedLists: [ + 'files', + 'favorites' + ], + + attach: function(fileList) { + if (this.allowedLists.indexOf(fileList.id) < 0) { + return; + } + + fileList.registerTabView(new OCA.Comments.CommentsTabView('commentsTabView')); + } + }; + +})(); + +OC.Plugins.register('OCA.Files.FileList', OCA.Comments.FilesPlugin); + diff --git a/core/shipped.json b/core/shipped.json index 5dd8700bf1a..5f995326625 100644 --- a/core/shipped.json +++ b/core/shipped.json @@ -3,6 +3,7 @@ "activity", "admin_audit", "encryption", + "comments", "dav", "enterprise_key", "external", From d1518045ecdf4dd006224256b25b292a92b1202d Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 28 Jan 2016 11:47:23 +0100 Subject: [PATCH 02/13] Improve comment date format --- apps/comments/js/commentstabview.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index cccb400dd68..b1a3f854fe1 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -30,7 +30,7 @@ '
    ' + '
    ' + ' {{actorDisplayName}}' + - ' {{creationDateTime}}' + + ' {{date}}' + '
    ' + '
    {{message}}
    ' + ''; @@ -101,8 +101,13 @@ }, _formatItem: function(commentModel) { + var timestamp = new Date(commentModel.get('creationDateTime')).getTime(); + var data = _.extend({ + date: OC.Util.relativeModifiedDate(timestamp), + altDate: OC.Util.formatDate(timestamp) + }, commentModel.attributes); // TODO: format - return commentModel.attributes; + return data; }, _toggleLoading: function(state) { @@ -128,6 +133,7 @@ } else { this.$container.append($el); } + $el.find('.has-tooltip').tooltip(); }, nextPage: function() { @@ -152,7 +158,8 @@ actorDisplayName: OC.currentUser, actorType: 'users', verb: 'comment', - message: $textArea.val() + message: $textArea.val(), + creationDateTime: (new Date()).getTime() }, {at: 0}); // TODO: spinner/disable field? From 29386eccf96aec3e6a4c776f43e74c95474697bb Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 28 Jan 2016 14:24:12 +0100 Subject: [PATCH 03/13] Add pagination support for comments GUI --- apps/comments/js/commentcollection.js | 56 ++++++++++++++++++++------ apps/comments/js/commentstabview.js | 7 ++-- core/js/oc-backbone-webdav.js | 22 ++++++---- core/vendor/davclient.js/lib/client.js | 29 +++++++------ 4 files changed, 77 insertions(+), 37 deletions(-) diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js index 61b5adb7da7..1fda4a4c709 100644 --- a/apps/comments/js/commentcollection.js +++ b/apps/comments/js/commentcollection.js @@ -10,9 +10,7 @@ (function(OC, OCA) { - function filterFunction(model, term) { - return model.get('name').substr(0, term.length) === term; - } + var NS_OWNCLOUD = 'http://owncloud.org/ns'; /** * @class OCA.Comments.CommentsCollection @@ -32,7 +30,7 @@ _objectId: null, _endReached: false, - _currentIndex: 0, + _limit : 5, initialize: function(models, options) { options = options || {}; @@ -58,22 +56,54 @@ return !this._endReached; }, + reset: function() { + this._endReached = false; + return OC.Backbone.Collection.prototype.reset.apply(this, arguments); + }, + /** * Fetch the next set of results */ - fetchNext: function() { + fetchNext: function(options) { + var self = this; if (!this.hasMoreResults()) { return null; } - if (this._currentIndex === 0) { - return this.fetch(); - } - return this.fetch({remove: false}); - }, - reset: function() { - this._currentIndex = 0; - OC.Backbone.Collection.prototype.reset.apply(this, arguments); + var body = '\n' + + '\n' + + ' ' + this._limit + '\n'; + + if (this.length > 0) { + body += ' ' + this.first().get('creationDateTime') + '\n'; + } + + body += '\n'; + + var oldLength = this.length; + + options = options || {}; + var success = options.success; + options = _.extend({ + remove: false, + data: body, + davProperties: CommentsCollection.prototype.model.prototype.davProperties, + success: function(resp) { + if (resp.length === oldLength) { + // no new entries, end reached + self._endReached = true; + } + if (!self.set(resp, options)) { + return false; + } + if (success) { + success.apply(null, arguments); + } + self.trigger('sync', 'REPORT', self, options); + } + }, options); + + return this.sync('REPORT', this, options); } }); diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index b1a3f854fe1..6e511732803 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -19,10 +19,8 @@ ' ' + '' + '' + - /* '' + - */ ''; var COMMENT_TEMPLATE = @@ -44,7 +42,8 @@ className: 'tab commentsTabView', events: { - 'submit .newCommentForm': '_onSubmitComment' + 'submit .newCommentForm': '_onSubmitComment', + 'click .showMore': '_onClickShowMore' }, initialize: function() { @@ -144,7 +143,7 @@ this.collection.fetchNext(); }, - _onClickShowMoreVersions: function(ev) { + _onClickShowMore: function(ev) { ev.preventDefault(); this.nextPage(); }, diff --git a/core/js/oc-backbone-webdav.js b/core/js/oc-backbone-webdav.js index 7c32116f011..d231a5b1ba0 100644 --- a/core/js/oc-backbone-webdav.js +++ b/core/js/oc-backbone-webdav.js @@ -76,6 +76,11 @@ * @param {Object} davProperties properties mapping */ function parsePropFindResult(result, davProperties) { + if (_.isArray(result)) { + return _.map(result, function(subResult) { + return parsePropFindResult(subResult, davProperties); + }); + } var props = { href: result.href }; @@ -151,15 +156,10 @@ if (isSuccessStatus(response.status)) { if (_.isFunction(options.success)) { var propsMapping = _.invert(options.davProperties); - var results; + var results = parsePropFindResult(response.body, propsMapping); if (options.depth > 0) { - results = _.map(response.body, function(data) { - return parsePropFindResult(data, propsMapping); - }); // discard root entry results.shift(); - } else { - results = parsePropFindResult(response.body, propsMapping); } options.success(results); @@ -217,7 +217,13 @@ options.success(responseJson); return; } - options.success(result.body); + // if multi-status, parse + if (result.status === 207) { + var propsMapping = _.invert(options.davProperties); + options.success(parsePropFindResult(result.body, propsMapping)); + } else { + options.success(result.body); + } } }); } @@ -249,7 +255,7 @@ * DAV transport */ function davSync(method, model, options) { - var params = {type: methodMap[method]}; + var params = {type: methodMap[method] || method}; var isCollection = (model instanceof Backbone.Collection); if (method === 'update' && (model.usePUT || (model.collection && model.collection.usePUT))) { diff --git a/core/vendor/davclient.js/lib/client.js b/core/vendor/davclient.js/lib/client.js index 1a73c7db020..dbdfd3823e4 100644 --- a/core/vendor/davclient.js/lib/client.js +++ b/core/vendor/davclient.js/lib/client.js @@ -1,17 +1,17 @@ if (typeof dav == 'undefined') { dav = {}; }; dav._XML_CHAR_MAP = { - '<': '<', - '>': '>', - '&': '&', - '"': '"', - "'": ''' + '<': '<', + '>': '>', + '&': '&', + '"': '"', + "'": ''' }; dav._escapeXml = function(s) { - return s.replace(/[<>&"']/g, function (ch) { - return dav._XML_CHAR_MAP[ch]; - }); + return s.replace(/[<>&"']/g, function (ch) { + return dav._XML_CHAR_MAP[ch]; + }); }; dav.Client = function(options) { @@ -79,17 +79,16 @@ dav.Client.prototype = { return this.request('PROPFIND', url, headers, body).then( function(result) { - var resultBody = this.parseMultiStatus(result.body); if (depth===0) { return { status: result.status, - body: resultBody[0], + body: result.body[0], xhr: result.xhr }; } else { return { status: result.status, - body: resultBody, + body: result.body, xhr: result.xhr }; } @@ -161,6 +160,7 @@ dav.Client.prototype = { */ request : function(method, url, headers, body) { + var self = this; var xhr = this.xhrProvider(); if (this.userName) { @@ -182,8 +182,13 @@ dav.Client.prototype = { return; } + var resultBody = xhr.response; + if (xhr.status === 207) { + resultBody = self.parseMultiStatus(xhr.response); + } + fulfill({ - body: xhr.response, + body: resultBody, status: xhr.status, xhr: xhr }); From 67a36a2cca65df4d4775e9ae5e1c0e51172ae081 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 28 Jan 2016 14:26:07 +0100 Subject: [PATCH 04/13] Use last comment's time for pagination --- apps/comments/js/commentcollection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js index 1fda4a4c709..eaa7a1d53fa 100644 --- a/apps/comments/js/commentcollection.js +++ b/apps/comments/js/commentcollection.js @@ -75,7 +75,7 @@ ' ' + this._limit + '\n'; if (this.length > 0) { - body += ' ' + this.first().get('creationDateTime') + '\n'; + body += ' ' + this.last().get('creationDateTime') + '\n'; } body += '\n'; From 3b581b051f33e141ba0c76c8bcde104ce65826c2 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 1 Feb 2016 15:11:42 +0100 Subject: [PATCH 05/13] Expose display name in JS side Adds a new method `OC.getCurrentUser` to get both the user id and display name Could be used for a future Js --- core/js/js.js | 32 ++++++++++++++++++++++++++++++++ core/templates/layout.user.php | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/core/js/js.js b/core/js/js.js index 43ea269c203..bc8c51e40d3 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -82,6 +82,12 @@ var OC={ webroot:oc_webroot, appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false, + /** + * Currently logged in user or null if none + * + * @type String + * @deprecated use {@link OC.getCurrentUser} instead + */ currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false, config: window.oc_config, appConfig: window.oc_appconfig || {}, @@ -271,6 +277,23 @@ var OC={ return OC.webroot; }, + /** + * Returns the currently logged in user or null if there is no logged in + * user (public page mode) + * + * @return {OC.CurrentUser} user spec + * @since 9.0.0 + */ + getCurrentUser: function() { + if (_.isUndefined(this._currentUserDisplayName)) { + this._currentUserDisplayName = document.getElementsByTagName('head')[0].getAttribute('data-user-displayname'); + } + return { + uid: this.currentUser, + displayName: this._currentUserDisplayName + }; + }, + /** * get the absolute path to an image file * if no extension is given for the image, it will automatically decide @@ -689,6 +712,15 @@ var OC={ }, }; +/** + * Current user attributes + * + * @typedef {Object} OC.CurrentUser + * + * @property {String} uid user id + * @property {String} displayName display name + */ + /** * @namespace OC.Plugins */ diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 7fe67159bb5..7905f5b7f3a 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -2,7 +2,7 @@ - data-update-version="" data-update-link="" From fdf555e814f84063c2dfa763a6aa285c52f9443d Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 1 Feb 2016 16:37:33 +0100 Subject: [PATCH 06/13] Improve comments style, add avatars --- apps/comments/css/comments.css | 51 ++++++++++++++++++++ apps/comments/js/commentmodel.js | 3 +- apps/comments/js/commentstabview.js | 72 ++++++++++++++++++++--------- 3 files changed, 104 insertions(+), 22 deletions(-) create mode 100644 apps/comments/css/comments.css diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css new file mode 100644 index 00000000000..b1108467f68 --- /dev/null +++ b/apps/comments/css/comments.css @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +#commentsTabView .newCommentForm { + margin-bottom: 20px; +} + +#commentsTabView .newCommentForm .message { + width: 90%; + resize: none; +} + +#commentsTabView .newCommentForm .submit { + display: block; +} + +#commentsTabView .comment { + margin-bottom: 30px; +} + +#commentsTabView .comment .avatar { + width: 28px; + height: 28px; + line-height: 28px; +} + +#commentsTabView .authorRow>div { + display: inline-block; + vertical-align: middle; +} + +#commentsTabView .comment .authorRow { + margin-bottom: 5px; + position: relative; +} + +#commentsTabView .comment .author { + font-weight: bold; +} + +#commentsTabView .comment .date { + position: absolute; + right: 0; +} diff --git a/apps/comments/js/commentmodel.js b/apps/comments/js/commentmodel.js index 8771bd2d0f4..b945f71fdd2 100644 --- a/apps/comments/js/commentmodel.js +++ b/apps/comments/js/commentmodel.js @@ -22,7 +22,8 @@ sync: OC.Backbone.davSync, defaults: { - // TODO + actorType: 'users', + objectType: 'files' }, davProperties: { diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 6e511732803..c2fa08ed20e 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -8,15 +8,21 @@ * */ -(function() { +(function(OC, OCA) { var TEMPLATE = - '
    ' + - '
    ' + - ' ' + - ' ' + - '
    ' + - '
      ' + - '
    ' + + '
    ' + + '
    ' + + ' {{#if avatarEnabled}}' + + '
    ' + + ' {{/if}}' + + '
    {{userDisplayName}}
    ' + + '
    ' + + '
    ' + + ' ' + + ' ' + + '
    ' + + '
      ' + + '
    ' + '
    ' + '' + '
    '; var COMMENT_TEMPLATE = - '
  • ' + - '
    ' + - '
    ' + - ' {{actorDisplayName}}' + - ' {{date}}' + - '
    ' + - '
    {{message}}
    ' + + '
  • ' + + '
    ' + + ' {{#if avatarEnabled}}' + + '
    ' + + ' {{/if}}' + + '
    {{actorDisplayName}}
    ' + + '
    {{date}}
    ' + + '
    ' + + '
    {{message}}
    ' + '
  • '; /** @@ -52,6 +60,9 @@ this.collection.on('request', this._onRequest, this); this.collection.on('sync', this._onEndRequest, this); this.collection.on('add', this._onAddModel, this); + + this._avatarsEnabled = !!OC.config.enable_avatars; + // TODO: error handling _.bindAll(this, '_onSubmitComment'); }, @@ -60,8 +71,13 @@ if (!this._template) { this._template = Handlebars.compile(TEMPLATE); } + var currentUser = OC.getCurrentUser(); return this._template(_.extend({ - submitText: t('comments', 'Submit comment') + avatarEnabled: this._avatarsEnabled, + userId: currentUser.uid, + userDisplayName: currentUser.displayName, + newMessagePlaceholder: t('comments', 'Type in a new comment...'), + submitText: t('comments', 'Post') }, params)); }, @@ -69,7 +85,9 @@ if (!this._commentTemplate) { this._commentTemplate = Handlebars.compile(COMMENT_TEMPLATE); } - return this._commentTemplate(params); + return this._commentTemplate(_.extend({ + avatarEnabled: this._avatarsEnabled + }, params)); }, getLabel: function() { @@ -96,6 +114,7 @@ })); this.$el.find('.has-tooltip').tooltip(); this.$container = this.$el.find('ul.comments'); + this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 28); this.delegateEvents(); }, @@ -132,7 +151,18 @@ } else { this.$container.append($el); } + + this._postRenderItem($el); + }, + + _postRenderItem: function($el) { $el.find('.has-tooltip').tooltip(); + if(this._avatarsEnabled) { + $el.find('.avatar').each(function() { + var $this = $(this); + $this.avatar($this.attr('data-username'), 28); + }); + } }, nextPage: function() { @@ -149,12 +179,12 @@ }, _onSubmitComment: function(e) { + var currentUser = OC.getCurrentUser(); var $textArea = $(e.target).find('textarea'); e.preventDefault(); this.collection.create({ - actorId: OC.currentUser, - // FIXME: how to get current user's display name ? - actorDisplayName: OC.currentUser, + actorId: currentUser.uid, + actorDisplayName: currentUser.displayName, actorType: 'users', verb: 'comment', message: $textArea.val(), @@ -168,5 +198,5 @@ }); OCA.Comments.CommentsTabView = CommentsTabView; -})(); +})(OC, OCA); From 64ad99db70a18bafdbcf906dd400db6e0712fe29 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 1 Feb 2016 16:54:18 +0100 Subject: [PATCH 07/13] Better comments pagination logic --- apps/comments/js/commentcollection.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js index eaa7a1d53fa..055752f327c 100644 --- a/apps/comments/js/commentcollection.js +++ b/apps/comments/js/commentcollection.js @@ -30,7 +30,7 @@ _objectId: null, _endReached: false, - _limit : 5, + _limit : 20, initialize: function(models, options) { options = options || {}; @@ -72,15 +72,10 @@ var body = '\n' + '\n' + - ' ' + this._limit + '\n'; - - if (this.length > 0) { - body += ' ' + this.last().get('creationDateTime') + '\n'; - } - - body += '\n'; - - var oldLength = this.length; + // load one more so we know there is more + ' ' + (this._limit + 1) + '\n' + + ' ' + this.length + '\n' + + '\n'; options = options || {}; var success = options.success; @@ -89,9 +84,12 @@ data: body, davProperties: CommentsCollection.prototype.model.prototype.davProperties, success: function(resp) { - if (resp.length === oldLength) { + if (resp.length <= self._limit) { // no new entries, end reached self._endReached = true; + } else { + // remove last entry, for next page load + resp = _.initial(resp); } if (!self.set(resp, options)) { return false; From 3a6d065e503def8e9ca47dd6780b9ddbc0772509 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 1 Feb 2016 16:54:27 +0100 Subject: [PATCH 08/13] Fix formatting messages with newlines --- apps/comments/js/commentstabview.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index c2fa08ed20e..bc496f2e599 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -38,7 +38,7 @@ '
    {{actorDisplayName}}
    ' + '
    {{date}}
    ' + ' ' + - '
    {{message}}
    ' + + '
    {{{formattedMessage}}}
    ' + ''; /** @@ -122,7 +122,8 @@ var timestamp = new Date(commentModel.get('creationDateTime')).getTime(); var data = _.extend({ date: OC.Util.relativeModifiedDate(timestamp), - altDate: OC.Util.formatDate(timestamp) + altDate: OC.Util.formatDate(timestamp), + formattedMessage: this._formatMessage(commentModel.get('message')) }, commentModel.attributes); // TODO: format return data; @@ -165,6 +166,14 @@ } }, + /** + * Convert a message to be displayed in HTML, + * converts newlines to
    tags. + */ + _formatMessage: function(message) { + return escapeHTML(message).replace(/\n/g, '
    '); + }, + nextPage: function() { if (this._loading || !this.collection.hasMoreResults()) { return; From d81c00304f8af4cdbc5739d1471f0261bcca6ccf Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 2 Feb 2016 11:52:55 +0100 Subject: [PATCH 09/13] Fix parsing empty Webdav property nodes Return empty string instead of undefined --- core/js/oc-backbone-webdav.js | 2 +- core/vendor/davclient.js/lib/client.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/js/oc-backbone-webdav.js b/core/js/oc-backbone-webdav.js index d231a5b1ba0..ba678a32fcf 100644 --- a/core/js/oc-backbone-webdav.js +++ b/core/js/oc-backbone-webdav.js @@ -92,7 +92,7 @@ for (var key in propStat.properties) { var propKey = key; - if (davProperties[key]) { + if (key in davProperties) { propKey = davProperties[key]; } props[propKey] = propStat.properties[key]; diff --git a/core/vendor/davclient.js/lib/client.js b/core/vendor/davclient.js/lib/client.js index dbdfd3823e4..89c11516a38 100644 --- a/core/vendor/davclient.js/lib/client.js +++ b/core/vendor/davclient.js/lib/client.js @@ -243,7 +243,7 @@ dav.Client.prototype = { } } - return content || propNode.textContent || propNode.text; + return content || propNode.textContent || propNode.text || ''; }, /** From 9028457ea2a150a586e63421382379f14cebd648 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 2 Feb 2016 12:06:12 +0100 Subject: [PATCH 10/13] Add spinner when submitting comments --- apps/comments/css/comments.css | 4 ++-- apps/comments/js/commentstabview.js | 35 ++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index b1108467f68..c1624dcc57b 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -17,8 +17,8 @@ resize: none; } -#commentsTabView .newCommentForm .submit { - display: block; +#commentsTabView .newCommentForm .submitLoading { + background-position: left; } #commentsTabView .comment { diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index bc496f2e599..fd6b7b07dcb 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -20,6 +20,7 @@ '
    ' + ' ' + ' ' + + ' '+ '
    ' + '
      ' + '
    ' + @@ -125,7 +126,6 @@ altDate: OC.Util.formatDate(timestamp), formattedMessage: this._formatMessage(commentModel.get('message')) }, commentModel.attributes); - // TODO: format return data; }, @@ -188,9 +188,22 @@ }, _onSubmitComment: function(e) { + var $form = $(e.target); var currentUser = OC.getCurrentUser(); - var $textArea = $(e.target).find('textarea'); + var $submit = $form.find('.submit'); + var $loading = $form.find('.submitLoading'); + var $textArea = $form.find('textarea'); + var message = $textArea.val().trim(); e.preventDefault(); + + if (!message.length) { + return; + } + + $textArea.prop('disabled', true); + $submit.addClass('hidden'); + $loading.removeClass('hidden'); + this.collection.create({ actorId: currentUser.uid, actorDisplayName: currentUser.displayName, @@ -198,10 +211,22 @@ verb: 'comment', message: $textArea.val(), creationDateTime: (new Date()).getTime() - }, {at: 0}); + }, { + at: 0, + success: function() { + $submit.removeClass('hidden'); + $loading.addClass('hidden'); + $textArea.val('').prop('disabled', false); + }, + error: function(msg) { + $submit.removeClass('hidden'); + $loading.addClass('hidden'); + $textArea.prop('disabled', false); + + OC.Notification.showTemporary(msg); + } + }); - // TODO: spinner/disable field? - $textArea.val(''); return false; } }); From 03f4b49eccc381deda4ad17fe7d74817b14b165a Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 2 Feb 2016 15:13:45 +0100 Subject: [PATCH 11/13] Added JS unit tests for comments --- apps/comments/js/commentcollection.js | 10 +- apps/comments/js/commentstabview.js | 2 +- .../tests/js/commentscollectionSpec.js | 104 +++++++++ apps/comments/tests/js/commentstabviewSpec.js | 198 ++++++++++++++++++ tests/karma.config.js | 12 ++ 5 files changed, 320 insertions(+), 6 deletions(-) create mode 100644 apps/comments/tests/js/commentscollectionSpec.js create mode 100644 apps/comments/tests/js/commentstabviewSpec.js diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js index 055752f327c..f39eeb020fa 100644 --- a/apps/comments/js/commentcollection.js +++ b/apps/comments/js/commentcollection.js @@ -13,14 +13,14 @@ var NS_OWNCLOUD = 'http://owncloud.org/ns'; /** - * @class OCA.Comments.CommentsCollection + * @class OCA.Comments.CommentCollection * @classdesc * * Collection of comments assigned to a file * */ - var CommentsCollection = OC.Backbone.Collection.extend( - /** @lends OCA.Comments.CommentsCollection.prototype */ { + var CommentCollection = OC.Backbone.Collection.extend( + /** @lends OCA.Comments.CommentCollection.prototype */ { sync: OC.Backbone.davSync, @@ -82,7 +82,7 @@ options = _.extend({ remove: false, data: body, - davProperties: CommentsCollection.prototype.model.prototype.davProperties, + davProperties: CommentCollection.prototype.model.prototype.davProperties, success: function(resp) { if (resp.length <= self._limit) { // no new entries, end reached @@ -105,6 +105,6 @@ } }); - OCA.Comments.CommentsCollection = CommentsCollection; + OCA.Comments.CommentCollection = CommentCollection; })(OC, OCA); diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index fd6b7b07dcb..463ac2d76ef 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -57,7 +57,7 @@ initialize: function() { OCA.Files.DetailTabView.prototype.initialize.apply(this, arguments); - this.collection = new OCA.Comments.CommentsCollection(); + this.collection = new OCA.Comments.CommentCollection(); this.collection.on('request', this._onRequest, this); this.collection.on('sync', this._onEndRequest, this); this.collection.on('add', this._onAddModel, this); diff --git a/apps/comments/tests/js/commentscollectionSpec.js b/apps/comments/tests/js/commentscollectionSpec.js new file mode 100644 index 00000000000..0dc68cc167c --- /dev/null +++ b/apps/comments/tests/js/commentscollectionSpec.js @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016 + * + * This file is licensed under the Affero General Public License comment 3 + * or later. + * + * See the COPYING-README file. + * + */ +describe('OCA.Comments.CommentCollection', function() { + var CommentCollection = OCA.Comments.CommentCollection; + var collection, syncStub; + var comment1, comment2, comment3; + + beforeEach(function() { + syncStub = sinon.stub(CommentCollection.prototype, 'sync'); + collection = new CommentCollection(); + collection.setObjectId(5); + + comment1 = { + id: 1, + actorType: 'users', + actorId: 'user1', + actorDisplayName: 'User One', + objectType: 'files', + objectId: 5, + message: 'First', + creationDateTime: Date.UTC(2016, 1, 3, 10, 5, 0) + }; + comment2 = { + id: 2, + actorType: 'users', + actorId: 'user2', + actorDisplayName: 'User Two', + objectType: 'files', + objectId: 5, + message: 'Second\nNewline', + creationDateTime: Date.UTC(2016, 1, 3, 10, 0, 0) + }; + comment3 = { + id: 3, + actorType: 'users', + actorId: 'user3', + actorDisplayName: 'User Three', + objectType: 'files', + objectId: 5, + message: 'Third', + creationDateTime: Date.UTC(2016, 1, 3, 5, 0, 0) + }; + }); + afterEach(function() { + syncStub.restore(); + }); + + it('fetches the next page', function() { + collection._limit = 2; + collection.fetchNext(); + + expect(syncStub.calledOnce).toEqual(true); + expect(syncStub.lastCall.args[0]).toEqual('REPORT'); + var options = syncStub.lastCall.args[2]; + expect(options.remove).toEqual(false); + + var parser = new DOMParser(); + var doc = parser.parseFromString(options.data, "application/xml"); + expect(doc.getElementsByTagNameNS('http://owncloud.org/ns', 'limit')[0].textContent).toEqual('3'); + expect(doc.getElementsByTagNameNS('http://owncloud.org/ns', 'offset')[0].textContent).toEqual('0'); + + syncStub.yieldTo('success', [comment1, comment2, comment3]); + + expect(collection.length).toEqual(2); + expect(collection.hasMoreResults()).toEqual(true); + + collection.fetchNext(); + + expect(syncStub.calledTwice).toEqual(true); + options = syncStub.lastCall.args[2]; + doc = parser.parseFromString(options.data, "application/xml"); + expect(doc.getElementsByTagNameNS('http://owncloud.org/ns', 'limit')[0].textContent).toEqual('3'); + expect(doc.getElementsByTagNameNS('http://owncloud.org/ns', 'offset')[0].textContent).toEqual('2'); + + syncStub.yieldTo('success', [comment3]); + + expect(collection.length).toEqual(3); + expect(collection.hasMoreResults()).toEqual(false); + + collection.fetchNext(); + + // no further requests + expect(syncStub.calledTwice).toEqual(true); + }); + it('resets page counted when calling reset', function() { + collection.fetchNext(); + + syncStub.yieldTo('success', [comment1]); + + expect(collection.hasMoreResults()).toEqual(false); + + collection.reset(); + + expect(collection.hasMoreResults()).toEqual(true); + }); +}); + diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js new file mode 100644 index 00000000000..0fb5eec0653 --- /dev/null +++ b/apps/comments/tests/js/commentstabviewSpec.js @@ -0,0 +1,198 @@ +/** +* ownCloud +* +* @author Vincent Petry +* @copyright 2016 Vincent Petry +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* comment 3 of the License, or any later comment. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see . +* +*/ + +describe('OCA.Comments.CommentsTabView tests', function() { + var view, fileInfoModel; + var fetchStub; + var testComments; + var clock; + + beforeEach(function() { + clock = sinon.useFakeTimers(Date.UTC(2016, 1, 3, 10, 5, 9)); + fetchStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'fetchNext'); + view = new OCA.Comments.CommentsTabView(); + fileInfoModel = new OCA.Files.FileInfoModel({ + id: 5, + name: 'One.txt', + mimetype: 'text/plain', + permissions: 31, + path: '/subdir', + size: 123456789, + etag: 'abcdefg', + mtime: Date.UTC(2016, 1, 0, 0, 0, 0) + }); + view.render(); + var comment1 = new OCA.Comments.CommentModel({ + id: 1, + actorType: 'users', + actorId: 'user1', + actorDisplayName: 'User One', + objectType: 'files', + objectId: 5, + message: 'First', + creationDateTime: Date.UTC(2016, 1, 3, 10, 5, 0) + }); + var comment2 = new OCA.Comments.CommentModel({ + id: 2, + actorType: 'users', + actorId: 'user2', + actorDisplayName: 'User Two', + objectType: 'files', + objectId: 5, + message: 'Second\nNewline', + creationDateTime: Date.UTC(2016, 1, 3, 10, 0, 0) + }); + + testComments = [comment1, comment2]; + }); + afterEach(function() { + view.remove(); + view = undefined; + fetchStub.restore(); + clock.restore(); + }); + describe('rendering', function() { + it('reloads matching comments when setting file info model', function() { + view.setFileInfo(fileInfoModel); + expect(fetchStub.calledOnce).toEqual(true); + }); + + it('renders loading icon while fetching comments', function() { + view.setFileInfo(fileInfoModel); + view.collection.trigger('request'); + + expect(view.$el.find('.loading').length).toEqual(1); + expect(view.$el.find('.comments li').length).toEqual(0); + }); + + it('renders comments', function() { + + view.setFileInfo(fileInfoModel); + view.collection.set(testComments); + + var $comments = view.$el.find('.comments>li'); + expect($comments.length).toEqual(2); + var $item = $comments.eq(0); + expect($item.find('.author').text()).toEqual('User One'); + expect($item.find('.date').text()).toEqual('seconds ago'); + expect($item.find('.message').text()).toEqual('First'); + + $item = $comments.eq(1); + expect($item.find('.author').text()).toEqual('User Two'); + expect($item.find('.date').text()).toEqual('5 minutes ago'); + expect($item.find('.message').html()).toEqual('Second
    Newline'); + }); + }); + describe('more comments', function() { + var hasMoreResultsStub; + + beforeEach(function() { + view.collection.set(testComments); + hasMoreResultsStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'hasMoreResults'); + }); + afterEach(function() { + hasMoreResultsStub.restore(); + }); + + it('shows "More comments" button when more comments are available', function() { + hasMoreResultsStub.returns(true); + view.collection.trigger('sync'); + + expect(view.$el.find('.showMore').hasClass('hidden')).toEqual(false); + }); + it('does not show "More comments" button when more comments are available', function() { + hasMoreResultsStub.returns(false); + view.collection.trigger('sync'); + + expect(view.$el.find('.showMore').hasClass('hidden')).toEqual(true); + }); + it('fetches and appends the next page when clicking the "More" button', function() { + hasMoreResultsStub.returns(true); + + expect(fetchStub.notCalled).toEqual(true); + + view.$el.find('.showMore').click(); + + expect(fetchStub.calledOnce).toEqual(true); + }); + it('appends comment to the list when added to collection', function() { + var comment3 = new OCA.Comments.CommentModel({ + id: 3, + actorType: 'users', + actorId: 'user3', + actorDisplayName: 'User Three', + objectType: 'files', + objectId: 5, + message: 'Third', + creationDateTime: Date.UTC(2016, 1, 3, 5, 0, 0) + }); + + view.collection.add(comment3); + + expect(view.$el.find('.comments>li').length).toEqual(3); + + var $item = view.$el.find('.comments>li').eq(2); + expect($item.find('.author').text()).toEqual('User Three'); + expect($item.find('.date').text()).toEqual('5 hours ago'); + expect($item.find('.message').html()).toEqual('Third'); + }); + }); + describe('posting comments', function() { + var createStub; + var currentUserStub; + + beforeEach(function() { + view.collection.set(testComments); + createStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'create'); + currentUserStub = sinon.stub(OC, 'getCurrentUser'); + currentUserStub.returns({ + uid: 'testuser', + displayName: 'Test User' + }); + }); + afterEach(function() { + createStub.restore(); + currentUserStub.restore(); + }); + + it('creates a new comment when clicking post button', function() { + view.$el.find('.message').val('New message'); + view.$el.find('form').submit(); + + expect(createStub.calledOnce).toEqual(true); + expect(createStub.lastCall.args[0]).toEqual({ + actorId: 'testuser', + actorDisplayName: 'Test User', + actorType: 'users', + verb: 'comment', + message: 'New message', + creationDateTime: Date.UTC(2016, 1, 3, 10, 5, 9) + }); + }); + it('does not create a comment if the field is empty', function() { + view.$el.find('.message').val(' '); + view.$el.find('form').submit(); + + expect(createStub.notCalled).toEqual(true); + }); + + }); +}); diff --git a/tests/karma.config.js b/tests/karma.config.js index 467b270b350..4a7a9ad236e 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -82,6 +82,18 @@ module.exports = function(config) { ], testFiles: ['apps/files_versions/tests/js/**/*.js'] }, + { + name: 'comments', + srcFiles: [ + // need to enforce loading order... + 'apps/comments/js/app.js', + 'apps/comments/js/commentmodel.js', + 'apps/comments/js/commentcollection.js', + 'apps/comments/js/commentstabview.js', + 'apps/comments/js/filesplugin' + ], + testFiles: ['apps/comments/tests/js/**/*.js'] + }, { name: 'systemtags', srcFiles: [ From 8b98cf5a5b10694f2b86c1d1533ac50b4f8e5708 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 2 Feb 2016 18:06:16 +0100 Subject: [PATCH 12/13] Fixed report name --- apps/comments/js/commentcollection.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js index f39eeb020fa..d10e5e00865 100644 --- a/apps/comments/js/commentcollection.js +++ b/apps/comments/js/commentcollection.js @@ -71,11 +71,11 @@ } var body = '\n' + - '\n' + + '\n' + // load one more so we know there is more ' ' + (this._limit + 1) + '\n' + ' ' + this.length + '\n' + - '\n'; + '\n'; options = options || {}; var success = options.success; From 5e08f1df78652e7a16de00041d376f55a4d2009e Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 2 Feb 2016 18:14:58 +0100 Subject: [PATCH 13/13] Add comments app to expected apps in test --- build/integration/features/provisioning-v1.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature index 4d4d5361647..3b8633b872a 100644 --- a/build/integration/features/provisioning-v1.feature +++ b/build/integration/features/provisioning-v1.feature @@ -282,8 +282,9 @@ Feature: provisioning Then the OCS status code should be "100" And the HTTP status code should be "200" And apps returned are - | files | + | comments | | dav | + | files | | files_sharing | | files_trashbin | | files_versions |