wire explore view into workspace and titlebar
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run

This commit is contained in:
2026-11-17 19:23:26 +07:00
parent c63acc8867
commit b491ae9d03
5 changed files with 60 additions and 13 deletions
+17 -8
View File
@@ -20,6 +20,7 @@ use ui::toast::{Toast, Toasts};
use crate::app::placeholder::PlaceholderView;
use crate::app::sign_in::SignedOutView;
use crate::explore::ExploreView;
use crate::identity;
use crate::shared::dialogs::DialogHost;
use crate::titlebar::{
@@ -54,24 +55,31 @@ impl AppRoot {
let backend = Backend::global(cx);
let settings = SettingsStore::global(cx);
let mut subscriptions = Vec::new();
subscriptions.push(
cx.subscribe(&backend, |this, _backend, event, cx| match event {
BackendEvent::PassphraseRequired => identity::helpers::open_passphrase(cx),
subscriptions.push(cx.subscribe_in(
&backend,
window,
|this, backend, event, window, cx| match event {
BackendEvent::PassphraseRequired => {
identity::helpers::open_passphrase(cx);
}
BackendEvent::Error(message) => {
this.toasts.update(cx, |toasts, cx| {
toasts.push(Toast::new(message.clone()).icon(IconRole::Warning), cx);
});
}
BackendEvent::SignerChanged => {
this.workspace
.update(cx, |workspace, cx| workspace.clear(cx));
this.workspace.update(cx, |workspace, cx| {
workspace.clear(cx);
});
if backend.read(cx).current_user().is_some() {
ExploreView::open(&this.workspace.downgrade(), window, cx);
}
}
_ => {}
}),
);
},
));
subscriptions.push(cx.observe(&settings, |_this, store, cx| {
let settings = store.read(cx).settings().clone();
@@ -108,6 +116,7 @@ impl Render for AppRoot {
let prefix = h_flex()
.gap_1()
.child(titlebar_view.render_new_repository())
.child(titlebar_view.render_explore())
.child(titlebar_view.repository_switcher());
let tab_bar = h_flex().gap_1().when_some(
+21 -3
View File
@@ -2,9 +2,9 @@ mod helpers;
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _, Render,
SharedString, Styled as _, Subscription, UniformListScrollHandle, WeakEntity, Window, div, px,
uniform_list,
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
ParentElement as _, Render, SharedString, Styled as _, Subscription, UniformListScrollHandle,
WeakEntity, Window, div, px, uniform_list,
};
use helpers::{RepoFilter, render_card};
use metadata::ProfileDirectory;
@@ -19,6 +19,7 @@ use ui::scrollbar::Scrollbar;
use ui::segmented::{Segmented, SegmentedOption};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
use crate::shared::panels;
use crate::workspace::Workspace;
const COLUMNS: usize = 2;
@@ -39,6 +40,23 @@ pub struct ExploreView {
}
impl ExploreView {
/// The identifier of the explore panel in the workspace; shown as its tab label.
pub(crate) const PANEL_ID: &'static str = "Explore";
/// Opens the explore panel in the main panel, reusing it when it is already cached.
pub(crate) fn open(workspace: &WeakEntity<Workspace>, window: &mut Window, cx: &mut App) {
panels::open_primary(
workspace,
Self::PANEL_ID,
{
let workspace = workspace.clone();
move |_, cx| cx.new(|cx| Self::new(workspace.clone(), cx))
},
window,
cx,
);
}
pub fn new(workspace: WeakEntity<Workspace>, cx: &mut Context<Self>) -> Self {
let store = RepoListStore::global(cx);
let directory = ProfileDirectory::new(cx);
-1
View File
@@ -1,5 +1,4 @@
mod app;
#[allow(dead_code)] // temporarily unlinked while the shell migrates
mod explore;
mod identity;
#[allow(dead_code)] // temporarily unlinked while the shell migrates
+22
View File
@@ -18,8 +18,10 @@ use ui::command_palette::{Command, CommandPalette, CommandPaletteState};
use ui::icons::{Icon, IconRole};
use ui::menu::{Menu, MenuItem};
use ui::tabs::{Tab, Tabs, TabsVariant};
use ui::theme::ActiveTheme as _;
use ui::tooltip::Tooltip;
use crate::explore::ExploreView;
use crate::repo::{RepoDetailView, actions, dialogs};
use crate::shared::{log_dropped, panels};
use crate::workspace::Workspace;
@@ -381,6 +383,12 @@ impl TitlebarView {
let mut tab = Tab::new(id.clone(), label).closeable(true);
if let Some(entry) = entry {
tab = tab.lead(entry.avatar(&lookup_directory, cx));
} else if *id == ExploreView::PANEL_ID {
tab = tab.lead(
Icon::named(IconRole::Grid)
.small()
.color(cx.theme().colors.muted_foreground),
);
}
tab
})
@@ -505,6 +513,20 @@ impl TitlebarView {
Some(self.render_user(&profile, cx).into_any_element())
}
pub fn render_explore(&self) -> AnyElement {
let workspace = self.workspace.clone();
Button::new("open-explore")
.icon(IconRole::Grid)
.variant(ButtonVariant::Ghost)
.fully_rounded(true)
.tooltip(Tooltip::text("Explore repositories"))
.on_click(move |_, window, cx| {
ExploreView::open(&workspace, window, cx);
})
.into_any_element()
}
pub fn render_new_repository(&self) -> AnyElement {
let workspace = self.workspace.clone();
@@ -269,7 +269,6 @@ impl Render for RepositorySwitcher {
on_create(window, cx);
}),
)
.child(Separator::horizontal())
.child(
Button::new("repo-switcher-rescan")
.variant(ButtonVariant::Ghost)