2020-06-23 00:09:42 +05:30
|
|
|
<script>
|
2022-04-04 11:22:00 +05:30
|
|
|
import { GlButton, GlSafeHtmlDirective, GlBadge } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex';
|
2022-08-13 15:12:31 +05:30
|
|
|
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
2020-06-23 00:09:42 +05:30
|
|
|
import NoteableNote from '~/notes/components/noteable_note.vue';
|
|
|
|
import PublishButton from './publish_button.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
NoteableNote,
|
|
|
|
PublishButton,
|
2020-10-24 23:57:45 +05:30
|
|
|
GlButton,
|
2022-04-04 11:22:00 +05:30
|
|
|
GlBadge,
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
2021-12-11 22:18:48 +05:30
|
|
|
directives: {
|
|
|
|
SafeHtml: GlSafeHtmlDirective,
|
|
|
|
},
|
2022-08-13 15:12:31 +05:30
|
|
|
mixins: [glFeatureFlagMixin()],
|
2020-06-23 00:09:42 +05:30
|
|
|
props: {
|
|
|
|
draft: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
line: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isEditingDraft: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState('batchComments', ['isPublishing']),
|
|
|
|
...mapGetters('batchComments', ['isPublishingDraft']),
|
|
|
|
draftCommands() {
|
|
|
|
return this.draft.references.commands;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (window.location.hash && window.location.hash === `#note_${this.draft.id}`) {
|
|
|
|
this.scrollToDraft(this.draft);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions('batchComments', [
|
|
|
|
'deleteDraft',
|
|
|
|
'updateDraft',
|
|
|
|
'publishSingleDraft',
|
|
|
|
'scrollToDraft',
|
|
|
|
'toggleResolveDiscussion',
|
|
|
|
]),
|
2020-07-28 23:09:34 +05:30
|
|
|
...mapActions(['setSelectedCommentPositionHover']),
|
2020-06-23 00:09:42 +05:30
|
|
|
update(data) {
|
|
|
|
this.updateDraft(data);
|
|
|
|
},
|
|
|
|
publishNow() {
|
|
|
|
this.publishSingleDraft(this.draft.id);
|
|
|
|
},
|
|
|
|
handleEditing() {
|
|
|
|
this.isEditingDraft = true;
|
|
|
|
},
|
|
|
|
handleNotEditing() {
|
|
|
|
this.isEditingDraft = false;
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
handleMouseEnter(draft) {
|
2021-03-11 19:13:27 +05:30
|
|
|
if (draft.position) {
|
2020-10-24 23:57:45 +05:30
|
|
|
this.setSelectedCommentPositionHover(draft.position.line_range);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleMouseLeave(draft) {
|
2021-03-11 19:13:27 +05:30
|
|
|
// Even though position isn't used here we still don't want to unnecessarily call a mutation
|
2020-10-24 23:57:45 +05:30
|
|
|
// The lack of position tells us that highlighting is irrelevant in this context
|
2021-03-11 19:13:27 +05:30
|
|
|
if (draft.position) {
|
2020-10-24 23:57:45 +05:30
|
|
|
this.setSelectedCommentPositionHover();
|
|
|
|
}
|
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
2021-12-11 22:18:48 +05:30
|
|
|
safeHtmlConfig: {
|
2022-01-26 12:08:38 +05:30
|
|
|
ADD_TAGS: ['use', 'gl-emoji', 'copy-code'],
|
2021-12-11 22:18:48 +05:30
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2020-07-28 23:09:34 +05:30
|
|
|
<article
|
|
|
|
class="draft-note-component note-wrapper"
|
2020-10-24 23:57:45 +05:30
|
|
|
@mouseenter="handleMouseEnter(draft)"
|
|
|
|
@mouseleave="handleMouseLeave(draft)"
|
2020-07-28 23:09:34 +05:30
|
|
|
>
|
2020-06-23 00:09:42 +05:30
|
|
|
<ul class="notes draft-notes">
|
|
|
|
<noteable-note
|
|
|
|
:note="draft"
|
|
|
|
:line="line"
|
2020-07-28 23:09:34 +05:30
|
|
|
:discussion-root="true"
|
2022-08-13 15:12:31 +05:30
|
|
|
:class="{ 'gl-mb-0!': glFeatures.mrReviewSubmitComment }"
|
2020-06-23 00:09:42 +05:30
|
|
|
class="draft-note"
|
|
|
|
@handleEdit="handleEditing"
|
|
|
|
@cancelForm="handleNotEditing"
|
|
|
|
@updateSuccess="handleNotEditing"
|
|
|
|
@handleDeleteNote="deleteDraft"
|
|
|
|
@handleUpdateNote="update"
|
|
|
|
@toggleResolveStatus="toggleResolveDiscussion(draft.id)"
|
|
|
|
>
|
2021-09-30 23:02:18 +05:30
|
|
|
<template #note-header-info>
|
2022-04-04 11:22:00 +05:30
|
|
|
<gl-badge variant="warning" class="gl-mr-2">{{ __('Pending') }}</gl-badge>
|
2021-09-30 23:02:18 +05:30
|
|
|
</template>
|
2020-06-23 00:09:42 +05:30
|
|
|
</noteable-note>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<template v-if="!isEditingDraft">
|
|
|
|
<div
|
|
|
|
v-if="draftCommands"
|
2021-12-11 22:18:48 +05:30
|
|
|
v-safe-html:[$options.safeHtmlConfig]="draftCommands"
|
2020-06-23 00:09:42 +05:30
|
|
|
class="referenced-commands draft-note-commands"
|
|
|
|
></div>
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
<p
|
|
|
|
v-if="!glFeatures.mrReviewSubmitComment"
|
|
|
|
class="draft-note-actions d-flex"
|
|
|
|
data-qa-selector="draft_note_content"
|
|
|
|
>
|
2022-04-04 11:22:00 +05:30
|
|
|
<publish-button
|
|
|
|
:show-count="true"
|
|
|
|
:should-publish="false"
|
|
|
|
category="secondary"
|
|
|
|
:disabled="isPublishingDraft(draft.id)"
|
|
|
|
/>
|
2020-10-24 23:57:45 +05:30
|
|
|
<gl-button
|
2022-04-04 11:22:00 +05:30
|
|
|
:disabled="isPublishing"
|
|
|
|
:loading="isPublishingDraft(draft.id)"
|
2020-10-24 23:57:45 +05:30
|
|
|
class="gl-ml-3"
|
2020-06-23 00:09:42 +05:30
|
|
|
@click="publishNow"
|
2020-10-24 23:57:45 +05:30
|
|
|
>
|
|
|
|
{{ __('Add comment now') }}
|
|
|
|
</gl-button>
|
2020-06-23 00:09:42 +05:30
|
|
|
</p>
|
|
|
|
</template>
|
|
|
|
</article>
|
|
|
|
</template>
|