diff options
author | Christopher Ng <chrng8@gmail.com> | 2024-03-27 15:08:08 -0700 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2024-03-28 11:00:22 -0700 |
commit | 1ae78095c87abb6d7ac8040d4e686f61414be18e (patch) | |
tree | 58851f01c8b6625cab6bb7088b48ad116c2a3e56 | |
parent | e317ebdbad52467d8a23841cf35bf555af516ebd (diff) | |
download | nextcloud-server-1ae78095c87abb6d7ac8040d4e686f61414be18e.tar.gz nextcloud-server-1ae78095c87abb6d7ac8040d4e686f61414be18e.zip |
feat(trashbin): Show original location of deleted file
Signed-off-by: Christopher Ng <chrng8@gmail.com>
-rw-r--r-- | apps/files_trashbin/src/main.ts | 39 | ||||
-rw-r--r-- | apps/files_trashbin/src/trashbin.scss | 3 |
2 files changed, 39 insertions, 3 deletions
diff --git a/apps/files_trashbin/src/main.ts b/apps/files_trashbin/src/main.ts index 5c625e7bf4f..d7a8ff48c18 100644 --- a/apps/files_trashbin/src/main.ts +++ b/apps/files_trashbin/src/main.ts @@ -19,7 +19,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { translate as t, translate } from '@nextcloud/l10n' + +import './trashbin.scss' + +import { translate as t } from '@nextcloud/l10n' import DeleteSvg from '@mdi/svg/svg/delete.svg?raw' import moment from '@nextcloud/moment' @@ -27,7 +30,20 @@ import { getContents } from './services/trashbin' // Register restore action import './actions/restoreAction' -import { Column, View, getNavigation } from '@nextcloud/files' +import { Column, Node, View, getNavigation } from '@nextcloud/files' +import { dirname, joinPaths } from '@nextcloud/paths' + +const parseOriginalLocation = (node: Node): string => { + const path = node.attributes?.['trashbin-original-location'] !== undefined ? String(node.attributes?.['trashbin-original-location']) : null + if (!path) { + return t('files_trashbin', 'Unknown') + } + const dir = dirname(path) + if (dir === path) { // Node is in root folder + return t('files_trashbin', 'All files') + } + return joinPaths(t('files_trashbin', 'All files'), dir) +} const Navigation = getNavigation() Navigation.register(new View({ @@ -46,6 +62,23 @@ Navigation.register(new View({ columns: [ new Column({ + id: 'original-location', + title: t('files_trashbin', 'Original location'), + render(node) { + const originalLocation = parseOriginalLocation(node) + const span = document.createElement('span') + span.title = originalLocation + span.textContent = originalLocation + return span + }, + sort(nodeA, nodeB) { + const locationA = parseOriginalLocation(nodeA) + const locationB = parseOriginalLocation(nodeB) + return locationA.localeCompare(locationB) + }, + }), + + new Column({ id: 'deleted', title: t('files_trashbin', 'Deleted'), render(node) { @@ -58,7 +91,7 @@ Navigation.register(new View({ } // Unknown deletion time - span.textContent = translate('files_trashbin', 'A long time ago') + span.textContent = t('files_trashbin', 'A long time ago') return span }, sort(nodeA, nodeB) { diff --git a/apps/files_trashbin/src/trashbin.scss b/apps/files_trashbin/src/trashbin.scss new file mode 100644 index 00000000000..4fa54c419c4 --- /dev/null +++ b/apps/files_trashbin/src/trashbin.scss @@ -0,0 +1,3 @@ +.files-list__row-trashbin-original-location { + width: 150px !important; +} |