Skip to content

Commit 0a73fe4

Browse files
committed
update
1 parent 5c5d6a6 commit 0a73fe4

File tree

9 files changed

+58
-29
lines changed

9 files changed

+58
-29
lines changed

routers/web/repo/editor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ 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
266267
ctx.Data["IsNewFile"] = isNewFile
267268

268269
// Check if the filename (and additional path) is specified in the querystring
@@ -378,6 +379,8 @@ func EditFilePost(ctx *context.Context) {
378379

379380
// DeleteFile render delete file page
380381
func DeleteFile(ctx *context.Context) {
382+
prepareTreePathFieldsAndPaths(ctx, ctx.Repo.TreePath)
383+
prepareTreeSideBarSwitch(ctx)
381384
prepareEditorCommitFormOptions(ctx, "_delete")
382385
if ctx.Written() {
383386
return

routers/web/repo/editor_apply_patch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
)
1515

1616
func NewDiffPatch(ctx *context.Context) {
17+
prepareTreeSideBarSwitch(ctx)
1718
prepareEditorCommitFormOptions(ctx, "_diffpatch")
1819
if ctx.Written() {
1920
return

templates/repo/editor/common_breadcrumb.tmpl

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

templates/repo/editor/delete.tmpl

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content repository file editor delete">
33
{{template "repo/header" .}}
4-
<div class="ui container">
4+
<div class="ui container fluid">
55
{{template "base/alert" .}}
6-
<form class="ui form form-fetch-action" method="post" action="{{.CommitFormOptions.TargetFormAction}}">
7-
{{.CsrfTokenHtml}}
8-
{{template "repo/editor/common_top" .}}
9-
{{template "repo/editor/commit_form" .}}
10-
</form>
6+
{{template "repo/editor/common_top" .}}
7+
<div class="repo-view-container">
8+
<div class="tw-flex tw-flex-col repo-view-file-tree-container not-mobile {{if (not .UserSettingCodeViewShowFileTree)}}tw-hidden{{end}}" data-user-is-signed-in>
9+
{{template "repo/view_file_tree" .}}
10+
</div>
11+
<div class="repo-view-content">
12+
<div class="ui form">
13+
<div class="repo-editor-header">
14+
{{template "repo/editor/file_tree_toggle" .}}
15+
{{template "repo/editor/common_breadcrumb" .}}
16+
</div>
17+
</div>
18+
<div class="ui container">
19+
<form class="ui form form-fetch-action tw-my-[40px]" method="post" action="{{.CommitFormOptions.TargetFormAction}}">
20+
{{.CsrfTokenHtml}}
21+
{{template "repo/editor/commit_form" .}}
22+
</form>
23+
</div>
24+
</div>
25+
</div>
1126
</div>
1227
</div>
1328
{{template "base/footer" .}}

templates/repo/editor/edit.tmpl

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@
33
{{template "repo/header" .}}
44
<div class="ui container fluid">
55
{{template "base/alert" .}}
6+
{{template "repo/editor/common_top" .}}
67
<div class="repo-view-container">
7-
<div class="tw-flex tw-flex-col repo-view-file-tree-container not-mobile {{if or (not .UserSettingCodeViewShowFileTree) .IsEditingFileOnly}}tw-hidden{{end}}" data-user-is-signed-in>
8-
{{template "repo/view_file_tree" .}}
9-
</div>
8+
<div class="tw-flex tw-flex-col repo-view-file-tree-container not-mobile {{if (not .UserSettingCodeViewShowFileTree)}}tw-hidden{{end}}" data-user-is-signed-in>
9+
{{template "repo/view_file_tree" .}}
10+
</div>
1011
<div class="repo-view-content">
1112
<form class="ui edit form form-fetch-action" method="post" action="{{.CommitFormOptions.TargetFormAction}}"
1213
data-text-empty-confirm-header="{{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}}"
1314
data-text-empty-confirm-content="{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}"
1415
>
1516
{{.CsrfTokenHtml}}
16-
{{template "repo/editor/common_top" .}}
1717
<div class="repo-editor-header">
18-
<button class="repo-view-file-tree-toggle-show ui compact basic button icon not-mobile {{if and .UserSettingCodeViewShowFileTree (not .IsEditingFileOnly)}}tw-hidden{{end}}"
19-
data-global-click="onRepoViewFileTreeToggle" data-toggle-action="show"
20-
data-tooltip-content="{{ctx.Locale.Tr "repo.diff.show_file_tree"}}"
21-
type="button">
22-
{{svg "octicon-sidebar-collapse"}}
23-
</button>
18+
{{template "repo/editor/file_tree_toggle" .}}
2419
{{template "repo/editor/common_breadcrumb" .}}
2520
</div>
2621
{{if not .NotEditableReason}}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<button class="repo-view-file-tree-toggle-show ui compact basic button icon not-mobile {{if .UserSettingCodeViewShowFileTree}}tw-hidden{{end}}"
2+
data-global-click="onRepoViewFileTreeToggle" data-toggle-action="show"
3+
data-tooltip-content="{{ctx.Locale.Tr "repo.diff.show_file_tree"}}"
4+
type="button">
5+
{{svg "octicon-sidebar-collapse"}}
6+
</button>

templates/repo/editor/fork.tmpl

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content repository">
33
{{template "repo/header" .}}
4-
<div class="ui container">
4+
<div class="ui container fluid">
55
{{template "base/alert" .}}
6-
<form class="ui form form-fetch-action" method="post" action="{{.RepoLink}}/_fork/{{.BranchName | PathEscapeSegments}}">
7-
{{.CsrfTokenHtml}}
8-
<div class="tw-text-center">
9-
<div class="tw-my-[40px]">
10-
<h3>{{ctx.Locale.Tr "repo.editor.fork_create"}}</h3>
11-
<p>{{ctx.Locale.Tr "repo.editor.fork_create_description"}}</p>
12-
</div>
13-
<button class="ui primary button">{{ctx.Locale.Tr "repo.fork_repo"}}</button>
6+
<div class="repo-view-container">
7+
<div class="tw-flex tw-flex-col repo-view-file-tree-container not-mobile {{if (not .UserSettingCodeViewShowFileTree)}}tw-hidden{{end}}" data-user-is-signed-in>
8+
{{template "repo/view_file_tree" .}}
149
</div>
15-
</form>
10+
<div class="repo-view-content">
11+
<form class="ui form form-fetch-action" method="post" action="{{.RepoLink}}/_fork/{{.BranchName | PathEscapeSegments}}">
12+
{{.CsrfTokenHtml}}
13+
<div class="tw-text-center">
14+
<div class="tw-my-[40px]">
15+
<h3>{{ctx.Locale.Tr "repo.editor.fork_create"}}</h3>
16+
<p>{{ctx.Locale.Tr "repo.editor.fork_create_description"}}</p>
17+
</div>
18+
<button class="ui primary button">{{ctx.Locale.Tr "repo.fork_repo"}}</button>
19+
</div>
20+
</form>
21+
</div>
22+
</div>
1623
</div>
1724
</div>
1825
{{template "base/footer" .}}

templates/repo/view_file_tree.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
data-repo-link="{{.RepoLink}}"
1313
data-tree-path="{{$.TreePath}}"
1414
data-current-ref-name-sub-url="{{.RefTypeNameSubURL}}"
15-
data-page-is-edit="{{not .PageIsViewCode}}"
15+
data-page-is-edit="{{or .PageIsEdit .PageIsDelete}}"
1616
></div>

web_src/js/components/ViewFileTreeItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const doLoadChildren = async () => {
3939
const onItemClick = (e: MouseEvent) => {
4040
// only handle the click event with partial page reloading if
4141
// - the user didn't press any special key let browsers handle special keys like "Ctrl+Click"
42-
// - the user doesn't edit the file (a full page reload shows a confirmation dialog if the editor has unsaved changed)
42+
// - the user doesn't edit the file (a full page reload shows a confirmation dialog if the editor or commit dialog have unsaved changed)
4343
if (!isPlainClick(e) || props.store.pageIsEdit) return;
4444
e.preventDefault();
4545
if (props.item.entryMode === 'tree') doLoadChildren();

0 commit comments

Comments
 (0)