summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-07-07 19:29:43 +0200
committerGitHub <noreply@github.com>2016-07-07 19:29:43 +0200
commit2a1a3957b65e847d51c4c735acf033f7df29cba6 (patch)
treee53ac77b3dfa0d425b9ea8084420988a4d7054b7 /apps/files_sharing
parentf5ed01617045a816977688a6c9e549fdf2dab509 (diff)
parentbeae00a5e5457c41994e54c7f0563245d9ccf5ce (diff)
downloadnextcloud-server-2a1a3957b65e847d51c4c735acf033f7df29cba6.tar.gz
nextcloud-server-2a1a3957b65e847d51c4c735acf033f7df29cba6.zip
Merge pull request #333 from nextcloud/sync-master
Sync master
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/js/sharedfilelist.js42
-rw-r--r--apps/files_sharing/templates/list.php3
-rw-r--r--apps/files_sharing/tests/MountProviderTest.php3
-rw-r--r--apps/files_sharing/tests/js/sharedfilelistSpec.js37
4 files changed, 82 insertions, 3 deletions
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index da0f957ed99..dccd6027b02 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -79,6 +79,42 @@
var permission = parseInt($tr.attr('data-permissions')) | OC.PERMISSION_DELETE;
$tr.attr('data-permissions', permission);
}
+
+ // add row with expiration date for link only shares - influenced by _createRow of filelist
+ if (this._linksOnly) {
+ var expirationTimestamp = 0;
+ if(fileData.shares[0].expiration !== null) {
+ expirationTimestamp = moment(fileData.shares[0].expiration).valueOf();
+ }
+ $tr.attr('data-expiration', expirationTimestamp);
+
+ // date column (1000 milliseconds to seconds, 60 seconds, 60 minutes, 24 hours)
+ // difference in days multiplied by 5 - brightest shade for expiry dates in more than 32 days (160/5)
+ var modifiedColor = Math.round((expirationTimestamp - (new Date()).getTime()) / 1000 / 60 / 60 / 24 * 5);
+ // ensure that the brightest color is still readable
+ if (modifiedColor >= 160) {
+ modifiedColor = 160;
+ }
+
+ if (expirationTimestamp > 0) {
+ formatted = OC.Util.formatDate(expirationTimestamp);
+ text = OC.Util.relativeModifiedDate(expirationTimestamp);
+ } else {
+ formatted = t('files_sharing', 'No expiration date set');
+ text = '';
+ modifiedColor = 160;
+ }
+ td = $('<td></td>').attr({"class": "date"});
+ td.append($('<span></span>').attr({
+ "class": "modified",
+ "title": formatted,
+ "style": 'color:rgb(' + modifiedColor + ',' + modifiedColor + ',' + modifiedColor + ')'
+ }).text(text)
+ .tooltip({placement: 'top'})
+ );
+
+ $tr.append(td);
+ }
return $tr;
},
@@ -98,6 +134,11 @@
// root has special permissions
this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty);
this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty);
+
+ // hide expiration date header for non link only shares
+ if (!this._linksOnly) {
+ this.$el.find('th.column-expiration').addClass('hidden');
+ }
}
else {
OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments);
@@ -249,6 +290,7 @@
type: share.share_type,
target: share.share_with,
stime: share.stime * 1000,
+ expiration: share.expiration,
};
if (self._sharedWithUser) {
file.shareOwner = share.displayname_owner;
diff --git a/apps/files_sharing/templates/list.php b/apps/files_sharing/templates/list.php
index fa0365c749c..f59cb7653d8 100644
--- a/apps/files_sharing/templates/list.php
+++ b/apps/files_sharing/templates/list.php
@@ -22,6 +22,9 @@
<th id="headerDate" class="hidden column-mtime">
<a id="modified" class="columntitle" data-sort="mtime"><span><?php p($l->t( 'Share time' )); ?></span><span class="sort-indicator"></span></a>
</th>
+ <th class="hidden column-expiration">
+ <a class="columntitle"><span><?php p($l->t( 'Expiration date' )); ?></span></a>
+ </th>
</tr>
</thead>
<tbody id="fileList">
diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php
index f69098cde7b..90d9f0a8567 100644
--- a/apps/files_sharing/tests/MountProviderTest.php
+++ b/apps/files_sharing/tests/MountProviderTest.php
@@ -30,6 +30,9 @@ use OCP\Share\IShare;
use OCP\Share\IManager;
use OCP\Files\Mount\IMountPoint;
+/**
+ * @group DB
+ */
class MountProviderTest extends \Test\TestCase {
/** @var MountProvider */
diff --git a/apps/files_sharing/tests/js/sharedfilelistSpec.js b/apps/files_sharing/tests/js/sharedfilelistSpec.js
index 0b0676a19e6..f177b61c78a 100644
--- a/apps/files_sharing/tests/js/sharedfilelistSpec.js
+++ b/apps/files_sharing/tests/js/sharedfilelistSpec.js
@@ -38,6 +38,9 @@ describe('OCA.Sharing.FileList tests', function() {
'<th class="hidden column-mtime">' +
'<a class="columntitle" data-sort="mtime"><span class="sort-indicator"></span></a>' +
'</th>' +
+ '<th class="column-expiration">' +
+ '<a class="columntitle"><span>Expiration date</span></a>' +
+ '</th>' +
'</tr></thead>' +
'<tbody id="fileList"></tbody>' +
'<tfoot></tfoot>' +
@@ -512,6 +515,9 @@ describe('OCA.Sharing.FileList tests', function() {
fileList.reload();
+ var expirationDateInADay = moment()
+ .add(1, 'days').format('YYYY-MM-DD HH:mm:ss');
+
/* jshint camelcase: false */
ocsResponse = {
ocs: {
@@ -528,12 +534,28 @@ describe('OCA.Sharing.FileList tests', function() {
path: '/local path/local name.txt',
permissions: 1,
stime: 11111,
+ expiration: null,
share_type: OC.Share.SHARE_TYPE_LINK,
share_with: null,
token: 'abc',
mimetype: 'text/plain',
uid_owner: 'user1',
displayname_owner: 'User One'
+ },{
+ id: 8,
+ item_type: 'file',
+ item_source: 50,
+ file_source: 50,
+ path: '/local path2/local name2.txt',
+ permissions: 1,
+ stime: 11112,
+ expiration: expirationDateInADay,
+ share_type: OC.Share.SHARE_TYPE_LINK,
+ share_with: null,
+ token: 'abcd',
+ mimetype: 'text/plain2',
+ uid_owner: 'user2',
+ displayname_owner: 'User One2'
}]
}
};
@@ -570,10 +592,10 @@ describe('OCA.Sharing.FileList tests', function() {
JSON.stringify(ocsResponse)
);
- // only renders the link share entry
+ // only renders the link share entries
var $rows = fileList.$el.find('tbody tr');
var $tr = $rows.eq(0);
- expect($rows.length).toEqual(1);
+ expect($rows.length).toEqual(2);
expect($tr.attr('data-id')).toEqual('49');
expect($tr.attr('data-type')).toEqual('file');
expect($tr.attr('data-file')).toEqual('local name.txt');
@@ -588,8 +610,17 @@ describe('OCA.Sharing.FileList tests', function() {
expect($tr.find('a.name').attr('href')).toEqual(
OC.webroot + '/remote.php/webdav/local%20path/local%20name.txt'
);
+ expect($tr.attr('data-expiration')).toEqual('0');
+ expect($tr.find('td:last-child span').text()).toEqual('');
expect($tr.find('.nametext').text().trim()).toEqual('local name.txt');
+
+ // change to next row
+ $tr = $rows.eq(1);
+ expect($tr.attr('data-id')).toEqual('50');
+ expect($tr.attr('data-file')).toEqual('local name2.txt');
+ expect($tr.attr('data-expiration')).not.toEqual('0');
+ expect($tr.find('td:last-child span').text()).toEqual('in a day');
});
it('does not show virtual token recipient as recipient when password was set', function() {
/* jshint camelcase: false */
@@ -613,7 +644,7 @@ describe('OCA.Sharing.FileList tests', function() {
// only renders the link share entry
var $rows = fileList.$el.find('tbody tr');
var $tr = $rows.eq(0);
- expect($rows.length).toEqual(1);
+ expect($rows.length).toEqual(2);
expect($tr.attr('data-id')).toEqual('49');
expect($tr.attr('data-type')).toEqual('file');
expect($tr.attr('data-file')).toEqual('local name.txt');