2018-11-08 19:23:39 +05:30
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2018-05-09 12:01:36 +05:30
|
|
|
import Api from '~/api';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
getFileData(endpoint) {
|
2018-11-08 19:23:39 +05:30
|
|
|
return axios.get(endpoint, {
|
|
|
|
params: { format: 'json', viewer: 'none' },
|
|
|
|
});
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
getRawFileData(file) {
|
2018-11-18 11:00:15 +05:30
|
|
|
if (file.tempFile && !file.prevPath) {
|
2018-05-09 12:01:36 +05:30
|
|
|
return Promise.resolve(file.content);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file.raw) {
|
|
|
|
return Promise.resolve(file.raw);
|
|
|
|
}
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
return axios
|
|
|
|
.get(file.rawPath, {
|
|
|
|
transformResponse: [f => f],
|
|
|
|
})
|
|
|
|
.then(({ data }) => data);
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
getBaseRawFileData(file, sha) {
|
|
|
|
if (file.tempFile) {
|
|
|
|
return Promise.resolve(file.baseRaw);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file.baseRaw) {
|
|
|
|
return Promise.resolve(file.baseRaw);
|
|
|
|
}
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
return axios
|
2018-05-09 12:01:36 +05:30
|
|
|
.get(file.rawPath.replace(`/raw/${file.branchId}/${file.path}`, `/raw/${sha}/${file.path}`), {
|
2018-11-08 19:23:39 +05:30
|
|
|
transformResponse: [f => f],
|
2018-05-09 12:01:36 +05:30
|
|
|
})
|
2018-11-08 19:23:39 +05:30
|
|
|
.then(({ data }) => data);
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
getProjectData(namespace, project) {
|
|
|
|
return Api.project(`${namespace}/${project}`);
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
getProjectMergeRequestData(projectId, mergeRequestId, params = {}) {
|
2019-02-13 22:33:31 +05:30
|
|
|
return Api.projectMergeRequest(projectId, mergeRequestId, params);
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
getProjectMergeRequestChanges(projectId, mergeRequestId) {
|
2019-02-13 22:33:31 +05:30
|
|
|
return Api.projectMergeRequestChanges(projectId, mergeRequestId);
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
getProjectMergeRequestVersions(projectId, mergeRequestId) {
|
2019-02-13 22:33:31 +05:30
|
|
|
return Api.projectMergeRequestVersions(projectId, mergeRequestId);
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
getBranchData(projectId, currentBranchId) {
|
|
|
|
return Api.branchSingle(projectId, currentBranchId);
|
|
|
|
},
|
|
|
|
commit(projectId, payload) {
|
|
|
|
return Api.commitMultiple(projectId, payload);
|
|
|
|
},
|
|
|
|
getFiles(projectUrl, branchId) {
|
|
|
|
const url = `${projectUrl}/files/${branchId}`;
|
2018-11-08 19:23:39 +05:30
|
|
|
return axios.get(url, { params: { format: 'json' } });
|
|
|
|
},
|
|
|
|
lastCommitPipelines({ getters }) {
|
|
|
|
const commitSha = getters.lastCommit.id;
|
|
|
|
return Api.commitPipelines(getters.currentProject.path_with_namespace, commitSha);
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
};
|