project(group)create: add private checkbox

This commit is contained in:
Simone Gotti 2019-05-14 14:24:40 +02:00
parent 5d6f6b8290
commit 4a7baaab02
3 changed files with 38 additions and 6 deletions

View File

@ -6,6 +6,15 @@
<input class="input" type="text" placeholder="Project name" v-model="projectName">
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" v-model="projectIsPrivate">
Private
</label>
</div>
</div>
<h4 class="title is-4">Available remote repositories</h4>
<div v-for="remoteSource in remoteSources" v-bind:key="remoteSource.id">
<remoterepos
@ -59,6 +68,7 @@ export default {
remoteSources: null,
remoteRepos: [],
projectName: "",
projectIsPrivate: false,
remoteRepoPath: null,
selectedRemoteSource: null
};
@ -94,10 +104,16 @@ export default {
}
let parentref = refArray.join("/");
let visibility = "public";
if (this.projectIsPrivate) {
visibility = "private";
}
this.startProjectLoading();
let { error } = await createProject(
parentref,
this.projectName,
visibility,
this.selectedRemoteSource.name,
this.remoteRepoPath
);

View File

@ -11,6 +11,15 @@
>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" v-model="projectGroupIsPrivate">
Private
</label>
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button
@ -45,7 +54,8 @@ export default {
createProjectGroupError: null,
createProjectGroupLoading: false,
createProjectGroupLoadingTimeout: null,
projectGroupName: ""
projectGroupName: "",
projectGroupIsPrivate: false
};
},
computed: {
@ -75,10 +85,16 @@ export default {
}
let parentref = refArray.join("/");
let visibility = "public";
if (this.projectGroupIsPrivate) {
visibility = "private";
}
this.startProjectGroupLoading();
let { error } = await createProjectGroup(
parentref,
this.projectGroupName
this.projectGroupName,
visibility
);
this.stopProjectGroupLoading();
if (error) {

View File

@ -196,27 +196,27 @@ export async function userRemoteRepos(remotesourceid) {
return await fetch(apiurl(path));
}
export async function createProjectGroup(parentref, name) {
export async function createProjectGroup(parentref, name, visibility) {
let path = "/projectgroups"
let init = {
method: "POST",
body: JSON.stringify({
name: name,
parent_ref: parentref,
visibility: "public",
visibility: visibility
})
}
return await fetch(apiurl(path), init)
}
export async function createProject(parentref, name, remotesourcename, remoterepopath) {
export async function createProject(parentref, name, visibility, remotesourcename, remoterepopath) {
let path = "/projects"
let init = {
method: "POST",
body: JSON.stringify({
name: name,
parent_ref: parentref,
visibility: "public",
visibility: visibility,
remote_source_name: remotesourcename,
repo_path: remoterepopath,
})