Browse Source

Issue: Show error prompt when add repository to team and it does not exist #533

Unknwon 10 years ago
parent
commit
85c9f7c5f3
3 changed files with 7 additions and 0 deletions
  1. 1 0
      conf/locale/locale_en-US.ini
  2. 1 0
      conf/locale/locale_zh-CN.ini
  3. 5 0
      routers/org/teams.go

+ 1 - 0
conf/locale/locale_en-US.ini

@@ -408,6 +408,7 @@ teams.admin_permission_desc = This team grants <strong>Admin</strong> access: me
 teams.repositories = Team Repositories
 teams.add_team_repository = Add Team Repository
 teams.remove_repo = Remove
+teams.add_nonexistent_repo = The repository you're trying to add does not exist, please create it first.
 
 [admin]
 dashboard = Dashboard

+ 1 - 0
conf/locale/locale_zh-CN.ini

@@ -408,6 +408,7 @@ teams.admin_permission_desc = 该团队拥有一定的 <strong>管理</strong> 
 teams.repositories = 团队仓库
 teams.add_team_repository = 添加团队仓库
 teams.remove_repo = 移除仓库
+teams.add_nonexistent_repo = 您尝试添加到团队的仓库不存在,请先创建仓库!
 
 [admin]
 dashboard = 控制面板

+ 5 - 0
routers/org/teams.go

@@ -124,6 +124,11 @@ func TeamsRepoAction(ctx *middleware.Context) {
 		var repo *models.Repository
 		repo, err = models.GetRepositoryByName(ctx.Org.Organization.Id, repoName)
 		if err != nil {
+			if err == models.ErrRepoNotExist {
+				ctx.Flash.Error(ctx.Tr("org.teams.add_nonexistent_repo"))
+				ctx.Redirect(ctx.Org.OrgLink + "/teams/" + ctx.Org.Team.LowerName + "/repositories")
+				return
+			}
 			ctx.Handle(500, "GetRepositoryByName", err)
 			return
 		}