Skip to content

Commit f0b68d7

Browse files
committed
Wip : Show owner information in sidebar
Resolves: #46178 Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
1 parent d843d67 commit f0b68d7

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
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: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
inline />
2424
{{ size }}
2525
<NcDateTime :timestamp="fileInfo.mtime" />
26+
<NcUserBubble
27+
:user="ownerId"
28+
:display-name="nodeOwnerLabel" />
2629
</template>
27-
2830
<!-- TODO: create a standard to allow multiple elements here? -->
2931
<template v-if="fileInfo" #description>
3032
<div class="sidebar__description">
@@ -95,6 +97,7 @@ import { encodePath } from '@nextcloud/paths'
9597
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
9698
import { ShareType } from '@nextcloud/sharing'
9799
import { mdiStar, mdiStarOutline } from '@mdi/js'
100+
import { fetchNode } from '../services/WebdavClient.ts'
98101
import axios from '@nextcloud/axios'
99102
import $ from 'jquery'
100103
@@ -103,6 +106,7 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
103106
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
104107
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
105108
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
109+
import NcUserBubble from '@nextcloud/vue/dist/Components/NcUserBubble.js'
106110
107111
import FileInfo from '../services/FileInfo.js'
108112
import LegacyView from '../components/LegacyView.vue'
@@ -122,6 +126,7 @@ export default {
122126
NcIconSvgWrapper,
123127
SidebarTab,
124128
SystemTags,
129+
NcUserBubble,
125130
},
126131
127132
setup() {
@@ -145,6 +150,7 @@ export default {
145150
error: null,
146151
loading: true,
147152
fileInfo: null,
153+
node: null,
148154
isFullScreen: false,
149155
hasLowHeight: false,
150156
}
@@ -287,6 +293,25 @@ export default {
287293
isSystemTagsEnabled() {
288294
return getCapabilities()?.systemtags?.enabled === true
289295
},
296+
ownerId() {
297+
return this.node?.attributes?.['owner-id']
298+
},
299+
currentUserIsOwner() {
300+
return this.ownerId && this.ownerId === this.currentUser
301+
},
302+
nodeOwnerLabel() {
303+
if (this.currentUserIsOwner) {
304+
return t('files', 'Owned by you')
305+
}
306+
const ownerDisplayName = this.node?.attributes?.['owner-display-name']
307+
return t('files', 'Owned by {ownerDisplayName}', { ownerDisplayName })
308+
},
309+
sharedMultipleTimes() {
310+
if (Array.isArray(node.attributes?.['share-types']) && node.attributes?.['share-types'].length > 1) {
311+
return t('files', 'Shared multiple times with different people')
312+
}
313+
return null
314+
},
290315
},
291316
created() {
292317
subscribe('files:node:deleted', this.onNodeDeleted)
@@ -298,7 +323,6 @@ export default {
298323
unsubscribe('file:node:deleted', this.onNodeDeleted)
299324
window.removeEventListener('resize', this.handleWindowResize)
300325
},
301-
302326
methods: {
303327
/**
304328
* Can this tab be displayed ?
@@ -460,6 +484,7 @@ export default {
460484
this.fileInfo = await FileInfo(this.davPath)
461485
// adding this as fallback because other apps expect it
462486
this.fileInfo.dir = this.file.split('/').slice(0, -1).join('/')
487+
this.node = await fetchNode({ path: (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/') })
463488
464489
// DEPRECATED legacy views
465490
// TODO: remove
@@ -549,6 +574,12 @@ export default {
549574
handleWindowResize() {
550575
this.hasLowHeight = document.documentElement.clientHeight < 1024
551576
},
577+
sharedMultipleTimes() {
578+
// Mixed share types
579+
if (Array.isArray(this.node.attributes?.['share-types']) && this.node.attributes?.['share-types'].length > 1) {
580+
return t('files', 'Shared multiple times with different people')
581+
}
582+
},
552583
},
553584
}
554585
</script>

0 commit comments

Comments
 (0)