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
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:
@@ -20,6 +20,7 @@ use ui::toast::{Toast, Toasts};
|
|||||||
|
|
||||||
use crate::app::placeholder::PlaceholderView;
|
use crate::app::placeholder::PlaceholderView;
|
||||||
use crate::app::sign_in::SignedOutView;
|
use crate::app::sign_in::SignedOutView;
|
||||||
|
use crate::explore::ExploreView;
|
||||||
use crate::identity;
|
use crate::identity;
|
||||||
use crate::shared::dialogs::DialogHost;
|
use crate::shared::dialogs::DialogHost;
|
||||||
use crate::titlebar::{
|
use crate::titlebar::{
|
||||||
@@ -54,24 +55,31 @@ impl AppRoot {
|
|||||||
|
|
||||||
let backend = Backend::global(cx);
|
let backend = Backend::global(cx);
|
||||||
let settings = SettingsStore::global(cx);
|
let settings = SettingsStore::global(cx);
|
||||||
|
|
||||||
let mut subscriptions = Vec::new();
|
let mut subscriptions = Vec::new();
|
||||||
|
|
||||||
subscriptions.push(
|
subscriptions.push(cx.subscribe_in(
|
||||||
cx.subscribe(&backend, |this, _backend, event, cx| match event {
|
&backend,
|
||||||
BackendEvent::PassphraseRequired => identity::helpers::open_passphrase(cx),
|
window,
|
||||||
|
|this, backend, event, window, cx| match event {
|
||||||
|
BackendEvent::PassphraseRequired => {
|
||||||
|
identity::helpers::open_passphrase(cx);
|
||||||
|
}
|
||||||
BackendEvent::Error(message) => {
|
BackendEvent::Error(message) => {
|
||||||
this.toasts.update(cx, |toasts, cx| {
|
this.toasts.update(cx, |toasts, cx| {
|
||||||
toasts.push(Toast::new(message.clone()).icon(IconRole::Warning), cx);
|
toasts.push(Toast::new(message.clone()).icon(IconRole::Warning), cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
BackendEvent::SignerChanged => {
|
BackendEvent::SignerChanged => {
|
||||||
this.workspace
|
this.workspace.update(cx, |workspace, cx| {
|
||||||
.update(cx, |workspace, cx| workspace.clear(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| {
|
subscriptions.push(cx.observe(&settings, |_this, store, cx| {
|
||||||
let settings = store.read(cx).settings().clone();
|
let settings = store.read(cx).settings().clone();
|
||||||
@@ -108,6 +116,7 @@ impl Render for AppRoot {
|
|||||||
let prefix = h_flex()
|
let prefix = h_flex()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(titlebar_view.render_new_repository())
|
.child(titlebar_view.render_new_repository())
|
||||||
|
.child(titlebar_view.render_explore())
|
||||||
.child(titlebar_view.repository_switcher());
|
.child(titlebar_view.repository_switcher());
|
||||||
|
|
||||||
let tab_bar = h_flex().gap_1().when_some(
|
let tab_bar = h_flex().gap_1().when_some(
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ mod helpers;
|
|||||||
|
|
||||||
use gpui::prelude::FluentBuilder as _;
|
use gpui::prelude::FluentBuilder as _;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyElement, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _, Render,
|
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
|
||||||
SharedString, Styled as _, Subscription, UniformListScrollHandle, WeakEntity, Window, div, px,
|
ParentElement as _, Render, SharedString, Styled as _, Subscription, UniformListScrollHandle,
|
||||||
uniform_list,
|
WeakEntity, Window, div, px, uniform_list,
|
||||||
};
|
};
|
||||||
use helpers::{RepoFilter, render_card};
|
use helpers::{RepoFilter, render_card};
|
||||||
use metadata::ProfileDirectory;
|
use metadata::ProfileDirectory;
|
||||||
@@ -19,6 +19,7 @@ use ui::scrollbar::Scrollbar;
|
|||||||
use ui::segmented::{Segmented, SegmentedOption};
|
use ui::segmented::{Segmented, SegmentedOption};
|
||||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||||
|
|
||||||
|
use crate::shared::panels;
|
||||||
use crate::workspace::Workspace;
|
use crate::workspace::Workspace;
|
||||||
|
|
||||||
const COLUMNS: usize = 2;
|
const COLUMNS: usize = 2;
|
||||||
@@ -39,6 +40,23 @@ pub struct ExploreView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
pub fn new(workspace: WeakEntity<Workspace>, cx: &mut Context<Self>) -> Self {
|
||||||
let store = RepoListStore::global(cx);
|
let store = RepoListStore::global(cx);
|
||||||
let directory = ProfileDirectory::new(cx);
|
let directory = ProfileDirectory::new(cx);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
mod app;
|
mod app;
|
||||||
#[allow(dead_code)] // temporarily unlinked while the shell migrates
|
|
||||||
mod explore;
|
mod explore;
|
||||||
mod identity;
|
mod identity;
|
||||||
#[allow(dead_code)] // temporarily unlinked while the shell migrates
|
#[allow(dead_code)] // temporarily unlinked while the shell migrates
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ use ui::command_palette::{Command, CommandPalette, CommandPaletteState};
|
|||||||
use ui::icons::{Icon, IconRole};
|
use ui::icons::{Icon, IconRole};
|
||||||
use ui::menu::{Menu, MenuItem};
|
use ui::menu::{Menu, MenuItem};
|
||||||
use ui::tabs::{Tab, Tabs, TabsVariant};
|
use ui::tabs::{Tab, Tabs, TabsVariant};
|
||||||
|
use ui::theme::ActiveTheme as _;
|
||||||
use ui::tooltip::Tooltip;
|
use ui::tooltip::Tooltip;
|
||||||
|
|
||||||
|
use crate::explore::ExploreView;
|
||||||
use crate::repo::{RepoDetailView, actions, dialogs};
|
use crate::repo::{RepoDetailView, actions, dialogs};
|
||||||
use crate::shared::{log_dropped, panels};
|
use crate::shared::{log_dropped, panels};
|
||||||
use crate::workspace::Workspace;
|
use crate::workspace::Workspace;
|
||||||
@@ -381,6 +383,12 @@ impl TitlebarView {
|
|||||||
let mut tab = Tab::new(id.clone(), label).closeable(true);
|
let mut tab = Tab::new(id.clone(), label).closeable(true);
|
||||||
if let Some(entry) = entry {
|
if let Some(entry) = entry {
|
||||||
tab = tab.lead(entry.avatar(&lookup_directory, cx));
|
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
|
tab
|
||||||
})
|
})
|
||||||
@@ -505,6 +513,20 @@ impl TitlebarView {
|
|||||||
Some(self.render_user(&profile, cx).into_any_element())
|
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 {
|
pub fn render_new_repository(&self) -> AnyElement {
|
||||||
let workspace = self.workspace.clone();
|
let workspace = self.workspace.clone();
|
||||||
|
|
||||||
|
|||||||
@@ -269,7 +269,6 @@ impl Render for RepositorySwitcher {
|
|||||||
on_create(window, cx);
|
on_create(window, cx);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.child(Separator::horizontal())
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("repo-switcher-rescan")
|
Button::new("repo-switcher-rescan")
|
||||||
.variant(ButtonVariant::Ghost)
|
.variant(ButtonVariant::Ghost)
|
||||||
|
|||||||
Reference in New Issue
Block a user