Browse Source

feat(files): Display mtime in grid view

Signed-off-by: Louis Chemineau <louis@chmn.me>
pull/46307/head
Louis Chemineau 1 year ago
committed by skjnldsv
parent
commit
e8790f0b89
  1. 24
      apps/files/src/components/FileEntry.vue
  2. 12
      apps/files/src/components/FileEntryGrid.vue
  3. 26
      apps/files/src/components/FileEntryMixin.ts

24
apps/files/src/components/FileEntry.vue

@ -121,18 +121,10 @@ export default defineComponent({
],
props: {
isMtimeAvailable: {
type: Boolean,
default: false,
},
isSizeAvailable: {
type: Boolean,
default: false,
},
compact: {
type: Boolean,
default: false,
},
},
setup() {
@ -204,23 +196,7 @@ export default defineComponent({
color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`,
}
},
mtimeOpacity() {
const maxOpacityTime = 31 * 24 * 60 * 60 * 1000 // 31 days
const mtime = this.source.mtime?.getTime?.()
if (!mtime) {
return {}
}
// 1 = today, 0 = 31 days ago
const ratio = Math.round(Math.min(100, 100 * (maxOpacityTime - (Date.now() - mtime)) / maxOpacityTime))
if (ratio < 0) {
return {}
}
return {
color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`,
}
},
mtimeTitle() {
if (this.source.mtime) {
return moment(this.source.mtime).format('LLL')

12
apps/files/src/components/FileEntryGrid.vue

@ -46,6 +46,15 @@
@click.native="execDefaultAction" />
</td>
<!-- Mtime -->
<td v-if="!compact && isMtimeAvailable"
:style="mtimeOpacity"
class="files-list__row-mtime"
data-cy-files-list-row-mtime
@click="openDetailsIfAvailable">
<NcDateTime v-if="source.mtime" :timestamp="source.mtime" :ignore-seconds="true" />
</td>
<!-- Actions -->
<FileEntryActions ref="actions"
:class="`files-list__row-actions-${uniqueId}`"
@ -60,6 +69,8 @@
<script lang="ts">
import { defineComponent } from 'vue'
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
import { useNavigation } from '../composables/useNavigation'
import { useActionsMenuStore } from '../store/actionsmenu.ts'
import { useDragAndDropStore } from '../store/dragging.ts'
@ -80,6 +91,7 @@ export default defineComponent({
FileEntryCheckbox,
FileEntryName,
FileEntryPreview,
NcDateTime,
},
mixins: [

26
apps/files/src/components/FileEntryMixin.ts

@ -37,6 +37,14 @@ export default defineComponent({
type: Number,
default: 0,
},
isMtimeAvailable: {
type: Boolean,
default: false,
},
compact: {
type: Boolean,
default: false,
},
},
data() {
@ -148,8 +156,22 @@ export default defineComponent({
},
},
isRenaming() {
return this.renamingStore.renamingNode === this.source
mtimeOpacity() {
const maxOpacityTime = 31 * 24 * 60 * 60 * 1000 // 31 days
const mtime = this.source.mtime?.getTime?.()
if (!mtime) {
return {}
}
// 1 = today, 0 = 31 days ago
const ratio = Math.round(Math.min(100, 100 * (maxOpacityTime - (Date.now() - mtime)) / maxOpacityTime))
if (ratio < 0) {
return {}
}
return {
color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`,
}
},
},

Loading…
Cancel
Save