diff options
Diffstat (limited to 'app/assets/javascripts/batch_comments')
5 files changed, 31 insertions, 33 deletions
diff --git a/app/assets/javascripts/batch_comments/components/preview_item.vue b/app/assets/javascripts/batch_comments/components/preview_item.vue index dca6d90fbcb..3e93168f0e2 100644 --- a/app/assets/javascripts/batch_comments/components/preview_item.vue +++ b/app/assets/javascripts/batch_comments/components/preview_item.vue @@ -47,7 +47,7 @@ export default { } return sprintf(__("%{authorsName}'s thread"), { - authorsName: this.discussion.notes.find(note => !note.system).author.name, + authorsName: this.discussion.notes.find((note) => !note.system).author.name, }); }, linePosition() { @@ -98,9 +98,7 @@ export default { {{ titleText }} </span> <template v-if="showLinePosition"> - <template v-if="!glFeatures.multilineComments" - >:{{ linePosition }}</template - > + <template v-if="!glFeatures.multilineComments">:{{ linePosition }}</template> <template v-else-if="startLineNumber === endLineNumber"> :<span :class="getLineClasses(startLineNumber)">{{ startLineNumber }}</span> </template> diff --git a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js index ebd821125fb..a29409c52ae 100644 --- a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js +++ b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js @@ -11,8 +11,8 @@ export const saveDraft = ({ dispatch }, draft) => export const addDraftToDiscussion = ({ commit }, { endpoint, data }) => service .addDraftToDiscussion(endpoint, data) - .then(res => res.data) - .then(res => { + .then((res) => res.data) + .then((res) => { commit(types.ADD_NEW_DRAFT, res); return res; }) @@ -23,8 +23,8 @@ export const addDraftToDiscussion = ({ commit }, { endpoint, data }) => export const createNewDraft = ({ commit }, { endpoint, data }) => service .createNewDraft(endpoint, data) - .then(res => res.data) - .then(res => { + .then((res) => res.data) + .then((res) => { commit(types.ADD_NEW_DRAFT, res); return res; }) @@ -43,8 +43,8 @@ export const deleteDraft = ({ commit, getters }, draft) => export const fetchDrafts = ({ commit, getters }) => service .fetchDrafts(getters.getNotesData.draftsPath) - .then(res => res.data) - .then(data => commit(types.SET_BATCH_COMMENTS_DRAFTS, data)) + .then((res) => res.data) + .then((data) => commit(types.SET_BATCH_COMMENTS_DRAFTS, data)) .catch(() => flash(__('An error occurred while fetching pending comments'))); export const publishSingleDraft = ({ commit, dispatch, getters }, draftId) => { @@ -86,8 +86,8 @@ export const updateDraft = ( resolveDiscussion, position: JSON.stringify(position), }) - .then(res => res.data) - .then(data => commit(types.RECEIVE_DRAFT_UPDATE_SUCCESS, data)) + .then((res) => res.data) + .then((data) => commit(types.RECEIVE_DRAFT_UPDATE_SUCCESS, data)) .then(callback) .catch(() => flash(__('An error occurred while updating the comment'))); @@ -116,8 +116,8 @@ export const scrollToDraft = ({ dispatch, rootGetters }, draft) => { export const expandAllDiscussions = ({ dispatch, state }) => state.drafts - .filter(draft => draft.discussion_id) - .forEach(draft => { + .filter((draft) => draft.discussion_id) + .forEach((draft) => { dispatch('expandDiscussion', { discussionId: draft.discussion_id }, { root: true }); }); diff --git a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/getters.js b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/getters.js index 22ae6c2e970..df5214ea7ab 100644 --- a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/getters.js +++ b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/getters.js @@ -1,12 +1,12 @@ import { parallelLineKey, showDraftOnSide } from '../../../utils'; -export const draftsCount = state => state.drafts.length; +export const draftsCount = (state) => state.drafts.length; export const getNotesData = (state, getters, rootState, rootGetters) => rootGetters.getNotesData; -export const hasDrafts = state => state.drafts.length > 0; +export const hasDrafts = (state) => state.drafts.length > 0; -export const draftsPerDiscussionId = state => +export const draftsPerDiscussionId = (state) => state.drafts.reduce((acc, draft) => { if (draft.discussion_id) { acc[draft.discussion_id] = draft; @@ -15,7 +15,7 @@ export const draftsPerDiscussionId = state => return acc; }, {}); -export const draftsPerFileHashAndLine = state => +export const draftsPerFileHashAndLine = (state) => state.drafts.reduce((acc, draft) => { if (draft.file_hash) { if (!acc[draft.file_hash]) { @@ -55,10 +55,10 @@ export const hasParallelDraftRight = (state, getters) => (diffFileSha, line) => return draftsForFile ? Boolean(draftsForFile[rkey]) : false; }; -export const shouldRenderDraftRowInDiscussion = (state, getters) => discussionId => +export const shouldRenderDraftRowInDiscussion = (state, getters) => (discussionId) => typeof getters.draftsPerDiscussionId[discussionId] !== 'undefined'; -export const draftForDiscussion = (state, getters) => discussionId => +export const draftForDiscussion = (state, getters) => (discussionId) => getters.draftsPerDiscussionId[discussionId] || {}; export const draftForLine = (state, getters) => (diffFileSha, line, side = null) => { @@ -75,10 +75,10 @@ export const draftForLine = (state, getters) => (diffFileSha, line, side = null) return {}; }; -export const draftsForFile = state => diffFileSha => - state.drafts.filter(draft => draft.file_hash === diffFileSha); +export const draftsForFile = (state) => (diffFileSha) => + state.drafts.filter((draft) => draft.file_hash === diffFileSha); -export const isPublishingDraft = state => draftId => +export const isPublishingDraft = (state) => (draftId) => state.currentlyPublishingDrafts.indexOf(draftId) !== -1; -export const sortedDrafts = state => [...state.drafts].sort((a, b) => a.id > b.id); +export const sortedDrafts = (state) => [...state.drafts].sort((a, b) => a.id > b.id); diff --git a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutations.js b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutations.js index 731f4b6d12a..dabfe864575 100644 --- a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutations.js +++ b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutations.js @@ -1,6 +1,6 @@ import * as types from './mutation_types'; -const processDraft = draft => ({ +const processDraft = (draft) => ({ ...draft, isDraft: true, }); @@ -11,7 +11,7 @@ export default { }, [types.DELETE_DRAFT](state, draftId) { - state.drafts = state.drafts.filter(draft => draft.id !== draftId); + state.drafts = state.drafts.filter((draft) => draft.id !== draftId); }, [types.SET_BATCH_COMMENTS_DRAFTS](state, drafts) { @@ -23,13 +23,13 @@ export default { }, [types.RECEIVE_PUBLISH_DRAFT_SUCCESS](state, draftId) { state.currentlyPublishingDrafts = state.currentlyPublishingDrafts.filter( - publishingDraftId => publishingDraftId !== draftId, + (publishingDraftId) => publishingDraftId !== draftId, ); - state.drafts = state.drafts.filter(d => d.id !== draftId); + state.drafts = state.drafts.filter((d) => d.id !== draftId); }, [types.RECEIVE_PUBLISH_DRAFT_ERROR](state, draftId) { state.currentlyPublishingDrafts = state.currentlyPublishingDrafts.filter( - publishingDraftId => publishingDraftId !== draftId, + (publishingDraftId) => publishingDraftId !== draftId, ); }, @@ -44,14 +44,14 @@ export default { state.isPublishing = false; }, [types.RECEIVE_DRAFT_UPDATE_SUCCESS](state, data) { - const index = state.drafts.findIndex(draft => draft.id === data.id); + const index = state.drafts.findIndex((draft) => draft.id === data.id); if (index >= 0) { state.drafts.splice(index, 1, processDraft(data)); } }, [types.TOGGLE_RESOLVE_DISCUSSION](state, draftId) { - state.drafts = state.drafts.map(draft => { + state.drafts = state.drafts.map((draft) => { if (draft.id === draftId) { return { ...draft, diff --git a/app/assets/javascripts/batch_comments/utils.js b/app/assets/javascripts/batch_comments/utils.js index cf4f7af0ebb..387e7e4a610 100644 --- a/app/assets/javascripts/batch_comments/utils.js +++ b/app/assets/javascripts/batch_comments/utils.js @@ -1,11 +1,11 @@ import { getFormData } from '~/diffs/store/utils'; -export const getDraftReplyFormData = data => ({ +export const getDraftReplyFormData = (data) => ({ endpoint: data.notesData.draftsPath, data, }); -export const getDraftFormData = params => ({ +export const getDraftFormData = (params) => ({ endpoint: params.notesData.draftsPath, data: getFormData(params), }); |