diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index c1624dcc57b9b118c2e9a2031b16ca0920387840..5e247aaeb7151b9d67f796f68f6230c24d14de5b 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -49,3 +49,7 @@ position: absolute; right: 0; } + +.app-files .action-comment>img { + margin-right: 5px; +} diff --git a/apps/comments/js/filesplugin.js b/apps/comments/js/filesplugin.js index c8d91e0ede33e2338ae15f40fac868b673f47907..bf6bb05146bf4d12023f5e392af4b61311bcfd74 100644 Binary files a/apps/comments/js/filesplugin.js and b/apps/comments/js/filesplugin.js differ diff --git a/apps/comments/tests/js/filespluginSpec.js b/apps/comments/tests/js/filespluginSpec.js new file mode 100644 index 0000000000000000000000000000000000000000..78becc5af09f823da249d05ef29739dbe3e08853 --- /dev/null +++ b/apps/comments/tests/js/filespluginSpec.js @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2016 Vincent Petry <pvince81@owncloud.com> + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +describe('OCA.Comments.FilesPlugin tests', function() { + var fileList; + var testFiles; + + beforeEach(function() { + var $content = $('<div id="content"></div>'); + $('#testArea').append($content); + // dummy file list + var $div = $( + '<div>' + + '<table id="filestable">' + + '<thead></thead>' + + '<tbody id="fileList"></tbody>' + + '</table>' + + '</div>'); + $('#content').append($div); + + fileList = new OCA.Files.FileList($div); + OCA.Comments.FilesPlugin.attach(fileList); + + testFiles = [{ + id: 1, + type: 'file', + name: 'One.txt', + path: '/subdir', + mimetype: 'text/plain', + size: 12, + permissions: OC.PERMISSION_ALL, + etag: 'abc', + shareOwner: 'User One', + isShareMountPoint: false, + commentsUnread: 3 + }]; + }); + afterEach(function() { + fileList.destroy(); + fileList = null; + }); + + describe('Comment icon', function() { + it('does not render icon when no unread comments available', function() { + testFiles[0].commentsUnread = 0; + fileList.setFiles(testFiles); + var $tr = fileList.findFileEl('One.txt'); + expect($tr.find('.action-comment').length).toEqual(0); + }); + it('renders comment icon and extra data', function() { + var $action, $tr; + fileList.setFiles(testFiles); + $tr = fileList.findFileEl('One.txt'); + $action = $tr.find('.action-comment'); + expect($action.length).toEqual(1); + expect($action.hasClass('permanent')).toEqual(true); + + expect($tr.attr('data-comments-unread')).toEqual('3'); + }); + it('clicking icon opens sidebar', function() { + var sidebarStub = sinon.stub(fileList, 'showDetailsView'); + var $action, $tr; + fileList.setFiles(testFiles); + $tr = fileList.findFileEl('One.txt'); + $action = $tr.find('.action-comment'); + $action.click(); + + expect(sidebarStub.calledOnce).toEqual(true); + expect(sidebarStub.lastCall.args[0]).toEqual('One.txt'); + expect(sidebarStub.lastCall.args[1]).toEqual('commentsTabView'); + }); + }); + describe('elementToFile', function() { + it('returns comment count', function() { + fileList.setFiles(testFiles); + var $tr = fileList.findFileEl('One.txt'); + var data = fileList.elementToFile($tr); + expect(data.commentsUnread).toEqual(3); + }); + it('does not set comment count when not set', function() { + delete testFiles[0].commentsUnread; + fileList.setFiles(testFiles); + var $tr = fileList.findFileEl('One.txt'); + var data = fileList.elementToFile($tr); + expect(data.commentsUnread).not.toBeDefined(); + }); + it('does not set comment count when zero', function() { + testFiles[0].commentsUnread = 0; + fileList.setFiles(testFiles); + var $tr = fileList.findFileEl('One.txt'); + var data = fileList.elementToFile($tr); + expect(data.commentsUnread).not.toBeDefined(); + }); + }); +}); diff --git a/core/img/actions/comment.png b/core/img/actions/comment.png new file mode 100644 index 0000000000000000000000000000000000000000..7ca20eba363b77d280b976c690ce778e9c4d2fbe Binary files /dev/null and b/core/img/actions/comment.png differ diff --git a/core/img/actions/comment.svg b/core/img/actions/comment.svg new file mode 100644 index 0000000000000000000000000000000000000000..a8ab95e615b59615254b11957f3979eb1fee1833 --- /dev/null +++ b/core/img/actions/comment.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> + <path style="color:#000000;block-progression:tb;text-transform:none;text-indent:0" d="m2.3496 1.002c-0.1975 0.0382-0.3531 0.2333-0.3496 0.4375v13.122c0 0.23 0.2061 0.438 0.4316 0.438h11.138c0.226 0 0.432-0.208 0.432-0.438v-10.142c-0.004-0.0669-0.023-0.133-0.055-0.1915l-3.312-3.1992c-0.043-0.0164-0.089-0.0255-0.135-0.0273h-8.0684c-0.0268-0.00265-0.0552-0.00265-0.082 0zm1.6504 1.998h6v1h-6v-1zm0 3h5v1h-5v-1zm0 3h8v1h-8v-1zm0 3h4v1h-4v-1z"/> +</svg> diff --git a/tests/karma.config.js b/tests/karma.config.js index 4a7a9ad236e664cefe34466598225caae354f329..fddcfb319ebcb432b189f176fd28ccfe2eeaccfc 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -90,7 +90,7 @@ module.exports = function(config) { 'apps/comments/js/commentmodel.js', 'apps/comments/js/commentcollection.js', 'apps/comments/js/commentstabview.js', - 'apps/comments/js/filesplugin' + 'apps/comments/js/filesplugin.js' ], testFiles: ['apps/comments/tests/js/**/*.js'] },