From 3c5fb68f7e0fa98187164208336615ffc2b83809 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Sat, 28 Nov 2026 10:06:29 +0700 Subject: [PATCH] chore: re-add inbox panel --- crates/signed_app/src/app/mod.rs | 65 ++++++++++++++++++++++++--- crates/signed_app/src/explore/mod.rs | 3 +- crates/signed_app/src/inbox/mod.rs | 33 +++++++++++++- crates/signed_app/src/lib.rs | 1 - crates/signed_app/src/titlebar/mod.rs | 34 +------------- crates/ui/src/components/tabs.rs | 2 +- crates/ui/src/icons/assets/bell.svg | 3 ++ crates/ui/src/icons/mod.rs | 3 ++ 8 files changed, 98 insertions(+), 46 deletions(-) create mode 100644 crates/ui/src/icons/assets/bell.svg diff --git a/crates/signed_app/src/app/mod.rs b/crates/signed_app/src/app/mod.rs index 6a2435d..0dd07eb 100644 --- a/crates/signed_app/src/app/mod.rs +++ b/crates/signed_app/src/app/mod.rs @@ -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) { + 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) { + 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.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) { 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) -> 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()), ) diff --git a/crates/signed_app/src/explore/mod.rs b/crates/signed_app/src/explore/mod.rs index 155131f..05090c4 100644 --- a/crates/signed_app/src/explore/mod.rs +++ b/crates/signed_app/src/explore/mod.rs @@ -320,8 +320,7 @@ impl Panel for ExploreView { fn prefix(&self, cx: &App) -> Option { Some( Icon::named(IconRole::Grid) - .small() - .color(cx.theme().colors.muted_foreground) + .color(cx.theme().colors.foreground) .into_any_element(), ) } diff --git a/crates/signed_app/src/inbox/mod.rs b/crates/signed_app/src/inbox/mod.rs index 6c0d7a2..9d2cd44 100644 --- a/crates/signed_app/src/inbox/mod.rs +++ b/crates/signed_app/src/inbox/mod.rs @@ -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, + workspace: WeakEntity, + 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, cx: &mut Context) -> 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 { + Some( + Icon::named(IconRole::Bell) + .color(cx.theme().colors.foreground) + .into_any_element(), + ) } } diff --git a/crates/signed_app/src/lib.rs b/crates/signed_app/src/lib.rs index 439e7cc..255f211 100644 --- a/crates/signed_app/src/lib.rs +++ b/crates/signed_app/src/lib.rs @@ -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; diff --git a/crates/signed_app/src/titlebar/mod.rs b/crates/signed_app/src/titlebar/mod.rs index b2a1605..af67e16 100644 --- a/crates/signed_app/src/titlebar/mod.rs +++ b/crates/signed_app/src/titlebar/mod.rs @@ -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) { + pub(crate) fn open_create(&mut self, window: &mut Window, cx: &mut Context) { 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(); diff --git a/crates/ui/src/components/tabs.rs b/crates/ui/src/components/tabs.rs index 21164c4..1bdba3c 100644 --- a/crates/ui/src/components/tabs.rs +++ b/crates/ui/src/components/tabs.rs @@ -410,6 +410,7 @@ impl Tab { .map(|on_close| self.render_tab_close(&ctx.id, index, on_close)); div() + .when_some(self.lead.take(), |strip_tab, lead| strip_tab.child(lead)) .child( div() .flex_grow(1.0) @@ -505,7 +506,6 @@ impl Tab { .max_w(TAB_MAX_WIDTH) .when(titlebar, |strip_tab| strip_tab.min_w(TAB_MIN_WIDTH)) }) - .when_some(self.lead.take(), |strip_tab, lead| strip_tab.child(lead)) .when(ctx.variant == TabsVariant::Pill, |strip_tab| { strip_tab.child(div().flex_none().w_4()) }) diff --git a/crates/ui/src/icons/assets/bell.svg b/crates/ui/src/icons/assets/bell.svg new file mode 100644 index 0000000..bbbd3f4 --- /dev/null +++ b/crates/ui/src/icons/assets/bell.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/ui/src/icons/mod.rs b/crates/ui/src/icons/mod.rs index d284eab..ea2fbba 100644 --- a/crates/ui/src/icons/mod.rs +++ b/crates/ui/src/icons/mod.rs @@ -59,6 +59,7 @@ pub enum IconRole { EllipsisVertical, ArrowUp, Inbox, + Bell, Stack, Message, PanelLeft, @@ -112,6 +113,7 @@ impl IconRole { Self::EllipsisVertical => "ellipsis-vertical", Self::ArrowUp => "arrow-up", Self::Inbox => "inbox", + Self::Bell => "bell", Self::Stack => "stack", Self::Message => "message", Self::PanelLeft => "panel-left", @@ -165,6 +167,7 @@ impl IconRole { Self::EllipsisVertical => "icons/ellipsis-vertical.svg", Self::ArrowUp => "icons/arrow-up.svg", Self::Inbox => "icons/inbox.svg", + Self::Bell => "icons/bell.svg", Self::Stack => "icons/stack.svg", Self::Message => "icons/message.svg", Self::PanelLeft => "icons/panel-left.svg",