update
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:
@@ -14,6 +14,7 @@ use gpui_native_kit::layout::panel::Panel;
|
||||
use gpui_native_kit::scrollbar::Scrollbar;
|
||||
use gpui_native_kit::segmented::{Segmented, SegmentedOption};
|
||||
use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use helpers::{IssueFilter, StatusCounts, filter_by_status};
|
||||
use metadata::ProfileDirectory;
|
||||
use nostr::prelude::PublicKey;
|
||||
use signed_core::GitEvent;
|
||||
@@ -21,8 +22,6 @@ use signed_state::RepoStore;
|
||||
use utils::relative_time;
|
||||
|
||||
use self::detail::IssueDetailView;
|
||||
use helpers::{IssueFilter, StatusCounts, filter_by_status};
|
||||
|
||||
use crate::shared::panels;
|
||||
use crate::shared::widgets::status_badge;
|
||||
use crate::workspace::Workspace;
|
||||
@@ -74,6 +73,11 @@ impl IssuesView {
|
||||
}
|
||||
}
|
||||
|
||||
/// Total number of issues across all statuses, for the sidebar label.
|
||||
pub fn total_count(&self) -> usize {
|
||||
self.counts.total
|
||||
}
|
||||
|
||||
fn rebuild(&mut self, cx: &mut Context<Self>) {
|
||||
let filter = self.filter;
|
||||
|
||||
|
||||
@@ -82,6 +82,11 @@ impl PullRequestsView {
|
||||
}
|
||||
}
|
||||
|
||||
/// Total number of pull requests across all statuses, for the sidebar label.
|
||||
pub fn total_count(&self) -> usize {
|
||||
self.counts.total
|
||||
}
|
||||
|
||||
fn rebuild(&mut self, cx: &mut Context<Self>) {
|
||||
let store = self.store.read(cx);
|
||||
let filter = self.filter;
|
||||
|
||||
@@ -9,7 +9,7 @@ use gpui::{
|
||||
use gpui_native_kit::avatar::Avatar;
|
||||
use gpui_native_kit::button::{Button, ButtonVariant};
|
||||
use gpui_native_kit::clipboard::ClipboardButton;
|
||||
use gpui_native_kit::common::{Sizable as _, h_flex, v_flex};
|
||||
use gpui_native_kit::common::{h_flex, v_flex};
|
||||
use gpui_native_kit::dropdown_menu::DropdownMenu;
|
||||
use gpui_native_kit::icons::{Icon, IconRole};
|
||||
use gpui_native_kit::menu::MenuItem;
|
||||
@@ -18,12 +18,10 @@ use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use gpui_native_kit::tooltip::Tooltip;
|
||||
use signed_state::{Backend, Nip34Kind};
|
||||
|
||||
use super::RepoDetailView;
|
||||
use super::actions;
|
||||
use super::dialogs;
|
||||
use super::helpers::{
|
||||
ShareTargets, bound_repo_label, clone_group, fork_row, nostr_clone_url, repo_display_name,
|
||||
};
|
||||
use super::{RepoDetailView, actions, dialogs};
|
||||
use crate::pull_requests::NewPullRequestView;
|
||||
|
||||
impl RepoDetailView {
|
||||
@@ -125,20 +123,19 @@ impl RepoDetailView {
|
||||
.flex_none()
|
||||
.p_4()
|
||||
.w_full()
|
||||
.gap_6()
|
||||
.border_b_1()
|
||||
.border_color(cx.theme().colors.border)
|
||||
.child(
|
||||
h_flex()
|
||||
.w_full()
|
||||
.gap_4()
|
||||
.gap_6()
|
||||
.items_start()
|
||||
.justify_between()
|
||||
.child(
|
||||
v_flex()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.gap_1()
|
||||
.gap_2()
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
@@ -151,23 +148,11 @@ impl RepoDetailView {
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.line_clamp(2)
|
||||
.line_clamp(3)
|
||||
.child(description),
|
||||
)
|
||||
.when_some(fork_row(&announcement, cx), |this, row| this.child(row))
|
||||
.child(
|
||||
h_flex()
|
||||
.mt_2()
|
||||
.w_full()
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption2, cx)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Maintainers:"),
|
||||
)
|
||||
.child(self.render_maintainers(cx)),
|
||||
),
|
||||
.child(h_flex().mt_4().gap_2().child(self.render_maintainers(cx))),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
@@ -210,9 +195,7 @@ impl RepoDetailView {
|
||||
}
|
||||
})
|
||||
.items(move |_, cx| {
|
||||
let owner = Backend::global(cx)
|
||||
.read(cx)
|
||||
.current_user()
|
||||
let owner = Backend::global(cx).read(cx).current_user()
|
||||
== Some(announcement_for_menu.owner);
|
||||
|
||||
let mut items = vec![MenuItem::new("About").handler({
|
||||
@@ -235,41 +218,51 @@ impl RepoDetailView {
|
||||
items.push(MenuItem::new("Republish").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.push_repository(window, cx);
|
||||
}) {
|
||||
if let Err(error) =
|
||||
weak.update(cx, |this, cx| {
|
||||
this.push_repository(window, cx);
|
||||
})
|
||||
{
|
||||
log::warn!("failed to republish: {error}");
|
||||
}
|
||||
}
|
||||
}));
|
||||
items.push(MenuItem::new("Reset remote to local").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.reset_remote(window, cx);
|
||||
}) {
|
||||
log::warn!("failed to reset remote: {error}");
|
||||
items.push(
|
||||
MenuItem::new("Reset remote to local").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) =
|
||||
weak.update(cx, |this, cx| {
|
||||
this.reset_remote(window, cx);
|
||||
})
|
||||
{
|
||||
log::warn!(
|
||||
"failed to reset remote: {error}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}),
|
||||
);
|
||||
items.push(MenuItem::separator());
|
||||
items.push(
|
||||
MenuItem::new("Delete")
|
||||
.destructive(true)
|
||||
.handler({
|
||||
MenuItem::new("Delete").destructive(true).handler(
|
||||
{
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) =
|
||||
weak.update(cx, |this, cx| {
|
||||
this.delete_repository(window, cx);
|
||||
this.delete_repository(
|
||||
window, cx,
|
||||
);
|
||||
})
|
||||
{
|
||||
log::warn!(
|
||||
"failed to delete repository: {error}"
|
||||
"failed to delete: {error}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -330,16 +323,18 @@ impl RepoDetailView {
|
||||
.child("No git clone urls."),
|
||||
)
|
||||
})
|
||||
.children(git_for_popover.iter().enumerate().map(
|
||||
|(ix, command)| {
|
||||
ClipboardButton::new(
|
||||
SharedString::from(format!(
|
||||
"copy-git-{ix}"
|
||||
)),
|
||||
command.clone(),
|
||||
)
|
||||
},
|
||||
)),
|
||||
.children(
|
||||
git_for_popover.iter().enumerate().map(
|
||||
|(ix, command)| {
|
||||
ClipboardButton::new(
|
||||
SharedString::from(format!(
|
||||
"copy-git-{ix}"
|
||||
)),
|
||||
command.clone(),
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
h_flex().justify_end().child(
|
||||
@@ -351,7 +346,9 @@ impl RepoDetailView {
|
||||
move |_, window, cx| {
|
||||
if let Err(error) =
|
||||
weak.update(cx, |this, cx| {
|
||||
this.clone_to_folder(window, cx);
|
||||
this.clone_to_folder(
|
||||
window, cx,
|
||||
);
|
||||
})
|
||||
{
|
||||
log::warn!(
|
||||
@@ -442,6 +439,7 @@ impl RepoDetailView {
|
||||
};
|
||||
|
||||
let mut seen = HashSet::new();
|
||||
|
||||
let rest: Vec<_> = announcement
|
||||
.maintainers
|
||||
.iter()
|
||||
@@ -464,8 +462,7 @@ impl RepoDetailView {
|
||||
.child(
|
||||
Avatar::new(announcement.owner)
|
||||
.name(owner_name.clone())
|
||||
.picture(owner.picture())
|
||||
.small(),
|
||||
.picture(owner.picture()),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
|
||||
@@ -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