branch.js 732 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
import * as types from '../mutation_types';

export default {
  [types.SET_CURRENT_BRANCH](state, currentBranchId) {
    Object.assign(state, {
      currentBranchId,
    });
  },
  [types.SET_BRANCH](state, { projectPath, branchName, branch }) {
    // Add client side properties
    Object.assign(branch, {
      treeId: `${projectPath}/${branchName}`,
      active: true,
      workingReference: '',
    });

    Object.assign(state.projects[projectPath], {
      branches: {
        [branchName]: branch,
      },
    });
  },
  [types.SET_BRANCH_WORKING_REFERENCE](state, { projectId, branchId, reference }) {
    Object.assign(state.projects[projectId].branches[branchId], {
      workingReference: reference,
    });
  },
};