Merge pull request #1119 from reasonerjt/dev

LGTM.
This commit is contained in:
kun wang 2016-11-18 14:56:31 +08:00 committed by GitHub
commit 8332defb07
2 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,11 @@
package controllers
import (
"github.com/vmware/harbor/src/common/dao"
"github.com/vmware/harbor/src/common/utils/log"
"github.com/vmware/harbor/src/ui/config"
)
// ProjectController handles requests to /project
type ProjectController struct {
BaseController
@ -7,5 +13,12 @@ type ProjectController struct {
// Get renders project page
func (pc *ProjectController) Get() {
uid := pc.GetSession("userId")
isSysAdmin, err := dao.IsAdminRole(uid)
if err != nil {
log.Warningf("Error in checking Admin Role for user, id: %d, error: %v", uid, err)
isSysAdmin = false
}
pc.Data["CanCreate"] = !config.OnlyAdminCreateProject() || isSysAdmin
pc.Forward("page_title_project", "project.htm")
}

View File

@ -46,8 +46,10 @@
<button class="btn btn-primary" type="button" ng-click="vm.searchProject()"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
{{ if eq .CanCreate true }}
<button ng-if="vm.isOpen" class="btn btn-default" disabled="disabled" type="button"><span class="glyphicon glyphicon-plus"></span> // 'new_project' | tr //</button>
<button ng-if="!vm.isOpen" class="btn btn-success" type="button" ng-show="vm.showAddButton()" ng-click="vm.showAddProject()"><span class="glyphicon glyphicon-plus"></span> // 'new_project' | tr //</button>
{{ end }}
</div>
</div>
<add-project ng-show="vm.isOpen" is-open="vm.isOpen"></add-project>