From aa260de0d2396744a339e2243d12f060dfa8be22 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Mon, 16 Nov 2026 10:49:56 +0700 Subject: [PATCH] update --- Cargo.lock | 102 ++-- Cargo.toml | 6 +- crates/signed_app/src/repo/banners.rs | 54 --- crates/signed_app/src/repo/header.rs | 664 ++++++++++++++++---------- crates/signed_app/src/repo/mod.rs | 387 +-------------- 5 files changed, 453 insertions(+), 760 deletions(-) delete mode 100644 crates/signed_app/src/repo/banners.rs diff --git a/Cargo.lock b/Cargo.lock index 9603c10..8722af0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -932,7 +932,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "gpui_util", "indexmap", @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "proc-macro2", "quote", @@ -1722,12 +1722,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce81f49ae8a0482e4c55ea62ebbd7e5a686af544c00b9d090bba3ff9be97b3d" -[[package]] -name = "float_next_after" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" - [[package]] name = "flume" version = "0.11.1" @@ -2994,7 +2988,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.2.2" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "accesskit", "anyhow", @@ -3020,7 +3014,7 @@ dependencies = [ "itertools", "libc", "log", - "lyon", + "lyon_path", "num_cpus", "objc2-core-foundation", "objc2-core-video", @@ -3046,6 +3040,7 @@ dependencies = [ "sum_tree", "taffy", "thiserror 2.0.21", + "tiny-skia-path", "ttf-parser", "unicode-segmentation", "url", @@ -3059,7 +3054,7 @@ dependencies = [ [[package]] name = "gpui-native-core" version = "0.1.0" -source = "git+https://git.reya.info/reya/gpui-native-kit#a7abeea8c6c377ab36e6675371743a31d0816c2a" +source = "git+https://git.reya.info/reya/gpui-native-kit#573d8a8303c216413992d685e431f6d8962758ca" dependencies = [ "cpal", "flume 0.12.0", @@ -3075,7 +3070,7 @@ dependencies = [ [[package]] name = "gpui-native-data" version = "0.1.0" -source = "git+https://git.reya.info/reya/gpui-native-kit#a7abeea8c6c377ab36e6675371743a31d0816c2a" +source = "git+https://git.reya.info/reya/gpui-native-kit#573d8a8303c216413992d685e431f6d8962758ca" dependencies = [ "gpui", "gpui-native-core", @@ -3087,7 +3082,7 @@ dependencies = [ [[package]] name = "gpui-native-editor" version = "0.1.0" -source = "git+https://git.reya.info/reya/gpui-native-kit#a7abeea8c6c377ab36e6675371743a31d0816c2a" +source = "git+https://git.reya.info/reya/gpui-native-kit#573d8a8303c216413992d685e431f6d8962758ca" dependencies = [ "gpui", "gpui-native-core", @@ -3106,7 +3101,7 @@ dependencies = [ [[package]] name = "gpui-native-icons" version = "0.1.0" -source = "git+https://git.reya.info/reya/gpui-native-kit#a7abeea8c6c377ab36e6675371743a31d0816c2a" +source = "git+https://git.reya.info/reya/gpui-native-kit#573d8a8303c216413992d685e431f6d8962758ca" dependencies = [ "anyhow", "gpui", @@ -3115,7 +3110,7 @@ dependencies = [ [[package]] name = "gpui-native-kit" version = "0.1.0" -source = "git+https://git.reya.info/reya/gpui-native-kit#a7abeea8c6c377ab36e6675371743a31d0816c2a" +source = "git+https://git.reya.info/reya/gpui-native-kit#573d8a8303c216413992d685e431f6d8962758ca" dependencies = [ "gpui", "gpui-native-core", @@ -3129,7 +3124,7 @@ dependencies = [ [[package]] name = "gpui-native-layout" version = "0.1.0" -source = "git+https://git.reya.info/reya/gpui-native-kit#a7abeea8c6c377ab36e6675371743a31d0816c2a" +source = "git+https://git.reya.info/reya/gpui-native-kit#573d8a8303c216413992d685e431f6d8962758ca" dependencies = [ "gpui", "gpui-native-core", @@ -3141,7 +3136,7 @@ dependencies = [ [[package]] name = "gpui-native-theme" version = "0.1.0" -source = "git+https://git.reya.info/reya/gpui-native-kit#a7abeea8c6c377ab36e6675371743a31d0816c2a" +source = "git+https://git.reya.info/reya/gpui-native-kit#573d8a8303c216413992d685e431f6d8962758ca" dependencies = [ "anyhow", "async-channel", @@ -3162,7 +3157,7 @@ dependencies = [ [[package]] name = "gpui-native-utils" version = "0.1.0" -source = "git+https://git.reya.info/reya/gpui-native-kit#a7abeea8c6c377ab36e6675371743a31d0816c2a" +source = "git+https://git.reya.info/reya/gpui-native-kit#573d8a8303c216413992d685e431f6d8962758ca" dependencies = [ "gpui", "gpui-native-theme", @@ -3172,7 +3167,7 @@ dependencies = [ [[package]] name = "gpui_apple" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "async-task", @@ -3211,7 +3206,7 @@ dependencies = [ [[package]] name = "gpui_ios" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "block2 0.6.2", @@ -3232,7 +3227,7 @@ dependencies = [ [[package]] name = "gpui_linux" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "accesskit", "anyhow", @@ -3259,7 +3254,7 @@ dependencies = [ [[package]] name = "gpui_macos" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "accesskit", "accesskit_macos", @@ -3291,6 +3286,7 @@ dependencies = [ "raw-window-handle", "scheduler", "semver", + "serde_json", "smallvec", "strum", "uuid", @@ -3299,7 +3295,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3310,7 +3306,7 @@ dependencies = [ [[package]] name = "gpui_platform" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "console_error_panic_hook", @@ -3325,7 +3321,7 @@ dependencies = [ [[package]] name = "gpui_shared_string" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "schemars", "serde", @@ -3335,7 +3331,7 @@ dependencies = [ [[package]] name = "gpui_util" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "log", @@ -3345,7 +3341,7 @@ dependencies = [ [[package]] name = "gpui_web" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "async-channel", @@ -3374,7 +3370,7 @@ dependencies = [ [[package]] name = "gpui_wgpu" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "bytemuck", @@ -3384,6 +3380,7 @@ dependencies = [ "gpui", "gpui_util", "itertools", + "js-sys", "log", "parking_lot", "profiling", @@ -3399,7 +3396,7 @@ dependencies = [ [[package]] name = "gpui_windows" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "accesskit", "accesskit_windows", @@ -3665,7 +3662,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "bytes", @@ -3682,7 +3679,7 @@ dependencies = [ [[package]] name = "http_client_tls" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "log", "rustls", @@ -4422,26 +4419,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" -[[package]] -name = "lyon" -version = "1.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd0578bdecb7d6d88987b8b2b1e3a4e2f81df9d0ece1078623324a567904e7b7" -dependencies = [ - "lyon_algorithms", - "lyon_tessellation", -] - -[[package]] -name = "lyon_algorithms" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a6b9d4e8b48acd531fbf1241ad9b270df6e60b6b92bdea1469f4f40899d805" -dependencies = [ - "lyon_path", - "num-traits", -] - [[package]] name = "lyon_geom" version = "1.0.20" @@ -4463,17 +4440,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "lyon_tessellation" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4872650e70dc907dd4f7ebc449d7d657a0d2658e423b2e724970870bbbf75b" -dependencies = [ - "float_next_after", - "lyon_path", - "num-traits", -] - [[package]] name = "mac-notification-sys" version = "0.6.15" @@ -6212,7 +6178,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "derive_refineable", ] @@ -6295,7 +6261,7 @@ dependencies = [ [[package]] name = "reqwest_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "bytes", @@ -6587,7 +6553,7 @@ dependencies = [ [[package]] name = "scheduler" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "async-task", "backtrace", @@ -7213,7 +7179,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "heapless 0.9.3", "rayon", @@ -9502,7 +9468,7 @@ dependencies = [ [[package]] name = "ztracing" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "tracing", "ztracing_macro", @@ -9511,7 +9477,7 @@ dependencies = [ [[package]] name = "ztracing_macro" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" [[package]] name = "zune-core" diff --git a/Cargo.toml b/Cargo.toml index f681989..73f1524 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,9 @@ edition = "2024" publish = false [workspace.dependencies] -gpui = { git = "https://github.com/zed-industries/zed", rev = "f8cfc7ed9e57503def9479138894f3139f5400cc" } -gpui_platform = { git = "https://github.com/zed-industries/zed", rev = "f8cfc7ed9e57503def9479138894f3139f5400cc", features = ["font-kit"] } -reqwest_client = { git = "https://github.com/zed-industries/zed", rev = "f8cfc7ed9e57503def9479138894f3139f5400cc" } +gpui = { git = "https://github.com/zed-industries/zed" } +gpui_platform = { git = "https://github.com/zed-industries/zed", features = ["font-kit"] } +reqwest_client = { git = "https://github.com/zed-industries/zed" } gpui-native-kit = { git = "https://git.reya.info/reya/gpui-native-kit", features = ["layout", "editor"] } diff --git a/crates/signed_app/src/repo/banners.rs b/crates/signed_app/src/repo/banners.rs deleted file mode 100644 index e0fca04..0000000 --- a/crates/signed_app/src/repo/banners.rs +++ /dev/null @@ -1,54 +0,0 @@ -use std::collections::HashSet; -use std::path::PathBuf; - -use signed_state::{CheckoutStatus, CheckoutSyncStatus}; - -#[derive(Default)] -pub(super) struct Banners { - dismissed: HashSet<(PathBuf, String)>, - sync_dismissed: HashSet, - ready_requested: bool, - ready_head: Option, - ready_statuses: Vec, - push_statuses: Vec, -} - -impl Banners { - pub(super) fn dismissal(&self, status: &CheckoutStatus) -> bool { - self.dismissed - .contains(&(status.path.clone(), status.branch.clone())) - } - - pub(super) fn dismiss(&mut self, status: &CheckoutStatus) { - self.dismissed - .insert((status.path.clone(), status.branch.clone())); - } - - pub(super) fn sync_dismissal(&self, checkout: &CheckoutSyncStatus) -> bool { - self.sync_dismissed.contains(&checkout.path) - } - - pub(super) fn sync_dismiss(&mut self, checkout: &CheckoutSyncStatus) { - self.sync_dismissed.insert(checkout.path.clone()); - } - - pub(super) fn ready_requested_at(&self) -> (bool, &Option) { - (self.ready_requested, &self.ready_head) - } - - pub(super) fn mark_ready_requested(&mut self, head: Option) { - self.ready_requested = true; - self.ready_head = head; - } - - pub(super) fn set_statuses( - &mut self, - ready: Vec, - push: Vec, - ) -> bool { - let changed = ready != self.ready_statuses || push != self.push_statuses; - self.ready_statuses = ready; - self.push_statuses = push; - changed - } -} diff --git a/crates/signed_app/src/repo/header.rs b/crates/signed_app/src/repo/header.rs index bb155a1..f2d111e 100644 --- a/crates/signed_app/src/repo/header.rs +++ b/crates/signed_app/src/repo/header.rs @@ -3,8 +3,9 @@ use std::collections::HashSet; use assets::CustomIconName; use gpui::prelude::FluentBuilder as _; use gpui::{ - AnyElement, AppContext as _, ClipboardItem, Context, IntoElement, ParentElement as _, - SharedString, Styled as _, Window, div, px, + AnyElement, App, AppContext as _, Context, InteractiveElement as _, IntoElement, + ParentElement as _, SharedString, StatefulInteractiveElement as _, Styled as _, Window, div, + px, }; use gpui_native_kit::avatar::Avatar; use gpui_native_kit::button::{Button, ButtonVariant}; @@ -16,14 +17,44 @@ use gpui_native_kit::menu::MenuItem; use gpui_native_kit::popover::Popover; use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _}; use gpui_native_kit::tooltip::Tooltip; -use signed_state::{Backend, Nip34Kind}; +use signed_state::{Backend, CheckoutStatus, CheckoutSyncStatus, CheckoutsStore, Nip34Kind}; +use utils::relative_time_secs; -use super::helpers::{ - ShareTargets, bound_repo_label, clone_group, fork_row, nostr_clone_url, repo_display_name, -}; +use super::helpers::{bound_repo_label, clone_group, fork_row, nostr_clone_url, repo_display_name}; use super::{RepoDetailView, actions, dialogs}; use crate::pull_requests::NewPullRequestView; +/// Push and sync bookkeeping for the repository header. +#[derive(Default)] +pub(super) struct Banners { + ready_requested: bool, + ready_head: Option, + ready_statuses: Vec, + push_statuses: Vec, +} + +impl Banners { + pub(super) fn ready_requested_at(&self) -> (bool, &Option) { + (self.ready_requested, &self.ready_head) + } + + pub(super) fn mark_ready_requested(&mut self, head: Option) { + self.ready_requested = true; + self.ready_head = head; + } + + pub(super) fn set_statuses( + &mut self, + ready: Vec, + push: Vec, + ) -> bool { + let changed = ready != self.ready_statuses || push != self.push_statuses; + self.ready_statuses = ready; + self.push_statuses = push; + changed + } +} + impl RepoDetailView { pub(super) fn open_upstream(&mut self, window: &mut Window, cx: &mut Context) { let Some(addr) = self @@ -75,11 +106,12 @@ impl RepoDetailView { ); } - pub(super) fn render_header(&mut self, cx: &mut Context) -> AnyElement { + pub(super) fn render_about(&mut self, cx: &mut Context) -> AnyElement { if self.store.read(cx).addr().is_none() { return self.render_local_header(cx); } + let backend = Backend::global(cx); let store = self.store.read(cx); let pushing = store.pushing; let cloning = store.cloning; @@ -97,7 +129,6 @@ impl RepoDetailView { .clone() .filter(|nip05| !nip05.trim().is_empty()); - let share = ShareTargets::from_announcement(&announcement); let nostr_url = nostr_clone_url(&announcement, nip05.as_deref()); let ngit_command = SharedString::from(format!("git clone {nostr_url}")); let nak_command = SharedString::from(format!("nak git clone {nostr_url}")); @@ -107,10 +138,7 @@ impl RepoDetailView { let description = announcement.description(); let avatar = Avatar::new(format!("{}:{}", announcement.owner, announcement.id)); - let share_naddr = share.naddr.clone(); - let share_for_menu = share.clone(); let announcement_for_menu = announcement.clone(); - let weak_share = cx.entity().downgrade(); let weak_menu_open = cx.entity().downgrade(); let weak_menu_items = cx.entity().downgrade(); let weak_clone = cx.entity().downgrade(); @@ -119,256 +147,206 @@ impl RepoDetailView { let nak_for_popover = nak_command.clone(); let git_for_popover = git_commands.clone(); - v_flex() - .flex_none() - .p_4() + h_flex() + .p_2() .w_full() - .border_b_1() - .border_color(cx.theme().colors.border) + .gap_6() + .items_start() + .justify_between() .child( - h_flex() - .w_full() - .gap_6() - .items_start() - .justify_between() - .child( - v_flex() - .flex_1() - .min_w_0() - .gap_2() - .child( - h_flex() - .gap_2() - .typeset(TextRole::Headline, cx) - .child(avatar) - .child(name), - ) - .child( - div() - .min_w_0() - .typeset(TextRole::Body, cx) - .text_color(cx.theme().colors.muted_foreground) - .line_clamp(3) - .child(description), - ) - .when_some(fork_row(&announcement, cx), |this, row| this.child(row)) - .child(h_flex().mt_4().gap_2().child(self.render_maintainers(cx))), - ) + v_flex() + .flex_1() + .min_w_0() + .gap_2() .child( h_flex() - .flex_none() .gap_2() - .justify_end() - .child( - DropdownMenu::new("share") - .icon(Icon::named(IconRole::Copy)) - .variant(ButtonVariant::Secondary) - .open(self.share_open) - .on_click(move |_, _, cx| { - cx.write_to_clipboard(ClipboardItem::new_string( - share_naddr.clone(), - )); - }) - .on_open_change(move |open, _, cx| { - if let Err(error) = weak_share.update(cx, |this, cx| { - this.share_open = open; - cx.notify(); - }) { - log::warn!("failed to update share menu: {error}"); - } - }) - .items(move |_, _| share_for_menu.menu()), - ) - .child( - DropdownMenu::new("repo-menu") - .icon(Icon::named(CustomIconName::EllipsisVertical)) - .variant(ButtonVariant::Secondary) - .loading(pushing) - .disabled(pushing) - .open(self.repo_menu_open) - .on_open_change(move |open, _, cx| { - if let Err(error) = weak_menu_open.update(cx, |this, cx| { - this.repo_menu_open = open; - cx.notify(); - }) { - log::warn!("failed to update repo menu: {error}"); - } - }) - .items(move |_, cx| { - let owner = Backend::global(cx).read(cx).current_user() - == Some(announcement_for_menu.owner); + .typeset(TextRole::Headline, cx) + .child(avatar) + .child(name), + ) + .child( + div() + .min_w_0() + .typeset(TextRole::Body, cx) + .text_color(cx.theme().colors.muted_foreground) + .line_clamp(3) + .child(description), + ) + .when_some(fork_row(&announcement, cx), |this, row| this.child(row)), + ) + .child( + h_flex() + .flex_none() + .gap_2() + .justify_end() + .child( + DropdownMenu::new("repo-menu") + .variant(ButtonVariant::Secondary) + .loading(pushing) + .disabled(pushing) + .open(self.repo_menu_open) + .on_open_change(move |open, _, cx| { + if let Err(error) = weak_menu_open.update(cx, |this, cx| { + this.repo_menu_open = open; + cx.notify(); + }) { + log::warn!("failed to update repo menu: {error}"); + } + }) + .items(move |_, cx| { + let owner = backend.read(cx).current_user() + == Some(announcement_for_menu.owner); - let mut items = vec![MenuItem::new("About").handler({ + let mut items = vec![MenuItem::new("About").handler({ + let weak = weak_menu_items.clone(); + let announcement = announcement_for_menu.clone(); + move |_, cx| { + if let Err(error) = weak.update(cx, |this, cx| { + dialogs::about::open( + announcement.clone(), + this.directory.clone(), + cx, + ); + }) { + log::warn!("failed to open about: {error}"); + } + } + })]; + + if owner { + 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); + }) { + 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::separator()); + items.push(MenuItem::new("Delete").destructive(true).handler( + { let weak = weak_menu_items.clone(); - let announcement = announcement_for_menu.clone(); - move |_, cx| { + move |window, cx| { if let Err(error) = weak.update(cx, |this, cx| { - dialogs::about::open( - announcement.clone(), - this.directory.clone(), - cx, - ); + this.delete_repository(window, cx); }) { - log::warn!("failed to open about: {error}"); + log::warn!("failed to delete: {error}"); } } - })]; + }, + )); + } - if owner { - 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); - }) - { - log::warn!("failed to republish: {error}"); - } - } - })); - items.push( - MenuItem::new("Reset remote to local").handler({ - let weak = weak_menu_items.clone(); - move |window, cx| { + items + }), + ) + .when_some(self.render_sync_button(cx), |this, button| { + this.child(button) + }) + .child( + Popover::new("clone") + .open(self.clone_open) + .on_change(move |open, _, cx| { + if let Err(error) = weak_clone.update(cx, |this, cx| { + this.clone_open = open; + cx.notify(); + }) { + log::warn!("failed to update clone popover: {error}"); + } + }) + .trigger(move |_, _| { + Button::new("clone") + .label("Clone") + .icon(Icon::named(CustomIconName::GitClone)) + .tooltip(Tooltip::text("Clone repository")) + .loading(cloning) + .disabled(cloning) + .into_any_element() + }) + .content(move |_, cx| { + v_flex() + .w(px(440.)) + .p_3() + .gap_4() + .child(clone_group( + "Clone with ngit", + "copy-ngit", + &ngit_for_popover, + cx, + )) + .child(clone_group( + "Clone with nak", + "copy-nak", + &nak_for_popover, + cx, + )) + .child( + v_flex() + .gap_1() + .child( + div() + .typeset(TextRole::Caption, cx) + .text_color(cx.theme().colors.muted_foreground) + .child("Grasp Servers"), + ) + .when(git_for_popover.is_empty(), |this| { + this.child( + div() + .typeset(TextRole::Caption, cx) + .child("No git clone urls."), + ) + }) + .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( + Button::new("download") + .icon(Icon::named(CustomIconName::GitClone)) + .label("Download") + .on_click({ + let weak = weak_download.clone(); + move |_, window, cx| { if let Err(error) = weak.update(cx, |this, cx| { - this.reset_remote(window, cx); + this.clone_to_folder(window, cx); }) { - log::warn!( - "failed to reset remote: {error}" - ); + log::warn!("failed to clone: {error}"); } } }), - ); - items.push(MenuItem::separator()); - items.push( - 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, - ); - }) - { - log::warn!( - "failed to delete: {error}" - ); - } - } - }, - ), - ); - } - - items - }), - ) - .child( - Popover::new("clone") - .open(self.clone_open) - .on_change(move |open, _, cx| { - if let Err(error) = weak_clone.update(cx, |this, cx| { - this.clone_open = open; - cx.notify(); - }) { - log::warn!("failed to update clone popover: {error}"); - } - }) - .trigger(move |_, _| { - Button::new("clone") - .icon(Icon::named(CustomIconName::GitClone)) - .tooltip(Tooltip::text("Clone")) - .loading(cloning) - .disabled(cloning) - .into_any_element() - }) - .content(move |_, cx| { - v_flex() - .w(px(440.)) - .p_3() - .gap_4() - .child(clone_group( - "Clone with ngit", - "copy-ngit", - &ngit_for_popover, - cx, - )) - .child(clone_group( - "Clone with nak", - "copy-nak", - &nak_for_popover, - cx, - )) - .child( - v_flex() - .gap_1() - .child( - div() - .typeset(TextRole::Caption, cx) - .text_color( - cx.theme().colors.muted_foreground, - ) - .child("Grasp Servers"), - ) - .when(git_for_popover.is_empty(), |this| { - this.child( - div() - .typeset(TextRole::Caption, cx) - .child("No git clone urls."), - ) - }) - .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( - Button::new("download") - .icon(Icon::named(CustomIconName::GitClone)) - .label("Download") - .on_click({ - let weak = weak_download.clone(); - move |_, window, cx| { - if let Err(error) = - weak.update(cx, |this, cx| { - this.clone_to_folder( - window, cx, - ); - }) - { - log::warn!( - "failed to clone: {error}" - ); - } - } - }), - ), - ) - .into_any_element() - }), - ), + ), + ) + .into_any_element() + }), ), ) .into_any_element() } fn render_local_header(&self, cx: &mut Context) -> AnyElement { - let name = repo_display_name(self.store.read(cx)); let path = self .store .read(cx) @@ -376,6 +354,8 @@ impl RepoDetailView { .as_ref() .map(|path| path.display().to_string()) .unwrap_or_default(); + + let name = repo_display_name(self.store.read(cx)); let avatar = Avatar::new(path.clone()); let bound = self.store.read(cx).nip34.clone(); @@ -433,6 +413,174 @@ impl RepoDetailView { .into_any_element() } + /// A checkout with commits the repository owner has not pushed yet. + pub(super) fn push_suggestion(&self, cx: &App) -> Option { + let store = self.store.read(cx); + let addr = store.addr()?; + let user = Backend::global(cx).read(cx).current_user()?; + + if !store.is_author(&user) { + return None; + } + + CheckoutsStore::global(cx) + .read(cx) + .push_statuses_of(addr) + .into_iter() + .next() + } + + /// A checkout whose branches are ahead of their nostr state. + pub(super) fn sync_suggestion(&self, cx: &App) -> Option { + let store = self.store.read(cx); + let addr = store.addr()?; + let user = Backend::global(cx).read(cx).current_user()?; + + if !store.is_author(&user) { + return None; + } + + self.sync_directory + .read(cx) + .statuses_of(addr, cx) + .into_iter() + .find(|checkout| checkout.status.ahead_total > 0) + } + + /// Pushes the sync/push suggestion. + fn render_sync_button(&self, cx: &mut Context) -> Option { + let pushing = self.store.read(cx).pushing; + + let (icon, label, tooltip, path) = if let Some(status) = self.push_suggestion(cx) { + let commits = if status.ahead == 1 { + "1 commit".to_owned() + } else { + format!("{} commits", status.ahead) + }; + let path = status.path.clone(); + ( + Icon::named(CustomIconName::ArrowUp), + SharedString::from(format!("{commits} ready to push")), + format!("Push {}", status.branch), + path, + ) + } else { + let checkout = self.sync_suggestion(cx)?; + let (branch, ahead) = checkout + .status + .refs + .iter() + .filter_map(|(name, sync)| match sync { + signed_git::RefSync::LocalAhead { ahead } => Some((name, *ahead)), + signed_git::RefSync::Diverged { ahead, .. } => Some((name, *ahead)), + _ => None, + }) + .max_by_key(|(_, ahead)| *ahead)?; + let commits = if ahead == 1 { + "1 commit".to_owned() + } else { + format!("{ahead} commits") + }; + let path = checkout.path.clone(); + ( + Icon::named(IconRole::Refresh), + SharedString::from(format!("{commits} ahead of Nostr")), + format!("Sync {branch}"), + path, + ) + }; + + Some( + Button::new("sync-button") + .icon(icon) + .label(label) + .tooltip(Tooltip::text(tooltip)) + .variant(ButtonVariant::Secondary) + .loading(pushing) + .disabled(pushing) + .on_click(cx.listener(move |this, _, window, cx| { + this.push_unpushed_checkout(path.clone(), window, cx); + })) + .into_any_element(), + ) + } + + pub(super) fn render_metadata(&self, cx: &mut Context) -> AnyElement { + h_flex() + .px_2() + .h_12() + .w_full() + .gap_4() + .items_center() + .justify_between() + .child(self.render_maintainers(cx)) + .child(self.render_ref_controls(cx)) + .into_any_element() + } + + fn render_ref_controls(&self, cx: &mut Context) -> AnyElement { + h_flex() + .justify_end() + .flex_none() + .gap_2() + .when_some(self.render_last_commit(cx), |this, commit| { + this.child(commit) + }) + .child(self.refs.branch_select.clone()) + .child(self.refs.tag_select.clone()) + .into_any_element() + } + + fn render_last_commit(&self, cx: &mut Context) -> Option { + let commit = self.head_commit.as_ref()?; + let short = commit.id.get(..8).unwrap_or(&commit.id).to_owned(); + let history = self.history.clone(); + let commit_id = commit.id.clone(); + + Some( + h_flex() + .id("last-commit") + .h_8() + .px_2() + .gap_2() + .min_w_0() + .rounded(cx.theme().radius.control) + .hover(|this| this.bg(cx.theme().colors.muted_hover)) + .tooltip(Tooltip::text("View latest commit")) + .on_click(move |_, window, cx| { + history.update(cx, |history, cx| { + history.open_commit_diff(&commit_id, window, cx); + }); + }) + .child( + Icon::named(CustomIconName::GitCommit) + .color(cx.theme().colors.muted_foreground), + ) + .child( + div() + .font_family(cx.theme().mono_font) + .typeset(TextRole::Callout, cx) + .text_color(cx.theme().colors.muted_foreground) + .child(SharedString::from(short)), + ) + .child( + div() + .max_w(px(220.)) + .typeset(TextRole::Callout, cx) + .text_ellipsis() + .whitespace_nowrap() + .child(commit.summary.clone()), + ) + .child( + div() + .typeset(TextRole::Callout, cx) + .text_color(cx.theme().colors.muted_foreground) + .child(relative_time_secs(commit.time)), + ) + .into_any_element(), + ) + } + fn render_maintainers(&self, cx: &mut Context) -> AnyElement { let Some(announcement) = self.announcement(cx) else { return div().into_any_element(); @@ -451,35 +599,31 @@ impl RepoDetailView { let owner_name = owner.name(); h_flex() - .w_full() - .gap_3() + .min_w_0() + .gap_2() .child( h_flex() - .gap_2() + .gap_1() .child( - h_flex() - .gap_1() - .child( - Avatar::new(announcement.owner) - .name(owner_name.clone()) - .picture(owner.picture()), - ) - .child( - div() - .typeset(TextRole::Caption, cx) - .whitespace_nowrap() - .child(owner_name), - ), + Avatar::new(announcement.owner) + .name(owner_name.clone()) + .picture(owner.picture()), ) - .when(!rest.is_empty(), |this| { - this.child( - div() - .typeset(TextRole::Caption, cx) - .text_color(cx.theme().colors.muted_foreground) - .child(SharedString::from(format!("+{}", rest.len()))), - ) - }), + .child( + div() + .typeset(TextRole::Caption, cx) + .whitespace_nowrap() + .child(owner_name), + ), ) + .when(!rest.is_empty(), |this| { + this.child( + div() + .typeset(TextRole::Caption, cx) + .text_color(cx.theme().colors.muted_foreground) + .child(SharedString::from(format!("+{}", rest.len()))), + ) + }) .into_any_element() } } diff --git a/crates/signed_app/src/repo/mod.rs b/crates/signed_app/src/repo/mod.rs index a469af4..312b1e4 100644 --- a/crates/signed_app/src/repo/mod.rs +++ b/crates/signed_app/src/repo/mod.rs @@ -10,11 +10,9 @@ use gpui::{ WeakEntity, Window, div, }; use gpui_native_kit::alert::{Alert, AlertSeverity}; -use gpui_native_kit::badge::Badge; -use gpui_native_kit::button::{Button, ButtonVariant}; -use gpui_native_kit::common::{Sizable as _, h_flex, v_flex}; +use gpui_native_kit::common::{h_flex, v_flex}; use gpui_native_kit::data::sidebar::{Sidebar, SidebarEntry}; -use gpui_native_kit::icons::{Icon, IconRole}; +use gpui_native_kit::icons::Icon; use gpui_native_kit::layout::panel::Panel; use gpui_native_kit::spinner::Spinner; use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _}; @@ -23,12 +21,10 @@ use nostr::prelude::{PublicKey, Url}; use signed_core::{Announcement, RepoAddr}; use signed_git::{FileCommit, GitCache, Repo}; use signed_state::{ - Backend, CheckoutStatus, CheckoutSyncStatus, CheckoutsStore, LocalReposStore, Mirrors, - Nip34Binding, PushStepStatus, RepoStore, SyncStatusDirectory, + Backend, CheckoutsStore, LocalReposStore, Mirrors, Nip34Binding, RepoStore, SyncStatusDirectory, }; pub mod actions; -pub mod banners; pub mod commit_diff; pub mod dialogs; pub mod files; @@ -37,8 +33,8 @@ pub mod helpers; pub mod history; pub mod refs; -use banners::Banners; use files::RepoFilesView; +use header::Banners; use helpers::{RepoData, load_repo_data}; use history::RepoHistoryView; use refs::RefSwitcher; @@ -183,8 +179,8 @@ impl RepoDetailView { error: None, head_commit: None, refs, - tasks: Vec::new(), banners: Banners::default(), + tasks: Vec::new(), directory: ProfileDirectory::new(cx), sync_directory: SyncStatusDirectory::new(cx), share_open: false, @@ -406,6 +402,7 @@ impl RepoDetailView { } let pushing = store.read_with(cx, |this, _| this.pushing)?; + if pushing { return Ok(()); } @@ -830,356 +827,6 @@ impl RepoDetailView { self.tasks.push(task); } - /// Open the upstream repository, the `u` tag of this fork's announcement. - fn ready_suggestion(&self, cx: &App) -> Option { - let store = self.store.read(cx); - let addr = store.addr()?; - let user = Backend::global(cx).read(cx).current_user()?; - - if store.is_author(&user) { - return None; - } - - let statuses = CheckoutsStore::global(cx).read(cx).ready_statuses_of(addr); - 'status: for status in statuses { - if self.banners.dismissal(&status) { - continue; - } - for pr in &store.pull_requests { - if CheckoutsStore::pr_proposes_checkout( - pr, - store.status_of(pr) == signed_core::RepoStatus::Open, - user, - &status, - ) { - continue 'status; - } - } - return Some(status); - } - None - } - - fn render_ready_banner(&self, cx: &Context) -> Option { - let status = self.ready_suggestion(cx)?; - let commits = if status.ahead == 1 { - SharedString::from("1 commit") - } else { - SharedString::from(format!("{} commits", status.ahead)) - }; - - Some( - h_flex() - .p_4() - .w_full() - .justify_between() - .bg(cx.theme().colors.muted) - .child( - h_flex() - .gap_2() - .typeset(TextRole::Body, cx) - .text_color(cx.theme().colors.muted_foreground) - .child(Badge::new("ready-branch", status.branch.clone())) - .child(commits) - .child("ahead of") - .child(Badge::new("ready-base", status.base.clone())), - ) - .child( - h_flex() - .gap_1() - .child( - Button::new("create-pr-from-banner") - .label("Create pull request") - .small() - .on_click(cx.listener(|this, _, window, cx| { - this.open_new_pull_request(window, cx); - })), - ) - .child( - Button::new("dismiss-ready-banner") - .icon(Icon::named(IconRole::Close)) - .variant(ButtonVariant::Ghost) - .small() - .on_click(cx.listener(move |this, _, _, cx| { - this.banners.dismiss(&status); - cx.notify(); - })), - ), - ) - .into_any_element(), - ) - } - - fn push_suggestion(&self, cx: &App) -> Option { - let store = self.store.read(cx); - let addr = store.addr()?; - let user = Backend::global(cx).read(cx).current_user()?; - - if !store.is_author(&user) { - return None; - } - - let statuses = CheckoutsStore::global(cx).read(cx).push_statuses_of(addr); - - statuses - .into_iter() - .find(|status| !self.banners.dismissal(status)) - } - - fn sync_suggestion(&self, cx: &App) -> Option { - let store = self.store.read(cx); - let addr = store.addr()?; - let user = Backend::global(cx).read(cx).current_user()?; - - if !store.is_author(&user) { - return None; - } - - let statuses = self.sync_directory.read(cx).statuses_of(addr, cx); - - statuses.into_iter().find(|checkout| { - checkout.status.ahead_total > 0 && !self.banners.sync_dismissal(checkout) - }) - } - - fn render_push_banner(&self, cx: &Context) -> Option { - let status = self.push_suggestion(cx)?; - let path = status.path.clone(); - let pushing = self.store.read(cx).pushing; - let commits = if status.ahead == 1 { - SharedString::from("1 commit") - } else { - SharedString::from(format!("{} commits", status.ahead)) - }; - - Some( - h_flex() - .p_4() - .gap_2() - .w_full() - .justify_between() - .bg(cx.theme().colors.muted) - .child( - h_flex() - .gap_2() - .typeset(TextRole::Body, cx) - .text_color(cx.theme().colors.muted_foreground) - .child(Badge::new("push-branch", status.branch.clone())) - .child(commits) - .child("ready to push"), - ) - .child( - h_flex() - .gap_1() - .child( - Button::new("push-checkout-banner") - .icon(Icon::named(CustomIconName::ArrowUp)) - .label("Push") - .small() - .loading(pushing) - .disabled(pushing) - .on_click(cx.listener(move |this, _, window, cx| { - this.push_unpushed_checkout(path.clone(), window, cx); - })), - ) - .child( - Button::new("dismiss-push-banner") - .icon(Icon::named(IconRole::Close)) - .variant(ButtonVariant::Ghost) - .small() - .disabled(pushing) - .on_click(cx.listener(move |this, _, _, cx| { - this.banners.dismiss(&status); - cx.notify(); - })), - ), - ) - .into_any_element(), - ) - } - - fn render_sync_banner(&self, cx: &Context) -> Option { - let checkout = self.sync_suggestion(cx)?; - let path = checkout.path.clone(); - let pushing = self.store.read(cx).pushing; - - let (branch, ahead) = checkout - .status - .refs - .iter() - .filter_map(|(name, sync)| match sync { - signed_git::RefSync::LocalAhead { ahead } => Some((name, *ahead)), - signed_git::RefSync::Diverged { ahead, .. } => Some((name, *ahead)), - _ => None, - }) - .max_by_key(|(_, ahead)| *ahead)?; - - let branch = SharedString::from(branch.clone()); - let commits = if ahead == 1 { - SharedString::from("1 commit") - } else { - SharedString::from(format!("{} commits", ahead)) - }; - - Some( - h_flex() - .p_4() - .gap_2() - .w_full() - .justify_between() - .bg(cx.theme().colors.muted) - .child( - h_flex() - .gap_2() - .typeset(TextRole::Body, cx) - .text_color(cx.theme().colors.muted_foreground) - .child(Badge::new("sync-branch", branch)) - .child(commits) - .child("ahead of Nostr"), - ) - .child( - h_flex() - .gap_1() - .child( - Button::new("sync-banner") - .icon(Icon::named(IconRole::Refresh)) - .label("Sync now") - .small() - .loading(pushing) - .disabled(pushing) - .on_click(cx.listener(move |this, _, window, cx| { - this.push_unpushed_checkout(path.clone(), window, cx); - })), - ) - .child( - Button::new("dismiss-sync-banner") - .icon(Icon::named(IconRole::Close)) - .variant(ButtonVariant::Ghost) - .small() - .disabled(pushing) - .on_click(cx.listener(move |this, _, _, cx| { - this.banners.sync_dismiss(&checkout); - cx.notify(); - })), - ), - ) - .into_any_element(), - ) - } - - fn render_push_progress_banner(&self, cx: &Context) -> Option { - let store = self.store.read(cx); - if !store.pushing || store.push_steps.is_empty() { - return None; - } - - let steps = store - .push_steps - .iter() - .map(|status| { - let label = SharedString::from(status.step().label()); - - match status { - PushStepStatus::Running(_) => h_flex() - .gap_2() - .typeset(TextRole::Body, cx) - .text_color(cx.theme().colors.muted_foreground) - .child(Spinner::new("push-step")) - .child(label) - .into_any_element(), - PushStepStatus::Done(_) => h_flex() - .gap_2() - .typeset(TextRole::Body, cx) - .child(Icon::named(IconRole::Check).small()) - .child(label) - .into_any_element(), - PushStepStatus::Failed(_, reason) => h_flex() - .gap_2() - .typeset(TextRole::Body, cx) - .text_color(cx.theme().ramps.destructive.base) - .child(Icon::named(IconRole::Close).small()) - .child(SharedString::from(format!( - "{}: {reason}", - status.step().label() - ))) - .into_any_element(), - } - }) - .collect::>(); - - Some( - v_flex() - .p_4() - .gap_1() - .w_full() - .bg(cx.theme().colors.muted) - .child(div().typeset(TextRole::Body, cx).child("Pushing")) - .children(steps) - .into_any_element(), - ) - } - - fn render_push_warning_banner(&self, cx: &Context) -> Option { - let store = self.store.read(cx); - let warning = store.last_push_warning.clone()?; - let pushing = store.pushing; - - Some( - h_flex() - .p_4() - .gap_2() - .w_full() - .items_start() - .justify_between() - .bg(cx.theme().colors.muted) - .child( - h_flex() - .gap_2() - .min_w_0() - .flex_1() - .items_start() - .child(Icon::named(IconRole::Warning).small()) - .child( - div() - .flex_1() - .min_w_0() - .typeset(TextRole::Body, cx) - .text_color(cx.theme().ramps.warning.base) - .child(SharedString::from(warning)), - ), - ) - .child( - h_flex() - .gap_1() - .child( - Button::new("republish-after-partial-push") - .icon(Icon::named(CustomIconName::Init)) - .label("Republish") - .small() - .loading(pushing) - .disabled(pushing) - .on_click(cx.listener(|this, _, window, cx| { - this.push_repository(window, cx); - })), - ) - .child( - Button::new("dismiss-push-warning") - .icon(Icon::named(IconRole::Close)) - .variant(ButtonVariant::Ghost) - .small() - .disabled(pushing) - .on_click(cx.listener(|this, _, _, cx| { - this.store.update(cx, |store, _| { - store.last_push_warning = None; - }); - cx.notify(); - })), - ), - ) - .into_any_element(), - ) - } - fn render_files_tab(&self, cx: &App) -> AnyElement { if self.loading { let label = if self.store.read(cx).path.is_some() { @@ -1269,7 +916,7 @@ impl RepoDetailView { .into_any_element() } - fn render_content(&mut self, cx: &mut Context) -> AnyElement { + fn render_pane(&mut self, cx: &mut Context) -> AnyElement { match self.active_section { RepoSection::Files => self.render_files_tab(cx), RepoSection::Commits => self.history.clone().into_any_element(), @@ -1284,12 +931,6 @@ impl Panel for RepoDetailView {} impl Render for RepoDetailView { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let weak = cx.entity().downgrade(); - - let banner = self - .render_ready_banner(cx) - .or_else(|| self.render_push_banner(cx)) - .or_else(|| self.render_sync_banner(cx)); - let error = self.error.clone().or_else(|| { self.store .read(cx) @@ -1301,14 +942,8 @@ impl Render for RepoDetailView { v_flex() .id("repo") .size_full() - .when_some(banner, |this, banner| this.child(banner)) - .when_some(self.render_push_progress_banner(cx), |this, banner| { - this.child(banner) - }) - .when_some(self.render_push_warning_banner(cx), |this, banner| { - this.child(banner) - }) - .child(self.render_header(cx)) + .child(self.render_about(cx)) + .child(self.render_metadata(cx)) .when_some(error, |this, error| { this.child( Alert::new("repo-error") @@ -1332,6 +967,8 @@ impl Render for RepoDetailView { .min_h_0() .w_full() .overflow_hidden() + .border_t_1() + .border_color(cx.theme().colors.border) .child(self.render_sidebar(cx)) .child( v_flex() @@ -1339,7 +976,7 @@ impl Render for RepoDetailView { .min_w_0() .h_full() .overflow_hidden() - .child(self.render_content(cx)), + .child(self.render_pane(cx)), ), ) }