merge with master

This commit is contained in:
Tan Jiang 2016-08-03 17:15:00 +08:00
commit fa18ab3a75
10 changed files with 26 additions and 11 deletions

View File

@ -30,6 +30,6 @@ notifications:
- name: harbor
disabled: false
url: http://ui/service/notifications
timeout: 500ms
timeout: 3000ms
threshold: 5
backoff: 1s

View File

@ -127,6 +127,10 @@ func (ra *RepJobAPI) Delete() {
ra.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
if job == nil {
ra.CustomAbort(http.StatusNotFound, fmt.Sprintf("job %d not found", ra.jobID))
}
if job.Status == models.JobPending || job.Status == models.JobRunning {
ra.CustomAbort(http.StatusBadRequest, fmt.Sprintf("job is %s, can not be deleted", job.Status))
}

View File

@ -222,6 +222,10 @@ func (ra *RepositoryAPI) GetTags() {
ra.CustomAbort(http.StatusInternalServerError, "")
}
if project == nil {
ra.CustomAbort(http.StatusNotFound, fmt.Sprintf("project %s not found", projectName))
}
if project.Public == 0 {
userID := ra.ValidateUser()
if !checkProjectPermission(userID, project.ProjectID) {

View File

@ -107,6 +107,12 @@ func (b *BaseController) Prepare() {
if _, err := os.Stat(filepath.Join("static", "resources", "js", "harbor.app.min.js")); os.IsNotExist(err) {
b.UseCompressedJS = false
}
selfRegistration := strings.ToLower(os.Getenv("SELF_REGISTRATION"))
if selfRegistration == "on" {
b.SelfRegistration = true
}
b.Data["SelfRegistration"] = b.SelfRegistration
}
// Forward to setup layout and template for content for a page.

View File

@ -11,7 +11,7 @@ type SignUpController struct {
// Get renders sign up page
func (suc *SignUpController) Get() {
if suc.AuthMode != "db_auth" {
if suc.AuthMode != "db_auth" || !suc.SelfRegistration {
suc.CustomAbort(http.StatusUnauthorized, "Status unauthorized.")
}
suc.Data["AddNew"] = false

View File

@ -195,7 +195,7 @@ func GetTopRepos(countNum int) ([]models.TopRepo, error) {
for i := 0; i < len(list); i++ {
for _, v := range usrnameList {
if v.RepoName == list[i].RepoName {
list[i].Creator = v.Creator
// list[i].Creator = v.Creator
break
}
}

View File

@ -770,9 +770,11 @@ func TestGetTopRepos(t *testing.T) {
if topRepos[0].AccessCount != 1 {
t.Errorf("error occured in get top reop's access count, expected: %v, actual: %v", 1, topRepos[0].AccessCount)
}
if topRepos[0].Creator != currentUser.Username {
t.Errorf("error occured in get top reop's creator, expected: %v, actual: %v", currentUser.Username, topRepos[0].Creator)
}
/*
if topRepos[0].Creator != currentUser.Username {
t.Errorf("error occured in get top reop's creator, expected: %v, actual: %v", currentUser.Username, topRepos[0].Creator)
}
*/
err = ToggleProjectPublicity(currentProject.ProjectID, publicityOff)
if err != nil {
t.Errorf("Error occurred in ToggleProjectPublicity: %v", err)

View File

@ -19,5 +19,5 @@ package models
type TopRepo struct {
RepoName string `json:"name"`
AccessCount int64 `json:"count"`
Creator string `json:"creator"`
// Creator string `json:"creator"`
}

View File

@ -18,8 +18,7 @@
<table class="table table-pane table-header">
<thead>
<th width="60%">// 'repository_name' | tr //</th>
<th width="15%">// 'count' | tr //</th>
<th width="25%">// 'creator' | tr //</th>
<th width="40%">// 'count' | tr //</th>
</thead>
</table>
</div>
@ -30,7 +29,7 @@
<td colspan="5" height="120px" class="empty-hint" ng-if="vm.top10Repositories.length === 0"><h4 class="text-muted">// 'no_top_repositories' | tr //</h4></td>
</tr>
<tr ng-if="vm.top10Repositories.length > 0" ng-repeat="t in vm.top10Repositories">
<td width="60%">//t.name//</td><td width="15%">//t.count//</td><td width="25%">//t.creator === '' ? '-' : t.creator //</td>
<td width="60%">//t.name//</td><td width="40%">//t.count//</td>
</tr>
</tbody>
</table>

View File

@ -46,7 +46,7 @@
<div class="col-sm-offset-1 col-sm-10">
<div class="pull-right">
<button type="submit" class="btn btn-default" ng-click="vm.doSignIn(user)" loading-progress hide-target="false" toggle-in-progress="vm.signInTIP">// 'sign_in' | tr //</button>
{{ if eq .AuthMode "db_auth" }}
{{ if and (eq .AuthMode "db_auth") (eq .SelfRegistration true) }}
<button type="button" class="btn btn-success" ng-click="vm.doSignUp()">// 'sign_up' | tr //</button>
{{ end }}
</div>