git: Implement a basic repository selector (#23419)
This PR adds a rough-and-ready picker for selecting which of the project's repositories the git panel should display. Release Notes: - N/A --------- Co-authored-by: Nate Butler <iamnbutler@gmail.com> Co-authored-by: Nate <nate@zed.dev>
This commit is contained in:
parent
417760ade7
commit
31909bf334
13 changed files with 661 additions and 356 deletions
|
@ -47,6 +47,7 @@ util.workspace = true
|
|||
telemetry.workspace = true
|
||||
workspace.workspace = true
|
||||
zed_actions.workspace = true
|
||||
git_ui.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows.workspace = true
|
||||
|
|
|
@ -16,6 +16,8 @@ use auto_update::AutoUpdateStatus;
|
|||
use call::ActiveCall;
|
||||
use client::{Client, UserStore};
|
||||
use feature_flags::{FeatureFlagAppExt, ZedPro};
|
||||
use git_ui::repository_selector::RepositorySelector;
|
||||
use git_ui::repository_selector::RepositorySelectorPopoverMenu;
|
||||
use gpui::{
|
||||
actions, div, px, Action, AnyElement, AppContext, Decorations, Element, InteractiveElement,
|
||||
Interactivity, IntoElement, Model, MouseButton, ParentElement, Render, Stateful,
|
||||
|
@ -98,6 +100,7 @@ pub struct TitleBar {
|
|||
platform_style: PlatformStyle,
|
||||
content: Stateful<Div>,
|
||||
children: SmallVec<[AnyElement; 2]>,
|
||||
repository_selector: View<RepositorySelector>,
|
||||
project: Model<Project>,
|
||||
user_store: Model<UserStore>,
|
||||
client: Arc<Client>,
|
||||
|
@ -181,6 +184,7 @@ impl Render for TitleBar {
|
|||
title_bar
|
||||
.children(self.render_project_host(cx))
|
||||
.child(self.render_project_name(cx))
|
||||
.children(self.render_current_repository(cx))
|
||||
.children(self.render_project_branch(cx))
|
||||
})
|
||||
})
|
||||
|
@ -290,6 +294,7 @@ impl TitleBar {
|
|||
content: div().id(id.into()),
|
||||
children: SmallVec::new(),
|
||||
application_menu,
|
||||
repository_selector: cx.new_view(|cx| RepositorySelector::new(project.clone(), cx)),
|
||||
workspace: workspace.weak_handle(),
|
||||
should_move: false,
|
||||
project,
|
||||
|
@ -474,6 +479,39 @@ impl TitleBar {
|
|||
}))
|
||||
}
|
||||
|
||||
// NOTE: Not sure we want to keep this in the titlebar, but for while we are working on Git it is helpful in the short term
|
||||
pub fn render_current_repository(
|
||||
&self,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<impl IntoElement> {
|
||||
// TODO what to render if no active repository?
|
||||
let active_repository = self.project.read(cx).active_repository(cx)?;
|
||||
let display_name = active_repository.display_name(self.project.read(cx), cx);
|
||||
Some(RepositorySelectorPopoverMenu::new(
|
||||
self.repository_selector.clone(),
|
||||
ButtonLike::new("active-repository")
|
||||
.style(ButtonStyle::Subtle)
|
||||
.child(
|
||||
h_flex().w_full().gap_0p5().child(
|
||||
div()
|
||||
.overflow_x_hidden()
|
||||
.flex_grow()
|
||||
.whitespace_nowrap()
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
Label::new(display_name)
|
||||
.size(LabelSize::Small)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn render_project_branch(&self, cx: &mut ViewContext<Self>) -> Option<impl IntoElement> {
|
||||
let entry = {
|
||||
let mut names_and_branches =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue