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'
2326import DeleteSvg from '@mdi/svg/svg/delete.svg?raw'
2427import moment from '@nextcloud/moment'
2528
2629import { getContents } from './services/trashbin'
2730
2831// Register restore action
2932import './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
3248const Navigation = getNavigation ( )
3349Navigation . 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 ) {
0 commit comments