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
|
<script>
import { formatDate } from '~/lib/utils/datetime_utility';
import IncidentTimelineEventListItem from './timeline_events_list_item.vue';
export default {
name: 'IncidentTimelineEventList',
components: {
IncidentTimelineEventListItem,
},
props: {
timelineEventLoading: {
type: Boolean,
required: false,
default: true,
},
timelineEvents: {
type: Array,
required: true,
default: () => [],
},
},
computed: {
dateGroupedEvents() {
const groupedEvents = new Map();
this.timelineEvents.forEach((event) => {
const date = formatDate(event.occurredAt, 'isoDate', true);
if (groupedEvents.has(date)) {
groupedEvents.get(date).push(event);
} else {
groupedEvents.set(date, [event]);
}
});
return groupedEvents;
},
},
methods: {
isLastItem(groups, groupIndex, events, eventIndex) {
if (groupIndex < groups.size - 1) {
return false;
}
return eventIndex === events.length - 1;
},
},
};
</script>
<template>
<div class="issuable-discussion incident-timeline-events">
<div
v-for="([eventDate, events], groupIndex) in dateGroupedEvents"
:key="eventDate"
data-testid="timeline-group"
>
<div class="gl-pb-3 gl-border-gray-50 gl-border-1 gl-border-b-solid">
<strong class="gl-font-size-h2" data-testid="event-date">{{ eventDate }}</strong>
</div>
<ul class="notes main-notes-list gl-pl-n3">
<incident-timeline-event-list-item
v-for="(event, eventIndex) in events"
:key="event.id"
:action="event.action"
:occurred-at="event.occurredAt"
:note-html="event.noteHtml"
:is-last-item="isLastItem(dateGroupedEvents, groupIndex, events, eventIndex)"
data-testid="timeline-event"
/>
</ul>
</div>
</div>
</template>
|