Skip to content
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
18 changes: 12 additions & 6 deletions apps/files_trashbin/src/files_views/columns.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import { deleted, deletedBy, originalLocation } from './columns.ts'
import { trashbinView } from './trashbinView.ts'
import * as ncAuth from '@nextcloud/auth'

vi.mock('@nextcloud/l10n', async (originalModule) => ({
...(await originalModule()),
getLanguage: () => 'en',
getCanonicalLocale: () => 'en-US',
}))

describe('files_trashbin: file list columns', () => {

describe('column: original location', () => {
Expand Down Expand Up @@ -100,19 +106,19 @@ describe('files_trashbin: file list columns', () => {
})

it('renders a node with deletion date', () => {
const node = new File({ owner: 'test', source: 'https://example.com/remote.php/dav/files/test/a.txt', mime: 'text/plain', attributes: { 'trashbin-deletion-time': 1741684522 } })
const node = new File({ owner: 'test', source: 'https://example.com/remote.php/dav/files/test/a.txt', mime: 'text/plain', attributes: { 'trashbin-deletion-time': (Date.now() / 1000) - 120 } })
const el: HTMLElement = deleted.render(node, trashbinView)
expect(el).toBeInstanceOf(HTMLElement)
expect(el.textContent).toBe('a minute ago')
expect(el.title).toBe('March 11, 2025 9:15 AM')
expect(el.textContent).toBe('2 minutes ago')
expect(el.title).toBe('March 11, 2025 at 9:14 AM')
})

it('renders a node when deletion date is missing and falls back to mtime', () => {
const node = new File({ owner: 'test', source: 'https://example.com/remote.php/dav/files/test/a.txt', mime: 'text/plain', mtime: new Date(1741684522000) })
const node = new File({ owner: 'test', source: 'https://example.com/remote.php/dav/files/test/a.txt', mime: 'text/plain', mtime: new Date(Date.now() - 60000) })
const el: HTMLElement = deleted.render(node, trashbinView)
expect(el).toBeInstanceOf(HTMLElement)
expect(el.textContent).toBe('a minute ago')
expect(el.title).toBe('March 11, 2025 9:15 AM')
expect(el.textContent).toBe('1 minute ago')
expect(el.title).toBe('March 11, 2025 at 9:15 AM')
})

it('renders a node when deletion date is missing', () => {
Expand Down
10 changes: 6 additions & 4 deletions apps/files_trashbin/src/files_views/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import moment from '@nextcloud/moment'
import { getCurrentUser } from '@nextcloud/auth'
import { Column, Node } from '@nextcloud/files'
import { getCanonicalLocale, getLanguage, translate as t } from '@nextcloud/l10n'
import { formatRelativeTime, getCanonicalLocale, getLanguage, t } from '@nextcloud/l10n'
import { dirname } from '@nextcloud/paths'

import Vue from 'vue'
Expand Down Expand Up @@ -67,8 +66,11 @@ export const deleted = new Column({
const deletionTime = node.attributes?.['trashbin-deletion-time'] || ((node?.mtime?.getTime() ?? 0) / 1000)
const span = document.createElement('span')
if (deletionTime) {
span.title = moment.unix(deletionTime).format('LLL')
span.textContent = moment.unix(deletionTime).fromNow()
const formatter = Intl.DateTimeFormat([getCanonicalLocale()], { dateStyle: 'long', timeStyle: 'short' })
const timestamp = new Date(deletionTime * 1000)

span.title = formatter.format(timestamp)
span.textContent = formatRelativeTime(timestamp, { ignoreSeconds: t('files', 'few seconds ago') })
return span
}

Expand Down
4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions dist/files-init.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jonas Schade <[email protected]>
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
SPDX-FileCopyrightText: Iskren Ivov Chernev <[email protected]> (https://github.com/ichernev)
SPDX-FileCopyrightText: Guillaume Chau <[email protected]>
SPDX-FileCopyrightText: Guillaume Chau
SPDX-FileCopyrightText: GitHub Inc.
Expand Down Expand Up @@ -84,9 +83,6 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/logger
- version: 3.0.2
- license: GPL-3.0-or-later
- @nextcloud/moment
- version: 1.3.4
- license: GPL-3.0-or-later
- @nextcloud/paths
- version: 2.2.1
- license: GPL-3.0-or-later
Expand Down Expand Up @@ -159,9 +155,6 @@ This file is generated from multiple sources. Included packages:
- md5
- version: 2.3.0
- license: BSD-3-Clause
- moment
- version: 2.30.1
- license: MIT
- buffer
- version: 6.0.3
- license: MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions dist/files-main.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jonas Schade <[email protected]>
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
SPDX-FileCopyrightText: Iskren Ivov Chernev <[email protected]> (https://github.com/ichernev)
SPDX-FileCopyrightText: Hiroki Osame
SPDX-FileCopyrightText: Guillaume Chau <[email protected]>
SPDX-FileCopyrightText: Guillaume Chau
Expand Down Expand Up @@ -90,9 +89,6 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/logger
- version: 3.0.2
- license: GPL-3.0-or-later
- @nextcloud/moment
- version: 1.3.4
- license: GPL-3.0-or-later
- @nextcloud/paths
- version: 2.2.1
- license: GPL-3.0-or-later
Expand Down Expand Up @@ -174,9 +170,6 @@ This file is generated from multiple sources. Included packages:
- md5
- version: 2.3.0
- license: BSD-3-Clause
- moment
- version: 2.30.1
- license: MIT
- buffer
- version: 6.0.3
- license: MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_trashbin-init.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions dist/files_trashbin-init.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jonas Schade <[email protected]>
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
SPDX-FileCopyrightText: Iskren Ivov Chernev <[email protected]> (https://github.com/ichernev)
SPDX-FileCopyrightText: Guillaume Chau <[email protected]>
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Feross Aboukhadijeh
Expand Down Expand Up @@ -75,9 +74,6 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/logger
- version: 3.0.2
- license: GPL-3.0-or-later
- @nextcloud/moment
- version: 1.3.4
- license: GPL-3.0-or-later
- @nextcloud/paths
- version: 2.2.1
- license: GPL-3.0-or-later
Expand Down Expand Up @@ -138,9 +134,6 @@ This file is generated from multiple sources. Included packages:
- md5
- version: 2.3.0
- license: BSD-3-Clause
- moment
- version: 2.30.1
- license: MIT
- buffer
- version: 6.0.3
- license: MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/files_trashbin-init.js.map

Large diffs are not rendered by default.

Loading
Loading