forge
Explore
Log in

Don't you dare go Hollow

Sidebar pins your repositories

Browse files at this commit

6c7efcee54fd1e20186391b5b699558f1eeef4feAhmet Kaan GümüşParent: 02c773d
  • feat
    • sidebar pins your repositories
Show full message
✨ feat: sidebar pins your repositories
crates/forge-web/src/views/mod.rsmodified+23 -4
@@ -148,7 +148,19 @@ pub async fn shell(
148148 href: repo_href(&repo.owner_name, &repo.name, "", ""),
149149 })
150150 .collect();
151- let current = nav_key(uri(__cx).path());
151+ // The viewer's own profile Repositories tab has its own sidebar key, so the pinned link lights up there.
152+ let own_repos_tab = viewer.is_some_and(|(user, _)| {
153+ uri(__cx).path().trim_matches('/') == user.username
154+ && uri(__cx).query().is_some_and(|q| q.split('&').any(|p| p == "tab=repositories"))
155+ });
156+ let current = if own_repos_tab {
157+ "repositories"
158+ } else {
159+ nav_key(uri(__cx).path())
160+ };
161+ let profile_repos_href = viewer
162+ .map(|(user, _)| format!("/{}?tab=repositories", enc(&user.username)))
163+ .unwrap_or_default();
152164 let signed_in = viewer.is_some();
153165 let nav = viewer.map(|(user, session)| {
154166 (
@@ -292,7 +304,7 @@ pub async fn shell(
292304 if let Some(section) = section_menu {
293305 section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)
294306 } else {
295- side_nav(lang: lang, current: current, unread: unread_menu, repos: side_repos_menu)
307+ side_nav(lang: lang, current: current, profile_repos_href: profile_repos_href.as_str(), unread: unread_menu, repos: side_repos_menu)
296308 }
297309 </div>
298310 </details>
@@ -379,7 +391,7 @@ pub async fn shell(
379391 if let Some(section) = section {
380392 section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)
381393 } else {
382- side_nav(lang: lang, current: current, unread: unread_aside, repos: side_repos)
394+ side_nav(lang: lang, current: current, profile_repos_href: profile_repos_href.as_str(), unread: unread_aside, repos: side_repos)
383395 }
384396 </aside>
385397 }
@@ -409,16 +421,19 @@ pub async fn shell(
409421 }
410422
411423 /// The signed-in global links and the viewer's repos. The sidebar shows it, and so does the phone
412-/// menu. `current` is the key from `nav_key`; `unread` is the bell count shown next to Notifications.
424+/// menu. `current` is the key from `nav_key`; `profile_repos_href` is the viewer's own Repositories
425+/// tab; `unread` is the bell count shown next to Notifications.
413426 #[component]
414427 async fn side_nav(
415428 lang: Lang,
416429 current: &str,
430+ profile_repos_href: &str,
417431 unread: Option<String>,
418432 repos: Vec<SideRepo>,
419433 ) -> Result<impl View> {
420434 let dashboard = current == "dashboard";
421435 let explore = current == "explore";
436+ let repositories = current == "repositories";
422437 let notifications = current == "notifications";
423438 let snippets = current == "snippets";
424439 let new_repo = current == "new";
@@ -434,6 +449,10 @@ async fn side_nav(
434449 <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/></svg>
435450 (t(lang, Key::Explore))
436451 </a>
452+ <a class=(side_class(repositories)) href=(profile_repos_href) aria-current=(repositories.then_some("page"))>
453+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 4.5A1.5 1.5 0 0 1 6.5 3H19v15H6.5A1.5 1.5 0 0 0 5 19.5z"/><path d="M5 19.5A1.5 1.5 0 0 0 6.5 21H19v-3"/></svg>
454+ (o::t(lang, OK::Repositories))
455+ </a>
437456 <a class=(side_class(notifications)) href="/notifications" aria-current=(notifications.then_some("page"))>
438457 <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 7 3 9H3c0-2 3-2 3-9"/><path d="M10.3 21a1.9 1.9 0 0 0 3.4 0"/></svg>
439458 (t(lang, Key::Notifications))