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:
@@ -1,7 +1,7 @@
|
||||
use assets::CustomIconName;
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
|
||||
AnyElement, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
|
||||
ParentElement as _, Render, SharedString, StatefulInteractiveElement as _, Styled as _,
|
||||
Subscription, UniformListScrollHandle, WeakEntity, Window, div, px, uniform_list,
|
||||
};
|
||||
@@ -10,7 +10,7 @@ use gpui_native_kit::avatar::Avatar;
|
||||
use gpui_native_kit::common::{Sizable as _, h_flex, v_flex};
|
||||
use gpui_native_kit::dropdown_menu::DropdownMenu;
|
||||
use gpui_native_kit::icons::Icon;
|
||||
use gpui_native_kit::layout::dock::{DockState, Panel};
|
||||
use gpui_native_kit::layout::panel::Panel;
|
||||
use gpui_native_kit::menu::MenuItem;
|
||||
use gpui_native_kit::scrollbar::Scrollbar;
|
||||
use gpui_native_kit::segmented::{Segmented, SegmentedOption};
|
||||
@@ -33,14 +33,14 @@ pub use new::NewPullRequestView;
|
||||
pub use send_patch::SendPatchView;
|
||||
|
||||
use crate::issues::helpers::{StatusCounts, filter_by_status};
|
||||
use crate::shared::widgets::{empty_state, repo_tab_avatar, status_badge};
|
||||
use crate::shared::widgets::{empty_state, status_badge};
|
||||
use crate::workspace::Workspace;
|
||||
|
||||
const ROW_HEIGHT: f32 = 73.;
|
||||
|
||||
pub struct PullRequestsView {
|
||||
dock: WeakEntity<DockState>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
store: Entity<RepoStore>,
|
||||
repo_name: SharedString,
|
||||
filter: PullRequestFilter,
|
||||
visible_prs: Vec<usize>,
|
||||
counts: StatusCounts,
|
||||
@@ -53,12 +53,11 @@ pub struct PullRequestsView {
|
||||
|
||||
impl PullRequestsView {
|
||||
pub fn new(
|
||||
dock: WeakEntity<DockState>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
store: Entity<RepoStore>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let weak = cx.entity().downgrade();
|
||||
let repo_name = store.read(cx).name();
|
||||
let subscription = cx.observe(&store, |this, _store, cx| {
|
||||
this.rebuild(cx);
|
||||
});
|
||||
@@ -70,9 +69,8 @@ impl PullRequestsView {
|
||||
});
|
||||
|
||||
Self {
|
||||
dock,
|
||||
workspace,
|
||||
store,
|
||||
repo_name,
|
||||
filter: PullRequestFilter::Open,
|
||||
visible_prs: Vec::new(),
|
||||
counts: StatusCounts::default(),
|
||||
@@ -136,17 +134,18 @@ impl PullRequestsView {
|
||||
};
|
||||
|
||||
let id = SharedString::from(format!("new-pr:{addr}"));
|
||||
let dock = self.dock.clone();
|
||||
let dock_for_build = dock.clone();
|
||||
let workspace = self.workspace.clone();
|
||||
let workspace_for_build = workspace.clone();
|
||||
let store = self.store.clone();
|
||||
|
||||
crate::shared::panels::open(
|
||||
&dock,
|
||||
crate::shared::panels::open_detail(
|
||||
&workspace,
|
||||
id.clone(),
|
||||
"New pull request",
|
||||
move |window, cx| {
|
||||
cx.new(|cx| {
|
||||
NewPullRequestView::new(
|
||||
dock_for_build.clone(),
|
||||
workspace_for_build.clone(),
|
||||
id.clone(),
|
||||
store.clone(),
|
||||
window,
|
||||
@@ -165,17 +164,18 @@ impl PullRequestsView {
|
||||
};
|
||||
|
||||
let id = SharedString::from(format!("send-patch:{addr}"));
|
||||
let dock = self.dock.clone();
|
||||
let dock_for_build = dock.clone();
|
||||
let workspace = self.workspace.clone();
|
||||
let workspace_for_build = workspace.clone();
|
||||
let store = self.store.clone();
|
||||
|
||||
crate::shared::panels::open(
|
||||
&dock,
|
||||
crate::shared::panels::open_detail(
|
||||
&workspace,
|
||||
id.clone(),
|
||||
"Send patch",
|
||||
move |window, cx| {
|
||||
cx.new(|cx| {
|
||||
SendPatchView::new(
|
||||
dock_for_build.clone(),
|
||||
workspace_for_build.clone(),
|
||||
id.clone(),
|
||||
store.clone(),
|
||||
window,
|
||||
@@ -275,15 +275,7 @@ impl PullRequestsView {
|
||||
}
|
||||
}
|
||||
|
||||
impl Panel for PullRequestsView {
|
||||
fn title(&self, _cx: &App) -> Option<SharedString> {
|
||||
Some(SharedString::from(format!("{}/pulls", self.repo_name)))
|
||||
}
|
||||
|
||||
fn lead(&self, cx: &App) -> Option<AnyElement> {
|
||||
Some(repo_tab_avatar(self.store.read(cx), &self.directory, cx))
|
||||
}
|
||||
}
|
||||
impl Panel for PullRequestsView {}
|
||||
|
||||
impl Render for PullRequestsView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
@@ -292,7 +284,7 @@ impl Render for PullRequestsView {
|
||||
let visible = self.visible_prs.clone();
|
||||
let directory = self.directory.clone();
|
||||
let store = self.store.clone();
|
||||
let dock = self.dock.clone();
|
||||
let workspace = self.workspace.clone();
|
||||
|
||||
let (last_error, last_warning) = {
|
||||
let store = self.store.read(cx);
|
||||
@@ -347,7 +339,7 @@ impl Render for PullRequestsView {
|
||||
let status = store.read(cx).status_of(pr);
|
||||
let profile = directory.read(cx).profile(&pr.pubkey, cx);
|
||||
let author = profile.name();
|
||||
let dock = dock.clone();
|
||||
let workspace = workspace.clone();
|
||||
let store = store.clone();
|
||||
|
||||
h_flex()
|
||||
@@ -361,15 +353,20 @@ impl Render for PullRequestsView {
|
||||
.hover(|this| this.bg(cx.theme().colors.muted_hover))
|
||||
.on_click(move |_, window, cx| {
|
||||
let id = SharedString::from(format!("pr:{pr_id}"));
|
||||
let dock_for_build = dock.clone();
|
||||
let hex = pr_id.to_hex();
|
||||
let short = hex.get(..8).unwrap_or(&hex);
|
||||
let label =
|
||||
SharedString::from(format!("PR {short}"));
|
||||
let workspace_for_build = workspace.clone();
|
||||
let store = store.clone();
|
||||
crate::shared::panels::open(
|
||||
&dock,
|
||||
crate::shared::panels::open_detail(
|
||||
&workspace,
|
||||
id,
|
||||
label,
|
||||
move |window, cx| {
|
||||
cx.new(|cx| {
|
||||
PullRequestDetailView::new(
|
||||
dock_for_build.clone(),
|
||||
workspace_for_build.clone(),
|
||||
store.clone(),
|
||||
pr_id,
|
||||
window,
|
||||
|
||||
Reference in New Issue
Block a user