BlueGit

ict rusty-teams

feat(teams): New message in the Teams list New menu

- opens the post composer of the selected channel
- disabled without a selected channel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-09 · 3 weeks ago

Hash
c708f2caa75511dc2f9c5c3762cd4dc9e0be1f72
Parent
96ae09c3
4 files changed +24 −1
crates/app/src/views/conversation/feed.rs +6 −0
@@ -42,6 +42,12 @@ impl ConversationView {
42 42 .is_some_and(|current| current.mode == ViewMode::ThreadList)
43 43 }
44 44
45 pub fn start_channel_post(&mut self, window: &mut Window, cx: &mut Context<Self>) {
46 if self.in_feed() {
47 self.open_new_post(window, cx);
48 }
49 }
50
45 51 pub(super) fn open_new_post(&mut self, window: &mut Window, cx: &mut Context<Self>) {
46 52 self.mark_new_post_open(cx);
47 53 self.composer
@@ -42,6 +42,12 @@ impl ConversationView {
42 .is_some_and(|current| current.mode == ViewMode::ThreadList)
42 .is_some_and(|current| current.mode == ViewMode::ThreadList)
43 }
43 }
44
44
45 pub fn start_channel_post(&mut self, window: &mut Window, cx: &mut Context<Self>) {
46 if self.in_feed() {
47 self.open_new_post(window, cx);
48 }
49 }
50
45 pub(super) fn open_new_post(&mut self, window: &mut Window, cx: &mut Context<Self>) {
51 pub(super) fn open_new_post(&mut self, window: &mut Window, cx: &mut Context<Self>) {
46 self.mark_new_post_open(cx);
52 self.mark_new_post_open(cx);
47 self.composer
53 self.composer
crates/app/src/views/shell.rs +3 −0
@@ -339,6 +339,9 @@ impl AppShell {
339 339 }
340 340 cx.notify();
341 341 }
342 SidebarEvent::NewChannelPost => this
343 .conversation
344 .update(cx, |conversation, cx| conversation.start_channel_post(window, cx)),
342 345 }
343 346 });
344 347 let calendar = cx.new(|cx| CalendarView::new(state.clone(), cx));
@@ -339,6 +339,9 @@ impl AppShell {
339 }
339 }
340 cx.notify();
340 cx.notify();
341 }
341 }
342 SidebarEvent::NewChannelPost => this
343 .conversation
344 .update(cx, |conversation, cx| conversation.start_channel_post(window, cx)),
342 }
345 }
343 });
346 });
344 let calendar = cx.new(|cx| CalendarView::new(state.clone(), cx));
347 let calendar = cx.new(|cx| CalendarView::new(state.clone(), cx));
crates/app/src/views/sidebar.rs +1 −0
@@ -334,6 +334,7 @@ fn confirm_delete_section(
334 334 pub enum SidebarEvent {
335 335 RestoreFocus,
336 336 TabChanged,
337 NewChannelPost,
337 338 }
338 339
339 340 impl EventEmitter<SidebarEvent> for SidebarView {}
@@ -334,6 +334,7 @@ fn confirm_delete_section(
334pub enum SidebarEvent {
334pub enum SidebarEvent {
335 RestoreFocus,
335 RestoreFocus,
336 TabChanged,
336 TabChanged,
337 NewChannelPost,
337}
338}
338
339
339impl EventEmitter<SidebarEvent> for SidebarView {}
340impl EventEmitter<SidebarEvent> for SidebarView {}
crates/app/src/views/sidebar/channel_filter_bar.rs +14 −1
@@ -16,6 +16,7 @@ use crate::views::widgets::{icon, menu_icon};
16 16
17 17 pub const CHANNEL_FILTER_TAG: &str = "shell/islands/sidebar/channel-filter";
18 18 const NEW_CHANNEL_LABEL: &str = "New channel";
19 const NEW_MESSAGE_LABEL: &str = "New message";
19 20 const INPUT_HEIGHT: f32 = 32.;
20 21 const PILL_HEIGHT: f32 = 24.;
21 22 const SIDE_INSET: f32 = 16.;
@@ -83,7 +84,9 @@ impl SidebarView {
83 84
84 85 pub(super) fn new_channel_items_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
85 86 let state = self.state.clone();
87 let sidebar = cx.entity().downgrade();
86 88 let app = self.state.read(cx);
89 let channel_selected = matches!(app.selection, Some(Selection::Channel(_)));
87 90 let team_id = match &app.selection {
88 91 Some(Selection::Channel(channel_id)) => app
89 92 .sidebar
@@ -101,8 +104,18 @@ impl SidebarView {
101 104 .rounded(px(8.))
102 105 .tooltip("New items")
103 106 .dropdown_menu(move |menu, _, _| {
104 let (state, team_id) = (state.clone(), team_id.clone());
107 let (state, team_id, sidebar) = (state.clone(), team_id.clone(), sidebar.clone());
105 108 menu.item(
109 PopupMenuItem::new(NEW_MESSAGE_LABEL)
110 .icon(menu_icon(IconName::MessageSquare))
111 .disabled(!channel_selected)
112 .on_click(move |_, _, cx| {
113 sidebar
114 .update(cx, |_, cx| cx.emit(SidebarEvent::NewChannelPost))
115 .ok();
116 }),
117 )
118 .item(
106 119 PopupMenuItem::new(NEW_CHANNEL_LABEL)
107 120 .icon(menu_icon(IconName::Hash))
108 121 .disabled(team_id.is_none())
@@ -16,6 +16,7 @@ use crate::views::widgets::{icon, menu_icon};
16
16
17pub const CHANNEL_FILTER_TAG: &str = "shell/islands/sidebar/channel-filter";
17pub const CHANNEL_FILTER_TAG: &str = "shell/islands/sidebar/channel-filter";
18const NEW_CHANNEL_LABEL: &str = "New channel";
18const NEW_CHANNEL_LABEL: &str = "New channel";
19const NEW_MESSAGE_LABEL: &str = "New message";
19const INPUT_HEIGHT: f32 = 32.;
20const INPUT_HEIGHT: f32 = 32.;
20const PILL_HEIGHT: f32 = 24.;
21const PILL_HEIGHT: f32 = 24.;
21const SIDE_INSET: f32 = 16.;
22const SIDE_INSET: f32 = 16.;
@@ -83,7 +84,9 @@ impl SidebarView {
83
84
84 pub(super) fn new_channel_items_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
85 pub(super) fn new_channel_items_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
85 let state = self.state.clone();
86 let state = self.state.clone();
87 let sidebar = cx.entity().downgrade();
86 let app = self.state.read(cx);
88 let app = self.state.read(cx);
89 let channel_selected = matches!(app.selection, Some(Selection::Channel(_)));
87 let team_id = match &app.selection {
90 let team_id = match &app.selection {
88 Some(Selection::Channel(channel_id)) => app
91 Some(Selection::Channel(channel_id)) => app
89 .sidebar
92 .sidebar
@@ -101,8 +104,18 @@ impl SidebarView {
101 .rounded(px(8.))
104 .rounded(px(8.))
102 .tooltip("New items")
105 .tooltip("New items")
103 .dropdown_menu(move |menu, _, _| {
106 .dropdown_menu(move |menu, _, _| {
104 let (state, team_id) = (state.clone(), team_id.clone());
107 let (state, team_id, sidebar) = (state.clone(), team_id.clone(), sidebar.clone());
105 menu.item(
108 menu.item(
109 PopupMenuItem::new(NEW_MESSAGE_LABEL)
110 .icon(menu_icon(IconName::MessageSquare))
111 .disabled(!channel_selected)
112 .on_click(move |_, _, cx| {
113 sidebar
114 .update(cx, |_, cx| cx.emit(SidebarEvent::NewChannelPost))
115 .ok();
116 }),
117 )
118 .item(
106 PopupMenuItem::new(NEW_CHANNEL_LABEL)
119 PopupMenuItem::new(NEW_CHANNEL_LABEL)
107 .icon(menu_icon(IconName::Hash))
120 .icon(menu_icon(IconName::Hash))
108 .disabled(team_id.is_none())
121 .disabled(team_id.is_none())