2018-06-21 12:22:40 +00:00
|
|
|
<script>
|
2018-09-03 15:43:35 +00:00
|
|
|
import { mapActions } from 'vuex';
|
2018-10-18 07:50:38 +00:00
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
2018-06-21 12:22:40 +00:00
|
|
|
import noteableDiscussion from '../../notes/components/noteable_discussion.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
noteableDiscussion,
|
2018-10-18 07:50:38 +00:00
|
|
|
Icon,
|
2018-06-21 12:22:40 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
discussions: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-12-13 19:17:19 +00:00
|
|
|
line: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
2018-10-18 07:50:38 +00:00
|
|
|
shouldCollapseDiscussions: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
renderAvatarBadge: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2018-12-13 19:17:19 +00:00
|
|
|
helpPagePath: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2018-06-21 12:22:40 +00:00
|
|
|
},
|
2018-09-03 15:43:35 +00:00
|
|
|
methods: {
|
2018-10-18 07:50:38 +00:00
|
|
|
...mapActions(['toggleDiscussion']),
|
2018-09-03 15:43:35 +00:00
|
|
|
...mapActions('diffs', ['removeDiscussionsFromDiff']),
|
|
|
|
deleteNoteHandler(discussion) {
|
|
|
|
if (discussion.notes.length <= 1) {
|
|
|
|
this.removeDiscussionsFromDiff(discussion);
|
|
|
|
}
|
|
|
|
},
|
2018-10-18 07:50:38 +00:00
|
|
|
isExpanded(discussion) {
|
|
|
|
return this.shouldCollapseDiscussions ? discussion.expanded : true;
|
|
|
|
},
|
2018-09-03 15:43:35 +00:00
|
|
|
},
|
2018-06-21 12:22:40 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-07-09 11:54:15 +00:00
|
|
|
<div>
|
2018-06-21 12:22:40 +00:00
|
|
|
<div
|
2018-10-18 07:50:38 +00:00
|
|
|
v-for="(discussion, index) in discussions"
|
2018-06-21 12:22:40 +00:00
|
|
|
:key="discussion.id"
|
2018-10-18 07:50:38 +00:00
|
|
|
:class="{
|
2018-11-16 20:07:38 +00:00
|
|
|
collapsed: !isExpanded(discussion),
|
2018-10-18 07:50:38 +00:00
|
|
|
}"
|
|
|
|
class="discussion-notes diff-discussions position-relative"
|
2018-06-21 12:22:40 +00:00
|
|
|
>
|
2018-11-16 20:07:38 +00:00
|
|
|
<ul :data-discussion-id="discussion.id" class="notes">
|
2018-10-18 07:50:38 +00:00
|
|
|
<template v-if="shouldCollapseDiscussions">
|
|
|
|
<button
|
|
|
|
:class="{
|
|
|
|
'diff-notes-collapse': discussion.expanded,
|
2018-11-16 20:07:38 +00:00
|
|
|
'btn-transparent badge badge-pill': !discussion.expanded,
|
2018-10-18 07:50:38 +00:00
|
|
|
}"
|
|
|
|
type="button"
|
|
|
|
class="js-diff-notes-toggle"
|
2019-01-10 21:56:37 +00:00
|
|
|
@click="toggleDiscussion({ discussionId: discussion.id })"
|
2018-10-18 07:50:38 +00:00
|
|
|
>
|
2018-11-16 20:07:38 +00:00
|
|
|
<icon v-if="discussion.expanded" name="collapse" class="collapse-icon" />
|
2018-10-18 07:50:38 +00:00
|
|
|
<template v-else>
|
|
|
|
{{ index + 1 }}
|
|
|
|
</template>
|
|
|
|
</button>
|
|
|
|
</template>
|
2018-06-21 12:22:40 +00:00
|
|
|
<noteable-discussion
|
2018-10-18 07:50:38 +00:00
|
|
|
v-show="isExpanded(discussion)"
|
2018-06-21 12:22:40 +00:00
|
|
|
:discussion="discussion"
|
|
|
|
:render-diff-file="false"
|
2018-08-01 02:21:14 +00:00
|
|
|
:discussions-by-diff-order="true"
|
2018-12-13 19:17:19 +00:00
|
|
|
:line="line"
|
|
|
|
:help-page-path="helpPagePath"
|
2018-09-07 14:20:57 +00:00
|
|
|
@noteDeleted="deleteNoteHandler"
|
2018-10-18 07:50:38 +00:00
|
|
|
>
|
2020-05-16 06:07:58 +00:00
|
|
|
<template v-if="renderAvatarBadge" #avatar-badge>
|
|
|
|
<span class="badge badge-pill">
|
|
|
|
{{ index + 1 }}
|
|
|
|
</span>
|
|
|
|
</template>
|
2018-10-18 07:50:38 +00:00
|
|
|
</noteable-discussion>
|
2018-06-21 12:22:40 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|