Skip to content

Commit 50309fe

Browse files
authored
Merge pull request #44512 from nextcloud/feat/trashbin-orig-location
feat(trashbin): Show original location of deleted file
2 parents a40838b + 74aad97 commit 50309fe

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

apps/files_trashbin/src/main.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,31 @@
1919
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*
2121
*/
22-
import { translate as t, translate } from '@nextcloud/l10n'
22+
23+
import './trashbin.scss'
24+
25+
import { translate as t } from '@nextcloud/l10n'
2326
import DeleteSvg from '@mdi/svg/svg/delete.svg?raw'
2427
import moment from '@nextcloud/moment'
2528

2629
import { getContents } from './services/trashbin'
2730

2831
// Register restore action
2932
import './actions/restoreAction'
30-
import { Column, View, getNavigation } from '@nextcloud/files'
33+
import { Column, Node, View, getNavigation } from '@nextcloud/files'
34+
import { dirname, joinPaths } from '@nextcloud/paths'
35+
36+
const parseOriginalLocation = (node: Node): string => {
37+
const path = node.attributes?.['trashbin-original-location'] !== undefined ? String(node.attributes?.['trashbin-original-location']) : null
38+
if (!path) {
39+
return t('files_trashbin', 'Unknown')
40+
}
41+
const dir = dirname(path)
42+
if (dir === path) { // Node is in root folder
43+
return t('files_trashbin', 'All files')
44+
}
45+
return joinPaths(t('files_trashbin', 'All files'), dir)
46+
}
3147

3248
const Navigation = getNavigation()
3349
Navigation.register(new View({
@@ -45,6 +61,23 @@ Navigation.register(new View({
4561
defaultSortKey: 'deleted',
4662

4763
columns: [
64+
new Column({
65+
id: 'original-location',
66+
title: t('files_trashbin', 'Original location'),
67+
render(node) {
68+
const originalLocation = parseOriginalLocation(node)
69+
const span = document.createElement('span')
70+
span.title = originalLocation
71+
span.textContent = originalLocation
72+
return span
73+
},
74+
sort(nodeA, nodeB) {
75+
const locationA = parseOriginalLocation(nodeA)
76+
const locationB = parseOriginalLocation(nodeB)
77+
return locationA.localeCompare(locationB)
78+
},
79+
}),
80+
4881
new Column({
4982
id: 'deleted',
5083
title: t('files_trashbin', 'Deleted'),
@@ -58,7 +91,7 @@ Navigation.register(new View({
5891
}
5992

6093
// Unknown deletion time
61-
span.textContent = translate('files_trashbin', 'A long time ago')
94+
span.textContent = t('files_trashbin', 'A long time ago')
6295
return span
6396
},
6497
sort(nodeA, nodeB) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.files-list__row-trashbin-original-location {
2+
width: 150px !important;
3+
}

dist/files_trashbin-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_trashbin-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)