1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

ability to activate an inactive repository

This commit is contained in:
Brad 2014-06-05 17:10:58 -07:00
parent 6a57b1b626
commit 2163f2da57
5 changed files with 61 additions and 14 deletions

View File

@ -50,7 +50,7 @@ func (h *RepoHandler) GetRepo(w http.ResponseWriter, r *http.Request) error {
return json.NewEncoder(w).Encode(repo)
}
// PostRepo gets the named repository.
// PostRepo activates the named repository.
// POST /v1/repos/:host/:owner/:name
func (h *RepoHandler) PostRepo(w http.ResponseWriter, r *http.Request) error {
var host, owner, name = parseRepo(r)

View File

@ -3482,12 +3482,14 @@ article.pure-g > .pure-u-3-4 {
.alert[data-status="Success"]:before {
content: "\f00c";
}
.alert-danger,
.alert[data-status="Error"],
.alert[data-status="Failure"] {
background: #fdf7f7;
border-left: 5px solid #ed5564;
color: #ed5564;
}
.alert-danger:before,
.alert[data-status="Error"]:before,
.alert[data-status="Failure"]:before {
content: "\f00d";

View File

@ -39,6 +39,7 @@
}
}
.alert-danger,
.alert[data-status="Error"],
.alert[data-status="Failure"] {
background: #fdf7f7;

View File

@ -29,13 +29,13 @@
<span>{{$__amber_6 := .Repo.Owner}}{{$__amber_6}}</span>
<span>/</span>
<a href="{{"#"}}">{{$__amber_7 := .Repo.Name}}{{$__amber_7}}</a>
</h1>{{$__amber_8 := .Repo.Name}}{{$__amber_9 := .Repo.Owner}}{{$__amber_10 := .Repo.Remote}}{{$__amber_11 := __amber_add "/" $__amber_10}}{{$__amber_12 := __amber_add $__amber_11 "/"}}{{$__amber_13 := __amber_add $__amber_12 $__amber_9}}{{$__amber_14 := __amber_add $__amber_13 "/"}}{{$__amber_15 := __amber_add $__amber_14 $__amber_8}}{{$__amber_16 := __amber_add $__amber_15 "/settings"}}
</h1>{{$__amber_8 := .Repo.Name}}{{$__amber_9 := .Repo.Owner}}{{$__amber_10 := .Repo.Host}}{{$__amber_11 := __amber_add "/" $__amber_10}}{{$__amber_12 := __amber_add $__amber_11 "/"}}{{$__amber_13 := __amber_add $__amber_12 $__amber_9}}{{$__amber_14 := __amber_add $__amber_13 "/"}}{{$__amber_15 := __amber_add $__amber_14 $__amber_8}}{{$__amber_16 := __amber_add $__amber_15 "/settings"}}
<a class="{{"pure-button"}}" href="{{$__amber_16}}">
<i class="{{"fa"}} {{"fa-cog"}}"></i>
</a>
</header>{{$repo := .Repo}}{{$__amber_17 := .Repo.Active}}{{if $__amber_17}}{{if .Commits}}
<section class="{{"pure-u-3-5"}}">
<div class="{{"commit-list"}}">{{range $commit := .Commits}}{{$__amber_18 := $repo.Name}}{{$__amber_19 := $repo.Owner}}{{$__amber_20 := $repo.Remote}}{{$__amber_21 := __amber_add "/" $__amber_20}}{{$__amber_22 := __amber_add $__amber_21 "/"}}{{$__amber_23 := __amber_add $__amber_22 $__amber_19}}{{$__amber_24 := __amber_add $__amber_23 "/"}}{{$__amber_25 := __amber_add $__amber_24 $__amber_18}}{{$__amber_26 := __amber_add $__amber_25 "/branch/"}}{{$__amber_27 := __amber_add $__amber_26 .Branch}}{{$__amber_28 := __amber_add $__amber_27 "/commit/"}}{{$__amber_29 := __amber_add $__amber_28 .Sha}}
<div class="{{"commit-list"}}">{{range $commit := .Commits}}{{$__amber_18 := $repo.Name}}{{$__amber_19 := $repo.Owner}}{{$__amber_20 := $repo.Host}}{{$__amber_21 := __amber_add "/" $__amber_20}}{{$__amber_22 := __amber_add $__amber_21 "/"}}{{$__amber_23 := __amber_add $__amber_22 $__amber_19}}{{$__amber_24 := __amber_add $__amber_23 "/"}}{{$__amber_25 := __amber_add $__amber_24 $__amber_18}}{{$__amber_26 := __amber_add $__amber_25 "/branch/"}}{{$__amber_27 := __amber_add $__amber_26 .Branch}}{{$__amber_28 := __amber_add $__amber_27 "/commit/"}}{{$__amber_29 := __amber_add $__amber_28 .Sha}}
<a class="{{"pure-g"}} {{"commit-item"}}" data-status="{{.Status}}" href="{{$__amber_29}}">
<div class="{{"pure-u-1-8"}}">{{$__amber_30 := __amber_add "https://secure.gravatar.com/avatar/" .Gravatar}}{{$__amber_31 := __amber_add $__amber_30 "?s=48&d=identicon"}}
<img src="{{$__amber_31}}" />
@ -54,7 +54,7 @@
<div class="{{"pure-u-1"}} {{"pure-menu"}} {{"pure-menu-open"}}">
<a class="{{"pure-menu-heading"}}">Recent Branches</a>
<ul>{{range $commit := .Branches}}
<li>{{$__amber_32 := $repo.Name}}{{$__amber_33 := $repo.Owner}}{{$__amber_34 := $repo.Remote}}{{$__amber_35 := __amber_add "/" $__amber_34}}{{$__amber_36 := __amber_add $__amber_35 "/"}}{{$__amber_37 := __amber_add $__amber_36 $__amber_33}}{{$__amber_38 := __amber_add $__amber_37 "/"}}{{$__amber_39 := __amber_add $__amber_38 $__amber_32}}{{$__amber_40 := __amber_add $__amber_39 "/branch/"}}{{$__amber_41 := __amber_add $__amber_40 .Branch}}
<li>{{$__amber_32 := $repo.Name}}{{$__amber_33 := $repo.Owner}}{{$__amber_34 := $repo.Host}}{{$__amber_35 := __amber_add "/" $__amber_34}}{{$__amber_36 := __amber_add $__amber_35 "/"}}{{$__amber_37 := __amber_add $__amber_36 $__amber_33}}{{$__amber_38 := __amber_add $__amber_37 "/"}}{{$__amber_39 := __amber_add $__amber_38 $__amber_32}}{{$__amber_40 := __amber_add $__amber_39 "/branch/"}}{{$__amber_41 := __amber_add $__amber_40 .Branch}}
<a data-status="{{.Status}}" href="{{$__amber_41}}">{{.Branch}}</a>
</li>{{end}}
</ul>
@ -65,9 +65,9 @@
<div class="{{"alert"}} {{"alert-info"}}">Your Build history is empty. Push to your remote repository to trigger a build. </div>
</section>{{end}}{{else}}
<section class="{{"pure-u-1"}}">
<div class="{{"alert"}} {{"alert-info"}}">This Repository is not yet active. Please activate to start testing commits.</div>
<br />
<form class="{{"pure-form"}} {{"pure-form-stacked"}}">
<div class="{{"alert"}} {{"alert-info"}}" id="{{"alert"}}">This Repository is not yet active. Please activate to start testing commits.</div>
<br />{{$__amber_42 := .Repo.Name}}{{$__amber_43 := .Repo.Owner}}{{$__amber_44 := .Repo.Host}}{{$__amber_45 := __amber_add "/v1/repos/" $__amber_44}}{{$__amber_46 := __amber_add $__amber_45 "/"}}{{$__amber_47 := __amber_add $__amber_46 $__amber_43}}{{$__amber_48 := __amber_add $__amber_47 "/"}}{{$__amber_49 := __amber_add $__amber_48 $__amber_42}}
<form class="{{"pure-form"}} {{"pure-form-stacked"}}" action="{{$__amber_49}}">
<div class="{{"pure-controls"}}">
<button class="{{"pure-button"}} {{"pure-button-primary"}}">Click to Active Repository</button>
</div>
@ -82,6 +82,27 @@
$(document).ready(function() {
$(".timeago").timeago();
});
</script>
</script>{{$__amber_50 := .Repo.Active}}{{if $__amber_50}}
<script></script>{{else}}
<script>
document.forms[0].onsubmit = function(event) {
var form = event.target
var formData = new FormData(form);
xhr = new XMLHttpRequest();
xhr.open('POST', form.action);
xhr.onload = function() {
if (this.status == 200) {
window.location.reload();
} else {
$("#alert").text("Failed to activate the repository settings. Please try again");
$("#alert").attr("class", "alert alert-danger");
};
};
xhr.send(formData);
return false;
}
</script>{{end}}
</body>
</html>

View File

@ -10,7 +10,7 @@ block content
span #{Repo.Owner}
span /
a[href="#"] #{Repo.Name}
a.pure-button[href="/"+Repo.Remote+"/"+Repo.Owner+"/"+Repo.Name+"/settings"]
a.pure-button[href="/"+Repo.Host+"/"+Repo.Owner+"/"+Repo.Name+"/settings"]
i.fa.fa-cog
$repo=Repo
@ -19,7 +19,7 @@ block content
section.pure-u-3-5
div.commit-list
each $commit in Commits
a.pure-g.commit-item[data-status=Status][href="/"+$repo.Remote+"/"+$repo.Owner+"/"+$repo.Name+"/branch/"+Branch+"/commit/"+Sha]
a.pure-g.commit-item[data-status=Status][href="/"+$repo.Host+"/"+$repo.Owner+"/"+$repo.Name+"/branch/"+Branch+"/commit/"+Sha]
div.pure-u-1-8
img[src="https://secure.gravatar.com/avatar/"+Gravatar+"?s=48&d=identicon"]
@ -35,7 +35,7 @@ block content
ul
each $commit in Branches
li
a[data-status=Status][href="/"+$repo.Remote+"/"+$repo.Owner+"/"+$repo.Name+"/branch/"+Branch] #{Branch}
a[data-status=Status][href="/"+$repo.Host+"/"+$repo.Owner+"/"+$repo.Name+"/branch/"+Branch] #{Branch}
else
section.pure-u-1
@ -45,10 +45,10 @@ block content
else
section.pure-u-1
div.alert.alert-info
div.alert.alert-info#alert
| This Repository is not yet active. Please activate to start testing commits.
br
form.pure-form.pure-form-stacked
form.pure-form.pure-form-stacked[action="/v1/repos/"+Repo.Host+"/"+Repo.Owner+"/"+Repo.Name]
div.pure-controls
button.pure-button.pure-button-primary Click to Active Repository
@ -56,4 +56,27 @@ block append scripts
script
$(document).ready(function() {
$(".timeago").timeago();
});
});
if Repo.Active
script
else
script
document.forms[0].onsubmit = function(event) {
var form = event.target
var formData = new FormData(form);
xhr = new XMLHttpRequest();
xhr.open('POST', form.action);
xhr.onload = function() {
if (this.status == 201) {
window.location.reload();
} else {
$("#alert").text("Failed to activate the repository settings. Please try again");
$("#alert").attr("class", "alert alert-danger");
};
};
xhr.send(formData);
return false;
}