aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/appinfo/app.php9
-rw-r--r--apps/files_sharing/js/app.js31
-rw-r--r--apps/files_sharing/js/sharedfilelist.js17
-rw-r--r--apps/files_sharing/tests/js/sharedfilelistSpec.js91
4 files changed, 146 insertions, 2 deletions
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 81f91b60d30..d44c652dd98 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -44,3 +44,12 @@ OC_FileProxy::register(new OCA\Files\Share\Proxy());
"name" => $l->t('Shared with others')
)
);
+\OCA\Files\App::getNavigationManager()->add(
+ array(
+ "id" => 'sharinglinks',
+ "appname" => 'files_sharing',
+ "script" => 'list.php',
+ "order" => 20,
+ "name" => $l->t('Shared by link')
+ )
+);
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js
index 800873cd638..1fc13d00382 100644
--- a/apps/files_sharing/js/app.js
+++ b/apps/files_sharing/js/app.js
@@ -55,6 +55,25 @@ OCA.Sharing.App = {
return this._outFileList;
},
+ initSharingLinks: function($el) {
+ if (this._linkFileList) {
+ return this._linkFileList;
+ }
+ this._linkFileList = new OCA.Sharing.FileList(
+ $el,
+ {
+ scrollContainer: $('#app-content'),
+ linksOnly: true,
+ fileActions: this._createFileActions()
+ }
+ );
+
+ this._extendFileList(this._linkFileList);
+ this._linkFileList.appName = t('files_sharing', 'Shared by link');
+ this._linkFileList.$el.find('#emptycontent').text(t('files_sharing', 'You haven\'t shared any files by link yet.'));
+ return this._linkFileList;
+ },
+
removeSharingIn: function() {
if (this._inFileList) {
this._inFileList.$fileList.empty();
@@ -67,6 +86,12 @@ OCA.Sharing.App = {
}
},
+ removeSharingLinks: function() {
+ if (this._linkFileList) {
+ this._linkFileList.$fileList.empty();
+ }
+ },
+
_createFileActions: function() {
// inherit file actions from the files app
var fileActions = new OCA.Files.FileActions();
@@ -104,5 +129,11 @@ $(document).ready(function() {
$('#app-content-sharingout').on('hide', function() {
OCA.Sharing.App.removeSharingOut();
});
+ $('#app-content-sharinglinks').on('show', function(e) {
+ OCA.Sharing.App.initSharingLinks($(e.target));
+ });
+ $('#app-content-sharinglinks').on('hide', function() {
+ OCA.Sharing.App.removeSharingLinks();
+ });
});
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index 97fabf87131..304f77a8d77 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -26,6 +26,7 @@
* the files that the user shared with others (false).
*/
_sharedWithUser: false,
+ _linksOnly: false,
initialize: function($el, options) {
OCA.Files.FileList.prototype.initialize.apply(this, arguments);
@@ -33,9 +34,13 @@
return;
}
+ // TODO: consolidate both options
if (options && options.sharedWithUser) {
this._sharedWithUser = true;
}
+ if (options && options.linksOnly) {
+ this._linksOnly = true;
+ }
},
_renderRow: function() {
@@ -137,12 +142,20 @@
* @return array of file info maps
*/
_makeFilesFromShares: function(data) {
+ /* jshint camelcase: false */
var self = this;
+ var files = data;
+
+ if (this._linksOnly) {
+ files = _.filter(data, function(share) {
+ return share.share_type === OC.Share.SHARE_TYPE_LINK;
+ });
+ }
+
// OCS API uses non-camelcased names
- var files = _.chain(data)
+ files = _.chain(files)
// convert share data to file data
.map(function(share) {
- /* jshint camelcase: false */
var file = {
id: share.file_source,
mimetype: share.mimetype
diff --git a/apps/files_sharing/tests/js/sharedfilelistSpec.js b/apps/files_sharing/tests/js/sharedfilelistSpec.js
index f53e79e277f..0f6d0a0ba49 100644
--- a/apps/files_sharing/tests/js/sharedfilelistSpec.js
+++ b/apps/files_sharing/tests/js/sharedfilelistSpec.js
@@ -417,4 +417,95 @@ describe('OCA.Sharing.FileList tests', function() {
expect($tr.find('.nametext').text().trim()).toEqual('local name.txt');
});
});
+ describe('loading file list for link shares', function() {
+ var ocsResponse;
+
+ beforeEach(function() {
+ fileList = new OCA.Sharing.FileList(
+ $('#app-content-container'), {
+ linksOnly: true
+ }
+ );
+
+ fileList.reload();
+
+ ocsResponse = {
+ ocs: {
+ meta: {
+ status: 'ok',
+ statuscode: 100,
+ message: null
+ },
+ data: [{
+ id: 7,
+ item_type: 'file',
+ item_source: 49,
+ file_source: 49,
+ path: '/local path/local name.txt',
+ permissions: 1,
+ stime: 11111,
+ share_type: OC.Share.SHARE_TYPE_LINK,
+ share_with: null,
+ token: 'abc',
+ mimetype: 'text/plain',
+ uid_owner: 'user1',
+ displayname_owner: 'User One'
+ }]
+ }
+ };
+ });
+ it('render only link shares', function() {
+ /* jshint camelcase: false */
+ var request;
+ ocsResponse.ocs.data.push({
+ // non-link share
+ id: 8,
+ item_type: 'file',
+ item_source: 49,
+ file_source: 49,
+ path: '/local path/local name.txt',
+ permissions: 27,
+ stime: 11111,
+ share_type: OC.Share.SHARE_TYPE_USER,
+ share_with: 'user2',
+ share_with_displayname: 'User Two',
+ mimetype: 'text/plain',
+ uid_owner: 'user1',
+ displayname_owner: 'User One'
+ });
+ expect(fakeServer.requests.length).toEqual(1);
+ request = fakeServer.requests[0];
+ expect(request.url).toEqual(
+ OC.linkToOCS('apps/files_sharing/api/v1') +
+ 'shares?format=json&shared_with_me=false'
+ );
+
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify(ocsResponse)
+ );
+
+ // only renders the link share entry
+ var $rows = fileList.$el.find('tbody tr');
+ var $tr = $rows.eq(0);
+ expect($rows.length).toEqual(1);
+ expect($tr.attr('data-id')).toEqual('49');
+ expect($tr.attr('data-type')).toEqual('file');
+ expect($tr.attr('data-file')).toEqual('local name.txt');
+ expect($tr.attr('data-path')).toEqual('/local path');
+ expect($tr.attr('data-size')).not.toBeDefined();
+ expect($tr.attr('data-permissions')).toEqual('31'); // read and delete
+ expect($tr.attr('data-mime')).toEqual('text/plain');
+ expect($tr.attr('data-mtime')).toEqual('11111000');
+ expect($tr.attr('data-share-owner')).not.toBeDefined();
+ expect($tr.attr('data-share-id')).toEqual('7');
+ expect($tr.find('a.name').attr('href')).toEqual(
+ OC.webroot +
+ '/index.php/apps/files/ajax/download.php' +
+ '?dir=%2Flocal%20path&files=local%20name.txt');
+
+ expect($tr.find('.nametext').text().trim()).toEqual('local name.txt');
+ });
+ });
});