Skip to content

Commit 6bf1166

Browse files
committed
fix filename being editable even if it shouldn't
1 parent a12962c commit 6bf1166

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

routers/web/repo/editor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ func editFileOpenExisting(ctx *context.Context) (prefetch []byte, dataRc io.Read
263263
func EditFile(ctx *context.Context) {
264264
editorAction := ctx.PathParam("editor_action")
265265
isNewFile := editorAction == "_new"
266-
ctx.Data["PageIsEdit"] = true
267266
ctx.Data["IsNewFile"] = isNewFile
268267

269268
// Check if the filename (and additional path) is specified in the querystring
@@ -323,6 +322,7 @@ func EditFile(ctx *context.Context) {
323322
}
324323
}
325324

325+
ctx.Data["PageIsEdit"] = true
326326
ctx.Data["EditorconfigJson"] = getContextRepoEditorConfig(ctx, ctx.Repo.TreePath)
327327
ctx.HTML(http.StatusOK, tplEditFile)
328328
}

templates/repo/editor/common_breadcrumb.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
{{range $i, $v := .TreeNames}}
66
<div class="breadcrumb-divider">/</div>
77
{{if eq $i $l}}
8-
<input id="file-name" class="field {{Iif $.PageIsDelete "disabled"}}" maxlength="255" value="{{$v}}"
8+
<input id="file-name" class="field {{Iif $.PageIsEdit "" "disabled"}}" maxlength="255" value="{{$v}}"
99
placeholder="{{ctx.Locale.Tr (Iif $.PageIsUpload "repo.editor.add_subdir" "repo.editor.name_your_file")}}"
10-
data-editorconfig="{{$.EditorconfigJson}}" {{Iif $.PageIsUpload "required"}} {{Iif $.PageIsDelete "disabled" "autofocus"}}>
10+
data-editorconfig="{{$.EditorconfigJson}}" {{Iif $.PageIsUpload "required"}} {{Iif $.PageIsEdit "autofocus" "disabled"}}>
1111
<span data-tooltip-content="{{ctx.Locale.Tr "repo.editor.filename_help"}}">{{svg "octicon-info"}}</span>
1212
{{else}}
1313
<span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span>

templates/repo/editor/fork.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<div class="repo-view-content">
1111
<form class="ui form form-fetch-action" method="post" action="{{.RepoLink}}/_fork/{{.BranchName | PathEscapeSegments}}">
1212
{{.CsrfTokenHtml}}
13+
<div class="repo-editor-header">
14+
{{template "repo/editor/file_tree_toggle" .}}
15+
{{template "repo/editor/common_breadcrumb" .}}
16+
</div>
1317
<div class="tw-text-center">
1418
<div class="tw-my-[40px]">
1519
<h3>{{ctx.Locale.Tr "repo.editor.fork_create"}}</h3>

0 commit comments

Comments
 (0)