summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo/services/index.js
blob: dc222ccac01e787a43bb62aab7f06cfc77517445 (plain)
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
29
30
31
32
33
import Vue from 'vue';
import VueResource from 'vue-resource';
import Api from '../../api';

Vue.use(VueResource);

export default {
  getTreeData(endpoint) {
    return Vue.http.get(endpoint, { params: { format: 'json' } });
  },
  getFileData(endpoint) {
    return Vue.http.get(endpoint, { params: { format: 'json' } });
  },
  getRawFileData(file) {
    if (file.tempFile) {
      return Promise.resolve(file.content);
    }

    return Vue.http.get(file.rawPath, { params: { format: 'json' } })
      .then(res => res.text());
  },
  getBranchData(projectId, currentBranch) {
    return Api.branchSingle(projectId, currentBranch);
  },
  createBranch(projectId, payload) {
    const url = Api.buildUrl(Api.createBranchPath).replace(':id', projectId);

    return Vue.http.post(url, payload);
  },
  commit(projectId, payload) {
    return Api.commitMultiple(projectId, payload);
  },
};