Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(files_versions): Use NcDateTime to ensure date is transalted pr…
…operly

Also do not use filters, filters are deprecated and will make migration to Vue 3 harder.

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux authored and AndyScherzinger committed Jul 10, 2024
commit 714fb1cce9f2e2f988d9b6c579b59355956f749a
34 changes: 14 additions & 20 deletions apps/files_versions/src/components/Version.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@
<!-- Version file size as subline -->
<template #subname>
<div class="version__info version__info__subline">
<span :title="formattedDate">{{ version.mtime | humanDateFromNow }}</span>
<NcDateTime class="version__info__date"
relative-time="short"
:timestamp="version.mtime" />
<!-- Separate dot to improve alignement -->
<span>•</span>
<span>{{ version.size | humanReadableSize }}</span>
<span>{{ humanReadableSize }}</span>
</div>
</template>

Expand Down Expand Up @@ -130,6 +132,7 @@ import Pencil from 'vue-material-design-icons/Pencil.vue'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
import NcListItem from '@nextcloud/vue/dist/Components/NcListItem.js'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'

Expand All @@ -151,6 +154,7 @@ export default defineComponent({
NcActionLink,
NcActionButton,
NcAvatar,
NcDateTime,
NcListItem,
BackupRestore,
Download,
Expand All @@ -164,20 +168,6 @@ export default defineComponent({
tooltip: Tooltip,
},

created() {
this.fetchDisplayName()
},

filters: {
humanReadableSize(bytes: number): string {
return formatFileSize(bytes)
},

humanDateFromNow(timestamp: number): string {
return moment(timestamp).fromNow()
},
},

props: {
version: {
type: Object as PropType<Version>,
Expand Down Expand Up @@ -221,6 +211,10 @@ export default defineComponent({
},

computed: {
humanReadableSize() {
return formatFileSize(this.version.size)
},

versionLabel(): string {
const label = this.version.label ?? ''

Expand All @@ -247,10 +241,6 @@ export default defineComponent({
}
},

formattedDate(): string {
return moment(this.version.mtime).format('LLL')
},

enableLabeling(): boolean {
return this.capabilities.files.version_labeling === true
},
Expand Down Expand Up @@ -286,6 +276,10 @@ export default defineComponent({
},
},

created() {
this.fetchDisplayName()
},

methods: {
labelUpdate() {
this.$emit('label-update-request')
Expand Down