feat: rework window layout around panel stack (#36)
Reviewed-on: #36
This commit was merged in pull request #36.
This commit is contained in:
@@ -8,13 +8,16 @@ use signed_core::GitEvent;
|
||||
use signed_state::RepoStore;
|
||||
use ui::avatar::Avatar;
|
||||
use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
|
||||
use ui::empty_state::EmptyState;
|
||||
use ui::input::InputState;
|
||||
use ui::layout::panel::Panel;
|
||||
use ui::scroll_area::ScrollArea;
|
||||
use ui::spinner::Spinner;
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use utils::relative_time;
|
||||
|
||||
use crate::issues::helpers::{comment_form, comments_section, issue_roots, sidebar_section};
|
||||
use crate::issues::helpers::{comment_form, comments_section, sidebar_section};
|
||||
use crate::shared::log_dropped;
|
||||
use crate::shared::widgets::status_badge;
|
||||
|
||||
pub struct IssueDetailView {
|
||||
@@ -39,7 +42,7 @@ impl IssueDetailView {
|
||||
let directory = ProfileDirectory::new(cx);
|
||||
let weak = cx.entity().downgrade();
|
||||
cx.defer(move |cx| {
|
||||
crate::shared::log_dropped(weak.update(cx, |this, cx| this.track_participants(cx)));
|
||||
log_dropped(weak.update(cx, |this, cx| this.track_participants(cx)));
|
||||
});
|
||||
|
||||
Self {
|
||||
@@ -94,9 +97,9 @@ impl Render for IssueDetailView {
|
||||
let Some(issue) = store.issues.iter().find(|issue| issue.id == self.issue_id) else {
|
||||
// A not-yet-loaded store is not the same as a missing issue.
|
||||
return if store.loaded {
|
||||
crate::shared::widgets::empty_state("Issue not found")
|
||||
EmptyState::centered("Issue not found")
|
||||
} else {
|
||||
crate::shared::widgets::centered_spinner("issue-loading")
|
||||
Spinner::centered("issue-loading")
|
||||
};
|
||||
};
|
||||
|
||||
@@ -189,7 +192,7 @@ impl Render for IssueDetailView {
|
||||
.child(comment_form(
|
||||
&self.store,
|
||||
issue_id,
|
||||
issue_roots,
|
||||
&store.issues,
|
||||
&self.comment_input,
|
||||
"comment",
|
||||
cx,
|
||||
@@ -200,7 +203,7 @@ impl Render for IssueDetailView {
|
||||
.child(sidebar_section(
|
||||
&self.store,
|
||||
issue_id,
|
||||
issue_roots,
|
||||
&store.issues,
|
||||
true,
|
||||
&self.directory,
|
||||
cx,
|
||||
|
||||
@@ -76,24 +76,16 @@ pub(crate) fn filter_by_status<'a>(
|
||||
(visible, counts)
|
||||
}
|
||||
|
||||
pub(crate) fn issue_roots(store: &RepoStore) -> &[Event] {
|
||||
&store.issues
|
||||
}
|
||||
|
||||
pub(crate) fn pr_roots(store: &RepoStore) -> &[Event] {
|
||||
&store.pull_requests
|
||||
}
|
||||
|
||||
pub(crate) fn sidebar_section(
|
||||
store: &Entity<RepoStore>,
|
||||
id: EventId,
|
||||
roots: fn(&RepoStore) -> &[Event],
|
||||
roots: &[Event],
|
||||
top_gap: bool,
|
||||
directory: &Entity<ProfileDirectory>,
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
let store = store.read(cx);
|
||||
let Some(root) = roots(store).iter().find(|event| event.id == id) else {
|
||||
let Some(root) = roots.iter().find(|event| event.id == id) else {
|
||||
return div().into_any_element();
|
||||
};
|
||||
|
||||
@@ -116,7 +108,13 @@ pub(crate) fn sidebar_section(
|
||||
v_flex()
|
||||
.when(top_gap, |this| this.mt_4())
|
||||
.gap_2()
|
||||
.child(crate::shared::widgets::section_label("Participants", cx))
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.font_medium()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Participants"),
|
||||
)
|
||||
.children(participants.iter().map(|pubkey| {
|
||||
let profile = directory.read(cx).profile(pubkey, cx);
|
||||
let name = profile.name();
|
||||
@@ -136,7 +134,13 @@ pub(crate) fn sidebar_section(
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(crate::shared::widgets::section_label("Labels", cx))
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.font_medium()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Labels"),
|
||||
)
|
||||
.map(|this| {
|
||||
if labels.is_empty() {
|
||||
this.child(
|
||||
@@ -215,11 +219,14 @@ pub(crate) fn comments_section(
|
||||
pub(crate) fn comment_form(
|
||||
store: &Entity<RepoStore>,
|
||||
root: EventId,
|
||||
roots: fn(&RepoStore) -> &[Event],
|
||||
roots: &[Event],
|
||||
comment_input: &Entity<InputState>,
|
||||
button_id: &'static str,
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
let Some(root) = roots.iter().find(|event| event.id == root).cloned() else {
|
||||
return div().into_any_element();
|
||||
};
|
||||
let comment_input = comment_input.clone();
|
||||
let store = store.clone();
|
||||
|
||||
@@ -254,13 +261,6 @@ pub(crate) fn comment_form(
|
||||
if content.is_empty() {
|
||||
return;
|
||||
}
|
||||
let Some(root) = roots(store.read(cx))
|
||||
.iter()
|
||||
.find(|event| event.id == root)
|
||||
.cloned()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
store.update(cx, |store, cx| {
|
||||
store.comment(&root, content, cx);
|
||||
});
|
||||
|
||||
@@ -19,17 +19,18 @@ use utils::relative_time;
|
||||
use std::rc::Rc;
|
||||
|
||||
use self::detail::IssueDetailView;
|
||||
use crate::app::AppRoot;
|
||||
use crate::repo::helpers::short_id;
|
||||
use crate::shared::event_list::{EventList, EventRow};
|
||||
use crate::shared::event_list::{EventHandler, EventList, EventRow, filter_toolbar};
|
||||
use crate::shared::log_dropped;
|
||||
use crate::shared::panels;
|
||||
use crate::workspace::Workspace;
|
||||
|
||||
pub mod detail;
|
||||
pub(crate) mod helpers;
|
||||
pub mod new_issue;
|
||||
|
||||
pub struct IssuesView {
|
||||
workspace: WeakEntity<Workspace>,
|
||||
workspace: WeakEntity<AppRoot>,
|
||||
store: Entity<RepoStore>,
|
||||
new_issue: Option<Entity<new_issue::NewIssueDialog>>,
|
||||
filter: IssueFilter,
|
||||
@@ -45,7 +46,7 @@ pub struct IssuesView {
|
||||
|
||||
impl IssuesView {
|
||||
pub fn new(
|
||||
workspace: WeakEntity<Workspace>,
|
||||
workspace: WeakEntity<AppRoot>,
|
||||
store: Entity<RepoStore>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
@@ -54,7 +55,7 @@ impl IssuesView {
|
||||
});
|
||||
let weak = cx.entity().downgrade();
|
||||
cx.defer(move |cx| {
|
||||
crate::shared::log_dropped(weak.update(cx, |this, cx| this.rebuild(cx)));
|
||||
log_dropped(weak.update(cx, |this, cx| this.rebuild(cx)));
|
||||
});
|
||||
|
||||
Self {
|
||||
@@ -128,7 +129,7 @@ impl IssuesView {
|
||||
let muted = cx.theme().colors.muted_foreground;
|
||||
let weak = cx.entity().downgrade();
|
||||
|
||||
crate::shared::event_list::filter_toolbar(
|
||||
filter_toolbar(
|
||||
cx,
|
||||
[
|
||||
Segmented::new("issue-filter", self.filter)
|
||||
@@ -190,7 +191,7 @@ impl Render for IssuesView {
|
||||
let id_hex = issue.id.to_hex();
|
||||
let status = store.read(cx).status_of(issue);
|
||||
|
||||
let on_click: crate::shared::event_list::EventHandler = {
|
||||
let on_click: EventHandler = {
|
||||
let workspace = workspace.clone();
|
||||
let store = store.clone();
|
||||
Rc::new(move |_, window, cx| {
|
||||
|
||||
@@ -3,14 +3,13 @@ use gpui::{
|
||||
Styled as _, Window, div,
|
||||
};
|
||||
use signed_state::RepoStore;
|
||||
use ui::button::Button;
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
|
||||
use crate::shared::progress::DialogProgress;
|
||||
use crate::shared::progress::{DialogProgress, dialog_submit_button};
|
||||
|
||||
pub struct NewIssueDialog {
|
||||
handle: DialogHandle,
|
||||
@@ -87,14 +86,18 @@ impl Render for NewIssueDialog {
|
||||
let this = this.clone();
|
||||
let busy = action_state.read(cx).busy;
|
||||
vec![
|
||||
Button::new("create-issue")
|
||||
.label("Create issue")
|
||||
.loading(busy)
|
||||
.disabled(busy)
|
||||
.on_click(move |_, _, cx| {
|
||||
crate::shared::log_dropped(this.update(cx, |this, cx| this.submit(cx)));
|
||||
})
|
||||
.into_any_element() as AnyElement,
|
||||
dialog_submit_button(
|
||||
"create-issue",
|
||||
"Create issue",
|
||||
None,
|
||||
busy,
|
||||
&this,
|
||||
|this, _window, cx| {
|
||||
this.submit(cx);
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
.into_any_element() as AnyElement,
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user