Skip to content

Commit 5df4956

Browse files
committed
feat(repo): Added tree view to adding new file(s) view.
1 parent 10ddd2a commit 5df4956

File tree

5 files changed

+52
-12
lines changed

5 files changed

+52
-12
lines changed

routers/web/repo/editor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ func EditFile(ctx *context.Context) {
280280
return
281281
}
282282

283+
prepareHomeTreeSideBarSwitch(ctx)
284+
283285
// on the "New File" page, we should add an empty path field to make end users could input a new name
284286
prepareTreePathFieldsAndPaths(ctx, util.Iif(isNewFile, ctx.Repo.TreePath+"/", ctx.Repo.TreePath))
285287

@@ -465,6 +467,7 @@ func DeleteFilePost(ctx *context.Context) {
465467

466468
func UploadFile(ctx *context.Context) {
467469
ctx.Data["PageIsUpload"] = true
470+
prepareHomeTreeSideBarSwitch(ctx)
468471
prepareTreePathFieldsAndPaths(ctx, ctx.Repo.TreePath)
469472
opts := prepareEditorCommitFormOptions(ctx, "_upload")
470473
if ctx.Written() {

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+
prepareHomeTreeSideBarSwitch(ctx)
1718
prepareEditorCommitFormOptions(ctx, "_diffpatch")
1819
if ctx.Written() {
1920
return

templates/repo/editor/edit.tmpl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content repository file editor edit">
33
{{template "repo/header" .}}
4-
<div class="ui container">
4+
<div class="ui container fluid padded">
55
{{template "base/alert" .}}
6-
<form class="ui edit form form-fetch-action" method="post" action="{{.CommitFormOptions.TargetFormAction}}"
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}}" {{if .IsSigned}}data-user-is-signed-in{{end}}>
8+
{{template "repo/view_file_tree" .}}
9+
</div>
10+
<div class="repo-view-content">
11+
<form class="ui edit form form-fetch-action" method="post" action="{{.CommitFormOptions.TargetFormAction}}"
712
data-text-empty-confirm-header="{{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}}"
813
data-text-empty-confirm-content="{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}"
914
>
1015
{{.CsrfTokenHtml}}
1116
{{template "repo/editor/common_top" .}}
12-
<div class="repo-editor-header">
17+
<div class="repo-editor-header tw-flex tw-items-center tw-gap-2">
18+
<button type="button" class="repo-view-file-tree-toggle-show ui compact basic button icon not-mobile {{if .UserSettingCodeViewShowFileTree}}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+
{{svg "octicon-sidebar-collapse"}}
22+
</button>
1323
{{template "repo/editor/common_breadcrumb" .}}
1424
</div>
1525
{{if not .NotEditableReason}}
@@ -47,7 +57,9 @@
4757
</div>
4858
{{end}}
4959
{{template "repo/editor/commit_form" .}}
50-
</form>
60+
</form>
61+
</div>
62+
</div>
5163
</div>
5264
</div>
5365
{{template "base/footer" .}}

templates/repo/editor/patch.tmpl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content repository file editor edit">
33
{{template "repo/header" .}}
4-
<div class="ui container">
4+
<div class="ui container fluid padded">
55
{{template "base/alert" .}}
6-
<form class="ui edit form form-fetch-action" method="post" action="{{.CommitFormOptions.TargetFormAction}}"
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}}" {{if .IsSigned}}data-user-is-signed-in{{end}}>
8+
{{template "repo/view_file_tree" .}}
9+
</div>
10+
<div class="repo-view-content">
11+
<form class="ui edit form form-fetch-action" method="post" action="{{.CommitFormOptions.TargetFormAction}}"
712
data-text-empty-confirm-header="{{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}}"
813
data-text-empty-confirm-content="{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}"
914
>
1015
{{.CsrfTokenHtml}}
1116
{{template "repo/editor/common_top" .}}
12-
<div class="repo-editor-header">
17+
<div class="repo-editor-header tw-flex tw-items-center tw-gap-2">
18+
<button type="button" class="repo-view-file-tree-toggle-show ui compact basic button icon not-mobile {{if .UserSettingCodeViewShowFileTree}}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+
{{svg "octicon-sidebar-collapse"}}
22+
</button>
1323
<div class="breadcrumb">
1424
{{ctx.Locale.Tr "repo.editor.patching"}}
1525
<a class="section" href="{{$.RepoLink}}">{{.Repository.FullName}}</a>
@@ -33,7 +43,9 @@
3343
</div>
3444
</div>
3545
{{template "repo/editor/commit_form" .}}
36-
</form>
46+
</form>
47+
</div>
48+
</div>
3749
</div>
3850
</div>
3951
{{template "base/footer" .}}

templates/repo/editor/upload.tmpl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content repository file editor upload">
33
{{template "repo/header" .}}
4-
<div class="ui container">
4+
<div class="ui container fluid padded">
55
{{template "base/alert" .}}
6-
<form class="ui comment form form-fetch-action" method="post" action="{{.CommitFormOptions.TargetFormAction}}">
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}}" {{if .IsSigned}}data-user-is-signed-in{{end}}>
8+
{{template "repo/view_file_tree" .}}
9+
</div>
10+
<div class="repo-view-content">
11+
<form class="ui comment form form-fetch-action" method="post" action="{{.CommitFormOptions.TargetFormAction}}">
712
{{.CsrfTokenHtml}}
813
{{template "repo/editor/common_top" .}}
9-
<div class="repo-editor-header">
14+
<div class="repo-editor-header tw-flex tw-items-center tw-gap-2">
15+
<button type="button" class="repo-view-file-tree-toggle-show ui compact basic button icon not-mobile {{if .UserSettingCodeViewShowFileTree}}tw-hidden{{end}}"
16+
data-global-click="onRepoViewFileTreeToggle" data-toggle-action="show"
17+
data-tooltip-content="{{ctx.Locale.Tr "repo.diff.show_file_tree"}}">
18+
{{svg "octicon-sidebar-collapse"}}
19+
</button>
1020
{{template "repo/editor/common_breadcrumb" .}}
1121
</div>
1222
<div class="field">
1323
{{template "repo/upload" .}}
1424
</div>
1525
{{template "repo/editor/commit_form" .}}
16-
</form>
26+
</form>
27+
</div>
28+
</div>
1729
</div>
1830
</div>
1931
{{template "base/footer" .}}

0 commit comments

Comments
 (0)