allow trash backends to overwrite the tooltip for trash items

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2019-10-02 16:36:53 +02:00 committed by John Molakvoæ (skjnldsv)
parent 2169c26195
commit ce433637da
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
8 changed files with 43 additions and 24 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -79,6 +79,10 @@ abstract class AbstractTrash implements ITrash {
return $this->data->getOriginalLocation();
}
public function getTitle(): string {
return $this->data->getTitle();
}
public function delete() {
$this->trashManager->removeItem($this->data);
}

View File

@ -32,6 +32,8 @@ interface ITrash {
public function getOriginalLocation(): string;
public function getTitle(): string;
public function getDeletionTime(): int;
public function getSize();

View File

@ -37,6 +37,7 @@ class PropfindPlugin extends ServerPlugin {
const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename';
const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location';
const TRASHBIN_DELETION_TIME = '{http://nextcloud.org/ns}trashbin-deletion-time';
const TRASHBIN_TITLE = '{http://nextcloud.org/ns}trashbin-title';
/** @var Server */
private $server;
@ -70,6 +71,10 @@ class PropfindPlugin extends ServerPlugin {
return $node->getOriginalLocation();
});
$propFind->handle(self::TRASHBIN_TITLE, function () use ($node) {
return $node->getTitle();
});
$propFind->handle(self::TRASHBIN_DELETION_TIME, function () use ($node) {
return $node->getDeletionTime();
});

View File

@ -75,4 +75,6 @@ interface ITrashItem extends FileInfo {
* @since 15.0.0
*/
public function getUser(): IUser;
public function getTitle(): string;
}

View File

@ -173,4 +173,8 @@ class TrashItem implements ITrashItem {
public function getExtension(): string {
return $this->fileInfo->getExtension();
}
public function getTitle(): string {
return $this->getOriginalLocation();
}
}

View File

@ -13,6 +13,7 @@
var FILENAME_PROP = '{http://nextcloud.org/ns}trashbin-filename'
var DELETION_TIME_PROP = '{http://nextcloud.org/ns}trashbin-deletion-time'
var TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location'
var TRASHBIN_TITLE = '{http://nextcloud.org/ns}trashbin-title'
/**
* Convert a file name in the format filename.d12345 to the real file name.
@ -45,32 +46,33 @@
}
FileList.prototype = _.extend({}, OCA.Files.FileList.prototype,
/** @lends OCA.Trashbin.FileList.prototype */ {
id: 'trashbin',
appName: t('files_trashbin', 'Deleted files'),
/** @type {OC.Files.Client} */
client: null,
id: 'trashbin',
appName: t('files_trashbin', 'Deleted files'),
/** @type {OC.Files.Client} */
client: null,
/**
/**
* @private
*/
initialize: function() {
this.client.addFileInfoParser(function(response, data) {
var props = response.propStat[0].properties
var path = props[TRASHBIN_ORIGINAL_LOCATION]
return {
displayName: props[FILENAME_PROP],
mtime: parseInt(props[DELETION_TIME_PROP], 10) * 1000,
hasPreview: true,
path: path,
extraData: path
}
})
initialize: function() {
this.client.addFileInfoParser(function(response, data) {
var props = response.propStat[0].properties
var path = props[TRASHBIN_ORIGINAL_LOCATION]
var title = props[TRASHBIN_TITLE]
return {
displayName: props[FILENAME_PROP],
mtime: parseInt(props[DELETION_TIME_PROP], 10) * 1000,
hasPreview: true,
path: path,
extraData: title
}
})
var result = OCA.Files.FileList.prototype.initialize.apply(this, arguments)
this.$el.find('.undelete').click('click', _.bind(this._onClickRestoreSelected, this))
var result = OCA.Files.FileList.prototype.initialize.apply(this, arguments)
this.$el.find('.undelete').click('click', _.bind(this._onClickRestoreSelected, this))
this.setSort('mtime', 'desc')
/**
this.setSort('mtime', 'desc')
/**
* Override crumb making to add "Deleted Files" entry
* and convert files with ".d" extensions to a more
* user friendly name.
@ -252,7 +254,7 @@
* Returns list of webdav properties to request
*/
_getWebdavProperties: function() {
return [FILENAME_PROP, DELETION_TIME_PROP, TRASHBIN_ORIGINAL_LOCATION].concat(this.filesClient.getPropfindProperties())
return [FILENAME_PROP, DELETION_TIME_PROP, TRASHBIN_ORIGINAL_LOCATION, TRASHBIN_TITLE].concat(this.filesClient.getPropfindProperties())
},
/**