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

View File

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

View File

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