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
97
98
99
100
|
<script>
import { GlIcon } from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { mapActions } from 'vuex';
import DesignNotePin from '~/vue_shared/components/design_management/design_note_pin.vue';
import NoteableDiscussion from '~/notes/components/noteable_discussion.vue';
export default {
components: {
NoteableDiscussion,
GlIcon,
DesignNotePin,
},
props: {
discussions: {
type: Array,
required: true,
},
line: {
type: Object,
required: false,
default: null,
},
shouldCollapseDiscussions: {
type: Boolean,
required: false,
default: false,
},
renderAvatarBadge: {
type: Boolean,
required: false,
default: false,
},
helpPagePath: {
type: String,
required: false,
default: '',
},
},
methods: {
...mapActions(['toggleDiscussion']),
isExpanded(discussion) {
return this.shouldCollapseDiscussions ? discussion.expanded : true;
},
},
};
</script>
<template>
<div>
<div
v-for="(discussion, index) in discussions"
:key="discussion.id"
:class="{
collapsed: !isExpanded(discussion),
}"
class="discussion-notes diff-discussions position-relative"
>
<ul :data-discussion-id="discussion.id" class="notes">
<template v-if="shouldCollapseDiscussions">
<button
v-if="discussion.expanded"
class="diff-notes-collapse js-diff-notes-toggle"
type="button"
:aria-label="__('Show comments')"
@click="toggleDiscussion({ discussionId: discussion.id })"
>
<gl-icon name="collapse" class="collapse-icon" />
</button>
<design-note-pin
v-else
:label="index + 1"
:is-resolved="discussion.resolved"
size="sm"
class="js-diff-notes-toggle gl-translate-x-n50"
@click="toggleDiscussion({ discussionId: discussion.id })"
/>
</template>
<noteable-discussion
v-show="isExpanded(discussion)"
:discussion="discussion"
:render-diff-file="false"
:discussions-by-diff-order="true"
:line="line"
:help-page-path="helpPagePath"
:should-scroll-to-note="false"
>
<template v-if="renderAvatarBadge" #avatar-badge>
<design-note-pin
:label="index + 1"
class="user-avatar"
:is-resolved="discussion.resolved"
size="sm"
/>
</template>
</noteable-discussion>
</ul>
</div>
</div>
</template>
|