debian-mirror-gitlab/app/assets/javascripts/diffs/components/diff_discussions.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

107 lines
2.8 KiB
Vue
Raw Normal View History

2018-11-08 19:23:39 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlIcon } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapActions } from 'vuex';
2022-04-04 11:22:00 +05:30
import DesignNotePin from '~/vue_shared/components/design_management/design_note_pin.vue';
2022-10-11 01:57:18 +05:30
import NoteableDiscussion from '~/notes/components/noteable_discussion.vue';
2018-11-08 19:23:39 +05:30
export default {
components: {
2022-10-11 01:57:18 +05:30
NoteableDiscussion,
2020-11-24 15:15:51 +05:30
GlIcon,
2022-04-04 11:22:00 +05:30
DesignNotePin,
2018-11-08 19:23:39 +05:30
},
props: {
discussions: {
type: Array,
required: true,
},
2019-02-15 15:39:39 +05:30
line: {
type: Object,
required: false,
default: null,
},
2018-12-13 13:39:08 +05:30
shouldCollapseDiscussions: {
type: Boolean,
required: false,
default: false,
},
renderAvatarBadge: {
type: Boolean,
required: false,
default: false,
},
2019-02-15 15:39:39 +05:30
helpPagePath: {
type: String,
required: false,
default: '',
},
2018-11-08 19:23:39 +05:30
},
2018-11-20 20:47:30 +05:30
methods: {
2018-12-13 13:39:08 +05:30
...mapActions(['toggleDiscussion']),
2018-11-20 20:47:30 +05:30
...mapActions('diffs', ['removeDiscussionsFromDiff']),
deleteNoteHandler(discussion) {
if (discussion.notes.length <= 1) {
this.removeDiscussionsFromDiff(discussion);
}
},
2018-12-13 13:39:08 +05:30
isExpanded(discussion) {
return this.shouldCollapseDiscussions ? discussion.expanded : true;
},
2018-11-20 20:47:30 +05:30
},
2018-11-08 19:23:39 +05:30
};
</script>
<template>
<div>
<div
2018-12-13 13:39:08 +05:30
v-for="(discussion, index) in discussions"
2018-11-08 19:23:39 +05:30
:key="discussion.id"
2018-12-13 13:39:08 +05:30
:class="{
2019-02-15 15:39:39 +05:30
collapsed: !isExpanded(discussion),
2018-12-13 13:39:08 +05:30
}"
class="discussion-notes diff-discussions position-relative"
2018-11-08 19:23:39 +05:30
>
2019-02-15 15:39:39 +05:30
<ul :data-discussion-id="discussion.id" class="notes">
2018-12-13 13:39:08 +05:30
<template v-if="shouldCollapseDiscussions">
<button
2022-04-04 11:22:00 +05:30
v-if="discussion.expanded"
class="diff-notes-collapse js-diff-notes-toggle"
2018-12-13 13:39:08 +05:30
type="button"
2021-04-29 21:17:54 +05:30
:aria-label="__('Show comments')"
2019-03-02 22:35:43 +05:30
@click="toggleDiscussion({ discussionId: discussion.id })"
2018-12-13 13:39:08 +05:30
>
2022-04-04 11:22:00 +05:30
<gl-icon name="collapse" class="collapse-icon" />
2018-12-13 13:39:08 +05:30
</button>
2022-04-04 11:22:00 +05:30
<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 })"
/>
2018-12-13 13:39:08 +05:30
</template>
2018-11-08 19:23:39 +05:30
<noteable-discussion
2018-12-13 13:39:08 +05:30
v-show="isExpanded(discussion)"
2018-11-08 19:23:39 +05:30
:discussion="discussion"
:render-diff-file="false"
2018-11-18 11:00:15 +05:30
:discussions-by-diff-order="true"
2019-02-15 15:39:39 +05:30
:line="line"
:help-page-path="helpPagePath"
2023-01-13 00:05:48 +05:30
:should-scroll-to-note="false"
2018-11-20 20:47:30 +05:30
@noteDeleted="deleteNoteHandler"
2018-12-13 13:39:08 +05:30
>
2020-05-24 23:13:21 +05:30
<template v-if="renderAvatarBadge" #avatar-badge>
2022-04-04 11:22:00 +05:30
<design-note-pin
:label="index + 1"
class="user-avatar"
:is-resolved="discussion.resolved"
size="sm"
/>
2020-05-24 23:13:21 +05:30
</template>
2018-12-13 13:39:08 +05:30
</noteable-discussion>
2018-11-08 19:23:39 +05:30
</ul>
</div>
</div>
</template>