Skip to content

Commit 51d2ce5

Browse files
committed
feat(sidebar): Show node owner in metadata subline
Resolves: #46178 Signed-off-by: fenn-cs <[email protected]>
1 parent 0451be7 commit 51d2ce5

File tree

2 files changed

+69
-12
lines changed

2 files changed

+69
-12
lines changed

apps/files/src/services/WebdavClient.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
import { davGetClient } from '@nextcloud/files'
5+
import { davGetClient, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
6+
import type { FileStat, ResponseDataDetailed } from 'webdav'
7+
import type { Node } from '@nextcloud/files'
68

79
export const client = davGetClient()
10+
11+
export const fetchNode = async (node: Node): Promise<Node> => {
12+
const propfindPayload = davGetDefaultPropfind()
13+
const result = await client.stat(`${davRootPath}${node.path}`, {
14+
details: true,
15+
data: propfindPayload,
16+
}) as ResponseDataDetailed<FileStat>
17+
return davResultToNode(result.data)
18+
}

apps/files/src/views/Sidebar.vue

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@
1717
@closing="handleClosing"
1818
@closed="handleClosed">
1919
<template v-if="fileInfo" #subname>
20-
<NcIconSvgWrapper v-if="fileInfo.isFavourited"
21-
:path="mdiStar"
22-
:name="t('files', 'Favorite')"
23-
inline />
24-
{{ size }}
25-
<NcDateTime :timestamp="fileInfo.mtime" />
20+
<div class="sidebar__subname">
21+
<NcIconSvgWrapper v-if="fileInfo.isFavourited"
22+
:path="mdiStar"
23+
:name="t('files', 'Favorite')"
24+
inline />
25+
<span>{{ size }}</span>
26+
<span class="sidebar__subname-separator">•</span>
27+
<NcDateTime :timestamp="fileInfo.mtime" />
28+
<span class="sidebar__subname-separator">•</span>
29+
<span>{{ t('files', 'Owner') }}</span>
30+
<NcUserBubble :user="ownerId"
31+
:display-name="nodeOwnerLabel" />
32+
</div>
2633
</template>
2734

2835
<!-- TODO: create a standard to allow multiple elements here? -->
@@ -96,6 +103,7 @@ import { encodePath } from '@nextcloud/paths'
96103
import { generateUrl } from '@nextcloud/router'
97104
import { ShareType } from '@nextcloud/sharing'
98105
import { mdiStar, mdiStarOutline } from '@mdi/js'
106+
import { fetchNode } from '../services/WebdavClient.ts'
99107
import axios from '@nextcloud/axios'
100108
import $ from 'jquery'
101109
@@ -104,6 +112,7 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
104112
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
105113
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
106114
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
115+
import NcUserBubble from '@nextcloud/vue/dist/Components/NcUserBubble.js'
107116
108117
import FileInfo from '../services/FileInfo.js'
109118
import LegacyView from '../components/LegacyView.vue'
@@ -123,6 +132,7 @@ export default {
123132
NcIconSvgWrapper,
124133
SidebarTab,
125134
SystemTags,
135+
NcUserBubble,
126136
},
127137
128138
setup() {
@@ -146,6 +156,7 @@ export default {
146156
error: null,
147157
loading: true,
148158
fileInfo: null,
159+
node: null,
149160
isFullScreen: false,
150161
hasLowHeight: false,
151162
}
@@ -287,6 +298,25 @@ export default {
287298
isSystemTagsEnabled() {
288299
return getCapabilities()?.systemtags?.enabled === true
289300
},
301+
ownerId() {
302+
return this.node?.attributes?.['owner-id'] ?? this.currentUser.uid
303+
},
304+
currentUserIsOwner() {
305+
return this.ownerId === this.currentUser.uid
306+
},
307+
nodeOwnerLabel() {
308+
let ownerDisplayName = this.node?.attributes?.['owner-display-name']
309+
if (this.currentUserIsOwner) {
310+
ownerDisplayName = `${ownerDisplayName} (${t('files', 'You')})`
311+
}
312+
return ownerDisplayName
313+
},
314+
sharedMultipleTimes() {
315+
if (Array.isArray(node.attributes?.['share-types']) && node.attributes?.['share-types'].length > 1) {
316+
return t('files', 'Shared multiple times with different people')
317+
}
318+
return null
319+
},
290320
},
291321
created() {
292322
subscribe('files:node:deleted', this.onNodeDeleted)
@@ -460,6 +490,7 @@ export default {
460490
this.fileInfo = await FileInfo(this.davPath)
461491
// adding this as fallback because other apps expect it
462492
this.fileInfo.dir = this.file.split('/').slice(0, -1).join('/')
493+
this.node = await fetchNode({ path: (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/') })
463494
464495
// DEPRECATED legacy views
465496
// TODO: remove
@@ -589,10 +620,25 @@ export default {
589620
}
590621
}
591622
592-
.sidebar__description {
593-
display: flex;
594-
flex-direction: column;
595-
width: 100%;
596-
gap: 8px 0;
623+
.sidebar__subname {
624+
display: flex;
625+
align-items: center;
626+
gap: 0 8px;
627+
628+
&-separator {
629+
display: inline-block;
630+
font-weight: bold !important;
631+
}
632+
633+
.user-bubble__wrapper {
634+
display: inline-flex;
635+
}
597636
}
637+
638+
.sidebar__description {
639+
display: flex;
640+
flex-direction: column;
641+
width: 100%;
642+
gap: 8px 0;
643+
}
598644
</style>

0 commit comments

Comments
 (0)