4343 <div class =" version__info" >
4444 <div v-if =" versionLabel"
4545 class =" version__info__label"
46+ data-cy-files-version-label
4647 :title =" versionLabel" >
4748 {{ versionLabel }}
4849 </div >
49- <div v-if =" versionAuthor" class =" version__info" >
50+ <div v-if =" versionAuthor"
51+ class =" version__info"
52+ data-cy-files-version-author-name >
5053 <span v-if =" versionLabel" >•</span >
5154 <NcAvatar class =" avatar"
5255 :user =" version.author"
53- :size =" 16 "
54- : disable-menu= " true "
55- : disable-tooltip= " true "
56+ :size =" 20 "
57+ disable-menu
58+ disable-tooltip
5659 :show-user-status =" false" />
5760 <div >{{ versionAuthor }}</div >
5861 </div >
6568 <NcDateTime class =" version__info__date"
6669 relative-time =" short"
6770 :timestamp =" version.mtime" />
68- <!-- Separate dot to improve alignement -->
71+ <!-- Separate dot to improve alignment -->
6972 <span >•</span >
7073 <span >{{ humanReadableSize }}</span >
7174 </div >
127130import type { PropType } from ' vue'
128131import type { Version } from ' ../utils/versions'
129132
133+ import { getCurrentUser } from ' @nextcloud/auth'
134+ import { Permission , formatFileSize } from ' @nextcloud/files'
135+ import { loadState } from ' @nextcloud/initial-state'
136+ import { t } from ' @nextcloud/l10n'
137+ import { joinPaths } from ' @nextcloud/paths'
138+ import { getRootUrl , generateUrl } from ' @nextcloud/router'
139+ import { defineComponent } from ' vue'
140+
141+ import axios from ' @nextcloud/axios'
142+ import logger from ' ../utils/logger'
143+
130144import BackupRestore from ' vue-material-design-icons/BackupRestore.vue'
131145import Delete from ' vue-material-design-icons/Delete.vue'
132146import Download from ' vue-material-design-icons/Download.vue'
@@ -141,15 +155,6 @@ import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
141155import NcListItem from ' @nextcloud/vue/dist/Components/NcListItem.js'
142156import Tooltip from ' @nextcloud/vue/dist/Directives/Tooltip.js'
143157
144- import { getRootUrl , generateOcsUrl } from ' @nextcloud/router'
145- import { joinPaths } from ' @nextcloud/paths'
146- import { loadState } from ' @nextcloud/initial-state'
147- import { Permission , formatFileSize } from ' @nextcloud/files'
148- import { translate as t } from ' @nextcloud/l10n'
149- import { defineComponent } from ' vue'
150-
151- import axios from ' @nextcloud/axios'
152-
153158const hasPermission = (permissions : number , permission : number ): boolean => (permissions & permission ) !== 0
154159
155160export default defineComponent ({
@@ -211,7 +216,7 @@ export default defineComponent({
211216 previewLoaded: false ,
212217 previewErrored: false ,
213218 capabilities: loadState (' core' , ' capabilities' , { files: { version_labeling: false , version_deletion: false } }),
214- versionAuthor: ' ' ,
219+ versionAuthor: ' ' as string | null ,
215220 }
216221 },
217222
@@ -303,21 +308,26 @@ export default defineComponent({
303308 },
304309
305310 async fetchDisplayName() {
306- // check to make sure that we have a valid author - in case database did not migrate, null author, etc.
307- if (this .version .author ) {
311+ this .versionAuthor = null
312+ if (! this .version .author ) {
313+ return
314+ }
315+
316+ if (this .version .author === getCurrentUser ()?.uid ) {
317+ this .versionAuthor = t (' files_versions' , ' You' )
318+ } else {
308319 try {
309- const { data } = await axios .get (generateOcsUrl (` /cloud/users/${this .version .author } ` ))
310- this .versionAuthor = data .ocs .data .displayname
311- } catch (e ) {
312- // Promise got rejected - default to null author to not try to load author profile
313- this .versionAuthor = null
320+ const { data } = await axios .post (generateUrl (' /displaynames' ), { users: [this .version .author ] })
321+ this .versionAuthor = data .users [this .version .author ]
322+ } catch (error ) {
323+ logger .warn (' Could not load user display name' , { error })
314324 }
315325 }
316326 },
317327
318328 click() {
319329 if (! this .canView ) {
320- window .location = this .downloadURL
330+ window .location . href = this .downloadURL
321331 return
322332 }
323333 this .$emit (' click' , { version: this .version })
0 commit comments