-
-
Notifications
You must be signed in to change notification settings - Fork 641
Expand file tree
/
Copy pathHistory.vue
More file actions
96 lines (84 loc) · 2.74 KB
/
Copy pathHistory.vue
File metadata and controls
96 lines (84 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<template>
<div class="">
<div class="">
<div class="loading flex h-full items-center justify-center" v-if="loading">
<Icon name="loading" />
</div>
<Heading size="sm" class="p-3" v-if="!loading && revisions.length === 0">
{{ __('No revisions') }}
</Heading>
<div v-for="group in revisions" :key="group.day">
<Heading size="sm" class="p-3 text-gray-600 dark:text-gray-300" v-text="formatRelativeDate(group.day)" />
<div class="relative grid gap-3">
<div class="absolute inset-y-0 left-6 top-3 border-l-1 border-gray-400 dark:border-gray-600 border-dashed" />
<revision
v-for="(revision, index) in group.revisions"
:key="revision.date"
:revision="revision"
:restore-url="restoreUrl"
:shared-preview-url="sharedPreviewUrl"
:reference="reference"
:can-restore-revisions="canRestoreRevisions"
:is-last="index === group.revisions.length - 1"
@working-copy-selected="close"
/>
</div>
</div>
</div>
</div>
</template>
<script>
import Revision from './Revision.vue';
import DateFormatter from '@/components/DateFormatter.js';
import { Heading, Button, Icon } from '@/components/ui';
export default {
emits: ['closed'],
components: {
Revision,
Heading,
Button,
Icon,
},
props: {
indexUrl: String,
restoreUrl: String,
sharedPreviewUrl: String,
reference: String,
canRestoreRevisions: Boolean,
},
data() {
return {
revisions: [],
loading: true,
escBinding: null,
};
},
mounted() {
this.$axios.get(this.indexUrl).then((response) => {
this.loading = false;
this.revisions = response.data.reverse();
});
this.escBinding = this.$keys.bindGlobal(['esc'], (e) => {
this.close();
});
},
beforeUnmount() {
this.escBinding.destroy();
},
methods: {
formatRelativeDate(value) {
const isToday = new Date(value * 1000) < new Date().setUTCHours(0, 0, 0, 0);
return !isToday
? __('Today')
: DateFormatter.format(value * 1000, {
month: 'long',
day: 'numeric',
year: 'numeric',
});
},
close() {
this.$emit('closed');
},
},
};
</script>