Skip to content

Commit 08c71bc

Browse files
committed
feat: author displayname and avatar on versions
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
1 parent 5ea10a0 commit 08c71bc

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

apps/files_versions/src/components/Version.vue

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@
3939
</div>
4040
</template>
4141

42+
<!-- author -->
43+
<template #name>
44+
<div class="version__info">
45+
<div v-if="versionLabel" class="version__info__label">{{ versionLabel }}</div>
46+
<div v-if="versionAuthor" class="version__info version__info__author">
47+
<div>•</div>
48+
<div>{{ versionAuthor }}</div>
49+
<NcAvatar class="avatar"
50+
:user="version.author"
51+
:size="24"
52+
:disable-menu="true"
53+
:disable-tooltip="true"
54+
:show-user-status="false" />
55+
</div>
56+
</div>
57+
</template>
58+
4259
<!-- Version file size as subline -->
4360
<template #subname>
4461
<div class="version__info">
@@ -113,11 +130,13 @@ import Pencil from 'vue-material-design-icons/Pencil.vue'
113130
114131
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
115132
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
133+
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
116134
import NcListItem from '@nextcloud/vue/dist/Components/NcListItem.js'
117135
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'
118136
119137
import { defineComponent, type PropType } from 'vue'
120-
import { getRootUrl } from '@nextcloud/router'
138+
import axios from '@nextcloud/axios'
139+
import { getRootUrl, generateOcsUrl } from '@nextcloud/router'
121140
import { joinPaths } from '@nextcloud/paths'
122141
import { loadState } from '@nextcloud/initial-state'
123142
import { Permission, formatFileSize } from '@nextcloud/files'
@@ -132,6 +151,7 @@ export default defineComponent({
132151
components: {
133152
NcActionLink,
134153
NcActionButton,
154+
NcAvatar,
135155
NcListItem,
136156
BackupRestore,
137157
Download,
@@ -145,6 +165,10 @@ export default defineComponent({
145165
tooltip: Tooltip,
146166
},
147167
168+
created() {
169+
this.fetchDisplayName()
170+
},
171+
148172
filters: {
149173
humanReadableSize(bytes: number): string {
150174
return formatFileSize(bytes)
@@ -193,6 +217,7 @@ export default defineComponent({
193217
previewLoaded: false,
194218
previewErrored: false,
195219
capabilities: loadState('core', 'capabilities', { files: { version_labeling: false, version_deletion: false } }),
220+
versionAuthor: '',
196221
}
197222
},
198223
@@ -279,6 +304,14 @@ export default defineComponent({
279304
this.$emit('delete', this.version)
280305
},
281306
307+
async fetchDisplayName() {
308+
// check to make sure that we have a valid author - in case database did not migrate, null author, etc.
309+
if (this.version.author) {
310+
const { data } = await axios.get(generateOcsUrl(`/cloud/users/${this.version.author}`))
311+
this.versionAuthor = data.ocs.data.displayname
312+
}
313+
},
314+
282315
click() {
283316
if (!this.canView) {
284317
window.location = this.downloadURL
@@ -310,8 +343,13 @@ export default defineComponent({
310343
align-items: center;
311344
gap: 0.5rem;
312345
313-
&__size {
346+
&__label {
347+
font-weight: 700;
348+
}
349+
350+
&__size, &__author {
314351
color: var(--color-text-lighter);
352+
font-weight: 500;
315353
}
316354
}
317355

apps/files_versions/src/utils/versions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import logger from '../utils/logger.js'
3535
export interface Version {
3636
fileId: string, // The id of the file associated to the version.
3737
label: string, // 'Current version' or ''
38+
author: string|null, // UID for the author of the version
3839
filename: string, // File name relative to the version DAV endpoint
3940
basename: string, // A base name generated from the mtime
4041
mime: string, // Empty for the current version, else the actual mime type of the version
@@ -107,6 +108,7 @@ function formatVersion(version: any, fileInfo: any): Version {
107108
return {
108109
fileId: fileInfo.id,
109110
label: version.props['version-label'],
111+
author: version.props['version-author'] ?? null,
110112
filename: version.filename,
111113
basename: moment(mtime).format('LLL'),
112114
mime: version.mime,

0 commit comments

Comments
 (0)