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(
148 href: repo_href(&repo.owner_name, &repo.name, "", ""),148 href: repo_href(&repo.owner_name, &repo.name, "", ""),
149 })149 })
150 .collect();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 let signed_in = viewer.is_some();164 let signed_in = viewer.is_some();
153 let nav = viewer.map(|(user, session)| {165 let nav = viewer.map(|(user, session)| {
154 (166 (
@@ -292,7 +304,7 @@ pub async fn shell(
292 if let Some(section) = section_menu {304 if let Some(section) = section_menu {
293 section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)305 section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)
294 } else {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 </div>309 </div>
298 </details>310 </details>
@@ -379,7 +391,7 @@ pub async fn shell(
379 if let Some(section) = section {391 if let Some(section) = section {
380 section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)392 section_nav(title: section.title.as_str(), back: section.back, items: section.items, current: section.current, live: section.live)
381 } else {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 </aside>396 </aside>
385 }397 }
@@ -409,16 +421,19 @@ pub async fn shell(
409 }421 }
410 422
411 /// The signed-in global links and the viewer's repos. The sidebar shows it, and so does the phone423 /// 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 #[component]426 #[component]
414 async fn side_nav(427 async fn side_nav(
415 lang: Lang,428 lang: Lang,
416 current: &str,429 current: &str,
430+ profile_repos_href: &str,
417 unread: Option<String>,431 unread: Option<String>,
418 repos: Vec<SideRepo>,432 repos: Vec<SideRepo>,
419 ) -> Result<impl View> {433 ) -> Result<impl View> {
420 let dashboard = current == "dashboard";434 let dashboard = current == "dashboard";
421 let explore = current == "explore";435 let explore = current == "explore";
436+ let repositories = current == "repositories";
422 let notifications = current == "notifications";437 let notifications = current == "notifications";
423 let snippets = current == "snippets";438 let snippets = current == "snippets";
424 let new_repo = current == "new";439 let new_repo = current == "new";
@@ -434,6 +449,10 @@ async fn side_nav(
434 <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>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 (t(lang, Key::Explore))450 (t(lang, Key::Explore))
436 </a>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 <a class=(side_class(notifications)) href="/notifications" aria-current=(notifications.then_some("page"))>456 <a class=(side_class(notifications)) href="/notifications" aria-current=(notifications.then_some("page"))>
438 <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>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 (t(lang, Key::Notifications))458 (t(lang, Key::Notifications))