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:
@@ -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<CheckoutStatus> {
|
||||
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<Self>) -> Option<AnyElement> {
|
||||
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<CheckoutStatus> {
|
||||
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<CheckoutSyncStatus> {
|
||||
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<Self>) -> Option<AnyElement> {
|
||||
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<Self>) -> Option<AnyElement> {
|
||||
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<Self>) -> Option<AnyElement> {
|
||||
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::<Vec<_>>();
|
||||
|
||||
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<Self>) -> Option<AnyElement> {
|
||||
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<Self>) -> AnyElement {
|
||||
fn render_pane(&mut self, cx: &mut Context<Self>) -> 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<Self>) -> 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)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user