Commit 28d6fd18 authored by Jacob Schatz's avatar Jacob Schatz

Attempts (unsuccessfully) a POST call to make commits.

parent fcd23d55
...@@ -96,12 +96,15 @@ const Api = { ...@@ -96,12 +96,15 @@ const Api = {
.done(projects => callback(projects)); .done(projects => callback(projects));
}, },
commitMultiple(id, data, callback) { commitMultiple(id, data, callback, token) {
// see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
const url = Api.buildUrl(Api.commitPath) const url = Api.buildUrl(Api.commitPath)
.replace(':id', id); .replace(':id', id);
return $.ajax({ return $.ajax({
url, url,
headers: {
'PRIVATE_TOKEN': token,
},
type: 'POST', type: 'POST',
data: data, data: data,
dataType: 'json', dataType: 'json',
......
...@@ -21,6 +21,7 @@ function initRepo() { ...@@ -21,6 +21,7 @@ function initRepo() {
Store.service.refsUrl = repo.dataset.refsUrl; Store.service.refsUrl = repo.dataset.refsUrl;
Store.currentBranch = $("button.dropdown-menu-toggle").attr('data-ref'); Store.currentBranch = $("button.dropdown-menu-toggle").attr('data-ref');
Store.checkIsCommitable(); Store.checkIsCommitable();
Store.projectId = repo.dataset.projectId;
new Vue({ new Vue({
el: repo, el: repo,
......
<script> <script>
import Vue from 'vue'; import Vue from 'vue';
import Store from './repo_store'; import Store from './repo_store';
import Api from '../api'
const RepoCommitSection = { const RepoCommitSection = {
data: () => Store, data: () => Store,
...@@ -28,7 +29,9 @@ const RepoCommitSection = { ...@@ -28,7 +29,9 @@ const RepoCommitSection = {
commit_message: commitMessage, commit_message: commitMessage,
actions: actions, actions: actions,
} }
console.log(branch, commitMessage, actions); Api.commitMultiple(Store.projectId, payload, (data) => {
console.log('got back', data);
})
} }
}, },
......
...@@ -10,6 +10,7 @@ const RepoStore = { ...@@ -10,6 +10,7 @@ const RepoStore = {
editMode: false, editMode: false,
isTree: false, isTree: false,
prevURL: '', prevURL: '',
projectId: '',
projectName: '', projectName: '',
trees: [], trees: [],
blobs: [], blobs: [],
......
#repo{ data: { url: repo_url(@project), 'project-name' => @project.name, refs_url: refs_namespace_project_path(@project.namespace, @project, format: "json"), project_url: namespace_project_path(@project.namespace, @project) } } #repo{ data: { url: repo_url(@project), 'project-name' => @project.name, refs_url: refs_namespace_project_path(@project.namespace, @project, format: "json"), project_url: namespace_project_path(@project.namespace, @project), project_id: @project.id } }
- if can_edit_tree? - if can_edit_tree?
= render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: project_create_blob_path(@project, @id), method: :post = render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: project_create_blob_path(@project, @id), method: :post
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment