refactor: move panel stack state into app root
This commit is contained in:
@@ -32,7 +32,7 @@ use crate::issues::helpers::{comment_form, comments_section, sidebar_section};
|
||||
use crate::repo::commit_diff::{CommitDiffView, DiffPane};
|
||||
use crate::shared::event_list::commit_list;
|
||||
use crate::shared::log_dropped;
|
||||
use crate::shared::panels::open_detail;
|
||||
use crate::shared::panels::{self, open_detail};
|
||||
use crate::shared::widgets::status_badge;
|
||||
|
||||
const NOT_FOUND: &str = "Pull request not found";
|
||||
@@ -50,6 +50,8 @@ struct PrBinding {
|
||||
|
||||
pub struct PullRequestDetailView {
|
||||
workspace: WeakEntity<AppRoot>,
|
||||
/// The sub panel id this view closes through.
|
||||
panel_id: SharedString,
|
||||
store: Entity<RepoStore>,
|
||||
pr_id: EventId,
|
||||
update_dialog: Option<Entity<dialogs::update::UpdatePrDialog>>,
|
||||
@@ -73,6 +75,7 @@ pub struct PullRequestDetailView {
|
||||
impl PullRequestDetailView {
|
||||
pub fn new(
|
||||
workspace: WeakEntity<AppRoot>,
|
||||
panel_id: SharedString,
|
||||
store: Entity<RepoStore>,
|
||||
pr_id: EventId,
|
||||
_window: &mut Window,
|
||||
@@ -92,6 +95,7 @@ impl PullRequestDetailView {
|
||||
|
||||
Self {
|
||||
workspace,
|
||||
panel_id,
|
||||
store,
|
||||
pr_id,
|
||||
update_dialog: None,
|
||||
@@ -304,13 +308,23 @@ impl PullRequestDetailView {
|
||||
None => SharedString::from(format!("commit:{}:{commit_id}", worktree.display())),
|
||||
};
|
||||
let workspace = self.workspace.clone();
|
||||
let workspace_for_build = workspace.clone();
|
||||
let panel_id = id.clone();
|
||||
let commit_id = commit_id.to_owned();
|
||||
open_detail(
|
||||
&workspace,
|
||||
id,
|
||||
move |window, cx| {
|
||||
cx.new(|cx| {
|
||||
CommitDiffView::new(worktree.clone(), commit_id.clone(), false, window, cx)
|
||||
CommitDiffView::new(
|
||||
workspace_for_build.clone(),
|
||||
panel_id.clone(),
|
||||
worktree.clone(),
|
||||
commit_id.clone(),
|
||||
false,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
},
|
||||
window,
|
||||
@@ -589,8 +603,16 @@ impl Render for PullRequestDetailView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
v_flex()
|
||||
.id("pull-request-detail")
|
||||
.relative()
|
||||
.size_full()
|
||||
.min_h_0()
|
||||
.child(
|
||||
div()
|
||||
.absolute()
|
||||
.top_1()
|
||||
.right_1()
|
||||
.child(panels::close_button(&self.workspace, &self.panel_id)),
|
||||
)
|
||||
.child(self.render_header(cx))
|
||||
.when_some(self.update_dialog.clone(), |el, view| el.child(view))
|
||||
.child(self.render_tabs(cx))
|
||||
|
||||
@@ -309,6 +309,7 @@ impl Render for PullRequestsView {
|
||||
let store = store.clone();
|
||||
Rc::new(move |_, window, cx| {
|
||||
let id = SharedString::from(format!("pr:{pr_id}"));
|
||||
let panel_id = id.clone();
|
||||
let workspace_for_build = workspace.clone();
|
||||
let store = store.clone();
|
||||
open_detail(
|
||||
@@ -318,6 +319,7 @@ impl Render for PullRequestsView {
|
||||
cx.new(|cx| {
|
||||
PullRequestDetailView::new(
|
||||
workspace_for_build.clone(),
|
||||
panel_id.clone(),
|
||||
store.clone(),
|
||||
pr_id,
|
||||
window,
|
||||
|
||||
@@ -28,7 +28,7 @@ use crate::repo::commit_diff::{CommitDiffView, DiffPane};
|
||||
use crate::repo::helpers::announcement_display_name;
|
||||
use crate::shared::event_list::commit_list;
|
||||
use crate::shared::log_dropped;
|
||||
use crate::shared::panels::open_detail;
|
||||
use crate::shared::panels::{self, open_detail};
|
||||
use crate::shared::progress::error_row;
|
||||
|
||||
pub struct NewPullRequestView {
|
||||
@@ -232,13 +232,23 @@ impl NewPullRequestView {
|
||||
None => SharedString::from(format!("commit:{}:{commit_id}", repo_path.display())),
|
||||
};
|
||||
let workspace = self.workspace.clone();
|
||||
let workspace_for_build = workspace.clone();
|
||||
let panel_id = id.clone();
|
||||
let commit_id = commit_id.to_owned();
|
||||
open_detail(
|
||||
&workspace,
|
||||
id,
|
||||
move |window, cx| {
|
||||
cx.new(|cx| {
|
||||
CommitDiffView::new(repo_path.clone(), commit_id.clone(), false, window, cx)
|
||||
CommitDiffView::new(
|
||||
workspace_for_build.clone(),
|
||||
panel_id.clone(),
|
||||
repo_path.clone(),
|
||||
commit_id.clone(),
|
||||
false,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
},
|
||||
window,
|
||||
@@ -806,7 +816,15 @@ impl Render for NewPullRequestView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
v_flex()
|
||||
.id("new-pr")
|
||||
.relative()
|
||||
.size_full()
|
||||
.child(
|
||||
div()
|
||||
.absolute()
|
||||
.top_1()
|
||||
.right_1()
|
||||
.child(panels::close_button(&self.workspace, &self.panel_id)),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_3()
|
||||
|
||||
@@ -13,6 +13,7 @@ use ui::theme::ActiveTheme as _;
|
||||
|
||||
use crate::app::AppRoot;
|
||||
use crate::shared::log_dropped;
|
||||
use crate::shared::panels;
|
||||
use crate::shared::progress::error_row;
|
||||
|
||||
pub struct SendPatchView {
|
||||
@@ -144,7 +145,15 @@ impl Render for SendPatchView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
v_flex()
|
||||
.id("send-patch")
|
||||
.relative()
|
||||
.size_full()
|
||||
.child(
|
||||
div()
|
||||
.absolute()
|
||||
.top_1()
|
||||
.right_1()
|
||||
.child(panels::close_button(&self.workspace, &self.panel_id)),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.p_4()
|
||||
|
||||
Reference in New Issue
Block a user