update
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s
Rust / build (macos-latest, stable) (pull_request) Canceled after 0s
Rust / build (ubuntu-latest, stable) (pull_request) Canceled after 0s
Rust / build (windows-latest, stable) (pull_request) Canceled after 0s
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s
Rust / build (macos-latest, stable) (pull_request) Canceled after 0s
Rust / build (ubuntu-latest, stable) (pull_request) Canceled after 0s
Rust / build (windows-latest, stable) (pull_request) Canceled after 0s
This commit is contained in:
@@ -7,7 +7,7 @@ use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
|
||||
ParentElement as _, PathPromptOptions, Render, SharedString, Styled as _, Subscription, Task,
|
||||
WeakEntity, Window, div, px,
|
||||
WeakEntity, Window, div,
|
||||
};
|
||||
use gpui_native_kit::alert::{Alert, AlertSeverity};
|
||||
use gpui_native_kit::badge::Badge;
|
||||
@@ -48,9 +48,6 @@ use crate::pull_requests::PullRequestsView;
|
||||
use crate::shared::tree::{build_tree_items, sorted_worktree_paths};
|
||||
use crate::workspace::Workspace;
|
||||
|
||||
const REPO_SIDEBAR_WIDTH: f32 = 240.;
|
||||
const REPO_SIDEBAR_ROW_HEIGHT: f32 = 30.;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub(super) enum RepoSection {
|
||||
Files,
|
||||
@@ -1211,14 +1208,11 @@ impl RepoDetailView {
|
||||
}
|
||||
|
||||
fn render_sidebar(&self, cx: &mut Context<Self>) -> AnyElement {
|
||||
let tree = self.files.read(cx).render_tree(self.files.downgrade());
|
||||
let commits = self
|
||||
.history
|
||||
.read(cx)
|
||||
.commit_count()
|
||||
.map(|count| SharedString::from(format!("Commits ({count})")))
|
||||
.unwrap_or_else(|| SharedString::from("Commits"));
|
||||
let files = self.files.clone();
|
||||
let commit_count = self.history.read(cx).commit_count();
|
||||
let include_issues = self.store.read(cx).addr().is_some();
|
||||
let issue_count = include_issues.then(|| self.issues.read(cx).total_count());
|
||||
let pull_count = include_issues.then(|| self.pulls.read(cx).total_count());
|
||||
let selected = match self.active_section {
|
||||
RepoSection::Commits => Some(0),
|
||||
RepoSection::Issues if include_issues => Some(1),
|
||||
@@ -1226,11 +1220,10 @@ impl RepoDetailView {
|
||||
_ => None,
|
||||
};
|
||||
let weak = cx.entity().downgrade();
|
||||
let rows = if include_issues { 3.0 } else { 1.0 };
|
||||
let nav_height = px(REPO_SIDEBAR_ROW_HEIGHT * rows + 8.);
|
||||
|
||||
let nav = Sidebar::new("repo-sidebar-nav")
|
||||
Sidebar::new("repo-sidebar")
|
||||
.selected(selected)
|
||||
.border_right(true)
|
||||
.on_change(move |index, _, cx| {
|
||||
let section = match (index, include_issues) {
|
||||
(Some(0), _) => RepoSection::Commits,
|
||||
@@ -1245,43 +1238,34 @@ impl RepoDetailView {
|
||||
})
|
||||
.entries(move |_, cx| {
|
||||
let color = cx.theme().colors.muted_foreground;
|
||||
|
||||
let mut entries = vec![
|
||||
SidebarEntry::row("repo-nav-commits", commits.clone())
|
||||
.prefix(Icon::named(CustomIconName::GitCommit).small().color(color)),
|
||||
SidebarEntry::row("repo-nav-commits", "Commits")
|
||||
.prefix(Icon::named(CustomIconName::GitCommit).color(color))
|
||||
.when_some(commit_count, |entry, count| entry.detail(count.to_string())),
|
||||
];
|
||||
|
||||
if include_issues {
|
||||
entries.push(
|
||||
SidebarEntry::row("repo-nav-issues", "Issues").prefix(
|
||||
Icon::named(CustomIconName::GitIssueDone)
|
||||
.small()
|
||||
.color(color),
|
||||
),
|
||||
SidebarEntry::row("repo-nav-issues", "Issues")
|
||||
.prefix(Icon::named(CustomIconName::GitIssueDone).color(color))
|
||||
.when_some(issue_count, |entry, count| entry.detail(count.to_string())),
|
||||
);
|
||||
entries.push(
|
||||
SidebarEntry::row("repo-nav-pulls", "Pull requests").prefix(
|
||||
Icon::named(CustomIconName::GitPullRequest)
|
||||
.small()
|
||||
.color(color),
|
||||
),
|
||||
SidebarEntry::row("repo-nav-pulls", "Pull requests")
|
||||
.prefix(Icon::named(CustomIconName::GitPullRequest).color(color))
|
||||
.when_some(pull_count, |entry, count| entry.detail(count.to_string())),
|
||||
);
|
||||
}
|
||||
entries
|
||||
});
|
||||
|
||||
div()
|
||||
.w(px(REPO_SIDEBAR_WIDTH))
|
||||
.h_full()
|
||||
.flex_none()
|
||||
.border_r_1()
|
||||
.border_color(cx.theme().colors.border)
|
||||
.child(
|
||||
Sidebar::new("repo-sidebar").content(
|
||||
v_flex()
|
||||
.size_full()
|
||||
.child(div().h(nav_height).flex_none().child(nav))
|
||||
.child(div().flex_1().min_h_0().px_2().pb_2().child(tree)),
|
||||
),
|
||||
)
|
||||
entries.push(SidebarEntry::header("Files"));
|
||||
|
||||
entries.push(SidebarEntry::custom(
|
||||
files.read(cx).render_tree(files.downgrade()),
|
||||
));
|
||||
|
||||
entries
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
@@ -1299,6 +1283,8 @@ impl Panel for RepoDetailView {}
|
||||
|
||||
impl Render for RepoDetailView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let weak = cx.entity().downgrade();
|
||||
|
||||
let banner = self
|
||||
.render_ready_banner(cx)
|
||||
.or_else(|| self.render_push_banner(cx))
|
||||
@@ -1312,8 +1298,6 @@ impl Render for RepoDetailView {
|
||||
.map(SharedString::from)
|
||||
});
|
||||
|
||||
let weak = cx.entity().downgrade();
|
||||
|
||||
v_flex()
|
||||
.id("repo")
|
||||
.size_full()
|
||||
|
||||
Reference in New Issue
Block a user