Sidebar pins your repositories
Browse files at this commit6c7efcee54fd1e20186391b5b699558f1eeef4feParent: 02c773d- feat
- sidebar pins your repositories
1 changed file +23 -4
crates/forge-web/src/views/mod.rsmodified+23 -4
| @@ -148,7 +148,19 @@ pub async fn shell( | ||
| 148 | 148 | href: repo_href(&repo.owner_name, &repo.name, "", ""), |
| 149 | 149 | }) |
| 150 | 150 | .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(); | |
| 152 | 164 | let signed_in = viewer.is_some(); |
| 153 | 165 | let nav = viewer.map(|(user, session)| { |
| 154 | 166 | ( |
| @@ -292,7 +304,7 @@ pub async fn shell( | ||
| 292 | 304 | if let Some(section) = section_menu { |
| 293 | 305 | section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live) |
| 294 | 306 | } 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) | |
| 296 | 308 | } |
| 297 | 309 | </div> |
| 298 | 310 | </details> |
| @@ -379,7 +391,7 @@ pub async fn shell( | ||
| 379 | 391 | if let Some(section) = section { |
| 380 | 392 | section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live) |
| 381 | 393 | } 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) | |
| 383 | 395 | } |
| 384 | 396 | </aside> |
| 385 | 397 | } |
| @@ -409,16 +421,19 @@ pub async fn shell( | ||
| 409 | 421 | } |
| 410 | 422 | |
| 411 | 423 | /// 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. | |
| 413 | 426 | #[component] |
| 414 | 427 | async fn side_nav( |
| 415 | 428 | lang: Lang, |
| 416 | 429 | current: &str, |
| 430 | + profile_repos_href: &str, | |
| 417 | 431 | unread: Option<String>, |
| 418 | 432 | repos: Vec<SideRepo>, |
| 419 | 433 | ) -> Result<impl View> { |
| 420 | 434 | let dashboard = current == "dashboard"; |
| 421 | 435 | let explore = current == "explore"; |
| 436 | + let repositories = current == "repositories"; | |
| 422 | 437 | let notifications = current == "notifications"; |
| 423 | 438 | let snippets = current == "snippets"; |
| 424 | 439 | let new_repo = current == "new"; |
| @@ -434,6 +449,10 @@ async fn side_nav( | ||
| 434 | 449 | <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> |
| 435 | 450 | (t(lang, Key::Explore)) |
| 436 | 451 | </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> | |
| 437 | 456 | <a class=(side_class(notifications)) href="/notifications" aria-current=(notifications.then_some("page"))> |
| 438 | 457 | <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> |
| 439 | 458 | (t(lang, Key::Notifications)) |