aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2024-01-09 13:08:08 +0100
committerJohn Molakvoæ <skjnldsv@protonmail.com>2024-01-11 11:57:49 +0100
commit365bb7ded033db22e3560cbffa1e885cf473429a (patch)
treeb98f3499938c295e5308dd5e142ddfe0c52243e8 /apps/files/src
parent9553718acfd3c3a5fb9812765d761dfc1c00f74b (diff)
downloadnextcloud-server-365bb7ded033db22e3560cbffa1e885cf473429a.tar.gz
nextcloud-server-365bb7ded033db22e3560cbffa1e885cf473429a.zip
chore(deps): bump `@nextcloud/files` to `3.1.0`
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/src')
-rw-r--r--apps/files/src/actions/deleteAction.spec.ts12
-rw-r--r--apps/files/src/actions/deleteAction.ts10
-rw-r--r--apps/files/src/services/Files.ts2
3 files changed, 11 insertions, 13 deletions
diff --git a/apps/files/src/actions/deleteAction.spec.ts b/apps/files/src/actions/deleteAction.spec.ts
index 195d257c017..f1aee5bdcba 100644
--- a/apps/files/src/actions/deleteAction.spec.ts
+++ b/apps/files/src/actions/deleteAction.spec.ts
@@ -38,6 +38,10 @@ const trashbinView = {
} as View
describe('Delete action conditions tests', () => {
+ afterEach(() => {
+ jest.restoreAllMocks()
+ })
+
const file = new File({
id: 1,
source: 'https://cloud.domain.com/remote.php/dav/files/test/foobar.txt',
@@ -48,8 +52,8 @@ describe('Delete action conditions tests', () => {
const file2 = new File({
id: 1,
- source: 'https://cloud.domain.com/remote.php/dav/files/test/foobar.txt',
- owner: 'user2',
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
+ owner: 'admin',
mime: 'text/plain',
permissions: Permission.ALL,
})
@@ -67,12 +71,12 @@ describe('Delete action conditions tests', () => {
expect(action.displayName([file], trashbinView)).toBe('Delete permanently')
})
- test('Shared node view values', () => {
+ test('Shared node values', () => {
jest.spyOn(auth, 'getCurrentUser').mockReturnValue(null)
expect(action.displayName([file2], view)).toBe('Unshare')
})
- test('Shared and owned nodes view values', () => {
+ test('Shared and owned nodes values', () => {
expect(action.displayName([file, file2], view)).toBe('Delete and unshare')
})
})
diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts
index d3f3a256517..29f1cf86c9b 100644
--- a/apps/files/src/actions/deleteAction.ts
+++ b/apps/files/src/actions/deleteAction.ts
@@ -29,16 +29,10 @@ import CloseSvg from '@mdi/svg/svg/close.svg?raw'
import logger from '../logger.js'
import { getCurrentUser } from '@nextcloud/auth'
-// A file which the owner is NOT the current user
-// is considered shared. Other methods like group folders
-// will always use the current user as the owner.
-// It will therefore not be considered shared.
const isAllUnshare = (nodes: Node[]) => {
- return !nodes.some(node => node.owner !== getCurrentUser()?.uid)
+ return !nodes.some(node => node.owner === getCurrentUser()?.uid)
}
-// Check whether the selection contains a mix of files
-// the current user owns and files owned by other users.
const isMixedUnshareAndDelete = (nodes: Node[]) => {
const hasUnshareItems = nodes.some(node => node.owner !== getCurrentUser()?.uid)
const hasDeleteItems = nodes.some(node => node.owner === getCurrentUser()?.uid)
@@ -79,7 +73,7 @@ export const action = new FileAction({
// Let's delete even if it's moved to the trashbin
// since it has been removed from the current view
- // and changing the view will trigger a reload anyway.
+ // and changing the view will trigger a reload anyway.
emit('files:node:deleted', node)
return true
} catch (error) {
diff --git a/apps/files/src/services/Files.ts b/apps/files/src/services/Files.ts
index c09be2d72ac..a293154f625 100644
--- a/apps/files/src/services/Files.ts
+++ b/apps/files/src/services/Files.ts
@@ -42,7 +42,7 @@ interface ResponseProps extends DAVResultResponseProps {
export const resultToNode = function(node: FileStat): File | Folder {
const props = node.props as ResponseProps
const permissions = davParsePermissions(props?.permissions)
- const owner = getCurrentUser()?.uid as string
+ const owner = (props['owner-id'] || getCurrentUser()?.uid) as string
const source = generateRemoteUrl('dav' + rootPath + node.filename)
const id = props?.fileid < 0