From b24b4043f34c44cf84b1ce48ad7c53e44409a3c0 Mon Sep 17 00:00:00 2001 From: brymut Date: Mon, 10 Nov 2025 11:45:56 +0300 Subject: [PATCH 1/5] feat(repo): Add file search functionality to repository file tree --- templates/repo/view_content.tmpl | 39 ++++--- templates/repo/view_file_tree.tmpl | 5 + web_src/js/components/ViewFileTree.vue | 150 ++++++++++++++++++++++++- 3 files changed, 171 insertions(+), 23 deletions(-) diff --git a/templates/repo/view_content.tmpl b/templates/repo/view_content.tmpl index 66e4fffcb9b19..0d9e97edd70a0 100644 --- a/templates/repo/view_content.tmpl +++ b/templates/repo/view_content.tmpl @@ -42,26 +42,6 @@ {{ctx.Locale.Tr "repo.find_file.go_to_file"}} {{end}} - {{if and .RefFullName.IsBranch (not .IsViewFile)}} - - {{end}} - {{if and $isTreePathRoot .Repository.IsTemplate}} {{ctx.Locale.Tr "repo.use_template"}} @@ -86,6 +66,25 @@
+ {{if and .RefFullName.IsBranch (not .IsViewFile)}} + + {{end}} {{if $isTreePathRoot}} {{template "repo/clone_panel" .}} diff --git a/templates/repo/view_file_tree.tmpl b/templates/repo/view_file_tree.tmpl index 8aed05f346940..844b396bd46f6 100644 --- a/templates/repo/view_file_tree.tmpl +++ b/templates/repo/view_file_tree.tmpl @@ -7,9 +7,14 @@ {{ctx.Locale.Tr "files"}}
+
+ +
+ {{/* TODO: Dynamically move components such as refSelector and createPR here */}}
diff --git a/web_src/js/components/ViewFileTree.vue b/web_src/js/components/ViewFileTree.vue index 1f90f9258670c..0526e360707a5 100644 --- a/web_src/js/components/ViewFileTree.vue +++ b/web_src/js/components/ViewFileTree.vue @@ -1,9 +1,15 @@ @@ -35,4 +128,55 @@ onMounted(async () => { gap: 1px; margin-right: .5rem; } + +.file-tree-search-results { + display: flex; + flex-direction: column; + margin: 0 0.5rem 0.5rem; + max-height: 400px; + overflow-y: auto; + background: var(--color-box-body); + border: 1px solid var(--color-secondary); + border-radius: 6px; + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); +} + +.file-tree-search-result-item { + display: flex; + align-items: center; + gap: 0.5rem; + padding: 0.5rem 0.75rem; + cursor: pointer; + transition: background-color 0.1s; + border-bottom: 1px solid var(--color-secondary); +} + +.file-tree-search-result-item:last-child { + border-bottom: none; +} + +.file-tree-search-result-item:hover, +.file-tree-search-result-item.selected { + background-color: var(--color-hover); +} + +.file-tree-search-result-path { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: 14px; +} + +.search-match { + color: var(--color-red); + font-weight: var(--font-weight-semibold); +} + +.file-tree-search-no-results { + padding: 1rem; + text-align: center; + color: var(--color-text-light-2); + font-size: 14px; +} From c8cc3e2f0c7406df4d8c55bf77c217bcf9bb25dd Mon Sep 17 00:00:00 2001 From: brymut Date: Mon, 10 Nov 2025 18:17:11 +0300 Subject: [PATCH 2/5] feat(repo): add tree view context menu actions --- options/locale/locale_en-US.ini | 2 ++ templates/repo/view_content.tmpl | 24 ++++++++++++++++++++ web_src/css/index.css | 1 + web_src/css/repo/file-actions.css | 19 ++++++++++++++++ web_src/js/features/repo-file-actions.ts | 28 ++++++++++++++++++++++++ web_src/js/index-domready.ts | 2 ++ 6 files changed, 76 insertions(+) create mode 100644 web_src/css/repo/file-actions.css create mode 100644 web_src/js/features/repo-file-actions.ts diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index ddc12aefaaaf9..d9ac17d1b92fd 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1317,6 +1317,7 @@ ambiguous_character = `%[1]c [U+%04[1]X] can be confused with %[2]c [U+%04[2]X]` escape_control_characters = Escape unescape_control_characters = Unescape file_copy_permalink = Copy Permalink +center_content = Center content view_git_blame = View Git Blame video_not_supported_in_browser = Your browser does not support the HTML5 'video' tag. audio_not_supported_in_browser = Your browser does not support the HTML5 'audio' tag. @@ -1354,6 +1355,7 @@ editor.this_file_locked = File is locked editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file. editor.fork_before_edit = You must fork this repository to make or propose changes to this file. editor.delete_this_file = Delete File +editor.delete_this_directory = Delete Directory editor.must_have_write_access = You must have write access to make or propose changes to this file. editor.file_delete_success = File "%s" has been deleted. editor.name_your_file = Name your file… diff --git a/templates/repo/view_content.tmpl b/templates/repo/view_content.tmpl index 0d9e97edd70a0..0716746a2401e 100644 --- a/templates/repo/view_content.tmpl +++ b/templates/repo/view_content.tmpl @@ -84,6 +84,30 @@ + {{end}} {{if $isTreePathRoot}} diff --git a/web_src/css/index.css b/web_src/css/index.css index 291cd04b2b95c..796497c6305b8 100644 --- a/web_src/css/index.css +++ b/web_src/css/index.css @@ -63,6 +63,7 @@ @import "./repo/issue-list.css"; @import "./repo/list-header.css"; @import "./repo/file-view.css"; +@import "./repo/file-actions.css"; @import "./repo/wiki.css"; @import "./repo/header.css"; @import "./repo/home.css"; diff --git a/web_src/css/repo/file-actions.css b/web_src/css/repo/file-actions.css new file mode 100644 index 0000000000000..c1a508aa9b851 --- /dev/null +++ b/web_src/css/repo/file-actions.css @@ -0,0 +1,19 @@ +/* Repository file actions dropdown and centered content */ +.repo-file-actions-dropdown .menu { + min-width: 200px; +} + +.repo-file-actions-dropdown .menu .item { + cursor: pointer; +} + +.repo-file-actions-dropdown .menu .divider { + margin: 0.5rem 0; +} + +/* Center content option */ +.repo-content-centered { + max-width: 980px; + margin-left: auto !important; + margin-right: auto !important; +} diff --git a/web_src/js/features/repo-file-actions.ts b/web_src/js/features/repo-file-actions.ts new file mode 100644 index 0000000000000..bd167e135ca84 --- /dev/null +++ b/web_src/js/features/repo-file-actions.ts @@ -0,0 +1,28 @@ +// Handle repository file/directory actions dropdown +export function initRepoFileActions() { + const centerContentCheckbox = document.querySelector('#center-content-checkbox'); + if (!centerContentCheckbox) return; + + // Load saved preference + const isCentered = localStorage.getItem('repo-content-centered') === 'true'; + centerContentCheckbox.checked = isCentered; + applyCenterContent(isCentered); + + // Handle checkbox change + centerContentCheckbox.addEventListener('change', () => { + const centered = centerContentCheckbox.checked; + localStorage.setItem('repo-content-centered', String(centered)); + applyCenterContent(centered); + }); +} + +function applyCenterContent(centered: boolean) { + const container = document.querySelector('.ui.container'); + if (!container) return; + + if (centered) { + container.classList.add('repo-content-centered'); + } else { + container.classList.remove('repo-content-centered'); + } +} diff --git a/web_src/js/index-domready.ts b/web_src/js/index-domready.ts index df56c85c868c6..49d7814b9656c 100644 --- a/web_src/js/index-domready.ts +++ b/web_src/js/index-domready.ts @@ -64,6 +64,7 @@ import {initGlobalButtonClickOnEnter, initGlobalButtons, initGlobalDeleteButton} import {initGlobalComboMarkdownEditor, initGlobalEnterQuickSubmit, initGlobalFormDirtyLeaveConfirm} from './features/common-form.ts'; import {callInitFunctions} from './modules/init.ts'; import {initRepoViewFileTree} from './features/repo-view-file-tree.ts'; +import {initRepoFileActions} from './features/repo-file-actions.ts'; const initStartTime = performance.now(); const initPerformanceTracer = callInitFunctions([ @@ -137,6 +138,7 @@ const initPerformanceTracer = callInitFunctions([ initRepoReleaseNew, initRepoTopicBar, initRepoViewFileTree, + initRepoFileActions, initRepoWikiForm, initRepository, initRepositoryActionView, From e7fbdcd5998cfe27089031b3c11531b0db3001b6 Mon Sep 17 00:00:00 2001 From: brymut Date: Tue, 11 Nov 2025 05:34:19 +0300 Subject: [PATCH 3/5] enhance(repo): fix overflow and scrolling on search results in sidebar search --- templates/repo/view_file_tree.tmpl | 2 +- web_src/css/repo/file-actions.css | 7 +- web_src/css/repo/home.css | 2 + web_src/js/components/ViewFileTree.vue | 118 +++++++++++++++++++------ 4 files changed, 99 insertions(+), 30 deletions(-) diff --git a/templates/repo/view_file_tree.tmpl b/templates/repo/view_file_tree.tmpl index 844b396bd46f6..29302599ef508 100644 --- a/templates/repo/view_file_tree.tmpl +++ b/templates/repo/view_file_tree.tmpl @@ -12,7 +12,7 @@ {{/* TODO: Dynamically move components such as refSelector and createPR here */}} -
.menu { + margin-top: 4px !important; +} + +.ui.dropdown.repo-file-actions-dropdown > .menu { + margin-top: 4px !important; min-width: 200px; } diff --git a/web_src/css/repo/home.css b/web_src/css/repo/home.css index ee371f1b1c982..f0c366c7650fa 100644 --- a/web_src/css/repo/home.css +++ b/web_src/css/repo/home.css @@ -63,6 +63,8 @@ bottom: 0; height: 100%; overflow-y: hidden; + overflow-x: visible; + z-index: 10; } .repo-view-content { diff --git a/web_src/js/components/ViewFileTree.vue b/web_src/js/components/ViewFileTree.vue index 0526e360707a5..2dde7392dcee8 100644 --- a/web_src/js/components/ViewFileTree.vue +++ b/web_src/js/components/ViewFileTree.vue @@ -1,12 +1,14 @@ diff --git a/web_src/js/features/repo-file-actions.ts b/web_src/js/features/repo-file-actions.ts deleted file mode 100644 index bd167e135ca84..0000000000000 --- a/web_src/js/features/repo-file-actions.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Handle repository file/directory actions dropdown -export function initRepoFileActions() { - const centerContentCheckbox = document.querySelector('#center-content-checkbox'); - if (!centerContentCheckbox) return; - - // Load saved preference - const isCentered = localStorage.getItem('repo-content-centered') === 'true'; - centerContentCheckbox.checked = isCentered; - applyCenterContent(isCentered); - - // Handle checkbox change - centerContentCheckbox.addEventListener('change', () => { - const centered = centerContentCheckbox.checked; - localStorage.setItem('repo-content-centered', String(centered)); - applyCenterContent(centered); - }); -} - -function applyCenterContent(centered: boolean) { - const container = document.querySelector('.ui.container'); - if (!container) return; - - if (centered) { - container.classList.add('repo-content-centered'); - } else { - container.classList.remove('repo-content-centered'); - } -} diff --git a/web_src/js/index-domready.ts b/web_src/js/index-domready.ts index 49d7814b9656c..df56c85c868c6 100644 --- a/web_src/js/index-domready.ts +++ b/web_src/js/index-domready.ts @@ -64,7 +64,6 @@ import {initGlobalButtonClickOnEnter, initGlobalButtons, initGlobalDeleteButton} import {initGlobalComboMarkdownEditor, initGlobalEnterQuickSubmit, initGlobalFormDirtyLeaveConfirm} from './features/common-form.ts'; import {callInitFunctions} from './modules/init.ts'; import {initRepoViewFileTree} from './features/repo-view-file-tree.ts'; -import {initRepoFileActions} from './features/repo-file-actions.ts'; const initStartTime = performance.now(); const initPerformanceTracer = callInitFunctions([ @@ -138,7 +137,6 @@ const initPerformanceTracer = callInitFunctions([ initRepoReleaseNew, initRepoTopicBar, initRepoViewFileTree, - initRepoFileActions, initRepoWikiForm, initRepository, initRepositoryActionView, From 0adcc74a4e38778b11c1973f54567bdc7bd9d807 Mon Sep 17 00:00:00 2001 From: brymut Date: Wed, 12 Nov 2025 13:08:20 +0300 Subject: [PATCH 5/5] feat(repo): Added tree view to adding new file(s) view. --- templates/repo/editor/edit.tmpl | 20 ++++++++++++++++---- templates/repo/editor/patch.tmpl | 20 ++++++++++++++++---- templates/repo/editor/upload.tmpl | 20 ++++++++++++++++---- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index 0911d02e1f423..75619ed8e0ec5 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -1,15 +1,25 @@ {{template "base/head" .}}
{{template "repo/header" .}} -
+
{{template "base/alert" .}} -
+
+ {{template "repo/view_file_tree" .}} +
+
+ {{.CsrfTokenHtml}} {{template "repo/editor/common_top" .}} -
+
+ {{template "repo/editor/common_breadcrumb" .}}
{{if not .NotEditableReason}} @@ -47,7 +57,9 @@
{{end}} {{template "repo/editor/commit_form" .}} - + +
+
{{template "base/footer" .}} diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl index fa00edd92e77c..be85a8aef95ea 100644 --- a/templates/repo/editor/patch.tmpl +++ b/templates/repo/editor/patch.tmpl @@ -1,15 +1,25 @@ {{template "base/head" .}}
{{template "repo/header" .}} -
+
{{template "base/alert" .}} -
+
+ {{template "repo/view_file_tree" .}} +
+
+ {{.CsrfTokenHtml}} {{template "repo/editor/common_top" .}} -
+
+
{{template "repo/editor/commit_form" .}} - + +
+
{{template "base/footer" .}} diff --git a/templates/repo/editor/upload.tmpl b/templates/repo/editor/upload.tmpl index 3e36c77b3b924..79541661c4393 100644 --- a/templates/repo/editor/upload.tmpl +++ b/templates/repo/editor/upload.tmpl @@ -1,19 +1,31 @@ {{template "base/head" .}}
{{template "repo/header" .}} -
+
{{template "base/alert" .}} -
+
+
+ {{template "repo/view_file_tree" .}} +
+
+ {{.CsrfTokenHtml}} {{template "repo/editor/common_top" .}} -
+
+ {{template "repo/editor/common_breadcrumb" .}}
{{template "repo/upload" .}}
{{template "repo/editor/commit_form" .}} - + +
+
{{template "base/footer" .}}