projects: add checkbox to pass variables to forked PR

This commit is contained in:
Carlo Mandelli 2020-01-28 16:18:22 +01:00
parent 2878905257
commit b7dfeddcbb
3 changed files with 23 additions and 6 deletions

View File

@ -14,7 +14,12 @@
Private Private
</label> </label>
</div> </div>
<div class="mb-4">
<label class="checkbox">
<input type="checkbox" v-model="pass_vars_to_forked_pr" />
Pass variables to run even if triggered by PR from forked repo (DANGEROUS)
</label>
</div>
<div class="mb-3 flex items-center"> <div class="mb-3 flex items-center">
<div class="flex relative w-64"> <div class="flex relative w-64">
<select <select
@ -165,7 +170,8 @@ export default {
this.projectName, this.projectName,
visibility, visibility,
remoteSource.name, remoteSource.name,
this.remoteRepoPath this.remoteRepoPath,
this.pass_vars_to_forked_pr
); );
this.stopProjectLoading(); this.stopProjectLoading();
if (error) { if (error) {

View File

@ -18,6 +18,12 @@
Private Private
</label> </label>
</div> </div>
<div class="mb-4">
<label class="checkbox">
<input type="checkbox" v-model="project.pass_vars_to_forked_pr" />
Pass variables to run even if triggered by PR from forked repo (DANGEROUS)
</label>
</div>
<button class="btn btn-blue" @click="updateProject()">Update</button> <button class="btn btn-blue" @click="updateProject()">Update</button>
<div <div
v-if="updateProjectError" v-if="updateProjectError"
@ -178,7 +184,8 @@ export default {
let { error } = await updateProject( let { error } = await updateProject(
projectref, projectref,
this.project.name, this.project.name,
visibility visibility,
this.project.pass_vars_to_forked_pr
); );
if (error) { if (error) {
this.updateProjectError = error; this.updateProjectError = error;
@ -235,6 +242,7 @@ export default {
this.$store.dispatch("setError", error); this.$store.dispatch("setError", error);
return; return;
} }
this.project = data; this.project = data;
this.projectIsPrivate = this.project.visibility == "private"; this.projectIsPrivate = this.project.visibility == "private";

View File

@ -335,6 +335,7 @@ export async function createProject(
visibility, visibility,
remotesourcename, remotesourcename,
remoterepopath, remoterepopath,
passvarstoforkedpr,
signal signal
) { ) {
let path = "/projects"; let path = "/projects";
@ -345,19 +346,21 @@ export async function createProject(
parent_ref: parentref, parent_ref: parentref,
visibility: visibility, visibility: visibility,
remote_source_name: remotesourcename, remote_source_name: remotesourcename,
repo_path: remoterepopath repo_path: remoterepopath,
pass_vars_to_forked_pr: passvarstoforkedpr
}) })
}; };
return await fetch(apiurl(path), init, signal); return await fetch(apiurl(path), init, signal);
} }
export async function updateProject(projectref, name, visibility, signal) { export async function updateProject(projectref, name, visibility, passvarstoforkedpr, signal) {
let path = "/projects/" + encodeURIComponent(projectref); let path = "/projects/" + encodeURIComponent(projectref);
let init = { let init = {
method: "PUT", method: "PUT",
body: JSON.stringify({ body: JSON.stringify({
name: name, name: name,
visibility: visibility visibility: visibility,
pass_vars_to_forked_pr: passvarstoforkedpr
}) })
}; };
return await fetch(apiurl(path), init, signal); return await fetch(apiurl(path), init, signal);