Replace dock shell with titlebar repository tabs
- Move repository navigation from the dock sidebar to titlebar tabs. - Route main and detail panels through Workspace. - Move sign-in into the main panel and remove unlinked navigation.
This commit is contained in:
@@ -13,26 +13,25 @@ use gpui_native_kit::common::{h_flex, v_flex};
|
||||
use gpui_native_kit::data::tabs::{Tab, Tabs};
|
||||
use gpui_native_kit::icons::{Icon, IconRole};
|
||||
use gpui_native_kit::input::{Input, InputState};
|
||||
use gpui_native_kit::layout::dock::{DockState, Panel};
|
||||
use gpui_native_kit::layout::panel::Panel;
|
||||
use gpui_native_kit::menu::Menu;
|
||||
use gpui_native_kit::scrollbar::Scrollbar;
|
||||
use gpui_native_kit::spinner::Spinner;
|
||||
use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use metadata::ProfileDirectory;
|
||||
use signed_state::{CheckoutsStore, RepoStore};
|
||||
|
||||
use super::helpers::{ForkCompare, fork_display_name, truncate_label};
|
||||
use crate::repo::commit_diff::{CommitDiffView, DiffPane};
|
||||
use crate::repo::helpers::commit_row;
|
||||
use crate::shared::widgets::empty_state;
|
||||
use crate::workspace::Workspace;
|
||||
|
||||
mod source;
|
||||
|
||||
pub struct NewPullRequestView {
|
||||
dock: WeakEntity<DockState>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
panel_id: SharedString,
|
||||
pub(super) store: Entity<RepoStore>,
|
||||
repo_name: SharedString,
|
||||
pub(super) repo_path: Option<PathBuf>,
|
||||
pub(super) branches: Vec<SharedString>,
|
||||
pub(super) fork: Option<ForkCompare>,
|
||||
@@ -53,21 +52,18 @@ pub struct NewPullRequestView {
|
||||
pub(super) pane: Entity<DiffPane>,
|
||||
scroll_handle: UniformListScrollHandle,
|
||||
pub(super) tasks: Vec<gpui::Task<Result<(), anyhow::Error>>>,
|
||||
directory: Entity<ProfileDirectory>,
|
||||
source_open: bool,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
}
|
||||
|
||||
impl NewPullRequestView {
|
||||
pub fn new(
|
||||
dock: WeakEntity<DockState>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
panel_id: SharedString,
|
||||
store: Entity<RepoStore>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let directory = ProfileDirectory::new(cx);
|
||||
let repo_name = store.read(cx).name();
|
||||
let pane = cx.new(DiffPane::new);
|
||||
|
||||
let weak = cx.entity().downgrade();
|
||||
@@ -116,10 +112,6 @@ impl NewPullRequestView {
|
||||
)
|
||||
});
|
||||
|
||||
if let Some(owner) = store.read(cx).announcement.as_ref().map(|a| a.owner) {
|
||||
directory.update(cx, |directory, cx| directory.track([owner], cx));
|
||||
}
|
||||
|
||||
window.defer(cx, move |window, cx| {
|
||||
crate::shared::log_dropped(weak.update(cx, |this, cx| {
|
||||
let Some(addr) = this.store.read(cx).addr().cloned() else {
|
||||
@@ -140,10 +132,9 @@ impl NewPullRequestView {
|
||||
});
|
||||
|
||||
Self {
|
||||
dock,
|
||||
workspace,
|
||||
panel_id,
|
||||
store,
|
||||
repo_name,
|
||||
repo_path: None,
|
||||
branches: Vec::new(),
|
||||
fork: None,
|
||||
@@ -164,7 +155,6 @@ impl NewPullRequestView {
|
||||
pane,
|
||||
scroll_handle: UniformListScrollHandle::new(),
|
||||
tasks: Vec::new(),
|
||||
directory,
|
||||
source_open: false,
|
||||
_subscriptions: Vec::new(),
|
||||
}
|
||||
@@ -185,7 +175,7 @@ impl NewPullRequestView {
|
||||
let branch_name = self.compare.to_string();
|
||||
let compare_ref = self.compare_ref();
|
||||
let store = self.store.clone();
|
||||
let dock = self.dock.clone();
|
||||
let workspace = self.workspace.clone();
|
||||
let panel_id = self.panel_id.clone();
|
||||
|
||||
self.submitting = true;
|
||||
@@ -216,7 +206,9 @@ impl NewPullRequestView {
|
||||
this.update(cx, |this, _cx| {
|
||||
this.submitting = false;
|
||||
})?;
|
||||
crate::shared::log_dropped(dock.update(cx, |dock, cx| dock.close_panel(&panel_id, cx)));
|
||||
crate::shared::log_dropped(
|
||||
workspace.update(cx, |workspace, cx| workspace.close_detail(&panel_id, cx)),
|
||||
);
|
||||
Ok(())
|
||||
});
|
||||
self.tasks.push(task);
|
||||
@@ -230,24 +222,16 @@ impl NewPullRequestView {
|
||||
Some(addr) => SharedString::from(format!("commit:{addr}:{commit_id}")),
|
||||
None => SharedString::from(format!("commit:{}:{commit_id}", repo_path.display())),
|
||||
};
|
||||
let dock = self.dock.clone();
|
||||
let store = self.store.clone();
|
||||
let repo_name = self.repo_name.clone();
|
||||
let workspace = self.workspace.clone();
|
||||
let short = commit_id.get(..8).unwrap_or(commit_id);
|
||||
let label = SharedString::from(format!("Commit {short}"));
|
||||
let commit_id = commit_id.to_owned();
|
||||
crate::shared::panels::open(
|
||||
&dock,
|
||||
crate::shared::panels::open_detail(
|
||||
&workspace,
|
||||
id,
|
||||
label,
|
||||
move |window, cx| {
|
||||
cx.new(|cx| {
|
||||
CommitDiffView::new(
|
||||
store.clone(),
|
||||
repo_path.clone(),
|
||||
repo_name.clone(),
|
||||
commit_id.clone(),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
cx.new(|cx| CommitDiffView::new(repo_path.clone(), commit_id.clone(), window, cx))
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
@@ -461,22 +445,7 @@ impl NewPullRequestView {
|
||||
}
|
||||
}
|
||||
|
||||
impl Panel for NewPullRequestView {
|
||||
fn title(&self, _cx: &gpui::App) -> Option<SharedString> {
|
||||
Some(SharedString::from(format!(
|
||||
"{}/new-pull-request",
|
||||
self.repo_name
|
||||
)))
|
||||
}
|
||||
|
||||
fn lead(&self, cx: &gpui::App) -> Option<AnyElement> {
|
||||
Some(crate::shared::widgets::repo_tab_avatar(
|
||||
self.store.read(cx),
|
||||
&self.directory,
|
||||
cx,
|
||||
))
|
||||
}
|
||||
}
|
||||
impl Panel for NewPullRequestView {}
|
||||
|
||||
impl Render for NewPullRequestView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
|
||||
Reference in New Issue
Block a user