chore: enforce clippy lints across workspace
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

This commit is contained in:
2026-11-20 08:14:03 +07:00
parent 51dd5c8630
commit 01c3ced1c7
85 changed files with 2773 additions and 2001 deletions
+46 -69
View File
@@ -1,13 +1,15 @@
use std::path::PathBuf;
use std::sync::Arc;
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
ParentElement as _, Render, SharedString, Styled as _, Subscription, UniformListScrollHandle,
WeakEntity, Window, div, uniform_list,
WeakEntity, Window, div,
};
use metadata::ProfileDirectory;
use nostr::prelude::{EventId, Kind, PublicKey, Url};
use nostr::prelude::{EventId, Kind, Url};
use signed_core::{GitEvent, PullRequest, RepoAddr};
use signed_git::{FileCommit, PatchParser};
use signed_state::{Backend, Mirrors, RepoStore};
@@ -19,8 +21,6 @@ use ui::icons::{Icon, IconRole};
use ui::input::InputState;
use ui::layout::panel::Panel;
use ui::scroll_area::ScrollArea;
use ui::scrollbar::Scrollbar;
use ui::spinner::Spinner;
use ui::tabs::{Tab, Tabs};
use ui::theme::ActiveTheme as _;
use utils::relative_time;
@@ -28,7 +28,6 @@ use utils::relative_time;
use super::dialogs;
use crate::issues::helpers::{comment_form, comments_section, pr_roots, sidebar_section};
use crate::repo::commit_diff::{CommitDiffView, DiffPane};
use crate::repo::helpers::commit_row;
use crate::shared::widgets::{empty_state, status_badge};
use crate::workspace::Workspace;
@@ -54,7 +53,7 @@ pub struct PullRequestDetailView {
worktree: Option<PathBuf>,
description: SharedString,
current_commit: Option<SharedString>,
commits: Vec<FileCommit>,
commits: Arc<Vec<FileCommit>>,
loading: bool,
error: Option<SharedString>,
bound: Option<PrBinding>,
@@ -96,7 +95,7 @@ impl PullRequestDetailView {
worktree: None,
description: SharedString::default(),
current_commit: None,
commits: Vec::new(),
commits: Arc::new(Vec::new()),
loading: true,
error: None,
bound: None,
@@ -112,18 +111,23 @@ impl PullRequestDetailView {
fn track_participants(&mut self, cx: &mut Context<Self>) {
let store = self.store.read(cx);
let mut keys: Vec<PublicKey> = store
let author = store
.pull_requests
.iter()
.find(|pr| pr.id == self.pr_id && pr.kind == Kind::GitPullRequest)
.map(|root| vec![root.pubkey])
.unwrap_or_default();
keys.extend(store.comments_of(&self.pr_id).map(|comment| comment.pubkey));
if let Some(owner) = store.announcement.as_ref().map(|a| a.owner) {
keys.push(owner);
}
self.directory
.update(cx, |directory, cx| directory.track(keys, cx));
.map(|root| root.pubkey);
let owner = store.announcement.as_ref().map(|a| a.owner);
let comments: Vec<_> = store
.comments_of(&self.pr_id)
.map(|comment| comment.pubkey)
.collect();
crate::shared::track_event_participants(
author,
owner,
comments.into_iter(),
&self.directory,
cx,
);
}
fn sync(&mut self, cx: &mut Context<Self>) {
@@ -181,6 +185,12 @@ impl PullRequestDetailView {
self.load_diff(binding, cx);
}
/// Reaps finished tasks, then queues another.
fn push_task(&mut self, task: gpui::Task<Result<(), anyhow::Error>>) {
self.tasks.retain(|task| !task.is_ready());
self.tasks.push(task);
}
fn load_diff(&mut self, binding: PrBinding, cx: &mut Context<Self>) {
self.loading = true;
self.error = None;
@@ -266,7 +276,7 @@ impl PullRequestDetailView {
}
this.loading = false;
this.worktree = worktree;
this.commits = commits;
this.commits = Arc::new(commits);
match diff {
Ok(diff) => this.pane.update(cx, |pane, cx| pane.set_diff(diff, cx)),
Err(error) => this.error = Some(error.to_string().into()),
@@ -275,7 +285,7 @@ impl PullRequestDetailView {
})?;
Ok(())
});
self.tasks.push(task);
self.push_task(task);
}
fn open_commit_diff(
@@ -443,54 +453,26 @@ impl PullRequestDetailView {
if self.commits.is_empty() {
return empty_state("No commits found");
}
let commits = self.commits.clone();
let commits = Arc::clone(&self.commits);
let worktree = self.worktree.clone();
let view = cx.entity().downgrade();
v_flex()
.relative()
.flex_1()
.min_h_0()
.child(
uniform_list("pr-commits", commits.len(), move |range, _, cx| {
range
.map(|ix| {
let commit = commits[ix].clone();
let id = commit.id.clone();
let worktree = worktree.clone();
let view = view.clone();
commit_row(
ix,
&commit,
None,
move |window, cx| {
if let Some(worktree) = worktree.clone() {
crate::shared::log_dropped(view.update(cx, |this, cx| {
this.open_commit_diff(worktree, &id, window, cx);
}));
}
},
cx,
)
})
.collect()
})
.track_scroll(&self.commit_scroll_handle)
.size_full(),
)
.child(
div()
.absolute()
.top_0()
.left_0()
.right_0()
.bottom_0()
.child(Scrollbar::vertical(
"pr-commits-scroll",
self.commit_scroll_handle.clone(),
)),
)
.into_any_element()
crate::shared::event_list::commit_list(
"pr-commits",
"pr-commits-scroll",
commits,
self.commit_scroll_handle.clone(),
|_, _, _| None,
move |commit, window, cx| {
if let Some(worktree) = worktree.clone() {
let id = commit.id.clone();
crate::shared::log_dropped(view.update(cx, |this, cx| {
this.open_commit_diff(worktree, &id, window, cx);
}));
}
},
cx,
)
}
fn render_header(&self, cx: &mut Context<Self>) -> AnyElement {
@@ -614,10 +596,5 @@ impl Render for PullRequestDetailView {
}
fn centered_spinner() -> AnyElement {
v_flex()
.size_full()
.items_center()
.justify_center()
.child(Spinner::new("pr-loading"))
.into_any_element()
crate::shared::widgets::centered_spinner("pr-loading")
}
@@ -11,29 +11,39 @@ use ui::field::Field;
use ui::input::{Input, InputState};
use ui::theme::ActiveTheme as _;
use crate::shared::progress::DialogProgress;
pub struct UpdatePrDialog {
handle: DialogHandle,
store: Entity<RepoStore>,
root: Event,
patch: Entity<InputState>,
state: Entity<DialogProgress>,
}
impl UpdatePrDialog {
pub fn new(store: Entity<RepoStore>, root: Event, cx: &mut App) -> Entity<Self> {
let patch = InputState::builder().multiline().build(cx);
let state = cx.new(|_| DialogProgress::default());
cx.new(|_| Self {
handle: DialogHandle::new(true),
store,
root,
patch,
state,
})
}
fn submit(&mut self, cx: &mut Context<Self>) {
// The publish runs detached in the store; one submission per dialog.
if self.state.read(cx).busy {
return;
}
let patch = self.patch.read(cx).value().to_string();
if patch.trim().is_empty() {
return;
}
self.state.update(cx, |state, _| state.begin());
self.store.update(cx, |store, cx| {
store.update_pull_request(&self.root, patch, cx);
});
@@ -45,6 +55,7 @@ impl Render for UpdatePrDialog {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let patch = self.patch.clone();
let this = cx.entity().downgrade();
let action_state = self.state.clone();
Dialog::new("update-pr-dialog")
.handle(self.handle.clone())
@@ -65,11 +76,14 @@ impl Render for UpdatePrDialog {
)
.into_any_element()
})
.actions(move |_, _| {
.actions(move |_, cx| {
let this = this.clone();
let busy = action_state.read(cx).busy;
vec![
Button::new("submit-update")
.label("Update pull request")
.loading(busy)
.disabled(busy)
.on_click(move |_, _, cx| {
crate::shared::log_dropped(this.update(cx, |this, cx| this.submit(cx)));
})
@@ -55,14 +55,6 @@ impl ForkCompare {
}
}
pub fn fork_display_name(announcement: &Announcement) -> SharedString {
announcement
.name
.as_deref()
.map(SharedString::from)
.unwrap_or_else(|| SharedString::from(announcement.id.clone()))
}
pub fn shorten_owner(owner: &PublicKey) -> String {
owner.to_hex().chars().take(10).collect()
}
@@ -121,7 +113,11 @@ pub fn source_menu_items(
} else {
SharedString::from(format!("by {}", shorten_owner(&candidate.owner)))
};
let title = format!("{} — {}", fork_display_name(&candidate), subtitle);
let title = format!(
"{} — {}",
crate::repo::helpers::announcement_display_name(&candidate),
subtitle
);
let target = view.clone();
let checked = active_fork == Some(candidate.addr());
let announcement = candidate;
+74 -147
View File
@@ -1,21 +1,19 @@
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
ParentElement as _, Render, SharedString, StatefulInteractiveElement as _, Styled as _,
Subscription, UniformListScrollHandle, WeakEntity, Window, div, px, uniform_list,
AnyElement, App, AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render,
SharedString, Styled as _, Subscription, UniformListScrollHandle, WeakEntity, Window, div,
};
use metadata::ProfileDirectory;
use nostr::prelude::{Kind, PublicKey};
use signed_core::GitEvent;
use signed_state::RepoStore;
use std::rc::Rc;
use ui::alert::{Alert, AlertSeverity};
use ui::avatar::Avatar;
use ui::common::{Sizable as _, h_flex, v_flex};
use ui::common::v_flex;
use ui::dropdown_menu::DropdownMenu;
use ui::icons::{Icon, IconRole};
use ui::layout::panel::Panel;
use ui::menu::MenuItem;
use ui::scrollbar::Scrollbar;
use ui::segmented::{Segmented, SegmentedOption};
use ui::theme::ActiveTheme as _;
use utils::relative_time;
@@ -32,11 +30,10 @@ pub use new::NewPullRequestView;
pub use send_patch::SendPatchView;
use crate::issues::helpers::{StatusCounts, filter_by_status};
use crate::shared::widgets::{empty_state, status_badge};
use crate::repo::helpers::short_id;
use crate::shared::event_list::{EventList, EventRow};
use crate::workspace::Workspace;
const ROW_HEIGHT: f32 = 73.;
pub struct PullRequestsView {
workspace: WeakEntity<Workspace>,
store: Entity<RepoStore>,
@@ -198,14 +195,9 @@ impl PullRequestsView {
let menu_open_weak = cx.entity().downgrade();
let patch_weak = cx.entity().downgrade();
h_flex()
.px_4()
.w_full()
.gap_3()
.border_b_1()
.border_color(cx.theme().colors.border)
.bg(cx.theme().colors.muted)
.child(
crate::shared::event_list::filter_toolbar(
cx,
[
Segmented::new("pr-filter", self.filter)
.options(vec![
SegmentedOption::new(
@@ -241,10 +233,9 @@ impl PullRequestsView {
}) {
log::warn!("failed to switch PR filter: {error}");
}
}),
)
.child(div().flex_1())
.child(
})
.into_any_element(),
div().flex_1().into_any_element(),
DropdownMenu::new("new-pr-actions")
.label("New")
.icon(Icon::named(IconRole::GitPullRequest))
@@ -271,9 +262,10 @@ impl PullRequestsView {
}));
}
})]
}),
)
.into_any_element()
})
.into_any_element(),
],
)
}
}
@@ -286,7 +278,6 @@ impl Panel for PullRequestsView {
impl Render for PullRequestsView {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let filter = self.filter;
let count = self.visible_prs.len();
let visible = self.visible_prs.clone();
let directory = self.directory.clone();
let store = self.store.clone();
@@ -300,9 +291,60 @@ impl Render for PullRequestsView {
let dismiss_warning_store = self.store.clone();
let dismiss_error_store = self.store.clone();
let rows = visible
.iter()
.enumerate()
.filter_map(|(ix, &pr_ix)| {
// The store re-read per frame can shrink below a captured index.
let pr = store.read(cx).pull_requests.get(pr_ix)?;
let profile = directory.read(cx).profile(&pr.pubkey, cx);
let pr_id = pr.id;
let id_hex = pr.id.to_hex();
let status = store.read(cx).status_of(pr);
let on_click: crate::shared::event_list::EventHandler = {
let workspace = workspace.clone();
let store = store.clone();
Rc::new(move |_, window, cx| {
let id = SharedString::from(format!("pr:{pr_id}"));
let workspace_for_build = workspace.clone();
let store = store.clone();
crate::shared::panels::open_detail(
&workspace,
id,
move |window, cx| {
cx.new(|cx| {
PullRequestDetailView::new(
workspace_for_build.clone(),
store.clone(),
pr_id,
window,
cx,
)
})
},
window,
cx,
);
})
};
Some(EventRow {
id: ix.into(),
status,
title: pr.activity_subject().into(),
author: profile.name(),
picture: profile.picture(),
pubkey: pr.pubkey,
short_id: short_id(&id_hex),
age: SharedString::from(relative_time(pr.created_at)),
on_click,
})
})
.collect();
v_flex()
.size_full()
.child(self.render_header(cx))
.when_some(last_warning, |this, warning| {
this.child(
Alert::new("pr-warning")
@@ -326,127 +368,12 @@ impl Render for PullRequestsView {
)
})
.child(
v_flex()
.relative()
.flex_1()
.min_h_0()
.w_full()
.when(count > 0, |this| {
this.child(
uniform_list("prl", count, move |range, _, cx| {
range
.map(|ix| {
let pr_ix = visible[ix];
let pr = &store.read(cx).pull_requests[pr_ix];
let pr_id = pr.id;
let title = pr.activity_subject();
let id_hex = pr.id.to_hex();
let age = relative_time(pr.created_at);
let status = store.read(cx).status_of(pr);
let profile = directory.read(cx).profile(&pr.pubkey, cx);
let author = profile.name();
let workspace = workspace.clone();
let store = store.clone();
h_flex()
.id(ix)
.w_full()
.h(px(ROW_HEIGHT))
.gap_4()
.px_4()
.border_b_1()
.border_color(cx.theme().colors.border)
.hover(|this| this.bg(cx.theme().colors.muted_hover))
.on_click(move |_, window, cx| {
let id = SharedString::from(format!("pr:{pr_id}"));
let workspace_for_build = workspace.clone();
let store = store.clone();
crate::shared::panels::open_detail(
&workspace,
id,
move |window, cx| {
cx.new(|cx| {
PullRequestDetailView::new(
workspace_for_build.clone(),
store.clone(),
pr_id,
window,
cx,
)
})
},
window,
cx,
);
})
.child(status_badge(status))
.child(
v_flex()
.flex_1()
.min_w_0()
.gap_1()
.child(
div()
.text_base()
.text_ellipsis()
.whitespace_nowrap()
.child(title),
)
.child(
h_flex()
.gap_2()
.text_xs()
.child(
h_flex()
.gap_1()
.child(
Avatar::new(pr.pubkey)
.name(author.clone())
.picture(
profile.picture(),
)
.small(),
)
.child(div().child(author)),
)
.child(SharedString::from("opened"))
.child(
div()
.text_color(
cx.theme()
.colors
.muted_foreground,
)
.child(SharedString::from(
&id_hex[..8],
)),
)
.child(SharedString::from(age)),
),
)
.into_any_element()
})
.collect()
})
.track_scroll(&self.scroll_handle)
.size_full(),
)
.child(
div()
.absolute()
.top_0()
.left_0()
.right_0()
.bottom_0()
.child(Scrollbar::vertical(
"prl-scroll",
self.scroll_handle.clone(),
)),
)
})
.when(count == 0, |this| {
this.child(empty_state(filter.empty_message()))
}),
EventList::new("prl")
.toolbar(self.render_header(cx))
.scroll_handle(self.scroll_handle.clone())
.rows(rows)
.empty_message(filter.empty_message())
.render(cx),
)
.into_any_element()
}
+33 -65
View File
@@ -1,10 +1,12 @@
use std::path::PathBuf;
use std::sync::Arc;
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
ParentElement as _, Render, SharedString, Styled as _, Subscription, UniformListScrollHandle,
WeakEntity, Window, div, px, uniform_list,
WeakEntity, Window, div, px,
};
use signed_state::{CheckoutsStore, RepoStore};
use ui::button::Button;
@@ -14,14 +16,11 @@ use ui::icons::{Icon, IconRole};
use ui::input::{Input, InputState};
use ui::layout::panel::Panel;
use ui::menu::Menu;
use ui::scrollbar::Scrollbar;
use ui::spinner::Spinner;
use ui::tabs::{Tab, Tabs};
use ui::theme::ActiveTheme as _;
use super::helpers::{ForkCompare, fork_display_name, truncate_label};
use super::helpers::{ForkCompare, truncate_label};
use crate::repo::commit_diff::{CommitDiffView, DiffPane};
use crate::repo::helpers::commit_row;
use crate::shared::progress::error_row;
use crate::shared::widgets::empty_state;
use crate::workspace::Workspace;
@@ -41,7 +40,7 @@ pub struct NewPullRequestView {
subject: Entity<InputState>,
description: Entity<InputState>,
pub(super) merge_base: Option<String>,
pub(super) commits: Option<Vec<signed_git::FileCommit>>,
pub(super) commits: Option<Arc<Vec<signed_git::FileCommit>>>,
pub(super) loading: bool,
pub(super) error: Option<SharedString>,
submitting: bool,
@@ -159,6 +158,12 @@ impl NewPullRequestView {
}
}
/// Reaps finished tasks, then queues another.
pub(super) fn push_task(&mut self, task: gpui::Task<Result<(), anyhow::Error>>) {
self.tasks.retain(|task| !task.is_ready());
self.tasks.push(task);
}
fn submit(&mut self, _window: &mut Window, cx: &mut Context<Self>) {
if self.submitting || self.loading {
return;
@@ -210,7 +215,7 @@ impl NewPullRequestView {
);
Ok(())
});
self.tasks.push(task);
self.push_task(task);
}
fn open_commit_diff(&mut self, commit_id: &str, window: &mut Window, cx: &mut Context<Self>) {
@@ -264,7 +269,9 @@ impl NewPullRequestView {
let active_fork = self.fork.as_ref().map(|fork| fork.announcement.addr());
let can_submit = self.submit_enabled(cx);
let source_label = match &self.fork {
Some(fork) => truncate_label(&fork_display_name(&fork.announcement)),
Some(fork) => truncate_label(&crate::repo::helpers::announcement_display_name(
&fork.announcement,
)),
None => self.repo_path.as_ref().map_or_else(
|| SharedString::from("No source"),
|path| truncate_label(&path.display().to_string()),
@@ -368,12 +375,7 @@ impl NewPullRequestView {
fn render_content(&self, cx: &mut Context<Self>) -> AnyElement {
if self.loading {
return v_flex()
.size_full()
.items_center()
.justify_center()
.child(Spinner::new("new-pr-loading"))
.into_any_element();
return crate::shared::widgets::centered_spinner("new-pr-loading");
}
if !self.has_source() {
return empty_state("Choose a local checkout or an announced fork to compare");
@@ -394,50 +396,23 @@ impl NewPullRequestView {
if commits.is_empty() {
return empty_state("No commits between the branches");
}
let commits = commits.clone();
let commits = Arc::clone(commits);
let view = cx.entity().downgrade();
v_flex()
.relative()
.flex_1()
.min_h_0()
.child(
uniform_list("new-pr-commits", commits.len(), move |range, _, cx| {
range
.map(|ix| {
let commit = commits[ix].clone();
let id = commit.id.clone();
let view = view.clone();
commit_row(
ix,
&commit,
None,
move |window, cx| {
crate::shared::log_dropped(view.update(cx, |this, cx| {
this.open_commit_diff(&id, window, cx);
}));
},
cx,
)
})
.collect()
})
.track_scroll(&self.scroll_handle)
.size_full(),
)
.child(
div()
.absolute()
.top_0()
.left_0()
.right_0()
.bottom_0()
.child(Scrollbar::vertical(
"new-pr-commits-scroll",
self.scroll_handle.clone(),
)),
)
.into_any_element()
crate::shared::event_list::commit_list(
"new-pr-commits",
"new-pr-commits-scroll",
commits,
self.scroll_handle.clone(),
|_, _, _| None,
move |commit, window, cx| {
let id = commit.id.clone();
crate::shared::log_dropped(view.update(cx, |this, cx| {
this.open_commit_diff(&id, window, cx);
}));
},
cx,
)
}
}
@@ -472,14 +447,7 @@ impl Render for NewPullRequestView {
.rows(3)
.placeholder("Describe..."),
)
.when_some(self.error.clone(), |this, error| {
this.child(
div()
.text_xs()
.text_color(cx.theme().ramps.destructive.base)
.child(error),
)
}),
.when_some(error_row(&self.error, cx), |this, error| this.child(error)),
)
.child(self.render_tabs(cx)),
)
@@ -1,4 +1,5 @@
use std::path::{Path, PathBuf};
use std::sync::Arc;
use gpui::{App, AppContext as _, Context, PathPromptOptions, SharedString, Window};
use nostr::prelude::Url;
@@ -9,6 +10,19 @@ use signed_state::{Backend, CheckoutsStore, Mirrors, RepoListStore};
use super::NewPullRequestView;
use crate::pull_requests::helpers::ForkCompare;
/// The announced head when listed, else `main`, else the first branch.
fn preferred_branch(branches: &[String], announced: Option<String>) -> String {
announced
.filter(|branch| branches.contains(branch))
.or_else(|| {
branches
.iter()
.find(|branch| branch.as_str() == "main")
.cloned()
})
.unwrap_or_else(|| branches[0].clone())
}
impl NewPullRequestView {
pub(super) fn has_source(&self) -> bool {
self.repo_path.is_some() || self.fork.is_some()
@@ -56,7 +70,7 @@ impl NewPullRequestView {
})?;
Ok(())
});
self.tasks.push(task);
self.push_task(task);
}
pub(crate) fn apply_folder_path(
@@ -93,7 +107,7 @@ impl NewPullRequestView {
})?;
Ok(())
});
self.tasks.push(task);
self.push_task(task);
}
fn apply_checkout(
@@ -126,12 +140,7 @@ impl NewPullRequestView {
}
let announced = self.store.read(cx).head.clone();
let base = announced
.as_ref()
.filter(|branch| branches.contains(branch))
.cloned()
.or_else(|| branches.iter().find(|branch| *branch == "main").cloned())
.unwrap_or_else(|| branches[0].clone());
let base = preferred_branch(&branches, announced);
let compare = current
.filter(|branch| branches.contains(branch))
.unwrap_or_else(|| base.clone());
@@ -266,7 +275,7 @@ impl NewPullRequestView {
}
Ok(())
});
self.tasks.push(task);
self.push_task(task);
}
fn apply_fork(
@@ -299,16 +308,7 @@ impl NewPullRequestView {
}
let announced = self.store.read(cx).head.clone();
let base = announced
.filter(|branch| base_branches.contains(branch))
.map(SharedString::from)
.or_else(|| {
base_branches
.iter()
.find(|branch| branch.as_str() == "main")
.map(|branch| SharedString::from(branch.clone()))
})
.unwrap_or_else(|| SharedString::from(base_branches[0].clone()));
let base = preferred_branch(&base_branches, announced);
let compare = compare_branches
.iter()
.find(|branch| branch.as_str() == "main")
@@ -321,7 +321,7 @@ impl NewPullRequestView {
mirror_path,
});
self.error = None;
self.base = base;
self.base = SharedString::from(base);
self.compare = compare;
self.branches = base_branches.into_iter().map(SharedString::from).collect();
self.sync_selectors(window, cx);
@@ -378,7 +378,7 @@ impl NewPullRequestView {
match result {
Ok((merge_base, commits, diff)) => {
this.merge_base = Some(merge_base);
this.commits = Some(commits);
this.commits = Some(Arc::new(commits));
this.pane.update(cx, |pane, cx| pane.set_diff(diff, cx));
}
Err(error) => {
@@ -392,6 +392,6 @@ impl NewPullRequestView {
})?;
Ok(())
});
self.tasks.push(task);
self.push_task(task);
}
}
@@ -5,12 +5,13 @@ use gpui::{
};
use signed_state::RepoStore;
use ui::button::Button;
use ui::common::{h_flex, v_flex};
use ui::common::{ResultLogErr as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole};
use ui::input::{Input, InputState};
use ui::layout::panel::Panel;
use ui::theme::ActiveTheme as _;
use crate::shared::progress::error_row;
use crate::workspace::Workspace;
pub struct SendPatchView {
@@ -65,7 +66,7 @@ impl SendPatchView {
self.error = None;
cx.notify();
let sync_error = self.store.update(cx, |store, cx| {
let task = self.store.update(cx, |store, cx| {
store.open_pull_request(
(!subject.is_empty()).then_some(subject),
description,
@@ -75,22 +76,30 @@ impl SendPatchView {
None,
None,
cx,
);
store.last_error.clone()
)
});
if let Some(error) = sync_error {
self.submitting = false;
self.error = Some(error.into());
cx.notify();
return;
}
let panel_id = self.panel_id.clone();
crate::shared::log_dropped(
self.workspace
.update(cx, |workspace, cx| workspace.close_detail(&panel_id, cx)),
);
cx.spawn(async move |this, cx| match task.await {
Ok(()) => {
this.update(cx, |this, cx| {
let panel_id = this.panel_id.clone();
crate::shared::log_dropped(
this.workspace
.update(cx, |workspace, cx| workspace.close_detail(&panel_id, cx)),
);
})
.log_err();
}
Err(error) => {
this.update(cx, |this, cx| {
this.submitting = false;
this.error = Some(error.to_string().into());
cx.notify();
})
.log_err();
}
})
.detach();
}
fn render_footer(&self, cx: &Context<Self>) -> AnyElement {
@@ -159,14 +168,7 @@ impl Render for SendPatchView {
.rows(12)
.placeholder("diff --git a/file.txt b/file.txt"),
)
.when_some(self.error.clone(), |this, error| {
this.child(
div()
.text_xs()
.text_color(cx.theme().ramps.destructive.base)
.child(error),
)
}),
.when_some(error_row(&self.error, cx), |this, error| this.child(error)),
)
.child(self.render_footer(cx))
}