From 1cf904f10183f7a0d942c6b171fac9a53b812424 Mon Sep 17 00:00:00 2001 From: bircni Date: Mon, 17 Aug 2026 22:08:15 +0200 Subject: [PATCH] feat(repo): add quick repository switcher to repo header (#38188) Add a GitHub-style quick repo switcher: a caret next to the owner/repo breadcrumb opens a dropdown that lists and searches the current owner's repositories and navigates to the selected one. The current repository is marked with a check, and private/fork repos show an icon. Also, fix various bugs in fomtantic dropdown remote query ## Screenshots image Fixes #38187 --------- Co-authored-by: wxiaoguang --- models/repo/repo_list.go | 4 +- options/locale/locale_en-US.json | 2 + templates/repo/header.tmpl | 12 +++++ .../issue/sidebar/issue_dependencies.tmpl | 2 +- web_src/css/modules/dropdown.css | 4 ++ web_src/fomantic/build/components/api.js | 46 ++++++----------- web_src/fomantic/build/components/dropdown.js | 25 ++++++++-- web_src/js/features/common-page.ts | 4 +- web_src/js/features/repo-home.ts | 2 - web_src/js/features/repo-issue-content.ts | 2 - web_src/js/features/repo-issue-list.ts | 50 +++++-------------- web_src/js/features/repo-issue-sidebar.ts | 3 +- web_src/js/features/repo-issue.ts | 2 - web_src/js/features/repo-new.ts | 1 - web_src/js/features/repo-switcher.ts | 39 +++++++++++++++ 15 files changed, 115 insertions(+), 83 deletions(-) create mode 100644 web_src/js/features/repo-switcher.ts diff --git a/models/repo/repo_list.go b/models/repo/repo_list.go index 95eca362350..268723787e5 100644 --- a/models/repo/repo_list.go +++ b/models/repo/repo_list.go @@ -169,8 +169,8 @@ type SearchRepoOptions struct { // False -> include just public IsPrivate optional.Option[bool] // None -> include collaborative AND non-collaborative - // True -> include just collaborative - // False -> include just non-collaborative + // True -> include just collaborative (the "OwnerID" is not really an owner, it just means a collaborator who doesn't own the repo) + // False -> include just non-collaborative (the repo must be in the owner's name space) Collaborate optional.Option[bool] // What type of unit the user can be collaborative in, // it is ignored if Collaborate is False. diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index aca025044eb..14a88aedda0 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -1072,6 +1072,8 @@ "repo.desc.internal": "Internal", "repo.desc.archived": "Archived", "repo.desc.sha256": "SHA256", + "repo.switch_repository": "Switch repository", + "repo.switch_repository.search": "Search repositories...", "repo.template.items": "Template Items", "repo.template.git_content": "Git Content (Default Branch)", "repo.template.git_hooks": "Git Hooks", diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index e5426cde462..bee08e53a50 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -7,6 +7,18 @@ {{template "repo/icon" .}}
{{.Owner.Name}}/{{.Name}} + {{if $.IsSigned}}{{/* actually the switch also works for anonymous users, GitHub only shows it for sign-in users */}} + + {{end}}
{{if .IsArchived}} diff --git a/templates/repo/issue/sidebar/issue_dependencies.tmpl b/templates/repo/issue/sidebar/issue_dependencies.tmpl index 58dd61fb696..37245f48f6b 100644 --- a/templates/repo/issue/sidebar/issue_dependencies.tmpl +++ b/templates/repo/issue/sidebar/issue_dependencies.tmpl @@ -111,7 +111,7 @@
-