Skip to content
Snippets Groups Projects
Verified Commit 1e78aa7c authored by Phil Hughes's avatar Phil Hughes
Browse files

Move frontend batch comments code into core

This moves all the frontend batch comments related code
out of the EE folder and into core

Part of #28154
parent df4787f2
No related branches found
No related tags found
No related merge requests found
Showing
with 79 additions and 11 deletions
import Vue from 'vue';
import { mapActions } from 'vuex';
import store from '~/mr_notes/stores';
import ReviewBar from './components/review_bar.vue';
// eslint-disable-next-line import/prefer-default-export
export const initReviewBar = () => {
const el = document.getElementById('js-review-bar');
// eslint-disable-next-line no-new
new Vue({
el,
store,
mounted() {
this.fetchDrafts();
},
methods: {
...mapActions('batchComments', ['fetchDrafts']),
},
render(createElement) {
return createElement(ReviewBar);
},
});
};
import { sprintf, __ } from '~/locale';
import { mapGetters } from 'vuex';
import { sprintf, s__, __ } from '~/locale';
export default {
props: {
discussionId: {
type: String,
required: false,
default: null,
},
resolveDiscussion: {
type: Boolean,
required: false,
default: false,
},
isDraft: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
...mapGetters(['isDiscussionResolved']),
resolvedStatusMessage() {
let message;
const discussionResolved = this.isDiscussionResolved(
this.draft ? this.draft.discussion_id : this.discussionId,
);
const discussionToBeResolved = this.draft
? this.draft.resolve_discussion
: this.resolveDiscussion;
if (discussionToBeResolved && discussionResolved && !this.$options.showStaysResolved) {
return undefined;
}
if (discussionToBeResolved) {
if (discussionResolved) {
message = s__('MergeRequests|Thread stays resolved');
} else {
message = s__('MergeRequests|Thread will be resolved');
}
} else if (discussionResolved) {
message = s__('MergeRequests|Thread will be unresolved');
} else if (this.$options.showStaysResolved) {
message = s__('MergeRequests|Thread stays unresolved');
}
return message;
},
componentClasses() {
return this.resolveDiscussion ? 'is-resolving-discussion' : 'is-unresolving-discussion';
},
resolveButtonTitle() {
let title = __('Mark comment as resolved');
if (this.isDraft || this.discussionId) return this.resolvedStatusMessage;
let title = __('Mark as resolved');
if (this.resolvedBy) {
title = sprintf(__('Resolved by %{name}'), { name: this.resolvedBy.name });
......@@ -12,4 +63,5 @@ export default {
return title;
},
},
showStaysResolved: true,
};
......@@ -5,10 +5,6 @@ import service from '../../../services/drafts_service';
import * as types from './mutation_types';
import { CHANGES_TAB, DISCUSSION_TAB, SHOW_TAB } from '../../../constants';
export const enableBatchComments = ({ commit }) => {
commit(types.ENABLE_BATCH_COMMENTS);
};
export const saveDraft = ({ dispatch }, draft) =>
dispatch('saveNote', { ...draft, isDraft: true }, { root: true });
......
......@@ -6,10 +6,6 @@ const processDraft = draft => ({
});
export default {
[types.ENABLE_BATCH_COMMENTS](state) {
state.withBatchComments = true;
},
[types.ADD_NEW_DRAFT](state, draft) {
state.drafts.push(processDraft(draft));
},
......
export default () => ({
withBatchComments: false,
withBatchComments: true,
isDraftsFetched: false,
drafts: [],
isPublishing: false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment