summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2024-04-01 15:44:39 -0700
committerPytal <24800714+Pytal@users.noreply.github.com>2024-04-03 11:38:54 -0700
commit9b96007e21090345b70c9b2b5ea462eabded5c39 (patch)
tree2f0f79028e6a9d36041a0d5413c8cfc1018cfa7a /apps/files_trashbin
parent96bf602d33ee150f4a6837a7fde38ddc8afdab02 (diff)
downloadnextcloud-server-9b96007e21090345b70c9b2b5ea462eabded5c39.tar.gz
nextcloud-server-9b96007e21090345b70c9b2b5ea462eabded5c39.zip
feat(trashbin): Show original location of deleted file
Signed-off-by: Christopher Ng <chrng8@gmail.com> (cherry picked from commit 1ae78095c87abb6d7ac8040d4e686f61414be18e)
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r--apps/files_trashbin/src/main.ts37
-rw-r--r--apps/files_trashbin/src/trashbin.scss3
2 files changed, 38 insertions, 2 deletions
diff --git a/apps/files_trashbin/src/main.ts b/apps/files_trashbin/src/main.ts
index aa41f48ab12..8e9e3250d87 100644
--- a/apps/files_trashbin/src/main.ts
+++ b/apps/files_trashbin/src/main.ts
@@ -19,10 +19,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
+import './trashbin.scss'
+
import type NavigationService from '../../files/src/services/Navigation.ts'
import type { Navigation } from '../../files/src/services/Navigation.ts'
-import { translate as t, translate } from '@nextcloud/l10n'
+import { translate as t } from '@nextcloud/l10n'
import DeleteSvg from '@mdi/svg/svg/delete.svg?raw'
import moment from '@nextcloud/moment'
@@ -30,6 +33,20 @@ import { getContents } from './services/trashbin'
// Register restore action
import './actions/restoreAction'
+import type { Node } 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 = window.OCP.Files.Navigation as NavigationService
Navigation.register({
@@ -45,6 +62,22 @@ Navigation.register({
columns: [
{
+ 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)
+ },
+ },
+ {
id: 'deleted',
title: t('files_trashbin', 'Deleted'),
render(node) {
@@ -57,7 +90,7 @@ Navigation.register({
}
// 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..e1b6b92dd6a
--- /dev/null
+++ b/apps/files_trashbin/src/trashbin.scss
@@ -0,0 +1,3 @@
+.files-list__row-trashbin-original-location {
+ width: 160px !important;
+}