Commit 45d8a62a authored by Phil Hughes's avatar Phil Hughes

Merge branch...

Merge branch '9971-move-ee-differences-for-app-assets-javascripts-notes-components-note_form-vue' into 'master'

Resolve "Move EE differences for `app/assets/javascripts/notes/components/note_form.vue`"

Closes #9971

See merge request gitlab-org/gitlab-ee!11151
parents bbf26b9c 9fdd97f9
...@@ -8,7 +8,7 @@ import issuableStateMixin from '../mixins/issuable_state'; ...@@ -8,7 +8,7 @@ import issuableStateMixin from '../mixins/issuable_state';
import resolvable from '../mixins/resolvable'; import resolvable from '../mixins/resolvable';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { getDraft, updateDraft } from '~/lib/utils/autosave'; import { getDraft, updateDraft } from '~/lib/utils/autosave';
import noteFormMixin from 'ee/batch_comments/mixins/note_form'; import noteFormMixin from 'ee_else_ce/notes/mixins/note_form';
export default { export default {
name: 'NoteForm', name: 'NoteForm',
...@@ -196,31 +196,6 @@ export default { ...@@ -196,31 +196,6 @@ export default {
return shouldResolve || shouldToggleState; return shouldResolve || shouldToggleState;
}, },
handleKeySubmit() {
if (this.showBatchCommentsActions) {
this.handleAddToReview();
} else {
this.handleUpdate();
}
},
handleUpdate(shouldResolve) {
const beforeSubmitDiscussionState = this.discussionResolved;
this.isSubmitting = true;
this.$emit(
'handleFormUpdate',
this.updatedNoteBody,
this.$refs.editNoteForm,
() => {
this.isSubmitting = false;
if (this.shouldToggleResolved(shouldResolve, beforeSubmitDiscussionState)) {
this.resolveHandler(beforeSubmitDiscussionState);
}
},
this.discussionResolved ? !this.isUnresolving : this.isResolving,
);
},
editMyLastNote() { editMyLastNote() {
if (this.updatedNoteBody === '') { if (this.updatedNoteBody === '') {
const lastNoteInDiscussion = this.getDiscussionLastNote(this.discussion); const lastNoteInDiscussion = this.getDiscussionLastNote(this.discussion);
...@@ -290,48 +265,50 @@ export default { ...@@ -290,48 +265,50 @@ export default {
></textarea> ></textarea>
</markdown-field> </markdown-field>
<div class="note-form-actions clearfix"> <div class="note-form-actions clearfix">
<p v-if="showResolveDiscussionToggle"> <template v-if="showBatchCommentsActions">
<label> <p v-if="showResolveDiscussionToggle">
<template v-if="discussionResolved"> <label>
<input <template v-if="discussionResolved">
v-model="isUnresolving" <input
type="checkbox" v-model="isUnresolving"
class="qa-unresolve-review-discussion" type="checkbox"
/> class="qa-unresolve-review-discussion"
{{ __('Unresolve discussion') }} />
</template> {{ __('Unresolve discussion') }}
<template v-else> </template>
<input v-model="isResolving" type="checkbox" class="qa-resolve-review-discussion" /> <template v-else>
{{ __('Resolve discussion') }} <input v-model="isResolving" type="checkbox" class="qa-resolve-review-discussion" />
</template> {{ __('Resolve discussion') }}
</label> </template>
</p> </label>
<div v-if="showBatchCommentsActions"> </p>
<button <div>
:disabled="isDisabled" <button
type="button" :disabled="isDisabled"
class="btn btn-success qa-start-review" type="button"
@click="handleAddToReview" class="btn btn-success qa-start-review"
> @click="handleAddToReview"
<template v-if="hasDrafts">{{ __('Add to review') }}</template> >
<template v-else>{{ __('Start a review') }}</template> <template v-if="hasDrafts">{{ __('Add to review') }}</template>
</button> <template v-else>{{ __('Start a review') }}</template>
<button </button>
:disabled="isDisabled" <button
type="button" :disabled="isDisabled"
class="btn qa-comment-now" type="button"
@click="handleUpdate()" class="btn qa-comment-now"
> @click="handleUpdate()"
{{ __('Add comment now') }} >
</button> {{ __('Add comment now') }}
<button </button>
class="btn btn-cancel note-edit-cancel js-close-discussion-note-form" <button
type="button" class="btn btn-cancel note-edit-cancel js-close-discussion-note-form"
@click="cancelHandler()" type="button"
> @click="cancelHandler()"
{{ __('Cancel') }} >
</button> {{ __('Cancel') }}
</div> </button>
</div>
</template>
<template v-else> <template v-else>
<button <button
:disabled="isDisabled" :disabled="isDisabled"
......
export default {
data() {
return {
showBatchCommentsActions: false,
};
},
methods: {
handleKeySubmit() {
this.handleUpdate();
},
handleUpdate(shouldResolve) {
const beforeSubmitDiscussionState = this.discussionResolved;
this.isSubmitting = true;
this.$emit('handleFormUpdate', this.updatedNoteBody, this.$refs.editNoteForm, () => {
this.isSubmitting = false;
if (this.shouldToggleResolved(shouldResolve, beforeSubmitDiscussionState)) {
this.resolveHandler(beforeSubmitDiscussionState);
}
});
},
},
};
...@@ -24,6 +24,31 @@ export default { ...@@ -24,6 +24,31 @@ export default {
}, },
}, },
methods: { methods: {
handleKeySubmit() {
if (this.showBatchCommentsActions) {
this.handleAddToReview();
} else {
this.handleUpdate();
}
},
handleUpdate(shouldResolve) {
const beforeSubmitDiscussionState = this.discussionResolved;
this.isSubmitting = true;
this.$emit(
'handleFormUpdate',
this.updatedNoteBody,
this.$refs.editNoteForm,
() => {
this.isSubmitting = false;
if (this.shouldToggleResolved(shouldResolve, beforeSubmitDiscussionState)) {
this.resolveHandler(beforeSubmitDiscussionState);
}
},
this.discussionResolved ? !this.isUnresolving : this.isResolving,
);
},
shouldBeResolved(resolveStatus) { shouldBeResolved(resolveStatus) {
if (this.withBatchComments) { if (this.withBatchComments) {
return ( return (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment