Skip to content
Snippets Groups Projects

Users can apply multiple suggestions at once.

Merged Jesse Hall requested to merge jessehall3/gitlab-ee:25486-batch-suggestions into master
3 files
+ 20
23
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -519,27 +519,25 @@ export const submitSuggestionBatch = (
{ commit, dispatch, state },
{ flashContainer },
) => {
const suggestionIds = state.batchSuggestionsInfo.map(suggestionInfo => suggestionInfo.suggestionId);
const suggestionIds = state.batchSuggestionsInfo.map(({ suggestionId }) => suggestionId);
const dispatchResolveDiscussion = (discussionId) =>
dispatch('resolveDiscussion', { discussionId }).catch(() => {});
const applyAllSuggestions = () =>
state.batchSuggestionsInfo.map(
(suggestionInfo) => commit(types.APPLY_SUGGESTION, suggestionInfo)
);
const resolveAllDiscussions = () =>
state.batchSuggestionsInfo.map( (suggestionInfo) => {
const { discussionId } = suggestionInfo;
return dispatch('resolveDiscussion', { discussionId }).catch(() => {});
});
commit(types.SET_APPLYING_BATCH_STATE)
commit(types.SET_APPLYING_BATCH_STATE);
return Api.applySuggestionBatch(suggestionIds)
.then(() => {
return Promise.all(state.batchSuggestionsInfo.map((suggestionInfo) => {
return commit(types.APPLY_SUGGESTION, suggestionInfo)
}))
})
.then(() => {
return Promise.all(state.batchSuggestionsInfo.map((suggestionInfo) => {
return dispatchResolveDiscussion(suggestionInfo.discussionId)
}))
})
.then(() => {
return commit(types.CLEAR_SUGGESTION_BATCH)
})
.then(() => Promise.all(applyAllSuggestions()))
.then(() => Promise.all(resolveAllDiscussions()))
.then(() => commit(types.CLEAR_SUGGESTION_BATCH))
.catch(err => {
const defaultMessage = __(
'Something went wrong while applying the batch of suggestions. Please try again.',
Loading