summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes/stores/actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/notes/stores/actions.js')
-rw-r--r--app/assets/javascripts/notes/stores/actions.js41
1 files changed, 17 insertions, 24 deletions
diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js
index 1fe5d6c2955..c6684efed4d 100644
--- a/app/assets/javascripts/notes/stores/actions.js
+++ b/app/assets/javascripts/notes/stores/actions.js
@@ -141,7 +141,7 @@ export const updateNote = ({ commit, dispatch }, { endpoint, note }) =>
export const updateOrCreateNotes = ({ commit, state, getters, dispatch }, notes) => {
const { notesById } = getters;
- const debouncedFetchDiscussions = isFetching => {
+ const debouncedFetchDiscussions = (isFetching) => {
if (!isFetching) {
commit(types.SET_FETCHING_DISCUSSIONS, true);
dispatch('fetchDiscussions', { path: state.notesData.discussionsPath });
@@ -159,7 +159,7 @@ export const updateOrCreateNotes = ({ commit, state, getters, dispatch }, notes)
}
};
- notes.forEach(note => {
+ notes.forEach((note) => {
if (notesById[note.id]) {
commit(types.UPDATE_NOTE, note);
} else if (note.type === constants.DISCUSSION_NOTE || note.type === constants.DIFF_NOTE) {
@@ -329,7 +329,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
}
}
- const processQuickActions = res => {
+ const processQuickActions = (res) => {
const { errors: { commands_only: message } = { commands_only: null } } = res;
/*
The following reply means that quick actions have been successfully applied:
@@ -347,7 +347,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return res;
};
- const processEmojiAward = res => {
+ const processEmojiAward = (res) => {
const { commands_changes: commandsChanges } = res;
const { emoji_award: emojiAward } = commandsChanges || {};
if (!emojiAward) {
@@ -357,7 +357,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
const votesBlock = $('.js-awards-block').eq(0);
return loadAwardsHandler()
- .then(awardsHandler => {
+ .then((awardsHandler) => {
awardsHandler.addAwardToEmojiBar(votesBlock, emojiAward);
awardsHandler.scrollToAwards();
})
@@ -371,7 +371,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
.then(() => res);
};
- const processTimeTracking = res => {
+ const processTimeTracking = (res) => {
const { commands_changes: commandsChanges } = res;
const { spend_time: spendTime, time_estimate: timeEstimate } = commandsChanges || {};
if (spendTime != null || timeEstimate != null) {
@@ -383,7 +383,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return res;
};
- const removePlaceholder = res => {
+ const removePlaceholder = (res) => {
if (replyId) {
commit(types.REMOVE_PLACEHOLDER_NOTES);
}
@@ -391,7 +391,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return res;
};
- const processErrors = error => {
+ const processErrors = (error) => {
if (error.response) {
const {
response: { data = {} },
@@ -435,7 +435,7 @@ const pollSuccessCallBack = (resp, commit, state, getters, dispatch) => {
return resp;
};
-const getFetchDataParams = state => {
+const getFetchDataParams = (state) => {
const endpoint = state.notesData.notesPath;
const options = {
headers: {
@@ -559,7 +559,7 @@ export const updateResolvableDiscussionsCounts = ({ commit }) =>
export const submitSuggestion = (
{ commit, dispatch },
- { discussionId, noteId, suggestionId, flashContainer },
+ { discussionId, suggestionId, flashContainer, message },
) => {
const dispatchResolveDiscussion = () =>
dispatch('resolveDiscussion', { discussionId }).catch(() => {});
@@ -567,10 +567,9 @@ export const submitSuggestion = (
commit(types.SET_RESOLVING_DISCUSSION, true);
dispatch('stopPolling');
- return Api.applySuggestion(suggestionId)
- .then(() => commit(types.APPLY_SUGGESTION, { discussionId, noteId, suggestionId }))
+ return Api.applySuggestion(suggestionId, message)
.then(dispatchResolveDiscussion)
- .catch(err => {
+ .catch((err) => {
const defaultMessage = __(
'Something went wrong while applying the suggestion. Please try again.',
);
@@ -590,13 +589,8 @@ export const submitSuggestion = (
export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContainer }) => {
const suggestionIds = state.batchSuggestionsInfo.map(({ suggestionId }) => suggestionId);
- const applyAllSuggestions = () =>
- state.batchSuggestionsInfo.map(suggestionInfo =>
- commit(types.APPLY_SUGGESTION, suggestionInfo),
- );
-
const resolveAllDiscussions = () =>
- state.batchSuggestionsInfo.map(suggestionInfo => {
+ state.batchSuggestionsInfo.map((suggestionInfo) => {
const { discussionId } = suggestionInfo;
return dispatch('resolveDiscussion', { discussionId }).catch(() => {});
});
@@ -606,10 +600,9 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
dispatch('stopPolling');
return Api.applySuggestionBatch(suggestionIds)
- .then(() => Promise.all(applyAllSuggestions()))
.then(() => Promise.all(resolveAllDiscussions()))
.then(() => commit(types.CLEAR_SUGGESTION_BATCH))
- .catch(err => {
+ .catch((err) => {
const defaultMessage = __(
'Something went wrong while applying the batch of suggestions. Please try again.',
);
@@ -652,10 +645,10 @@ export const fetchDescriptionVersion = ({ dispatch }, { endpoint, startingVersio
return axios
.get(requestUrl)
- .then(res => {
+ .then((res) => {
dispatch('receiveDescriptionVersion', { descriptionVersion: res.data, versionId });
})
- .catch(error => {
+ .catch((error) => {
dispatch('receiveDescriptionVersionError', error);
Flash(__('Something went wrong while fetching description changes. Please try again.'));
});
@@ -687,7 +680,7 @@ export const softDeleteDescriptionVersion = (
.then(() => {
dispatch('receiveDeleteDescriptionVersion', versionId);
})
- .catch(error => {
+ .catch((error) => {
dispatch('receiveDeleteDescriptionVersionError', error);
Flash(__('Something went wrong while deleting description changes. Please try again.'));