mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Improve behavior of "Fork" button (#17288)
* Improbe behaviour of fork button * Apply suggestions from code review * Remove old lines * Apply suggestions * Fix test * Remove unnecessary or * Update templates/repo/header.tmpl Co-authored-by: silverwind <me@silverwind.io> * Add comment * Fix situation if you can't fork but don't have forks * Fix lint * Apply changes from #17783 * fmt * fmt * Apply tweaks Co-authored by: silverwind <me@silverwind.io> * Rm dupl css * Fix build Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		| @@ -499,10 +499,24 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { | ||||
| 	ctx.Data["CanWriteIssues"] = ctx.Repo.CanWrite(unit_model.TypeIssues) | ||||
| 	ctx.Data["CanWritePulls"] = ctx.Repo.CanWrite(unit_model.TypePullRequests) | ||||
|  | ||||
| 	if ctx.Data["CanSignedUserFork"], err = models.CanUserForkRepo(ctx.User, ctx.Repo.Repository); err != nil { | ||||
| 		ctx.ServerError("CanSignedUserFork", err) | ||||
| 	canSignedUserFork, err := models.CanUserForkRepo(ctx.User, ctx.Repo.Repository) | ||||
| 	if err != nil { | ||||
| 		ctx.ServerError("CanUserForkRepo", err) | ||||
| 		return | ||||
| 	} | ||||
| 	ctx.Data["CanSignedUserFork"] = canSignedUserFork | ||||
|  | ||||
| 	userAndOrgForks, err := models.GetForksByUserAndOrgs(ctx.User, ctx.Repo.Repository) | ||||
| 	if err != nil { | ||||
| 		ctx.ServerError("GetForksByUserAndOrgs", err) | ||||
| 		return | ||||
| 	} | ||||
| 	ctx.Data["UserAndOrgForks"] = userAndOrgForks | ||||
|  | ||||
| 	// canSignedUserFork is true if the current user doesn't have a fork of this repo yet or | ||||
| 	// if he owns an org that doesn't have a fork of this repo yet | ||||
| 	// If multiple forks are available or if the user can fork to another account, but there is already a fork: open selection dialog | ||||
| 	ctx.Data["ShowForkModal"] = len(userAndOrgForks) > 1 || (canSignedUserFork && len(userAndOrgForks) > 0) | ||||
|  | ||||
| 	ctx.Data["DisableSSH"] = setting.SSH.Disabled | ||||
| 	ctx.Data["ExposeAnonSSH"] = setting.SSH.ExposeAnonymous | ||||
|   | ||||
		Reference in New Issue
	
	Block a user