Skip to content

Commit 065451d

Browse files
committed
fix ui
1 parent 713ab7c commit 065451d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

routers/web/repo/view_file.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ func prepareToRenderButtons(ctx *context.Context, lfsLock *git_model.LFSLock) {
302302
}
303303

304304
if !ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, ctx.Repo.BranchName) {
305+
ctx.Data["CanEditFile"] = true
305306
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.fork_before_edit")
307+
ctx.Data["CanDeleteFile"] = true
306308
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access")
307309
return
308310
}

templates/repo/view_file.tmpl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@
6262
</a>
6363
{{end}}
6464
{{if .Repository.CanEnableEditor}}
65-
<a class="btn-octicon" data-tooltip-content="{{.EditFileTooltip}}" href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}">{{svg "octicon-pencil"}}</a>
66-
<a class="btn-octicon btn-octicon-danger" data-tooltip-content="{{.DeleteFileTooltip}}" href="{{.RepoLink}}/_delete/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}">{{svg "octicon-trash"}}</a>
65+
{{if .CanEditFile}}
66+
<a class="btn-octicon" data-tooltip-content="{{.EditFileTooltip}}" href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}">{{svg "octicon-pencil"}}</a>
67+
{{else}}
68+
<span class="btn-octicon disabled" data-tooltip-content="{{.EditFileTooltip}}">{{svg "octicon-pencil"}}</span>
69+
{{end}}
70+
{{if .CanDeleteFile}}
71+
<a class="btn-octicon btn-octicon-danger" data-tooltip-content="{{.DeleteFileTooltip}}" href="{{.RepoLink}}/_delete/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}">{{svg "octicon-trash"}}</a>
72+
{{else}}
73+
<span class="btn-octicon disabled" data-tooltip-content="{{.DeleteFileTooltip}}">{{svg "octicon-trash"}}</span>
74+
{{end}}
6775
{{end}}
6876
{{else if .EscapeStatus.Escaped}}
6977
<button class="ui mini basic button unescape-button tw-mr-1 tw-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button>

0 commit comments

Comments
 (0)