Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] feat(trashbin): Show original location of deleted file #44584

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions apps/files_trashbin/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,31 @@
* 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'

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({
Expand All @@ -45,6 +61,23 @@ Navigation.register(new View({
defaultSortKey: 'deleted',

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'),
Expand All @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions apps/files_trashbin/src/trashbin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.files-list__row-trashbin-original-location {
width: 150px !important;
}
4 changes: 2 additions & 2 deletions dist/files_trashbin-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_trashbin-main.js.map

Large diffs are not rendered by default.

Loading