summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/merge_conflicts/store/mutations.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/merge_conflicts/store/mutations.js')
-rw-r--r--app/assets/javascripts/merge_conflicts/store/mutations.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/assets/javascripts/merge_conflicts/store/mutations.js b/app/assets/javascripts/merge_conflicts/store/mutations.js
new file mode 100644
index 00000000000..2cee55319eb
--- /dev/null
+++ b/app/assets/javascripts/merge_conflicts/store/mutations.js
@@ -0,0 +1,40 @@
+import { VIEW_TYPES } from '../constants';
+import * as types from './mutation_types';
+
+export default {
+ [types.SET_LOADING_STATE]: (state, value) => {
+ state.isLoading = value;
+ },
+ [types.SET_ERROR_STATE]: (state, value) => {
+ state.hasError = value;
+ },
+ [types.SET_FAILED_REQUEST]: (state, value) => {
+ state.hasError = true;
+ state.conflictsData.errorMessage = value;
+ },
+ [types.SET_VIEW_TYPE]: (state, value) => {
+ state.diffView = value;
+ state.isParallel = value === VIEW_TYPES.PARALLEL;
+ },
+ [types.SET_SUBMIT_STATE]: (state, value) => {
+ state.isSubmitting = value;
+ },
+ [types.SET_CONFLICTS_DATA]: (state, data) => {
+ state.conflictsData = {
+ files: data.files,
+ commitMessage: data.commit_message,
+ sourceBranch: data.source_branch,
+ targetBranch: data.target_branch,
+ shortCommitSha: data.commit_sha.slice(0, 7),
+ };
+ },
+ [types.UPDATE_CONFLICTS_DATA]: (state, payload) => {
+ state.conflictsData = {
+ ...state.conflictsData,
+ ...payload,
+ };
+ },
+ [types.UPDATE_FILE]: (state, { file, index }) => {
+ state.conflictsData.files.splice(index, 1, file);
+ },
+};