Skip to content

Commit 823a6f8

Browse files
susnuxAndyScherzinger
authored andcommitted
fix: Access node owner by top level owner property
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 994b63d commit 823a6f8

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

apps/files/src/components/FileEntry/FileEntryActions.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
:close-after-click="!isMenu(action.id)"
5555
:data-cy-files-list-row-action="action.id"
5656
:is-menu="isMenu(action.id)"
57+
:aria-label="action.title?.([source], currentView)"
5758
:title="action.title?.([source], currentView)"
5859
@click="onActionClick(action)">
5960
<template #icon>

apps/files/src/newMenu/newFolder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const entry = {
7272
source,
7373
id: fileid,
7474
mtime: new Date(),
75-
owner: getCurrentUser()?.uid || null,
75+
owner: context.owner,
7676
permissions: Permission.ALL,
7777
root: context?.root || '/files/' + getCurrentUser()?.uid,
7878
// Include mount-type from parent folder as this is inherited

apps/files_sharing/src/actions/sharingStatusAction.ts

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*
2121
*/
2222
import { Node, View, registerFileAction, FileAction, Permission } from '@nextcloud/files'
23-
import { translate as t } from '@nextcloud/l10n'
24-
import { Type } from '@nextcloud/sharing'
23+
import { t } from '@nextcloud/l10n'
24+
import { ShareType } from '@nextcloud/sharing'
2525

2626
import AccountGroupSvg from '@mdi/svg/svg/account-group.svg?raw'
2727
import AccountPlusSvg from '@mdi/svg/svg/account-plus.svg?raw'
@@ -55,17 +55,31 @@ export const action = new FileAction({
5555
title(nodes: Node[]) {
5656
const node = nodes[0]
5757

58-
// Mixed share types
59-
if (Array.isArray(node.attributes?.['share-types']) && node.attributes?.['share-types'].length > 1) {
60-
return t('files_sharing', 'Shared multiple times with different people')
61-
}
62-
6358
if (node.owner && (node.owner !== getCurrentUser()?.uid || isExternal(node))) {
6459
const ownerDisplayName = node?.attributes?.['owner-display-name']
6560
return t('files_sharing', 'Shared by {ownerDisplayName}', { ownerDisplayName })
6661
}
6762

68-
return t('files_sharing', 'Show sharing options')
63+
const shareTypes = Object.values(node?.attributes?.['share-types'] || {}).flat() as number[]
64+
if (shareTypes.length > 1) {
65+
return t('files_sharing', 'Shared multiple times with different people')
66+
}
67+
68+
const sharees = node.attributes.sharees?.sharee as { id: string, 'display-name': string, type: ShareType }[] | undefined
69+
if (!sharees) {
70+
// No sharees so just show the default message to create a new share
71+
return t('files_sharing', 'Show sharing options')
72+
}
73+
74+
const sharee = [sharees].flat()[0] // the property is sometimes weirdly normalized, so we need to compensate
75+
switch (sharee.type) {
76+
case ShareType.User:
77+
return t('files_sharing', 'Shared with {user}', { user: sharee['display-name'] })
78+
case ShareType.Group:
79+
return t('files_sharing', 'Shared with group {group}', { group: sharee['display-name'] ?? sharee.id })
80+
default:
81+
return t('files_sharing', 'Shared with others')
82+
}
6983
},
7084

7185
iconSvgInline(nodes: Node[]) {
@@ -78,25 +92,24 @@ export const action = new FileAction({
7892
}
7993

8094
// Link shares
81-
if (shareTypes.includes(Type.SHARE_TYPE_LINK)
82-
|| shareTypes.includes(Type.SHARE_TYPE_EMAIL)) {
95+
if (shareTypes.includes(ShareType.Link)
96+
|| shareTypes.includes(ShareType.Email)) {
8397
return LinkSvg
8498
}
8599

86100
// Group shares
87-
if (shareTypes.includes(Type.SHARE_TYPE_GROUP)
88-
|| shareTypes.includes(Type.SHARE_TYPE_REMOTE_GROUP)) {
101+
if (shareTypes.includes(ShareType.Group)
102+
|| shareTypes.includes(ShareType.RemoteGroup)) {
89103
return AccountGroupSvg
90104
}
91105

92106
// Circle shares
93-
if (shareTypes.includes(Type.SHARE_TYPE_CIRCLE)) {
107+
if (shareTypes.includes(ShareType.Team)) {
94108
return CircleSvg
95109
}
96110

97111
if (node.owner && (node.owner !== getCurrentUser()?.uid || isExternal(node))) {
98-
const sanitizeId = (id: string) => id.replace(/[^a-zA-Z0-9._%+@-]+/g, '').replace(/\//g, '')
99-
return generateAvatarSvg(sanitizeId(node.owner), isExternal(node))
112+
return generateAvatarSvg(node.owner, isExternal(node))
100113
}
101114

102115
return AccountPlusSvg
@@ -118,7 +131,7 @@ export const action = new FileAction({
118131
}
119132

120133
// If the node is shared by someone else
121-
if (node.owner && (node.owner !== getCurrentUser()?.uid || isExternal(node))) {
134+
if (node.owner !== getCurrentUser()?.uid || isExternal(node)) {
122135
return true
123136
}
124137

0 commit comments

Comments
 (0)