chore: re-add inbox panel
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s

This commit is contained in:
2026-11-28 10:06:29 +07:00
parent 71bbcfaf51
commit 3c5fb68f7e
8 changed files with 98 additions and 46 deletions
+58 -7
View File
@@ -9,6 +9,7 @@ use nostr::prelude::EventId;
use settings::{AppearanceMode, SettingsStore};
use signed_core::{Announcement, RepoAddr};
use signed_state::{Backend, BackendEvent, RepoStore};
use ui::button::{Button, ButtonVariant};
use ui::common::{h_flex, v_flex};
use ui::icons::IconRole;
use ui::layout::panel::{PanelSlot, PanelStack};
@@ -16,12 +17,14 @@ use ui::layout::root::{Root, RootContext as _};
use ui::layout::titlebar::Titlebar;
use ui::theme::{ThemeEngine, ThemeVariant};
use ui::toast::Toast;
use ui::tooltip::Tooltip;
use crate::app::placeholder::PlaceholderView;
use crate::explore::ExploreView;
use crate::identity::import::ImportDialog;
use crate::identity::onboarding::OnboardingDialog;
use crate::identity::passphrase::PassphraseDialog;
use crate::inbox::InboxView;
use crate::issues::IssuesView;
use crate::issues::detail::IssueDetailView;
use crate::pull_requests::{PullRequestDetailView, PullRequestsView};
@@ -232,6 +235,23 @@ impl AppRoot {
}
}
/// Opens the explore panel in the main stack.
fn open_explore(&mut self, window: &mut Window, cx: &mut Context<Self>) {
ExploreView::open(&self.panels, cx.weak_entity(), window, cx);
}
/// Opens the inbox panel in the main stack.
fn open_inbox(&mut self, window: &mut Window, cx: &mut Context<Self>) {
InboxView::open_panel(&self.panels, cx.weak_entity(), window, cx);
}
/// Opens the dialog that creates a repository.
fn open_create_repository(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.titlebar.update(cx, |titlebar, cx| {
titlebar.open_create(window, cx);
});
}
/// Opens the dialog that imports an identity from a secret.
pub(crate) fn open_import_dialog(&mut self, _window: &mut Window, cx: &mut Context<Self>) {
let dialog = ImportDialog::new(cx);
@@ -248,7 +268,8 @@ impl AppRoot {
impl Render for AppRoot {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let repo_tabs = PanelStack::main_tabs(self.panels.clone(), cx);
let titlebar_view = self.titlebar.read(cx);
let repository_switcher = self.titlebar.read(cx).repository_switcher();
let user_menu = self.titlebar.read(cx).render_user_menu(cx);
div()
.relative()
@@ -277,18 +298,48 @@ impl Render for AppRoot {
.prefix(
h_flex()
.gap_1()
.child(titlebar_view.render_new_repository())
.child(titlebar_view.render_explore())
.child(titlebar_view.repository_switcher()),
.child(
Button::new("open-explore")
.icon(IconRole::Grid)
.variant(ButtonVariant::Ghost)
.fully_rounded(true)
.tooltip(Tooltip::text("Explore repositories"))
.on_click(cx.listener(|this, _, window, cx| {
this.open_explore(window, cx);
})),
)
.child(repository_switcher),
)
.tab_bar(
h_flex()
.gap_1()
.when_some(repo_tabs, |bar, tabs| bar.child(tabs)),
)
.when_some(titlebar_view.render_user_menu(cx), |titlebar, menu| {
titlebar.suffix(menu)
}),
.suffix(
h_flex()
.gap_1()
.child(
Button::new("add-repo")
.icon(IconRole::Plus)
.variant(ButtonVariant::Ghost)
.fully_rounded(true)
.tooltip(Tooltip::text("Create repository"))
.on_click(cx.listener(|this, _, window, cx| {
this.open_create_repository(window, cx);
})),
)
.child(
Button::new("open-inbox")
.icon(IconRole::Bell)
.variant(ButtonVariant::Ghost)
.fully_rounded(true)
.tooltip(Tooltip::text("Inbox"))
.on_click(cx.listener(|this, _, window, cx| {
this.open_inbox(window, cx);
})),
)
.when_some(user_menu, |bar, menu| bar.child(menu)),
),
)
.child(self.panels.clone()),
)
+1 -2
View File
@@ -320,8 +320,7 @@ impl Panel for ExploreView {
fn prefix(&self, cx: &App) -> Option<AnyElement> {
Some(
Icon::named(IconRole::Grid)
.small()
.color(cx.theme().colors.muted_foreground)
.color(cx.theme().colors.foreground)
.into_any_element(),
)
}
+31 -2
View File
@@ -18,7 +18,8 @@ use ui::button::Button;
use ui::common::{StyledExt as _, h_flex, v_flex};
use ui::empty_state::EmptyState;
use ui::icons::{Icon, IconRole};
use ui::layout::panel::Panel;
use ui::layout::panel::{Panel, PanelSlot, PanelStack};
use ui::theme::ActiveTheme;
mod helpers;
@@ -81,6 +82,26 @@ pub struct InboxView {
}
impl InboxView {
pub(crate) const PANEL_ID: &'static str = "Inbox";
/// Opens the inbox panel in the main panel, reusing it when it is already cached.
pub(crate) fn open_panel(
panels: &Entity<PanelStack>,
workspace: WeakEntity<AppRoot>,
window: &mut Window,
cx: &mut App,
) {
panels.update(cx, |panels, cx| {
panels.open(
PanelSlot::Main,
Self::PANEL_ID,
move |_, cx| cx.new(|cx| Self::new(workspace.clone(), cx)),
window,
cx,
);
});
}
pub fn new(workspace: WeakEntity<AppRoot>, cx: &mut Context<Self>) -> Self {
let backend = Backend::global(cx);
let inbox = backend.read(cx).inbox();
@@ -434,7 +455,15 @@ impl InboxView {
impl Panel for InboxView {
fn title(&self, _cx: &App) -> SharedString {
SharedString::from("Inbox")
SharedString::from(Self::PANEL_ID)
}
fn prefix(&self, cx: &App) -> Option<AnyElement> {
Some(
Icon::named(IconRole::Bell)
.color(cx.theme().colors.foreground)
.into_any_element(),
)
}
}
-1
View File
@@ -1,7 +1,6 @@
mod app;
mod explore;
mod identity;
#[expect(dead_code, reason = "unlinked while the shell migrates")]
mod inbox;
mod issues;
mod pull_requests;
+1 -33
View File
@@ -18,10 +18,8 @@ use ui::icons::{Icon, IconRole};
use ui::layout::panel::PanelSlot;
use ui::layout::root::RootContext as _;
use ui::menu::{Menu, MenuItem};
use ui::tooltip::Tooltip;
use crate::app::AppRoot;
use crate::explore::ExploreView;
use crate::identity::exit::ExitDialog;
use crate::repo::RepoDetailView;
use crate::repo::dialogs::create::CreateRepoDialog;
@@ -328,7 +326,7 @@ impl TitlebarView {
cx.open_dialog(dialog);
}
fn open_create(&mut self, window: &mut Window, cx: &mut Context<Self>) {
pub(crate) fn open_create(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let view = CreateRepoDialog::new(self.app.clone(), window, cx);
cx.open_dialog(view);
}
@@ -432,36 +430,6 @@ impl TitlebarView {
Some(self.render_user(&profile, cx).into_any_element())
}
pub fn render_explore(&self) -> Button {
let workspace = self.app.clone();
Button::new("open-explore")
.icon(IconRole::Grid)
.variant(ButtonVariant::Ghost)
.fully_rounded(true)
.tooltip(Tooltip::text("Explore repositories"))
.on_click(move |_, window, cx| {
let panels = workspace.read_with(cx, |root, _| root.panels().clone());
let Ok(panels) = panels else {
return;
};
ExploreView::open(&panels, workspace.clone(), window, cx);
})
}
pub fn render_new_repository(&self) -> Button {
let weak = self.weak.clone();
Button::new("add-repo")
.icon(IconRole::Plus)
.variant(ButtonVariant::Ghost)
.fully_rounded(true)
.tooltip(Tooltip::text("Create repository"))
.on_click(move |_, window, cx| {
log_dropped(weak.update(cx, |this, cx| this.open_create(window, cx)));
})
}
fn render_user(&self, profile: &Profile, _cx: &App) -> impl IntoElement {
let name = profile.name();
let picture = profile.picture();