mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 19:38:23 +00:00 
			
		
		
		
	Put an edit file button on pull request files to allow a quick operation (#29697)
Resolve #23848 This PR put an edit file button on pull request files to allow a quick edit for a file. After the edit finished, it will return back to the viewed file position on pull request files tab. It also use a branch view file link instead of commit link when it's a non-commit pull request files view. <img width="1532" alt="image" src="https://github.com/go-gitea/gitea/assets/81045/3637ca4c-89d5-4621-847b-79702a44f617"> --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
		| @@ -80,8 +80,12 @@ func redirectForCommitChoice(ctx *context.Context, commitChoice, newBranchName, | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Redirect to viewing file or folder | ||||
| 	ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(newBranchName) + "/" + util.PathEscapeSegments(treePath)) | ||||
| 	returnURI := ctx.FormString("return_uri") | ||||
|  | ||||
| 	ctx.RedirectToCurrentSite( | ||||
| 		returnURI, | ||||
| 		ctx.Repo.RepoLink+"/src/branch/"+util.PathEscapeSegments(newBranchName)+"/"+util.PathEscapeSegments(treePath), | ||||
| 	) | ||||
| } | ||||
|  | ||||
| // getParentTreeFields returns list of parent tree names and corresponding tree paths | ||||
| @@ -100,6 +104,7 @@ func getParentTreeFields(treePath string) (treeNames, treePaths []string) { | ||||
| } | ||||
|  | ||||
| func editFile(ctx *context.Context, isNewFile bool) { | ||||
| 	ctx.Data["PageIsViewCode"] = true | ||||
| 	ctx.Data["PageIsEdit"] = true | ||||
| 	ctx.Data["IsNewFile"] = isNewFile | ||||
| 	canCommit := renderCommitRights(ctx) | ||||
| @@ -190,6 +195,9 @@ func editFile(ctx *context.Context, isNewFile bool) { | ||||
| 	ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",") | ||||
| 	ctx.Data["EditorconfigJson"] = GetEditorConfig(ctx, treePath) | ||||
|  | ||||
| 	ctx.Data["IsEditingFileOnly"] = ctx.FormString("return_uri") != "" | ||||
| 	ctx.Data["ReturnURI"] = ctx.FormString("return_uri") | ||||
|  | ||||
| 	ctx.HTML(http.StatusOK, tplEditFile) | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user