From f330813ff01e321a9e39822b183c49805bff16a5 Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Wed, 22 Mar 2023 11:45:59 +0100 Subject: feat(files): custom columns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files_trashbin/src/css/trashbin.css | 2 ++ apps/files_trashbin/src/main.ts | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 apps/files_trashbin/src/css/trashbin.css (limited to 'apps/files_trashbin') diff --git a/apps/files_trashbin/src/css/trashbin.css b/apps/files_trashbin/src/css/trashbin.css new file mode 100644 index 00000000000..dd6cd8af591 --- /dev/null +++ b/apps/files_trashbin/src/css/trashbin.css @@ -0,0 +1,2 @@ +.files-list__row-trashbin-deleted { +} \ No newline at end of file diff --git a/apps/files_trashbin/src/main.ts b/apps/files_trashbin/src/main.ts index 626b9ef813d..d9cd2841b23 100644 --- a/apps/files_trashbin/src/main.ts +++ b/apps/files_trashbin/src/main.ts @@ -21,8 +21,9 @@ */ import type NavigationService from '../../files/src/services/Navigation' -import { translate as t } from '@nextcloud/l10n' +import { translate as t, translate } from '@nextcloud/l10n' import DeleteSvg from '@mdi/svg/svg/delete.svg?raw' +import moment from '@nextcloud/moment' import getContents from './services/trashbin' @@ -35,5 +36,25 @@ Navigation.register({ order: 50, sticky: true, + columns: [ + { + id: 'deleted', + title: t('files_trashbin', 'Deleted'), + render(mount, node) { + const deletionTime = node.attributes?.['trashbin-deletion-time'] + if (deletionTime) { + mount.innerText = moment.unix(deletionTime).fromNow() + return + } + mount.innerText = translate('files_trashbin', 'Deleted a long time ago') + }, + sort(nodeA, nodeB) { + const deletionTimeA = nodeA.attributes?.['trashbin-deletion-time'] || nodeA?.mtime || 0 + const deletionTimeB = nodeB.attributes?.['trashbin-deletion-time'] || nodeB?.mtime || 0 + return deletionTimeA - deletionTimeB + }, + }, + ], + getContents, }) -- cgit v1.2.3