Skip to content

Commit

Permalink
Wip : Show owner information in sidebar
Browse files Browse the repository at this point in the history
Resolves: #46178

Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
nfebe committed Jul 26, 2024
1 parent c2acabf commit 6a3886f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
13 changes: 12 additions & 1 deletion apps/files/src/services/WebdavClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { davGetClient } from '@nextcloud/files'
import { davGetClient, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
import type { FileStat, ResponseDataDetailed } from 'webdav'
import type { Node } from '@nextcloud/files'

export const client = davGetClient()

export const fetchNode = async (node: Node): Promise<Node> => {
const propfindPayload = davGetDefaultPropfind()
const result = await client.stat(`${davRootPath}${node.path}`, {
details: true,
data: propfindPayload,
}) as ResponseDataDetailed<FileStat>
return davResultToNode(result.data)
}
35 changes: 33 additions & 2 deletions apps/files/src/views/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
inline />
{{ size }}
<NcDateTime :timestamp="fileInfo.mtime" />
<NcUserBubble
:user="ownerId"

Check failure on line 27 in apps/files/src/views/Sidebar.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected no linebreak before this attribute
:display-name="nodeOwnerLabel" />
</template>

<!-- TODO: create a standard to allow multiple elements here? -->
<template v-if="fileInfo" #description>
<div class="sidebar__description">
Expand Down Expand Up @@ -95,6 +97,7 @@ import { encodePath } from '@nextcloud/paths'
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
import { ShareType } from '@nextcloud/sharing'
import { mdiStar, mdiStarOutline } from '@mdi/js'
import { fetchNode } from '../services/WebdavClient.ts'
import axios from '@nextcloud/axios'
import $ from 'jquery'
Expand All @@ -103,6 +106,7 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import NcUserBubble from '@nextcloud/vue/dist/Components/NcUserBubble.js'
import FileInfo from '../services/FileInfo.js'
import LegacyView from '../components/LegacyView.vue'
Expand All @@ -122,6 +126,7 @@ export default {
NcIconSvgWrapper,
SidebarTab,
SystemTags,
NcUserBubble,
},
setup() {
Expand All @@ -145,6 +150,7 @@ export default {
error: null,
loading: true,
fileInfo: null,
node: null,
isFullScreen: false,
hasLowHeight: false,
}
Expand Down Expand Up @@ -287,6 +293,25 @@ export default {
isSystemTagsEnabled() {
return getCapabilities()?.systemtags?.enabled === true
},
ownerId() {
return this.node?.attributes?.['owner-id']
},
currentUserIsOwner() {
return this.ownerId && this.ownerId === this.currentUser
},
nodeOwnerLabel() {
if (this.currentUserIsOwner) {
return t('files', 'Owned by you')
}
const ownerDisplayName = this.node?.attributes?.['owner-display-name']
return t('files', 'Owned by {ownerDisplayName}', { ownerDisplayName })
},
sharedMultipleTimes() {
if (Array.isArray(node.attributes?.['share-types']) && node.attributes?.['share-types'].length > 1) {
return t('files', 'Shared multiple times with different people')
}
return null
},
},
created() {
subscribe('files:node:deleted', this.onNodeDeleted)
Expand All @@ -298,7 +323,6 @@ export default {
unsubscribe('file:node:deleted', this.onNodeDeleted)
window.removeEventListener('resize', this.handleWindowResize)
},
methods: {
/**
* Can this tab be displayed ?
Expand Down Expand Up @@ -460,6 +484,7 @@ export default {
this.fileInfo = await FileInfo(this.davPath)
// adding this as fallback because other apps expect it
this.fileInfo.dir = this.file.split('/').slice(0, -1).join('/')
this.node = await fetchNode({ path: (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/') })
// DEPRECATED legacy views
// TODO: remove
Expand Down Expand Up @@ -549,6 +574,12 @@ export default {
handleWindowResize() {
this.hasLowHeight = document.documentElement.clientHeight < 1024
},
sharedMultipleTimes() {

Check failure on line 577 in apps/files/src/views/Sidebar.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Duplicate key 'sharedMultipleTimes'. May cause name collision in script or template tag
// Mixed share types
if (Array.isArray(this.node.attributes?.['share-types']) && this.node.attributes?.['share-types'].length > 1) {
return t('files', 'Shared multiple times with different people')
}
},
},
}
</script>
Expand Down

0 comments on commit 6a3886f

Please sign in to comment.