feat(parity): composer, menus and reply box like Teams
- composer: "Type a message", paper-plane send after a divider, "+" menu (schedule message, delivery options, schedule meeting with the chat members) replaces the "!" button - message "..." menu in Teams order and labels, Translation submenu, quote reply only in the hover bar - chat rows: "..." on hover instead of the time; row menu in Teams order with Copy link - chat list "...": Mark all as read, Collapse all sections - channel reply box with own avatar, no Cancel button (Esc closes) - activity headlines wrap to two lines for every kind, not only apps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -8,7 +8,7 @@ macro_rules! symbols {
8
8
};
9
9
}
10
10
11
const SYMBOLS: [(&str, &[u8]); 79] = symbols![
11
const SYMBOLS: [(&str, &[u8]); 82] = symbols![
12
12
"campaign",
13
13
"lock",
14
14
"bot",
@@ -88,6 +88,9 @@ const SYMBOLS: [(&str, &[u8]); 79] = symbols![
88
88
"fluent_code_block",
89
89
"fluent_text_header_1",
90
90
"fluent_text_font_size",
91
"fluent_send",
92
"fluent_add",
93
"fluent_calendar_add",
91
94
];
92
95
93
96
pub struct AppAssets;
@@ -8,7 +8,7 @@ macro_rules! symbols {8
};8
};9
}9
}10
10
11
const SYMBOLS: [(&str, &[u8]); 79] = symbols![11
const SYMBOLS: [(&str, &[u8]); 82] = symbols![12
"campaign",12
"campaign",13
"lock",13
"lock",14
"bot",14
"bot",@@ -88,6 +88,9 @@ const SYMBOLS: [(&str, &[u8]); 79] = symbols![88
"fluent_code_block",88
"fluent_code_block",89
"fluent_text_header_1",89
"fluent_text_header_1",90
"fluent_text_font_size",90
"fluent_text_font_size",91
"fluent_send",92
"fluent_add",93
"fluent_calendar_add",91
];94
];92
95
93
pub struct AppAssets;96
pub struct AppAssets;@@ -212,22 +212,6 @@ pub fn chat_title(chat: &ChatRecord) -> String {
212
212
chat.display_title()
213
213
}
214
214
215
pub fn composer_name(sidebar: &Sidebar, selection: &Selection) -> String {
216
let unnamed_group = match selection {
217
Selection::Chat(id) => sidebar.chats.iter().any(|chat| {
218
&chat.id == id
219
&& chat.title.trim().is_empty()
220
&& !chat.kind.eq_ignore_ascii_case("oneOnOne")
221
}),
222
Selection::Channel(_) => false,
223
};
224
if unnamed_group {
225
String::new()
226
} else {
227
selection_title(sidebar, selection)
228
}
229
}
230
231
215
pub fn selection_title(sidebar: &Sidebar, selection: &Selection) -> String {
232
216
match selection {
233
217
Selection::Chat(id) => sidebar
@@ -419,6 +403,37 @@ impl AppState {
419
403
cx.notify();
420
404
}
421
405
406
pub fn collapse_sections(&mut self, section_ids: &[String], cx: &mut Context<Self>) {
407
let newly_collapsed: Vec<String> = section_ids
408
.iter()
409
.filter(|id| !data::is_pending_folder(id) && !self.collapsed.contains(*id))
410
.cloned()
411
.collect();
412
if newly_collapsed.is_empty() {
413
return;
414
}
415
for id in &newly_collapsed {
416
self.collapsed.insert(id.clone());
417
self.sync_folder_expanded(id, false);
418
}
419
self.save_collapsed();
420
cx.emit(AppEvent::Sidebar);
421
cx.notify();
422
}
423
424
pub fn mark_all_chats_read(&mut self, cx: &mut Context<Self>) {
425
let unread: Vec<String> = self
426
.sidebar
427
.chats
428
.iter()
429
.filter(|chat| chat.unread)
430
.map(|chat| chat.id.clone())
431
.collect();
432
for conversation_id in unread {
433
self.mark_chat_read(&conversation_id, cx);
434
}
435
}
436
422
437
pub fn older_chats(&self) -> (bool, bool) {
423
438
self.engine.as_ref().map_or((false, false), |engine| {
424
439
(engine.has_older_chats(), engine.is_loading_older_chats())
@@ -212,22 +212,6 @@ pub fn chat_title(chat: &ChatRecord) -> String {212
chat.display_title()212
chat.display_title()213
}213
}214
214
215
pub fn composer_name(sidebar: &Sidebar, selection: &Selection) -> String {216
let unnamed_group = match selection {217
Selection::Chat(id) => sidebar.chats.iter().any(|chat| {218
&chat.id == id219
&& chat.title.trim().is_empty()220
&& !chat.kind.eq_ignore_ascii_case("oneOnOne")221
}),222
Selection::Channel(_) => false,223
};224
if unnamed_group {225
String::new()226
} else {227
selection_title(sidebar, selection)228
}229
}230
231
pub fn selection_title(sidebar: &Sidebar, selection: &Selection) -> String {215
pub fn selection_title(sidebar: &Sidebar, selection: &Selection) -> String {232
match selection {216
match selection {233
Selection::Chat(id) => sidebar217
Selection::Chat(id) => sidebar@@ -419,6 +403,37 @@ impl AppState {419
cx.notify();403
cx.notify();420
}404
}421
405
406
pub fn collapse_sections(&mut self, section_ids: &[String], cx: &mut Context<Self>) {407
let newly_collapsed: Vec<String> = section_ids408
.iter()409
.filter(|id| !data::is_pending_folder(id) && !self.collapsed.contains(*id))410
.cloned()411
.collect();412
if newly_collapsed.is_empty() {413
return;414
}415
for id in &newly_collapsed {416
self.collapsed.insert(id.clone());417
self.sync_folder_expanded(id, false);418
}419
self.save_collapsed();420
cx.emit(AppEvent::Sidebar);421
cx.notify();422
}423
424
pub fn mark_all_chats_read(&mut self, cx: &mut Context<Self>) {425
let unread: Vec<String> = self426
.sidebar427
.chats428
.iter()429
.filter(|chat| chat.unread)430
.map(|chat| chat.id.clone())431
.collect();432
for conversation_id in unread {433
self.mark_chat_read(&conversation_id, cx);434
}435
}436
422
pub fn older_chats(&self) -> (bool, bool) {437
pub fn older_chats(&self) -> (bool, bool) {423
self.engine.as_ref().map_or((false, false), |engine| {438
self.engine.as_ref().map_or((false, false), |engine| {424
(engine.has_older_chats(), engine.is_loading_older_chats())439
(engine.has_older_chats(), engine.is_loading_older_chats())@@ -0,0 +1 @@
1
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2.5c.28 0 .5.22.5.5v6.5H17a.5.5 0 0 1 0 1h-6.5V17a.5.5 0 0 1-1 0v-6.5H3a.5.5 0 0 1 0-1h6.5V3c0-.28.22-.5.5-.5Z"/></svg>
@@ -0,0 +1 @@1
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2.5c.28 0 .5.22.5.5v6.5H17a.5.5 0 0 1 0 1h-6.5V17a.5.5 0 0 1-1 0v-6.5H3a.5.5 0 0 1 0-1h6.5V3c0-.28.22-.5.5-.5Z"/></svg>@@ -0,0 +1 @@
1
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 3A2.5 2.5 0 0 1 17 5.5v4.1c-.32-.16-.65-.3-1-.4V7H4v7.5c0 .83.67 1.5 1.5 1.5h3.7c.1.35.24.68.4 1H5.5A2.5 2.5 0 0 1 3 14.5v-9A2.5 2.5 0 0 1 5.5 3h9Zm0 1h-9C4.67 4 4 4.67 4 5.5V6h12v-.5c0-.83-.67-1.5-1.5-1.5ZM19 14.5a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm-4-2a.5.5 0 0 0-1 0V14h-1.5a.5.5 0 0 0 0 1H14v1.5a.5.5 0 0 0 1 0V15h1.5a.5.5 0 0 0 0-1H15v-1.5Z"/></svg>
@@ -0,0 +1 @@1
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 3A2.5 2.5 0 0 1 17 5.5v4.1c-.32-.16-.65-.3-1-.4V7H4v7.5c0 .83.67 1.5 1.5 1.5h3.7c.1.35.24.68.4 1H5.5A2.5 2.5 0 0 1 3 14.5v-9A2.5 2.5 0 0 1 5.5 3h9Zm0 1h-9C4.67 4 4 4.67 4 5.5V6h12v-.5c0-.83-.67-1.5-1.5-1.5ZM19 14.5a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm-4-2a.5.5 0 0 0-1 0V14h-1.5a.5.5 0 0 0 0 1H14v1.5a.5.5 0 0 0 1 0V15h1.5a.5.5 0 0 0 0-1H15v-1.5Z"/></svg>@@ -0,0 +1 @@
1
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.18 2.11a.5.5 0 0 1 .54-.06l15 7.5a.5.5 0 0 1 0 .9l-15 7.5a.5.5 0 0 1-.7-.58L3.98 10 2.02 2.63a.5.5 0 0 1 .16-.52Zm2.7 8.39-1.61 6.06L16.38 10 3.27 3.44 4.88 9.5h6.62a.5.5 0 1 1 0 1H4.88Z"/></svg>
@@ -0,0 +1 @@1
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.18 2.11a.5.5 0 0 1 .54-.06l15 7.5a.5.5 0 0 1 0 .9l-15 7.5a.5.5 0 0 1-.7-.58L3.98 10 2.02 2.63a.5.5 0 0 1 .16-.52Zm2.7 8.39-1.61 6.06L16.38 10 3.27 3.44 4.88 9.5h6.62a.5.5 0 1 1 0 1H4.88Z"/></svg>@@ -179,9 +179,10 @@ mod frames {
179
179
use crate::views::call_transcript::TranscriptPanel;
180
180
use crate::views::call_view::CHAT_PANEL_TAG;
181
181
use crate::views::composer::delivery::{
182
COMPOSER_DELIVERY_TAG, COMPOSER_IMPORTANCE_LABEL_TAG, COMPOSER_URGENT_BANNER_TAG,
182
COMPOSER_IMPORTANCE_LABEL_TAG, COMPOSER_URGENT_BANNER_TAG,
183
183
DELIVERY_MENU_TAG,
184
184
};
185
use crate::views::composer::plus_menu::{COMPOSER_PLUS_TAG, PlusAction};
185
186
use crate::views::composer::{
186
187
COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,
187
188
COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG,
@@ -2452,7 +2453,7 @@ mod frames {
2452
2453
const DELIVERY_TAGS: [&str; 5] = [
2453
2454
COMPOSER_BOX_TAG,
2454
2455
COMPOSER_ACTIONS_TAG,
2455
COMPOSER_DELIVERY_TAG,
2456
COMPOSER_PLUS_TAG,
2456
2457
COMPOSER_IMPORTANCE_LABEL_TAG,
2457
2458
COMPOSER_URGENT_BANNER_TAG,
2458
2459
];
@@ -2466,11 +2467,13 @@ mod frames {
2466
2467
origin: point(px(0.), px(0.)),
2467
2468
size: size(px(width), px(height)),
2468
2469
};
2469
collect(&mut visual, Some(COMPOSER_DELIVERY_TAG));
2470
let button = visual
2471
.debug_bounds(COMPOSER_DELIVERY_TAG)
2472
.expect("delivery button");
2470
collect(&mut visual, Some(COMPOSER_PLUS_TAG));
2471
let button = visual.debug_bounds(COMPOSER_PLUS_TAG).expect("plus button");
2473
2472
visual.simulate_click(button.center(), Default::default());
2473
let delivery_tag = PlusAction::DeliveryOptions.tag();
2474
collect(&mut visual, Some(delivery_tag));
2475
let delivery = visual.debug_bounds(delivery_tag).expect("delivery item");
2476
visual.simulate_click(delivery.center(), Default::default());
2474
2477
collect(&mut visual, Some(URGENT_OPTION));
2475
2478
let menu = visual.debug_bounds(DELIVERY_MENU_TAG).expect("menu");
2476
2479
assert!(
@@ -179,9 +179,10 @@ mod frames {179
use crate::views::call_transcript::TranscriptPanel;179
use crate::views::call_transcript::TranscriptPanel;180
use crate::views::call_view::CHAT_PANEL_TAG;180
use crate::views::call_view::CHAT_PANEL_TAG;181
use crate::views::composer::delivery::{181
use crate::views::composer::delivery::{182
COMPOSER_DELIVERY_TAG, COMPOSER_IMPORTANCE_LABEL_TAG, COMPOSER_URGENT_BANNER_TAG,182
COMPOSER_IMPORTANCE_LABEL_TAG, COMPOSER_URGENT_BANNER_TAG,183
DELIVERY_MENU_TAG,183
DELIVERY_MENU_TAG,184
};184
};185
use crate::views::composer::plus_menu::{COMPOSER_PLUS_TAG, PlusAction};185
use crate::views::composer::{186
use crate::views::composer::{186
COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,187
COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,187
COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG,188
COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG,@@ -2452,7 +2453,7 @@ mod frames {2452
const DELIVERY_TAGS: [&str; 5] = [2453
const DELIVERY_TAGS: [&str; 5] = [2453
COMPOSER_BOX_TAG,2454
COMPOSER_BOX_TAG,2454
COMPOSER_ACTIONS_TAG,2455
COMPOSER_ACTIONS_TAG,2455
COMPOSER_DELIVERY_TAG,2456
COMPOSER_PLUS_TAG,2456
COMPOSER_IMPORTANCE_LABEL_TAG,2457
COMPOSER_IMPORTANCE_LABEL_TAG,2457
COMPOSER_URGENT_BANNER_TAG,2458
COMPOSER_URGENT_BANNER_TAG,2458
];2459
];@@ -2466,11 +2467,13 @@ mod frames {2466
origin: point(px(0.), px(0.)),2467
origin: point(px(0.), px(0.)),2467
size: size(px(width), px(height)),2468
size: size(px(width), px(height)),2468
};2469
};2469
collect(&mut visual, Some(COMPOSER_DELIVERY_TAG));2470
collect(&mut visual, Some(COMPOSER_PLUS_TAG));2470
let button = visual2471
let button = visual.debug_bounds(COMPOSER_PLUS_TAG).expect("plus button");2471
.debug_bounds(COMPOSER_DELIVERY_TAG)2472
.expect("delivery button");2473
visual.simulate_click(button.center(), Default::default());2472
visual.simulate_click(button.center(), Default::default());2473
let delivery_tag = PlusAction::DeliveryOptions.tag();2474
collect(&mut visual, Some(delivery_tag));2475
let delivery = visual.debug_bounds(delivery_tag).expect("delivery item");2476
visual.simulate_click(delivery.center(), Default::default());2474
collect(&mut visual, Some(URGENT_OPTION));2477
collect(&mut visual, Some(URGENT_OPTION));2475
let menu = visual.debug_bounds(DELIVERY_MENU_TAG).expect("menu");2478
let menu = visual.debug_bounds(DELIVERY_MENU_TAG).expect("menu");2476
assert!(2479
assert!(@@ -731,17 +731,15 @@ fn recap_tile() -> Div {
731
731
.child(symbol("recap", RECAP_GLYPH_SIZE, theme::white()))
732
732
}
733
733
734
fn headline_wraps(entry: &Entry, text_width: f32, window: &mut Window) -> bool {
735
let Some(title) = entry.title.as_deref().filter(|_| entry.kind == Kind::App) else {
736
return false;
737
};
734
fn headline_wraps(headline: String, text_width: f32, window: &mut Window) -> bool {
738
735
if text_width <= 0. {
739
736
return false;
740
737
}
741
let run = window.text_style().to_run(title.len());
738
let mut run = window.text_style().to_run(headline.len());
739
run.font.weight = FontWeight::SEMIBOLD;
742
740
let width = window
743
741
.text_system()
744
.shape_line(title.to_owned().into(), px(13.), &[run], None)
742
.shape_line(headline.into(), px(13.), &[run], None)
745
743
.width;
746
744
f32::from(width) > text_width
747
745
}
@@ -833,7 +831,8 @@ impl Render for ActivityPanel {
833
831
for section in §ions {
834
832
slots.push(Slot::Header(section.bucket.label()));
835
833
slots.extend(section.entries.iter().map(|entry| {
836
let wraps = headline_wraps(entry, text_width, window);
834
let text = headline(entry, &state.sidebar, &self.resolved_names);
835
let wraps = headline_wraps(text, text_width, window);
837
836
Slot::Row(entry, RowText::new(entry, &state.sidebar, wraps))
838
837
}));
839
838
}
@@ -731,17 +731,15 @@ fn recap_tile() -> Div {731
.child(symbol("recap", RECAP_GLYPH_SIZE, theme::white()))731
.child(symbol("recap", RECAP_GLYPH_SIZE, theme::white()))732
}732
}733
733
734
fn headline_wraps(entry: &Entry, text_width: f32, window: &mut Window) -> bool {734
fn headline_wraps(headline: String, text_width: f32, window: &mut Window) -> bool {735
let Some(title) = entry.title.as_deref().filter(|_| entry.kind == Kind::App) else {736
return false;737
};738
if text_width <= 0. {735
if text_width <= 0. {739
return false;736
return false;740
}737
}741
let run = window.text_style().to_run(title.len());738
let mut run = window.text_style().to_run(headline.len());739
run.font.weight = FontWeight::SEMIBOLD;742
let width = window740
let width = window743
.text_system()741
.text_system()744
.shape_line(title.to_owned().into(), px(13.), &[run], None)742
.shape_line(headline.into(), px(13.), &[run], None)745
.width;743
.width;746
f32::from(width) > text_width744
f32::from(width) > text_width747
}745
}@@ -833,7 +831,8 @@ impl Render for ActivityPanel {833
for section in §ions {831
for section in §ions {834
slots.push(Slot::Header(section.bucket.label()));832
slots.push(Slot::Header(section.bucket.label()));835
slots.extend(section.entries.iter().map(|entry| {833
slots.extend(section.entries.iter().map(|entry| {836
let wraps = headline_wraps(entry, text_width, window);834
let text = headline(entry, &state.sidebar, &self.resolved_names);835
let wraps = headline_wraps(text, text_width, window);837
Slot::Row(entry, RowText::new(entry, &state.sidebar, wraps))836
Slot::Row(entry, RowText::new(entry, &state.sidebar, wraps))838
}));837
}));839
}838
}@@ -33,6 +33,7 @@ use teams_core::{
33
33
pub(crate) mod delivery;
34
34
mod drafts;
35
35
mod format_menus;
36
pub(crate) mod plus_menu;
36
37
mod post;
37
38
pub use post::{
38
39
POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG, POST_AUDIENCE_TAG, POST_CARD_DIVIDER_TAG,
@@ -88,6 +89,8 @@ const MENTION_QUERY_MAX_WORDS: usize = 3;
88
89
const POPUP_WIDTH: f32 = 380.;
89
90
const POPUP_ROW_HEIGHT: f32 = 44.;
90
91
const DEMO_UPLOAD_STEPS: u8 = 10;
92
const COMPOSER_PLACEHOLDER: &str = "Type a message";
93
const SEND_DIVIDER_HEIGHT: f32 = 20.;
91
94
const COMPOSER_ICON_SIZE: f32 = 20.;
92
95
const COMPOSER_BUTTON_SIZE: f32 = 32.;
93
96
const COMPOSER_BUTTON_INSET: f32 = 6.;
@@ -256,6 +259,7 @@ pub struct Composer {
256
259
caret_text: String,
257
260
importance: store::MessageImportance,
258
261
delivery_menu: bool,
262
plus_menu: bool,
259
263
_subscriptions: [Subscription; 4],
260
264
}
261
265
@@ -527,6 +531,7 @@ impl Composer {
527
531
caret_text: String::new(),
528
532
importance: store::MessageImportance::Normal,
529
533
delivery_menu: false,
534
plus_menu: false,
530
535
_subscriptions: [subscription, observer, image_observer, picker_subscription],
531
536
}
532
537
}
@@ -1759,16 +1764,10 @@ impl Composer {
1759
1764
pub fn set_conversation(
1760
1765
&mut self,
1761
1766
conversation_id: &str,
1762
name: &str,
1763
1767
window: &mut Window,
1764
1768
cx: &mut Context<Self>,
1765
1769
) {
1766
let placeholder = if name.is_empty() {
1767
"Type a message".to_owned()
1768
} else {
1769
format!("Message {name}")
1770
};
1771
self.set_placeholder(&placeholder, window, cx);
1770
self.set_placeholder(COMPOSER_PLACEHOLDER, window, cx);
1772
1771
if self.conversation_id.as_deref() != Some(conversation_id) {
1773
1772
self.save_draft_now(cx);
1774
1773
self.draft_save = None;
@@ -2891,7 +2890,7 @@ impl Render for Composer {
2891
2890
.items_center()
2892
2891
.justify_center()
2893
2892
.rounded(px(8.))
2894
.child(symbol("keyboard_return", 20., theme::text()))
2893
.child(symbol("fluent_send", COMPOSER_ICON_SIZE, theme::text()))
2895
2894
.on_mouse_down(
2896
2895
MouseButton::Right,
2897
2896
cx.listener(|this, _, _, cx| this.open_schedule_menu(cx)),
@@ -2993,9 +2992,9 @@ impl Render for Composer {
2993
2992
.flex_none()
2994
2993
.gap(px(COMPOSER_BUTTON_INSET))
2995
2994
.children(format_toggle)
2996
.children(self.render_delivery_button(cx))
2997
2995
.children(fun)
2998
.children(attach);
2996
.children(attach)
2997
.children(self.render_plus_button(cx));
2999
2998
let (row_actions, post_footer) = if post_layout {
3000
2999
(None, Some(self.render_post_footer(actions, can_send, cx)))
3001
3000
} else {
@@ -3413,6 +3412,7 @@ impl Render for Composer {
3413
3412
.children(self.render_toolbar(focused, cx))
3414
3413
.children(self.render_schedule(cx))
3415
3414
.children(self.render_delivery_menu(cx))
3415
.children(self.render_plus_menu(cx))
3416
3416
.child(
3417
3417
v_flex()
3418
3418
.debug_selector(|| COMPOSER_BOX_TAG.into())
@@ -3485,7 +3485,17 @@ impl Render for Composer {
3485
3485
.child(input),
3486
3486
)
3487
3487
.children(row_actions)
3488
.when(!post_layout, |row| row.child(send)),
3488
.when(!post_layout, |row| {
3489
row.child(
3490
div()
3491
.flex_none()
3492
.w(px(1.))
3493
.h(px(SEND_DIVIDER_HEIGHT))
3494
.ml(px(COMPOSER_BUTTON_INSET))
3495
.bg(theme::border()),
3496
)
3497
.child(send)
3498
}),
3489
3499
)
3490
3500
.children(post_footer),
3491
3501
),
@@ -4864,7 +4874,7 @@ mod tests {
4864
4874
let composer = composer.clone();
4865
4875
typist.act(|window, cx| {
4866
4876
composer.update(cx, |composer, cx| {
4867
composer.set_conversation(id, "", window, cx);
4877
composer.set_conversation(id, window, cx);
4868
4878
composer.focus(window, cx);
4869
4879
})
4870
4880
});
@@ -5061,7 +5071,7 @@ mod tests {
5061
5071
std::fs::write(&path, b"%PDF-1.7").unwrap();
5062
5072
cx.update_window(handle, |_, window, cx| {
5063
5073
composer.update(cx, |composer, cx| {
5064
composer.set_conversation("demo-chat", "Demo", window, cx);
5074
composer.set_conversation("demo-chat", window, cx);
5065
5075
composer.add_paths(vec![path], window, cx);
5066
5076
});
5067
5077
})
@@ -5108,7 +5118,7 @@ mod tests {
5108
5118
std::fs::write(&path, b"%PDF-1.7").unwrap();
5109
5119
cx.update_window(handle, |_, window, cx| {
5110
5120
composer.update(cx, |composer, cx| {
5111
composer.set_conversation("demo-chat", "Demo", window, cx);
5121
composer.set_conversation("demo-chat", window, cx);
5112
5122
composer.add_paths(vec![path], window, cx);
5113
5123
});
5114
5124
})
@@ -5116,7 +5126,7 @@ mod tests {
5116
5126
cx.run_until_parked();
5117
5127
cx.update_window(handle, |_, window, cx| {
5118
5128
composer.update(cx, |composer, cx| {
5119
composer.set_conversation("other-chat", "Other", window, cx)
5129
composer.set_conversation("other-chat", window, cx)
5120
5130
});
5121
5131
})
5122
5132
.unwrap();
@@ -5159,7 +5169,7 @@ mod tests {
5159
5169
std::fs::write(&path, b"%PDF-1.7").unwrap();
5160
5170
cx.update_window(handle, |_, window, cx| {
5161
5171
composer.update(cx, |composer, cx| {
5162
composer.set_conversation("demo-chat", "Demo", window, cx);
5172
composer.set_conversation("demo-chat", window, cx);
5163
5173
composer.add_paths(vec![path], window, cx);
5164
5174
});
5165
5175
})
@@ -5220,7 +5230,7 @@ mod tests {
5220
5230
] {
5221
5231
cx.update_window(handle, |_, window, cx| {
5222
5232
composer.update(cx, |composer, cx| {
5223
composer.set_conversation("", "", window, cx);
5233
composer.set_conversation("", window, cx);
5224
5234
composer.add_paths(vec![path.clone()], window, cx);
5225
5235
});
5226
5236
})
@@ -5231,7 +5241,7 @@ mod tests {
5231
5241
if let Some(chat) = carry {
5232
5242
composer.carry_images_into(chat.to_owned());
5233
5243
}
5234
composer.set_conversation(chosen, "Chat", window, cx);
5244
composer.set_conversation(chosen, window, cx);
5235
5245
});
5236
5246
})
5237
5247
.unwrap();
@@ -5244,9 +5254,9 @@ mod tests {
5244
5254
let (handle, composer) = demo_composer(cx);
5245
5255
cx.update_window(handle, |_, window, cx| {
5246
5256
composer.update(cx, |composer, cx| {
5247
composer.set_conversation("chat-a", "A", window, cx);
5257
composer.set_conversation("chat-a", window, cx);
5248
5258
composer.set_text("**hello** there", window, cx);
5249
composer.set_conversation("chat-b", "B", window, cx);
5259
composer.set_conversation("chat-b", window, cx);
5250
5260
});
5251
5261
})
5252
5262
.unwrap();
@@ -5265,7 +5275,7 @@ mod tests {
5265
5275
cx.update_window(handle, |_, window, cx| {
5266
5276
composer.update(cx, |composer, cx| {
5267
5277
composer.set_text("other", window, cx);
5268
composer.set_conversation("chat-a", "A", window, cx);
5278
composer.set_conversation("chat-a", window, cx);
5269
5279
});
5270
5280
})
5271
5281
.unwrap();
@@ -5307,15 +5317,15 @@ mod tests {
5307
5317
let subject = cx.new(|cx| InputState::new(window, cx));
5308
5318
subject.update(cx, |input, cx| input.set_value("Code freeze", window, cx));
5309
5319
composer.update(cx, |composer, cx| {
5310
composer.set_conversation("channel-a", "A", window, cx);
5320
composer.set_conversation("channel-a", window, cx);
5311
5321
composer.set_post_layout(Some(subject), cx);
5312
5322
composer.toggle_announcement(window, cx);
5313
5323
let headline = composer.announcement.as_ref().unwrap().headline.clone();
5314
5324
headline.update(cx, |input, cx| input.set_value("Release 43", window, cx));
5315
5325
composer.leave_conversation("channel-b", cx);
5316
5326
composer.set_post_layout(None, cx);
5317
composer.set_conversation("channel-b", "B", window, cx);
5318
composer.set_conversation("channel-a", "A", window, cx);
5327
composer.set_conversation("channel-b", window, cx);
5328
composer.set_conversation("channel-a", window, cx);
5319
5329
});
5320
5330
})
5321
5331
.unwrap();
@@ -5335,7 +5345,7 @@ mod tests {
5335
5345
let (handle, composer) = demo_composer(cx);
5336
5346
cx.update_window(handle, |_, window, cx| {
5337
5347
composer.update(cx, |composer, cx| {
5338
composer.set_conversation("chat-a", "A", window, cx);
5348
composer.set_conversation("chat-a", window, cx);
5339
5349
composer.set_text("hi", window, cx);
5340
5350
composer.save_draft_now(cx);
5341
5351
});
@@ -5382,7 +5392,7 @@ mod tests {
5382
5392
std::fs::write(&pdf, b"%PDF-1.7").unwrap();
5383
5393
cx.update_window(handle, |_, window, cx| {
5384
5394
composer.update(cx, |composer, cx| {
5385
composer.set_conversation("bob-chat", "Bob", window, cx);
5395
composer.set_conversation("bob-chat", window, cx);
5386
5396
composer.add_paths(vec![png, pdf], window, cx);
5387
5397
});
5388
5398
})
@@ -5392,7 +5402,7 @@ mod tests {
5392
5402
cx.update_window(handle, |_, window, cx| {
5393
5403
composer.update(cx, |composer, cx| {
5394
5404
composer.carry_images_into(String::new());
5395
composer.set_conversation("", "", window, cx);
5405
composer.set_conversation("", window, cx);
5396
5406
});
5397
5407
})
5398
5408
.unwrap();
@@ -33,6 +33,7 @@ use teams_core::{33
pub(crate) mod delivery;33
pub(crate) mod delivery;34
mod drafts;34
mod drafts;35
mod format_menus;35
mod format_menus;36
pub(crate) mod plus_menu;36
mod post;37
mod post;37
pub use post::{38
pub use post::{38
POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG, POST_AUDIENCE_TAG, POST_CARD_DIVIDER_TAG,39
POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG, POST_AUDIENCE_TAG, POST_CARD_DIVIDER_TAG,@@ -88,6 +89,8 @@ const MENTION_QUERY_MAX_WORDS: usize = 3;88
const POPUP_WIDTH: f32 = 380.;89
const POPUP_WIDTH: f32 = 380.;89
const POPUP_ROW_HEIGHT: f32 = 44.;90
const POPUP_ROW_HEIGHT: f32 = 44.;90
const DEMO_UPLOAD_STEPS: u8 = 10;91
const DEMO_UPLOAD_STEPS: u8 = 10;92
const COMPOSER_PLACEHOLDER: &str = "Type a message";93
const SEND_DIVIDER_HEIGHT: f32 = 20.;91
const COMPOSER_ICON_SIZE: f32 = 20.;94
const COMPOSER_ICON_SIZE: f32 = 20.;92
const COMPOSER_BUTTON_SIZE: f32 = 32.;95
const COMPOSER_BUTTON_SIZE: f32 = 32.;93
const COMPOSER_BUTTON_INSET: f32 = 6.;96
const COMPOSER_BUTTON_INSET: f32 = 6.;@@ -256,6 +259,7 @@ pub struct Composer {256
caret_text: String,259
caret_text: String,257
importance: store::MessageImportance,260
importance: store::MessageImportance,258
delivery_menu: bool,261
delivery_menu: bool,262
plus_menu: bool,259
_subscriptions: [Subscription; 4],263
_subscriptions: [Subscription; 4],260
}264
}261
265
@@ -527,6 +531,7 @@ impl Composer {527
caret_text: String::new(),531
caret_text: String::new(),528
importance: store::MessageImportance::Normal,532
importance: store::MessageImportance::Normal,529
delivery_menu: false,533
delivery_menu: false,534
plus_menu: false,530
_subscriptions: [subscription, observer, image_observer, picker_subscription],535
_subscriptions: [subscription, observer, image_observer, picker_subscription],531
}536
}532
}537
}@@ -1759,16 +1764,10 @@ impl Composer {1759
pub fn set_conversation(1764
pub fn set_conversation(1760
&mut self,1765
&mut self,1761
conversation_id: &str,1766
conversation_id: &str,1762
name: &str,1763
window: &mut Window,1767
window: &mut Window,1764
cx: &mut Context<Self>,1768
cx: &mut Context<Self>,1765
) {1769
) {1766
let placeholder = if name.is_empty() {1770
self.set_placeholder(COMPOSER_PLACEHOLDER, window, cx);1767
"Type a message".to_owned()1768
} else {1769
format!("Message {name}")1770
};1771
self.set_placeholder(&placeholder, window, cx);1772
if self.conversation_id.as_deref() != Some(conversation_id) {1771
if self.conversation_id.as_deref() != Some(conversation_id) {1773
self.save_draft_now(cx);1772
self.save_draft_now(cx);1774
self.draft_save = None;1773
self.draft_save = None;@@ -2891,7 +2890,7 @@ impl Render for Composer {2891
.items_center()2890
.items_center()2892
.justify_center()2891
.justify_center()2893
.rounded(px(8.))2892
.rounded(px(8.))2894
.child(symbol("keyboard_return", 20., theme::text()))2893
.child(symbol("fluent_send", COMPOSER_ICON_SIZE, theme::text()))2895
.on_mouse_down(2894
.on_mouse_down(2896
MouseButton::Right,2895
MouseButton::Right,2897
cx.listener(|this, _, _, cx| this.open_schedule_menu(cx)),2896
cx.listener(|this, _, _, cx| this.open_schedule_menu(cx)),@@ -2993,9 +2992,9 @@ impl Render for Composer {2993
.flex_none()2992
.flex_none()2994
.gap(px(COMPOSER_BUTTON_INSET))2993
.gap(px(COMPOSER_BUTTON_INSET))2995
.children(format_toggle)2994
.children(format_toggle)2996
.children(self.render_delivery_button(cx))2997
.children(fun)2995
.children(fun)2998
.children(attach);2996
.children(attach)2997
.children(self.render_plus_button(cx));2999
let (row_actions, post_footer) = if post_layout {2998
let (row_actions, post_footer) = if post_layout {3000
(None, Some(self.render_post_footer(actions, can_send, cx)))2999
(None, Some(self.render_post_footer(actions, can_send, cx)))3001
} else {3000
} else {@@ -3413,6 +3412,7 @@ impl Render for Composer {3413
.children(self.render_toolbar(focused, cx))3412
.children(self.render_toolbar(focused, cx))3414
.children(self.render_schedule(cx))3413
.children(self.render_schedule(cx))3415
.children(self.render_delivery_menu(cx))3414
.children(self.render_delivery_menu(cx))3415
.children(self.render_plus_menu(cx))3416
.child(3416
.child(3417
v_flex()3417
v_flex()3418
.debug_selector(|| COMPOSER_BOX_TAG.into())3418
.debug_selector(|| COMPOSER_BOX_TAG.into())@@ -3485,7 +3485,17 @@ impl Render for Composer {3485
.child(input),3485
.child(input),3486
)3486
)3487
.children(row_actions)3487
.children(row_actions)3488
.when(!post_layout, |row| row.child(send)),3488
.when(!post_layout, |row| {3489
row.child(3490
div()3491
.flex_none()3492
.w(px(1.))3493
.h(px(SEND_DIVIDER_HEIGHT))3494
.ml(px(COMPOSER_BUTTON_INSET))3495
.bg(theme::border()),3496
)3497
.child(send)3498
}),3489
)3499
)3490
.children(post_footer),3500
.children(post_footer),3491
),3501
),@@ -4864,7 +4874,7 @@ mod tests {4864
let composer = composer.clone();4874
let composer = composer.clone();4865
typist.act(|window, cx| {4875
typist.act(|window, cx| {4866
composer.update(cx, |composer, cx| {4876
composer.update(cx, |composer, cx| {4867
composer.set_conversation(id, "", window, cx);4877
composer.set_conversation(id, window, cx);4868
composer.focus(window, cx);4878
composer.focus(window, cx);4869
})4879
})4870
});4880
});@@ -5061,7 +5071,7 @@ mod tests {5061
std::fs::write(&path, b"%PDF-1.7").unwrap();5071
std::fs::write(&path, b"%PDF-1.7").unwrap();5062
cx.update_window(handle, |_, window, cx| {5072
cx.update_window(handle, |_, window, cx| {5063
composer.update(cx, |composer, cx| {5073
composer.update(cx, |composer, cx| {5064
composer.set_conversation("demo-chat", "Demo", window, cx);5074
composer.set_conversation("demo-chat", window, cx);5065
composer.add_paths(vec![path], window, cx);5075
composer.add_paths(vec![path], window, cx);5066
});5076
});5067
})5077
})@@ -5108,7 +5118,7 @@ mod tests {5108
std::fs::write(&path, b"%PDF-1.7").unwrap();5118
std::fs::write(&path, b"%PDF-1.7").unwrap();5109
cx.update_window(handle, |_, window, cx| {5119
cx.update_window(handle, |_, window, cx| {5110
composer.update(cx, |composer, cx| {5120
composer.update(cx, |composer, cx| {5111
composer.set_conversation("demo-chat", "Demo", window, cx);5121
composer.set_conversation("demo-chat", window, cx);5112
composer.add_paths(vec![path], window, cx);5122
composer.add_paths(vec![path], window, cx);5113
});5123
});5114
})5124
})@@ -5116,7 +5126,7 @@ mod tests {5116
cx.run_until_parked();5126
cx.run_until_parked();5117
cx.update_window(handle, |_, window, cx| {5127
cx.update_window(handle, |_, window, cx| {5118
composer.update(cx, |composer, cx| {5128
composer.update(cx, |composer, cx| {5119
composer.set_conversation("other-chat", "Other", window, cx)5129
composer.set_conversation("other-chat", window, cx)5120
});5130
});5121
})5131
})5122
.unwrap();5132
.unwrap();@@ -5159,7 +5169,7 @@ mod tests {5159
std::fs::write(&path, b"%PDF-1.7").unwrap();5169
std::fs::write(&path, b"%PDF-1.7").unwrap();5160
cx.update_window(handle, |_, window, cx| {5170
cx.update_window(handle, |_, window, cx| {5161
composer.update(cx, |composer, cx| {5171
composer.update(cx, |composer, cx| {5162
composer.set_conversation("demo-chat", "Demo", window, cx);5172
composer.set_conversation("demo-chat", window, cx);5163
composer.add_paths(vec![path], window, cx);5173
composer.add_paths(vec![path], window, cx);5164
});5174
});5165
})5175
})@@ -5220,7 +5230,7 @@ mod tests {5220
] {5230
] {5221
cx.update_window(handle, |_, window, cx| {5231
cx.update_window(handle, |_, window, cx| {5222
composer.update(cx, |composer, cx| {5232
composer.update(cx, |composer, cx| {5223
composer.set_conversation("", "", window, cx);5233
composer.set_conversation("", window, cx);5224
composer.add_paths(vec![path.clone()], window, cx);5234
composer.add_paths(vec![path.clone()], window, cx);5225
});5235
});5226
})5236
})@@ -5231,7 +5241,7 @@ mod tests {5231
if let Some(chat) = carry {5241
if let Some(chat) = carry {5232
composer.carry_images_into(chat.to_owned());5242
composer.carry_images_into(chat.to_owned());5233
}5243
}5234
composer.set_conversation(chosen, "Chat", window, cx);5244
composer.set_conversation(chosen, window, cx);5235
});5245
});5236
})5246
})5237
.unwrap();5247
.unwrap();@@ -5244,9 +5254,9 @@ mod tests {5244
let (handle, composer) = demo_composer(cx);5254
let (handle, composer) = demo_composer(cx);5245
cx.update_window(handle, |_, window, cx| {5255
cx.update_window(handle, |_, window, cx| {5246
composer.update(cx, |composer, cx| {5256
composer.update(cx, |composer, cx| {5247
composer.set_conversation("chat-a", "A", window, cx);5257
composer.set_conversation("chat-a", window, cx);5248
composer.set_text("**hello** there", window, cx);5258
composer.set_text("**hello** there", window, cx);5249
composer.set_conversation("chat-b", "B", window, cx);5259
composer.set_conversation("chat-b", window, cx);5250
});5260
});5251
})5261
})5252
.unwrap();5262
.unwrap();@@ -5265,7 +5275,7 @@ mod tests {5265
cx.update_window(handle, |_, window, cx| {5275
cx.update_window(handle, |_, window, cx| {5266
composer.update(cx, |composer, cx| {5276
composer.update(cx, |composer, cx| {5267
composer.set_text("other", window, cx);5277
composer.set_text("other", window, cx);5268
composer.set_conversation("chat-a", "A", window, cx);5278
composer.set_conversation("chat-a", window, cx);5269
});5279
});5270
})5280
})5271
.unwrap();5281
.unwrap();@@ -5307,15 +5317,15 @@ mod tests {5307
let subject = cx.new(|cx| InputState::new(window, cx));5317
let subject = cx.new(|cx| InputState::new(window, cx));5308
subject.update(cx, |input, cx| input.set_value("Code freeze", window, cx));5318
subject.update(cx, |input, cx| input.set_value("Code freeze", window, cx));5309
composer.update(cx, |composer, cx| {5319
composer.update(cx, |composer, cx| {5310
composer.set_conversation("channel-a", "A", window, cx);5320
composer.set_conversation("channel-a", window, cx);5311
composer.set_post_layout(Some(subject), cx);5321
composer.set_post_layout(Some(subject), cx);5312
composer.toggle_announcement(window, cx);5322
composer.toggle_announcement(window, cx);5313
let headline = composer.announcement.as_ref().unwrap().headline.clone();5323
let headline = composer.announcement.as_ref().unwrap().headline.clone();5314
headline.update(cx, |input, cx| input.set_value("Release 43", window, cx));5324
headline.update(cx, |input, cx| input.set_value("Release 43", window, cx));5315
composer.leave_conversation("channel-b", cx);5325
composer.leave_conversation("channel-b", cx);5316
composer.set_post_layout(None, cx);5326
composer.set_post_layout(None, cx);5317
composer.set_conversation("channel-b", "B", window, cx);5327
composer.set_conversation("channel-b", window, cx);5318
composer.set_conversation("channel-a", "A", window, cx);5328
composer.set_conversation("channel-a", window, cx);5319
});5329
});5320
})5330
})5321
.unwrap();5331
.unwrap();@@ -5335,7 +5345,7 @@ mod tests {5335
let (handle, composer) = demo_composer(cx);5345
let (handle, composer) = demo_composer(cx);5336
cx.update_window(handle, |_, window, cx| {5346
cx.update_window(handle, |_, window, cx| {5337
composer.update(cx, |composer, cx| {5347
composer.update(cx, |composer, cx| {5338
composer.set_conversation("chat-a", "A", window, cx);5348
composer.set_conversation("chat-a", window, cx);5339
composer.set_text("hi", window, cx);5349
composer.set_text("hi", window, cx);5340
composer.save_draft_now(cx);5350
composer.save_draft_now(cx);5341
});5351
});@@ -5382,7 +5392,7 @@ mod tests {5382
std::fs::write(&pdf, b"%PDF-1.7").unwrap();5392
std::fs::write(&pdf, b"%PDF-1.7").unwrap();5383
cx.update_window(handle, |_, window, cx| {5393
cx.update_window(handle, |_, window, cx| {5384
composer.update(cx, |composer, cx| {5394
composer.update(cx, |composer, cx| {5385
composer.set_conversation("bob-chat", "Bob", window, cx);5395
composer.set_conversation("bob-chat", window, cx);5386
composer.add_paths(vec![png, pdf], window, cx);5396
composer.add_paths(vec![png, pdf], window, cx);5387
});5397
});5388
})5398
})@@ -5392,7 +5402,7 @@ mod tests {5392
cx.update_window(handle, |_, window, cx| {5402
cx.update_window(handle, |_, window, cx| {5393
composer.update(cx, |composer, cx| {5403
composer.update(cx, |composer, cx| {5394
composer.carry_images_into(String::new());5404
composer.carry_images_into(String::new());5395
composer.set_conversation("", "", window, cx);5405
composer.set_conversation("", window, cx);5396
});5406
});5397
})5407
})5398
.unwrap();5408
.unwrap();@@ -2,22 +2,20 @@ use gpui_kit::component::fluent::{
2
2
MENU_ICON_LABEL_GAP, MENU_ICON_SLOT, MENU_ITEM_GAP, MENU_ITEM_HEIGHT, MENU_ITEM_PADDING_X,
3
3
MENU_LIST_PADDING, OPTION_CHECK_SIZE,
4
4
};
5
use gpui_kit::component::tooltip::{PopupTriggerTooltip as _, Tooltip};
5
use gpui_kit::component::tooltip::Tooltip;
6
6
use gpui_kit::component::{h_flex, v_flex};
7
use gpui_kit::prelude::FluentBuilder as _;
8
7
use gpui_kit::*;
9
8
use store::MessageImportance;
10
9
11
10
use super::{COMPOSER_BUTTON_INSET, COMPOSER_BUTTON_SIZE, COMPOSER_ICON_SIZE, Composer};
12
11
use crate::delivery_options::{
13
DELIVERY_BUTTON_TITLE, DeliveryOption, URGENT_TOO_MANY_MEMBERS, UrgentAvailability,
12
DeliveryOption, URGENT_TOO_MANY_MEMBERS, UrgentAvailability,
14
13
allowed_importance, delivery_options, urgent_banner,
15
14
};
16
15
use crate::importance::importance_label;
17
16
use crate::theme::{self, ElevatedSurface as _};
18
17
use crate::views::widgets::symbol;
19
18
20
pub const COMPOSER_DELIVERY_TAG: &str = "composer/actions/delivery";
21
19
pub const COMPOSER_IMPORTANCE_LABEL_TAG: &str = "composer/importance-label";
22
20
pub const COMPOSER_URGENT_BANNER_TAG: &str = "composer-urgent-banner";
23
21
pub const DELIVERY_MENU_TAG: &str = "delivery-menu";
@@ -66,46 +64,6 @@ impl Composer {
66
64
cx.notify();
67
65
}
68
66
69
pub(super) fn render_delivery_button(&self, cx: &mut Context<Self>) -> Option<Stateful<Div>> {
70
if self.editing.is_some() {
71
return None;
72
}
73
let open = self.delivery_menu;
74
let marked = self.importance.is_marked();
75
Some(
76
div()
77
.id("composer-delivery")
78
.debug_selector(|| COMPOSER_DELIVERY_TAG.into())
79
.size(px(COMPOSER_BUTTON_SIZE))
80
.flex_none()
81
.flex()
82
.items_center()
83
.justify_center()
84
.rounded(px(8.))
85
.cursor_pointer()
86
.when(open, |button| button.bg(theme::popup_hover()))
87
.hover(|button| button.bg(theme::popup_hover()))
88
.popup_trigger_tooltip_text(open, DELIVERY_BUTTON_TITLE)
89
.child(symbol(
90
"fluent_important",
91
COMPOSER_ICON_SIZE,
92
if marked {
93
theme::red()
94
} else {
95
theme::text_muted()
96
},
97
))
98
.on_mouse_down(MouseButton::Left, |_, window, cx| {
99
window.prevent_default();
100
cx.stop_propagation();
101
})
102
.on_click(cx.listener(|this, _, _, cx| {
103
this.delivery_menu = !this.delivery_menu;
104
cx.notify();
105
})),
106
)
107
}
108
109
67
pub(super) fn render_delivery_menu(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
110
68
if !self.delivery_menu || self.editing.is_some() {
111
69
return None;
@@ -2,22 +2,20 @@ use gpui_kit::component::fluent::{2
MENU_ICON_LABEL_GAP, MENU_ICON_SLOT, MENU_ITEM_GAP, MENU_ITEM_HEIGHT, MENU_ITEM_PADDING_X,2
MENU_ICON_LABEL_GAP, MENU_ICON_SLOT, MENU_ITEM_GAP, MENU_ITEM_HEIGHT, MENU_ITEM_PADDING_X,3
MENU_LIST_PADDING, OPTION_CHECK_SIZE,3
MENU_LIST_PADDING, OPTION_CHECK_SIZE,4
};4
};5
use gpui_kit::component::tooltip::{PopupTriggerTooltip as _, Tooltip};5
use gpui_kit::component::tooltip::Tooltip;6
use gpui_kit::component::{h_flex, v_flex};6
use gpui_kit::component::{h_flex, v_flex};7
use gpui_kit::prelude::FluentBuilder as _;8
use gpui_kit::*;7
use gpui_kit::*;9
use store::MessageImportance;8
use store::MessageImportance;10
9
11
use super::{COMPOSER_BUTTON_INSET, COMPOSER_BUTTON_SIZE, COMPOSER_ICON_SIZE, Composer};10
use super::{COMPOSER_BUTTON_INSET, COMPOSER_BUTTON_SIZE, COMPOSER_ICON_SIZE, Composer};12
use crate::delivery_options::{11
use crate::delivery_options::{13
DELIVERY_BUTTON_TITLE, DeliveryOption, URGENT_TOO_MANY_MEMBERS, UrgentAvailability,12
DeliveryOption, URGENT_TOO_MANY_MEMBERS, UrgentAvailability,14
allowed_importance, delivery_options, urgent_banner,13
allowed_importance, delivery_options, urgent_banner,15
};14
};16
use crate::importance::importance_label;15
use crate::importance::importance_label;17
use crate::theme::{self, ElevatedSurface as _};16
use crate::theme::{self, ElevatedSurface as _};18
use crate::views::widgets::symbol;17
use crate::views::widgets::symbol;19
18
20
pub const COMPOSER_DELIVERY_TAG: &str = "composer/actions/delivery";21
pub const COMPOSER_IMPORTANCE_LABEL_TAG: &str = "composer/importance-label";19
pub const COMPOSER_IMPORTANCE_LABEL_TAG: &str = "composer/importance-label";22
pub const COMPOSER_URGENT_BANNER_TAG: &str = "composer-urgent-banner";20
pub const COMPOSER_URGENT_BANNER_TAG: &str = "composer-urgent-banner";23
pub const DELIVERY_MENU_TAG: &str = "delivery-menu";21
pub const DELIVERY_MENU_TAG: &str = "delivery-menu";@@ -66,46 +64,6 @@ impl Composer {66
cx.notify();64
cx.notify();67
}65
}68
66
69
pub(super) fn render_delivery_button(&self, cx: &mut Context<Self>) -> Option<Stateful<Div>> {70
if self.editing.is_some() {71
return None;72
}73
let open = self.delivery_menu;74
let marked = self.importance.is_marked();75
Some(76
div()77
.id("composer-delivery")78
.debug_selector(|| COMPOSER_DELIVERY_TAG.into())79
.size(px(COMPOSER_BUTTON_SIZE))80
.flex_none()81
.flex()82
.items_center()83
.justify_center()84
.rounded(px(8.))85
.cursor_pointer()86
.when(open, |button| button.bg(theme::popup_hover()))87
.hover(|button| button.bg(theme::popup_hover()))88
.popup_trigger_tooltip_text(open, DELIVERY_BUTTON_TITLE)89
.child(symbol(90
"fluent_important",91
COMPOSER_ICON_SIZE,92
if marked {93
theme::red()94
} else {95
theme::text_muted()96
},97
))98
.on_mouse_down(MouseButton::Left, |_, window, cx| {99
window.prevent_default();100
cx.stop_propagation();101
})102
.on_click(cx.listener(|this, _, _, cx| {103
this.delivery_menu = !this.delivery_menu;104
cx.notify();105
})),106
)107
}108
109
pub(super) fn render_delivery_menu(&self, cx: &mut Context<Self>) -> Option<AnyElement> {67
pub(super) fn render_delivery_menu(&self, cx: &mut Context<Self>) -> Option<AnyElement> {110
if !self.delivery_menu || self.editing.is_some() {68
if !self.delivery_menu || self.editing.is_some() {111
return None;69
return None;@@ -72,7 +72,7 @@ use super::scroll_edge::edge_divider;
72
72
use super::toolbar_placement::{TimelineBounds, record_bounds};
73
73
use super::widgets::{icon, symbol};
74
74
use crate::agents::{AgentRun, StartRequest};
75
use crate::app_state::{AppEvent, AppState, Selection, composer_name, selection_title};
75
use crate::app_state::{AppEvent, AppState, Selection, selection_title};
76
76
use crate::backend::Engine;
77
77
use crate::card_state::CardScope;
78
78
use crate::channel_files::DownloadSource;
@@ -762,11 +762,6 @@ impl ConversationView {
762
762
let title = selection_title(&self.app.read(cx).sidebar, ¤t.selection);
763
763
if current.title != title {
764
764
current.title = title;
765
let conversation_id = current.selection.conversation_id().to_owned();
766
let name = composer_name(&self.app.read(cx).sidebar, ¤t.selection);
767
self.composer.update(cx, |composer, cx| {
768
composer.set_conversation(&conversation_id, &name, window, cx)
769
});
770
765
cx.notify();
771
766
}
772
767
}
@@ -978,18 +973,13 @@ impl ConversationView {
978
973
self.app
979
974
.update(cx, |state, cx| state.refresh_pins(&conversation_id, cx));
980
975
}
981
let target = self
976
let conversation_id = self
982
977
.current
983
978
.as_ref()
984
.map(|current| {
985
(
986
current.selection.conversation_id().to_owned(),
987
composer_name(&self.app.read(cx).sidebar, ¤t.selection),
988
)
989
})
979
.map(|current| current.selection.conversation_id().to_owned())
990
980
.unwrap_or_default();
991
981
self.composer.update(cx, |composer, cx| {
992
composer.set_conversation(&target.0, &target.1, window, cx);
982
composer.set_conversation(&conversation_id, window, cx);
993
983
});
994
984
self.sync_reply_composer(window, cx);
995
985
if !self.draft_active && !self.in_feed() {
@@ -1016,7 +1006,7 @@ impl ConversationView {
1016
1006
self.sync_generation += 1;
1017
1007
self.draft.update(cx, |draft, cx| draft.reset(window, cx));
1018
1008
self.composer.update(cx, |composer, cx| {
1019
composer.set_conversation("", "", window, cx)
1009
composer.set_conversation("", window, cx)
1020
1010
});
1021
1011
self.on_draft_changed(window, cx);
1022
1012
self.rebuild(true, cx);
@@ -1097,7 +1087,7 @@ impl ConversationView {
1097
1087
None => {
1098
1088
self.composer.update(cx, |composer, cx| {
1099
1089
composer.carry_images_into(String::new());
1100
composer.set_conversation("", "", window, cx);
1090
composer.set_conversation("", window, cx);
1101
1091
});
1102
1092
self.current = None;
1103
1093
self.sync_generation += 1;
@@ -72,7 +72,7 @@ use super::scroll_edge::edge_divider;72
use super::toolbar_placement::{TimelineBounds, record_bounds};72
use super::toolbar_placement::{TimelineBounds, record_bounds};73
use super::widgets::{icon, symbol};73
use super::widgets::{icon, symbol};74
use crate::agents::{AgentRun, StartRequest};74
use crate::agents::{AgentRun, StartRequest};75
use crate::app_state::{AppEvent, AppState, Selection, composer_name, selection_title};75
use crate::app_state::{AppEvent, AppState, Selection, selection_title};76
use crate::backend::Engine;76
use crate::backend::Engine;77
use crate::card_state::CardScope;77
use crate::card_state::CardScope;78
use crate::channel_files::DownloadSource;78
use crate::channel_files::DownloadSource;@@ -762,11 +762,6 @@ impl ConversationView {762
let title = selection_title(&self.app.read(cx).sidebar, ¤t.selection);762
let title = selection_title(&self.app.read(cx).sidebar, ¤t.selection);763
if current.title != title {763
if current.title != title {764
current.title = title;764
current.title = title;765
let conversation_id = current.selection.conversation_id().to_owned();766
let name = composer_name(&self.app.read(cx).sidebar, ¤t.selection);767
self.composer.update(cx, |composer, cx| {768
composer.set_conversation(&conversation_id, &name, window, cx)769
});770
cx.notify();765
cx.notify();771
}766
}772
}767
}@@ -978,18 +973,13 @@ impl ConversationView {978
self.app973
self.app979
.update(cx, |state, cx| state.refresh_pins(&conversation_id, cx));974
.update(cx, |state, cx| state.refresh_pins(&conversation_id, cx));980
}975
}981
let target = self976
let conversation_id = self982
.current977
.current983
.as_ref()978
.as_ref()984
.map(|current| {979
.map(|current| current.selection.conversation_id().to_owned())985
(986
current.selection.conversation_id().to_owned(),987
composer_name(&self.app.read(cx).sidebar, ¤t.selection),988
)989
})990
.unwrap_or_default();980
.unwrap_or_default();991
self.composer.update(cx, |composer, cx| {981
self.composer.update(cx, |composer, cx| {992
composer.set_conversation(&target.0, &target.1, window, cx);982
composer.set_conversation(&conversation_id, window, cx);993
});983
});994
self.sync_reply_composer(window, cx);984
self.sync_reply_composer(window, cx);995
if !self.draft_active && !self.in_feed() {985
if !self.draft_active && !self.in_feed() {@@ -1016,7 +1006,7 @@ impl ConversationView {1016
self.sync_generation += 1;1006
self.sync_generation += 1;1017
self.draft.update(cx, |draft, cx| draft.reset(window, cx));1007
self.draft.update(cx, |draft, cx| draft.reset(window, cx));1018
self.composer.update(cx, |composer, cx| {1008
self.composer.update(cx, |composer, cx| {1019
composer.set_conversation("", "", window, cx)1009
composer.set_conversation("", window, cx)1020
});1010
});1021
self.on_draft_changed(window, cx);1011
self.on_draft_changed(window, cx);1022
self.rebuild(true, cx);1012
self.rebuild(true, cx);@@ -1097,7 +1087,7 @@ impl ConversationView {1097
None => {1087
None => {1098
self.composer.update(cx, |composer, cx| {1088
self.composer.update(cx, |composer, cx| {1099
composer.carry_images_into(String::new());1089
composer.carry_images_into(String::new());1100
composer.set_conversation("", "", window, cx);1090
composer.set_conversation("", window, cx);1101
});1091
});1102
self.current = None;1092
self.current = None;1103
self.sync_generation += 1;1093
self.sync_generation += 1;@@ -166,7 +166,7 @@ impl ConversationView {
166
166
return;
167
167
};
168
168
composer.update(cx, |composer, cx| {
169
composer.set_conversation(&conversation_id, "", window, cx);
169
composer.set_conversation(&conversation_id, window, cx);
170
170
composer.set_placeholder(REPLY_PLACEHOLDER, window, cx);
171
171
composer.set_text("", window, cx);
172
172
composer.set_reply(None, cx);
@@ -166,7 +166,7 @@ impl ConversationView {166
return;166
return;167
};167
};168
composer.update(cx, |composer, cx| {168
composer.update(cx, |composer, cx| {169
composer.set_conversation(&conversation_id, "", window, cx);169
composer.set_conversation(&conversation_id, window, cx);170
composer.set_placeholder(REPLY_PLACEHOLDER, window, cx);170
composer.set_placeholder(REPLY_PLACEHOLDER, window, cx);171
composer.set_text("", window, cx);171
composer.set_text("", window, cx);172
composer.set_reply(None, cx);172
composer.set_reply(None, cx);@@ -2,10 +2,6 @@ use std::cell::RefCell;
2
2
use std::collections::HashMap;
3
3
use std::rc::Rc;
4
4
5
use gpui_kit::component::{
6
button::{Button, ButtonVariants as _},
7
h_flex, v_flex,
8
};
9
5
use gpui_kit::*;
10
6
use mcp::ReactionProposal;
11
7
use teams_core::{AnnouncementBanner, FileCard, ImageRef, LinkPreview};
@@ -517,23 +513,7 @@ impl RenderEnv {
517
513
}
518
514
519
515
fn inline_reply_editor(&self, composer: &Entity<Composer>) -> AnyElement {
520
let view = self.view.clone();
521
v_flex()
522
.w_full()
523
.gap(px(6.))
524
.child(composer.clone())
525
.child(
526
h_flex().justify_end().child(
527
Button::new("cancel-inline-reply")
528
.ghost()
529
.compact()
530
.label("Cancel")
531
.on_click(move |_, _, cx| {
532
view.update(cx, |this, cx| this.close_reply_editor(cx)).ok();
533
}),
534
),
535
)
536
.into_any_element()
516
composer.clone().into_any_element()
537
517
}
538
518
}
539
519
@@ -2,10 +2,6 @@ use std::cell::RefCell;2
use std::collections::HashMap;2
use std::collections::HashMap;3
use std::rc::Rc;3
use std::rc::Rc;4
4
5
use gpui_kit::component::{6
button::{Button, ButtonVariants as _},7
h_flex, v_flex,8
};9
use gpui_kit::*;5
use gpui_kit::*;10
use mcp::ReactionProposal;6
use mcp::ReactionProposal;11
use teams_core::{AnnouncementBanner, FileCard, ImageRef, LinkPreview};7
use teams_core::{AnnouncementBanner, FileCard, ImageRef, LinkPreview};@@ -517,23 +513,7 @@ impl RenderEnv {517
}513
}518
514
519
fn inline_reply_editor(&self, composer: &Entity<Composer>) -> AnyElement {515
fn inline_reply_editor(&self, composer: &Entity<Composer>) -> AnyElement {520
let view = self.view.clone();516
composer.clone().into_any_element()521
v_flex()522
.w_full()523
.gap(px(6.))524
.child(composer.clone())525
.child(526
h_flex().justify_end().child(527
Button::new("cancel-inline-reply")528
.ghost()529
.compact()530
.label("Cancel")531
.on_click(move |_, _, cx| {532
view.update(cx, |this, cx| this.close_reply_editor(cx)).ok();533
}),534
),535
)536
.into_any_element()537
}517
}538
}518
}539
519
@@ -21,6 +21,7 @@ use crate::rows::reaction_glyph;
21
21
use crate::share_outlook::SHARE_TO_OUTLOOK_LABEL;
22
22
use crate::theme::{self, ElevatedSurface as _};
23
23
24
const TRANSLATION_LABEL: &str = "Translation";
24
25
const BAR_BUTTON: f32 = 30.;
25
26
const BAR_PADDING: f32 = 3.;
26
27
const BAR_ICON: f32 = 16.;
@@ -193,7 +194,6 @@ pub fn add_reaction_pill(adder: ReactionAdder, height: f32, cx: &App) -> AnyElem
193
194
fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {
194
195
let forward_multiple = menu.forward_multiple.clone();
195
196
let (
196
reply,
197
197
forward,
198
198
copy_link,
199
199
copy,
@@ -208,7 +208,6 @@ fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {
208
208
share_to_outlook,
209
209
pin,
210
210
) = (
211
menu.reply.clone(),
212
211
menu.forward.clone(),
213
212
menu.copy_link.clone(),
214
213
menu.copy.clone(),
@@ -237,9 +236,6 @@ fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {
237
236
.on_click(move |_, window, cx| action(window, cx))
238
237
};
239
238
let mut popup = popup;
240
if let Some(reply) = reply.clone() {
241
popup = popup.item(item("Reply with quote", IconName::Reply, reply));
242
}
243
239
match (forward.clone(), forward_multiple.clone()) {
244
240
(Some(forward), Some(forward_multiple)) => {
245
241
popup = popup.submenu_with_icon(
@@ -269,34 +265,24 @@ fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {
269
265
if let Some(copy_link) = copy_link.clone() {
270
266
popup = popup.item(item("Copy link", IconName::Link, copy_link));
271
267
}
272
if let Some(refresh_card) = refresh_card.clone() {
273
popup = popup.item(item("Refresh card", IconName::RefreshCw, refresh_card));
274
}
275
268
popup = popup.item(item("Copy text", IconName::Copy, copy.clone()));
276
if let Some(translate) = translate.clone() {
277
popup = popup.item(item(translate_label, IconName::Languages, translate));
278
}
279
if let Some(share_to_outlook) = share_to_outlook.clone() {
280
popup = popup.item(item(
281
SHARE_TO_OUTLOOK_LABEL,
282
IconName::Mail,
283
share_to_outlook,
284
));
285
}
286
269
if let Some(save) = save.clone() {
287
270
popup = popup.item(if saved {
288
item("Unsave message", IconName::BookmarkOff, save)
271
item("Unsave this message", IconName::BookmarkOff, save)
289
272
} else {
290
item("Save message", IconName::Bookmark, save)
273
item("Save this message", IconName::Bookmark, save)
291
274
});
292
275
}
293
276
if let Some(toggle_pinned) = toggle_pinned.clone() {
294
277
popup = popup.item(if pinned {
295
278
item("Unpin", IconName::PinOff, toggle_pinned)
296
279
} else {
297
item("Pin", IconName::Pin, toggle_pinned)
280
item("Pin for everyone", IconName::Pin, toggle_pinned)
298
281
});
299
282
}
283
if let Some(edit) = edit.clone() {
284
popup = popup.item(item("Edit", IconName::Pencil, edit));
285
}
300
286
if let Some(toggle_follow) = toggle_follow.clone() {
301
287
popup = popup.item(if followed {
302
288
item(follow_label(true), IconName::BellOff, toggle_follow)
@@ -304,18 +290,40 @@ fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {
304
290
item(follow_label(false), IconName::Bell, toggle_follow)
305
291
});
306
292
}
307
if let Some(edit) = edit.clone() {
308
popup = popup.item(item("Edit", IconName::Pencil, edit));
293
if let Some(refresh_card) = refresh_card.clone() {
294
popup = popup.item(item("Refresh card", IconName::RefreshCw, refresh_card));
295
}
296
popup = popup.separator();
297
if let Some(mark_unread) = mark_unread.clone() {
298
popup = popup.item(item("Mark as unread", IconName::EyeOff, mark_unread));
299
}
300
if let Some(share_to_outlook) = share_to_outlook.clone() {
301
popup = popup.item(item(
302
SHARE_TO_OUTLOOK_LABEL,
303
IconName::Mail,
304
share_to_outlook,
305
));
306
}
307
if let Some(translate) = translate.clone() {
308
popup = popup.submenu_with_icon(
309
Some(IconName::Languages.into()),
310
TRANSLATION_LABEL,
311
window,
312
cx,
313
move |submenu, _, _| {
314
let translate = translate.clone();
315
submenu.item(
316
PopupMenuItem::new(translate_label)
317
.on_click(move |_, window, cx| translate(window, cx)),
318
)
319
},
320
);
309
321
}
310
322
if let Some(delete) = delete.clone() {
311
323
popup = popup
312
324
.separator()
313
325
.item(item("Delete", IconName::Trash, delete));
314
326
}
315
if let Some(mark_unread) = mark_unread.clone() {
316
let entry = item("Mark as unread", IconName::EyeOff, mark_unread);
317
popup = popup.separator().item(entry);
318
}
319
327
popup
320
328
})
321
329
.on_open_change(move |open, window, cx| pin(*open, window, cx))
@@ -21,6 +21,7 @@ use crate::rows::reaction_glyph;21
use crate::share_outlook::SHARE_TO_OUTLOOK_LABEL;21
use crate::share_outlook::SHARE_TO_OUTLOOK_LABEL;22
use crate::theme::{self, ElevatedSurface as _};22
use crate::theme::{self, ElevatedSurface as _};23
23
24
const TRANSLATION_LABEL: &str = "Translation";24
const BAR_BUTTON: f32 = 30.;25
const BAR_BUTTON: f32 = 30.;25
const BAR_PADDING: f32 = 3.;26
const BAR_PADDING: f32 = 3.;26
const BAR_ICON: f32 = 16.;27
const BAR_ICON: f32 = 16.;@@ -193,7 +194,6 @@ pub fn add_reaction_pill(adder: ReactionAdder, height: f32, cx: &App) -> AnyElem193
fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {194
fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {194
let forward_multiple = menu.forward_multiple.clone();195
let forward_multiple = menu.forward_multiple.clone();195
let (196
let (196
reply,197
forward,197
forward,198
copy_link,198
copy_link,199
copy,199
copy,@@ -208,7 +208,6 @@ fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {208
share_to_outlook,208
share_to_outlook,209
pin,209
pin,210
) = (210
) = (211
menu.reply.clone(),212
menu.forward.clone(),211
menu.forward.clone(),213
menu.copy_link.clone(),212
menu.copy_link.clone(),214
menu.copy.clone(),213
menu.copy.clone(),@@ -237,9 +236,6 @@ fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {237
.on_click(move |_, window, cx| action(window, cx))236
.on_click(move |_, window, cx| action(window, cx))238
};237
};239
let mut popup = popup;238
let mut popup = popup;240
if let Some(reply) = reply.clone() {241
popup = popup.item(item("Reply with quote", IconName::Reply, reply));242
}243
match (forward.clone(), forward_multiple.clone()) {239
match (forward.clone(), forward_multiple.clone()) {244
(Some(forward), Some(forward_multiple)) => {240
(Some(forward), Some(forward_multiple)) => {245
popup = popup.submenu_with_icon(241
popup = popup.submenu_with_icon(@@ -269,34 +265,24 @@ fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {269
if let Some(copy_link) = copy_link.clone() {265
if let Some(copy_link) = copy_link.clone() {270
popup = popup.item(item("Copy link", IconName::Link, copy_link));266
popup = popup.item(item("Copy link", IconName::Link, copy_link));271
}267
}272
if let Some(refresh_card) = refresh_card.clone() {273
popup = popup.item(item("Refresh card", IconName::RefreshCw, refresh_card));274
}275
popup = popup.item(item("Copy text", IconName::Copy, copy.clone()));268
popup = popup.item(item("Copy text", IconName::Copy, copy.clone()));276
if let Some(translate) = translate.clone() {277
popup = popup.item(item(translate_label, IconName::Languages, translate));278
}279
if let Some(share_to_outlook) = share_to_outlook.clone() {280
popup = popup.item(item(281
SHARE_TO_OUTLOOK_LABEL,282
IconName::Mail,283
share_to_outlook,284
));285
}286
if let Some(save) = save.clone() {269
if let Some(save) = save.clone() {287
popup = popup.item(if saved {270
popup = popup.item(if saved {288
item("Unsave message", IconName::BookmarkOff, save)271
item("Unsave this message", IconName::BookmarkOff, save)289
} else {272
} else {290
item("Save message", IconName::Bookmark, save)273
item("Save this message", IconName::Bookmark, save)291
});274
});292
}275
}293
if let Some(toggle_pinned) = toggle_pinned.clone() {276
if let Some(toggle_pinned) = toggle_pinned.clone() {294
popup = popup.item(if pinned {277
popup = popup.item(if pinned {295
item("Unpin", IconName::PinOff, toggle_pinned)278
item("Unpin", IconName::PinOff, toggle_pinned)296
} else {279
} else {297
item("Pin", IconName::Pin, toggle_pinned)280
item("Pin for everyone", IconName::Pin, toggle_pinned)298
});281
});299
}282
}283
if let Some(edit) = edit.clone() {284
popup = popup.item(item("Edit", IconName::Pencil, edit));285
}300
if let Some(toggle_follow) = toggle_follow.clone() {286
if let Some(toggle_follow) = toggle_follow.clone() {301
popup = popup.item(if followed {287
popup = popup.item(if followed {302
item(follow_label(true), IconName::BellOff, toggle_follow)288
item(follow_label(true), IconName::BellOff, toggle_follow)@@ -304,18 +290,40 @@ fn more_button(menu: &MessageMenu, cx: &App) -> AnyElement {304
item(follow_label(false), IconName::Bell, toggle_follow)290
item(follow_label(false), IconName::Bell, toggle_follow)305
});291
});306
}292
}307
if let Some(edit) = edit.clone() {293
if let Some(refresh_card) = refresh_card.clone() {308
popup = popup.item(item("Edit", IconName::Pencil, edit));294
popup = popup.item(item("Refresh card", IconName::RefreshCw, refresh_card));295
}296
popup = popup.separator();297
if let Some(mark_unread) = mark_unread.clone() {298
popup = popup.item(item("Mark as unread", IconName::EyeOff, mark_unread));299
}300
if let Some(share_to_outlook) = share_to_outlook.clone() {301
popup = popup.item(item(302
SHARE_TO_OUTLOOK_LABEL,303
IconName::Mail,304
share_to_outlook,305
));306
}307
if let Some(translate) = translate.clone() {308
popup = popup.submenu_with_icon(309
Some(IconName::Languages.into()),310
TRANSLATION_LABEL,311
window,312
cx,313
move |submenu, _, _| {314
let translate = translate.clone();315
submenu.item(316
PopupMenuItem::new(translate_label)317
.on_click(move |_, window, cx| translate(window, cx)),318
)319
},320
);309
}321
}310
if let Some(delete) = delete.clone() {322
if let Some(delete) = delete.clone() {311
popup = popup323
popup = popup312
.separator()324
.separator()313
.item(item("Delete", IconName::Trash, delete));325
.item(item("Delete", IconName::Trash, delete));314
}326
}315
if let Some(mark_unread) = mark_unread.clone() {316
let entry = item("Mark as unread", IconName::EyeOff, mark_unread);317
popup = popup.separator().item(entry);318
}319
popup327
popup320
})328
})321
.on_open_change(move |open, window, cx| pin(*open, window, cx))329
.on_open_change(move |open, window, cx| pin(*open, window, cx))@@ -408,10 +408,6 @@ fn reply_footer(
408
408
.px(px(CARD_PADDING - FOOTER_BUTTON_PADDING))
409
409
.rounded_b(px(CARD_RADIUS))
410
410
.bg(theme::reply_surface());
411
if let Some(editor) = editor {
412
return Some(footer.px(px(CARD_PADDING)).py(px(8.)).child(editor));
413
}
414
let open = open?;
415
411
let own_avatar = directory.me.as_ref().map(|me| {
416
412
div()
417
413
.debug_selector(|| POST_FOOTER_AVATAR_TAG.into())
@@ -423,6 +419,19 @@ fn reply_footer(
423
419
FOOTER_AVATAR,
424
420
))
425
421
});
422
if let Some(editor) = editor {
423
return Some(
424
footer.px(px(CARD_PADDING)).py(px(8.)).child(
425
h_flex()
426
.w_full()
427
.gap(px(8.))
428
.items_center()
429
.children(own_avatar)
430
.child(div().flex_1().min_w_0().child(editor)),
431
),
432
);
433
}
434
let open = open?;
426
435
Some(
427
436
footer.py(px(CARD_PADDING - FOOTER_BUTTON_VERTICAL)).child(
428
437
h_flex().child(
@@ -408,10 +408,6 @@ fn reply_footer(408
.px(px(CARD_PADDING - FOOTER_BUTTON_PADDING))408
.px(px(CARD_PADDING - FOOTER_BUTTON_PADDING))409
.rounded_b(px(CARD_RADIUS))409
.rounded_b(px(CARD_RADIUS))410
.bg(theme::reply_surface());410
.bg(theme::reply_surface());411
if let Some(editor) = editor {412
return Some(footer.px(px(CARD_PADDING)).py(px(8.)).child(editor));413
}414
let open = open?;415
let own_avatar = directory.me.as_ref().map(|me| {411
let own_avatar = directory.me.as_ref().map(|me| {416
div()412
div()417
.debug_selector(|| POST_FOOTER_AVATAR_TAG.into())413
.debug_selector(|| POST_FOOTER_AVATAR_TAG.into())@@ -423,6 +419,19 @@ fn reply_footer(423
FOOTER_AVATAR,419
FOOTER_AVATAR,424
))420
))425
});421
});422
if let Some(editor) = editor {423
return Some(424
footer.px(px(CARD_PADDING)).py(px(8.)).child(425
h_flex()426
.w_full()427
.gap(px(8.))428
.items_center()429
.children(own_avatar)430
.child(div().flex_1().min_w_0().child(editor)),431
),432
);433
}434
let open = open?;426
Some(435
Some(427
footer.py(px(CARD_PADDING - FOOTER_BUTTON_VERTICAL)).child(436
footer.py(px(CARD_PADDING - FOOTER_BUTTON_VERTICAL)).child(428
h_flex().child(437
h_flex().child(@@ -1,4 +1,4 @@
1
use std::cell::Cell;
1
use std::cell::{Cell, RefCell};
2
2
use std::collections::{HashMap, HashSet};
3
3
use std::time::Duration;
4
4
@@ -8,14 +8,16 @@ use gpui_kit::assets::IconName;
8
8
use gpui_kit::component::button::{Button, ButtonVariants as _};
9
9
use gpui_kit::component::dialog::DialogFooter;
10
10
use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenu, PopupMenuItem};
11
use gpui_kit::component::{Icon, WindowExt as _, h_flex, tooltip::Tooltip, v_flex};
11
use gpui_kit::component::{Icon, Sizable as _, WindowExt as _, h_flex, tooltip::Tooltip, v_flex};
12
12
use gpui_kit::prelude::FluentBuilder as _;
13
13
use gpui_kit::*;
14
14
use store::{
15
15
ChannelNotificationLevel, ChannelNotifications, ChannelRecord, MessageImportance, SidebarTeam,
16
16
Store,
17
17
};
18
use teams_core::{ChatNotificationMode, DesktopNotifications, is_notes_chat, team_avatar_key};
18
use teams_core::{
19
ChatNotificationMode, DesktopNotifications, chat_link, is_notes_chat, team_avatar_key,
20
};
19
21
20
22
use super::activity_panel::ActivityPanel;
21
23
use super::avatar::{spec_avatar, team_avatar, with_presence};
@@ -56,6 +58,8 @@ pub(crate) mod chat_filter_bar;
56
58
pub const SIDEBAR_SCROLL_DIVIDER: &str = "shell/islands/sidebar/divider-scroll";
57
59
const COLLAPSED_TEAMS_META_KEY: &str = "sidebar_collapsed_teams";
58
60
const ROW_HEIGHT: f32 = 54.;
61
const ROW_MORE_TOP: f32 = 6.;
62
const ROW_MORE_RIGHT: f32 = 6.;
59
63
const PROPOSAL_DOT_SIZE: f32 = 8.;
60
64
const PINNED_CHANNEL_HEIGHT: f32 = 48.;
61
65
const SECTION_HEIGHT: f32 = 30.;
@@ -70,6 +74,7 @@ const AVATAR_SIZE: f32 = 36.;
70
74
const PINNED_LABEL: &str = "Pinned";
71
75
const TEAMS_LABEL: &str = "Teams";
72
76
const MARK_ALL_READ_LABEL: &str = "Mark all as read";
77
const COLLAPSE_ALL_LABEL: &str = "Collapse all sections";
73
78
const HIDDEN_TEAMS_LABEL: &str = "Hidden teams";
74
79
const TEAM_ROW_HEIGHT: f32 = 36.;
75
80
const CHANNEL_ROW_HEIGHT: f32 = 32.;
@@ -141,6 +146,7 @@ impl Render for DragGhost {
141
146
}
142
147
}
143
148
149
#[derive(Clone)]
144
150
struct ChatMenuTarget {
145
151
id: String,
146
152
title: String,
@@ -165,6 +171,36 @@ fn chat_menu(
165
171
target: &ChatMenuTarget,
166
172
) -> PopupMenu {
167
173
let mut popup = popup;
174
let read_state = context.state.clone();
175
let read_id = target.id.clone();
176
let unread = target.unread;
177
let mute_state = context.state.clone();
178
let mute_id = target.id.clone();
179
let muted = target.muted;
180
let hide_state = context.state.clone();
181
let hide_id = target.id.clone();
182
let notes = is_notes_chat(&target.id);
183
popup = popup.item(
184
PopupMenuItem::new(if unread {
185
"Mark as read"
186
} else {
187
"Mark as unread"
188
})
189
.icon(menu_icon(if unread {
190
IconName::MailOpen
191
} else {
192
IconName::Mail
193
}))
194
.on_click(move |_, _, cx| {
195
read_state.update(cx, |state, cx| {
196
if unread {
197
state.mark_chat_read(&read_id, cx);
198
} else {
199
state.mark_chat_unread(&read_id, cx);
200
}
201
});
202
}),
203
);
168
204
let current = target.folder_id.clone();
169
205
let folders: Vec<(String, String)> = context
170
206
.folders
@@ -204,36 +240,6 @@ fn chat_menu(
204
240
}),
205
241
);
206
242
}
207
let read_state = context.state.clone();
208
let read_id = target.id.clone();
209
let unread = target.unread;
210
let mute_state = context.state.clone();
211
let mute_id = target.id.clone();
212
let muted = target.muted;
213
let hide_state = context.state.clone();
214
let hide_id = target.id.clone();
215
let notes = is_notes_chat(&target.id);
216
popup = popup.separator().item(
217
PopupMenuItem::new(if unread {
218
"Mark as read"
219
} else {
220
"Mark as unread"
221
})
222
.icon(menu_icon(if unread {
223
IconName::MailOpen
224
} else {
225
IconName::Mail
226
}))
227
.on_click(move |_, _, cx| {
228
read_state.update(cx, |state, cx| {
229
if unread {
230
state.mark_chat_read(&read_id, cx);
231
} else {
232
state.mark_chat_unread(&read_id, cx);
233
}
234
});
235
}),
236
);
237
243
let hide_item = PopupMenuItem::new("Hide")
238
244
.icon(menu_icon(IconName::EyeOff))
239
245
.on_click(move |_, _, cx| {
@@ -281,7 +287,18 @@ fn chat_menu(
281
287
}),
282
288
);
283
289
}
290
let (link_state, link_id) = (context.state.clone(), target.id.clone());
284
291
popup = popup
292
.item(
293
PopupMenuItem::new("Copy link")
294
.icon(menu_icon(IconName::Link))
295
.on_click(move |_, _, cx| {
296
cx.write_to_clipboard(ClipboardItem::new_string(chat_link(&link_id)));
297
link_state.update(cx, |state, cx| {
298
state.raise_notice("Link copied".to_owned(), None, cx)
299
});
300
}),
301
)
285
302
.item(pop_out_item(context, target))
286
303
.separator()
287
304
.item(hide_item);
@@ -670,6 +687,7 @@ pub struct SidebarView {
670
687
chats_scroll: ScrollHandle,
671
688
older_chats_trigger_top: Cell<Option<f32>>,
672
689
older_chats_seen: Cell<(bool, bool)>,
690
section_ids: RefCell<Vec<String>>,
673
691
channels_scroll: ScrollHandle,
674
692
calls_scroll: ScrollHandle,
675
693
chat_filter: ChatFilter,
@@ -803,6 +821,7 @@ impl SidebarView {
803
821
chats_scroll: ScrollHandle::new(),
804
822
older_chats_trigger_top: Cell::new(None),
805
823
older_chats_seen: Cell::new((false, false)),
824
section_ids: RefCell::new(Vec::new()),
806
825
channels_scroll: ScrollHandle::new(),
807
826
calls_scroll: ScrollHandle::new(),
808
827
chat_filter: ChatFilter::default(),
@@ -958,6 +977,7 @@ impl SidebarView {
958
977
959
978
fn chat_list_menu_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
960
979
let state = self.state.clone();
980
let section_ids = self.section_ids.borrow().clone();
961
981
let read_only = self.state.read(cx).mode.read_only;
962
982
Button::new("chat-list-more")
963
983
.icon(IconName::Ellipsis)
@@ -965,7 +985,29 @@ impl SidebarView {
965
985
.size(px(NEW_CHAT_BUTTON_SIZE))
966
986
.rounded(px(8.))
967
987
.tooltip("More options")
968
.dropdown_menu(move |menu, _, _| menu.item(new_section_item(&state, read_only)))
988
.dropdown_menu(move |menu, _, _| {
989
let (read_state, collapse_state) = (state.clone(), state.clone());
990
let section_ids = section_ids.clone();
991
menu.item(
992
PopupMenuItem::new(MARK_ALL_READ_LABEL)
993
.icon(menu_icon(IconName::CheckCheck))
994
.disabled(read_only)
995
.on_click(move |_, _, cx| {
996
read_state.update(cx, |state, cx| state.mark_all_chats_read(cx));
997
}),
998
)
999
.item(
1000
PopupMenuItem::new(COLLAPSE_ALL_LABEL)
1001
.icon(menu_icon(IconName::ChevronsDownUp))
1002
.on_click(move |_, _, cx| {
1003
let ids = section_ids.clone();
1004
collapse_state
1005
.update(cx, |state, cx| state.collapse_sections(&ids, cx));
1006
}),
1007
)
1008
.separator()
1009
.item(new_section_item(&state, read_only))
1010
})
969
1011
}
970
1012
971
1013
fn channel_list_menu_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
@@ -1168,6 +1210,7 @@ impl SidebarView {
1168
1210
})
1169
1211
.text_color(theme::text())
1170
1212
.child(item.title.clone());
1213
let row_group = SharedString::from(format!("chat-row-{}", item.id));
1171
1214
let time = h_flex()
1172
1215
.flex_none()
1173
1216
.gap(px(4.))
@@ -1178,6 +1221,7 @@ impl SidebarView {
1178
1221
} else {
1179
1222
theme::text_muted()
1180
1223
})
1224
.group_hover(row_group.clone(), |time| time.invisible())
1181
1225
.child(item.time_label.clone());
1182
1226
let preview_color = if matches!(item.preview, Preview::Typing(_)) {
1183
1227
theme::accent_text()
@@ -1261,9 +1305,30 @@ impl SidebarView {
1261
1305
is_group: item.is_group,
1262
1306
member_count: item.member_count,
1263
1307
};
1308
let more_context = menu.clone();
1309
let more_target = target.clone();
1310
let more_button = div()
1311
.absolute()
1312
.top(px(ROW_MORE_TOP))
1313
.right(px(ROW_MORE_RIGHT))
1314
.invisible()
1315
.group_hover(row_group.clone(), |button| button.visible())
1316
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
1317
.child(
1318
Button::new(SharedString::from(format!("chat-more-{}", item.id)))
1319
.ghost()
1320
.xsmall()
1321
.icon(IconName::Ellipsis)
1322
.tooltip("More options")
1323
.dropdown_menu(move |popup, window, cx| {
1324
chat_menu(popup, window, cx, &more_context, &more_target)
1325
}),
1326
);
1264
1327
h_flex()
1265
1328
.id(SharedString::from(format!("chat-{}", item.id)))
1266
1329
.debug_selector(|| chat_row_selector(&item.id))
1330
.group(row_group)
1331
.relative()
1267
1332
.mx(px(6.))
1268
1333
.h(px(ROW_HEIGHT))
1269
1334
.flex_none()
@@ -1289,6 +1354,7 @@ impl SidebarView {
1289
1354
})
1290
1355
.child(avatar)
1291
1356
.child(lines)
1357
.child(more_button)
1292
1358
.on_click(move |_, _, cx| {
1293
1359
let selection = Selection::Chat(chat_id.clone());
1294
1360
state.update(cx, |state, cx| state.select(selection, cx));
@@ -1332,6 +1398,8 @@ impl SidebarView {
1332
1398
};
1333
1399
let section_menus =
1334
1400
section_menu_targets(§ions, &state.directory, state.mode.read_only);
1401
*self.section_ids.borrow_mut() =
1402
sections.iter().map(|section| section.id.clone()).collect();
1335
1403
(sections, section_menus, menu, state.local_previews.clone())
1336
1404
};
1337
1405
@@ -1,4 +1,4 @@1
use std::cell::Cell;1
use std::cell::{Cell, RefCell};2
use std::collections::{HashMap, HashSet};2
use std::collections::{HashMap, HashSet};3
use std::time::Duration;3
use std::time::Duration;4
4
@@ -8,14 +8,16 @@ use gpui_kit::assets::IconName;8
use gpui_kit::component::button::{Button, ButtonVariants as _};8
use gpui_kit::component::button::{Button, ButtonVariants as _};9
use gpui_kit::component::dialog::DialogFooter;9
use gpui_kit::component::dialog::DialogFooter;10
use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenu, PopupMenuItem};10
use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenu, PopupMenuItem};11
use gpui_kit::component::{Icon, WindowExt as _, h_flex, tooltip::Tooltip, v_flex};11
use gpui_kit::component::{Icon, Sizable as _, WindowExt as _, h_flex, tooltip::Tooltip, v_flex};12
use gpui_kit::prelude::FluentBuilder as _;12
use gpui_kit::prelude::FluentBuilder as _;13
use gpui_kit::*;13
use gpui_kit::*;14
use store::{14
use store::{15
ChannelNotificationLevel, ChannelNotifications, ChannelRecord, MessageImportance, SidebarTeam,15
ChannelNotificationLevel, ChannelNotifications, ChannelRecord, MessageImportance, SidebarTeam,16
Store,16
Store,17
};17
};18
use teams_core::{ChatNotificationMode, DesktopNotifications, is_notes_chat, team_avatar_key};18
use teams_core::{19
ChatNotificationMode, DesktopNotifications, chat_link, is_notes_chat, team_avatar_key,20
};19
21
20
use super::activity_panel::ActivityPanel;22
use super::activity_panel::ActivityPanel;21
use super::avatar::{spec_avatar, team_avatar, with_presence};23
use super::avatar::{spec_avatar, team_avatar, with_presence};@@ -56,6 +58,8 @@ pub(crate) mod chat_filter_bar;56
pub const SIDEBAR_SCROLL_DIVIDER: &str = "shell/islands/sidebar/divider-scroll";58
pub const SIDEBAR_SCROLL_DIVIDER: &str = "shell/islands/sidebar/divider-scroll";57
const COLLAPSED_TEAMS_META_KEY: &str = "sidebar_collapsed_teams";59
const COLLAPSED_TEAMS_META_KEY: &str = "sidebar_collapsed_teams";58
const ROW_HEIGHT: f32 = 54.;60
const ROW_HEIGHT: f32 = 54.;61
const ROW_MORE_TOP: f32 = 6.;62
const ROW_MORE_RIGHT: f32 = 6.;59
const PROPOSAL_DOT_SIZE: f32 = 8.;63
const PROPOSAL_DOT_SIZE: f32 = 8.;60
const PINNED_CHANNEL_HEIGHT: f32 = 48.;64
const PINNED_CHANNEL_HEIGHT: f32 = 48.;61
const SECTION_HEIGHT: f32 = 30.;65
const SECTION_HEIGHT: f32 = 30.;@@ -70,6 +74,7 @@ const AVATAR_SIZE: f32 = 36.;70
const PINNED_LABEL: &str = "Pinned";74
const PINNED_LABEL: &str = "Pinned";71
const TEAMS_LABEL: &str = "Teams";75
const TEAMS_LABEL: &str = "Teams";72
const MARK_ALL_READ_LABEL: &str = "Mark all as read";76
const MARK_ALL_READ_LABEL: &str = "Mark all as read";77
const COLLAPSE_ALL_LABEL: &str = "Collapse all sections";73
const HIDDEN_TEAMS_LABEL: &str = "Hidden teams";78
const HIDDEN_TEAMS_LABEL: &str = "Hidden teams";74
const TEAM_ROW_HEIGHT: f32 = 36.;79
const TEAM_ROW_HEIGHT: f32 = 36.;75
const CHANNEL_ROW_HEIGHT: f32 = 32.;80
const CHANNEL_ROW_HEIGHT: f32 = 32.;@@ -141,6 +146,7 @@ impl Render for DragGhost {141
}146
}142
}147
}143
148
149
#[derive(Clone)]144
struct ChatMenuTarget {150
struct ChatMenuTarget {145
id: String,151
id: String,146
title: String,152
title: String,@@ -165,6 +171,36 @@ fn chat_menu(165
target: &ChatMenuTarget,171
target: &ChatMenuTarget,166
) -> PopupMenu {172
) -> PopupMenu {167
let mut popup = popup;173
let mut popup = popup;174
let read_state = context.state.clone();175
let read_id = target.id.clone();176
let unread = target.unread;177
let mute_state = context.state.clone();178
let mute_id = target.id.clone();179
let muted = target.muted;180
let hide_state = context.state.clone();181
let hide_id = target.id.clone();182
let notes = is_notes_chat(&target.id);183
popup = popup.item(184
PopupMenuItem::new(if unread {185
"Mark as read"186
} else {187
"Mark as unread"188
})189
.icon(menu_icon(if unread {190
IconName::MailOpen191
} else {192
IconName::Mail193
}))194
.on_click(move |_, _, cx| {195
read_state.update(cx, |state, cx| {196
if unread {197
state.mark_chat_read(&read_id, cx);198
} else {199
state.mark_chat_unread(&read_id, cx);200
}201
});202
}),203
);168
let current = target.folder_id.clone();204
let current = target.folder_id.clone();169
let folders: Vec<(String, String)> = context205
let folders: Vec<(String, String)> = context170
.folders206
.folders@@ -204,36 +240,6 @@ fn chat_menu(204
}),240
}),205
);241
);206
}242
}207
let read_state = context.state.clone();208
let read_id = target.id.clone();209
let unread = target.unread;210
let mute_state = context.state.clone();211
let mute_id = target.id.clone();212
let muted = target.muted;213
let hide_state = context.state.clone();214
let hide_id = target.id.clone();215
let notes = is_notes_chat(&target.id);216
popup = popup.separator().item(217
PopupMenuItem::new(if unread {218
"Mark as read"219
} else {220
"Mark as unread"221
})222
.icon(menu_icon(if unread {223
IconName::MailOpen224
} else {225
IconName::Mail226
}))227
.on_click(move |_, _, cx| {228
read_state.update(cx, |state, cx| {229
if unread {230
state.mark_chat_read(&read_id, cx);231
} else {232
state.mark_chat_unread(&read_id, cx);233
}234
});235
}),236
);237
let hide_item = PopupMenuItem::new("Hide")243
let hide_item = PopupMenuItem::new("Hide")238
.icon(menu_icon(IconName::EyeOff))244
.icon(menu_icon(IconName::EyeOff))239
.on_click(move |_, _, cx| {245
.on_click(move |_, _, cx| {@@ -281,7 +287,18 @@ fn chat_menu(281
}),287
}),282
);288
);283
}289
}290
let (link_state, link_id) = (context.state.clone(), target.id.clone());284
popup = popup291
popup = popup292
.item(293
PopupMenuItem::new("Copy link")294
.icon(menu_icon(IconName::Link))295
.on_click(move |_, _, cx| {296
cx.write_to_clipboard(ClipboardItem::new_string(chat_link(&link_id)));297
link_state.update(cx, |state, cx| {298
state.raise_notice("Link copied".to_owned(), None, cx)299
});300
}),301
)285
.item(pop_out_item(context, target))302
.item(pop_out_item(context, target))286
.separator()303
.separator()287
.item(hide_item);304
.item(hide_item);@@ -670,6 +687,7 @@ pub struct SidebarView {670
chats_scroll: ScrollHandle,687
chats_scroll: ScrollHandle,671
older_chats_trigger_top: Cell<Option<f32>>,688
older_chats_trigger_top: Cell<Option<f32>>,672
older_chats_seen: Cell<(bool, bool)>,689
older_chats_seen: Cell<(bool, bool)>,690
section_ids: RefCell<Vec<String>>,673
channels_scroll: ScrollHandle,691
channels_scroll: ScrollHandle,674
calls_scroll: ScrollHandle,692
calls_scroll: ScrollHandle,675
chat_filter: ChatFilter,693
chat_filter: ChatFilter,@@ -803,6 +821,7 @@ impl SidebarView {803
chats_scroll: ScrollHandle::new(),821
chats_scroll: ScrollHandle::new(),804
older_chats_trigger_top: Cell::new(None),822
older_chats_trigger_top: Cell::new(None),805
older_chats_seen: Cell::new((false, false)),823
older_chats_seen: Cell::new((false, false)),824
section_ids: RefCell::new(Vec::new()),806
channels_scroll: ScrollHandle::new(),825
channels_scroll: ScrollHandle::new(),807
calls_scroll: ScrollHandle::new(),826
calls_scroll: ScrollHandle::new(),808
chat_filter: ChatFilter::default(),827
chat_filter: ChatFilter::default(),@@ -958,6 +977,7 @@ impl SidebarView {958
977
959
fn chat_list_menu_button(&self, cx: &mut Context<Self>) -> impl IntoElement {978
fn chat_list_menu_button(&self, cx: &mut Context<Self>) -> impl IntoElement {960
let state = self.state.clone();979
let state = self.state.clone();980
let section_ids = self.section_ids.borrow().clone();961
let read_only = self.state.read(cx).mode.read_only;981
let read_only = self.state.read(cx).mode.read_only;962
Button::new("chat-list-more")982
Button::new("chat-list-more")963
.icon(IconName::Ellipsis)983
.icon(IconName::Ellipsis)@@ -965,7 +985,29 @@ impl SidebarView {965
.size(px(NEW_CHAT_BUTTON_SIZE))985
.size(px(NEW_CHAT_BUTTON_SIZE))966
.rounded(px(8.))986
.rounded(px(8.))967
.tooltip("More options")987
.tooltip("More options")968
.dropdown_menu(move |menu, _, _| menu.item(new_section_item(&state, read_only)))988
.dropdown_menu(move |menu, _, _| {989
let (read_state, collapse_state) = (state.clone(), state.clone());990
let section_ids = section_ids.clone();991
menu.item(992
PopupMenuItem::new(MARK_ALL_READ_LABEL)993
.icon(menu_icon(IconName::CheckCheck))994
.disabled(read_only)995
.on_click(move |_, _, cx| {996
read_state.update(cx, |state, cx| state.mark_all_chats_read(cx));997
}),998
)999
.item(1000
PopupMenuItem::new(COLLAPSE_ALL_LABEL)1001
.icon(menu_icon(IconName::ChevronsDownUp))1002
.on_click(move |_, _, cx| {1003
let ids = section_ids.clone();1004
collapse_state1005
.update(cx, |state, cx| state.collapse_sections(&ids, cx));1006
}),1007
)1008
.separator()1009
.item(new_section_item(&state, read_only))1010
})969
}1011
}970
1012
971
fn channel_list_menu_button(&self, cx: &mut Context<Self>) -> impl IntoElement {1013
fn channel_list_menu_button(&self, cx: &mut Context<Self>) -> impl IntoElement {@@ -1168,6 +1210,7 @@ impl SidebarView {1168
})1210
})1169
.text_color(theme::text())1211
.text_color(theme::text())1170
.child(item.title.clone());1212
.child(item.title.clone());1213
let row_group = SharedString::from(format!("chat-row-{}", item.id));1171
let time = h_flex()1214
let time = h_flex()1172
.flex_none()1215
.flex_none()1173
.gap(px(4.))1216
.gap(px(4.))@@ -1178,6 +1221,7 @@ impl SidebarView {1178
} else {1221
} else {1179
theme::text_muted()1222
theme::text_muted()1180
})1223
})1224
.group_hover(row_group.clone(), |time| time.invisible())1181
.child(item.time_label.clone());1225
.child(item.time_label.clone());1182
let preview_color = if matches!(item.preview, Preview::Typing(_)) {1226
let preview_color = if matches!(item.preview, Preview::Typing(_)) {1183
theme::accent_text()1227
theme::accent_text()@@ -1261,9 +1305,30 @@ impl SidebarView {1261
is_group: item.is_group,1305
is_group: item.is_group,1262
member_count: item.member_count,1306
member_count: item.member_count,1263
};1307
};1308
let more_context = menu.clone();1309
let more_target = target.clone();1310
let more_button = div()1311
.absolute()1312
.top(px(ROW_MORE_TOP))1313
.right(px(ROW_MORE_RIGHT))1314
.invisible()1315
.group_hover(row_group.clone(), |button| button.visible())1316
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())1317
.child(1318
Button::new(SharedString::from(format!("chat-more-{}", item.id)))1319
.ghost()1320
.xsmall()1321
.icon(IconName::Ellipsis)1322
.tooltip("More options")1323
.dropdown_menu(move |popup, window, cx| {1324
chat_menu(popup, window, cx, &more_context, &more_target)1325
}),1326
);1264
h_flex()1327
h_flex()1265
.id(SharedString::from(format!("chat-{}", item.id)))1328
.id(SharedString::from(format!("chat-{}", item.id)))1266
.debug_selector(|| chat_row_selector(&item.id))1329
.debug_selector(|| chat_row_selector(&item.id))1330
.group(row_group)1331
.relative()1267
.mx(px(6.))1332
.mx(px(6.))1268
.h(px(ROW_HEIGHT))1333
.h(px(ROW_HEIGHT))1269
.flex_none()1334
.flex_none()@@ -1289,6 +1354,7 @@ impl SidebarView {1289
})1354
})1290
.child(avatar)1355
.child(avatar)1291
.child(lines)1356
.child(lines)1357
.child(more_button)1292
.on_click(move |_, _, cx| {1358
.on_click(move |_, _, cx| {1293
let selection = Selection::Chat(chat_id.clone());1359
let selection = Selection::Chat(chat_id.clone());1294
state.update(cx, |state, cx| state.select(selection, cx));1360
state.update(cx, |state, cx| state.select(selection, cx));@@ -1332,6 +1398,8 @@ impl SidebarView {1332
};1398
};1333
let section_menus =1399
let section_menus =1334
section_menu_targets(§ions, &state.directory, state.mode.read_only);1400
section_menu_targets(§ions, &state.directory, state.mode.read_only);1401
*self.section_ids.borrow_mut() =1402
sections.iter().map(|section| section.id.clone()).collect();1335
(sections, section_menus, menu, state.local_previews.clone())1403
(sections, section_menus, menu, state.local_previews.clone())1336
};1404
};1337
1405
@@ -169,7 +169,7 @@ pub use meeting_join::{
169
169
pub use mentions::{MentionInput, apply_mentions, plain_mention_spans};
170
170
pub use message_link::{
171
171
ChannelAddress, ChannelLinkInput, channel_link, channel_message_link, channel_tab_link,
172
chat_message_link, outlook_compose_link, team_link,
172
chat_link, chat_message_link, outlook_compose_link, team_link,
173
173
};
174
174
pub use message_window::{JumpPlan, WINDOW_PAGE_SIZE, WindowPage, jump_plan, without_islands};
175
175
pub use notes_chat::{is_notes_chat, notes_chat_title};
@@ -169,7 +169,7 @@ pub use meeting_join::{169
pub use mentions::{MentionInput, apply_mentions, plain_mention_spans};169
pub use mentions::{MentionInput, apply_mentions, plain_mention_spans};170
pub use message_link::{170
pub use message_link::{171
ChannelAddress, ChannelLinkInput, channel_link, channel_message_link, channel_tab_link,171
ChannelAddress, ChannelLinkInput, channel_link, channel_message_link, channel_tab_link,172
chat_message_link, outlook_compose_link, team_link,172
chat_link, chat_message_link, outlook_compose_link, team_link,173
};173
};174
pub use message_window::{JumpPlan, WINDOW_PAGE_SIZE, WindowPage, jump_plan, without_islands};174
pub use message_window::{JumpPlan, WINDOW_PAGE_SIZE, WindowPage, jump_plan, without_islands};175
pub use notes_chat::{is_notes_chat, notes_chat_title};175
pub use notes_chat::{is_notes_chat, notes_chat_title};@@ -57,6 +57,14 @@ pub fn chat_message_link(
57
57
)
58
58
}
59
59
60
pub fn chat_link(conversation_id: &str) -> String {
61
let context = json!({"contextType": "chat"});
62
format!(
63
"{LINK_HOST}/l/chat/{conversation_id}/conversations?context={}",
64
encode(&context.to_string())
65
)
66
}
67
60
68
pub fn channel_message_link(input: &ChannelLinkInput) -> String {
61
69
format!(
62
70
"{LINK_HOST}/l/message/{}/{}?tenantId={}&groupId={}&parentMessageId={}&teamName={}&channelName={}&createdTime={}",
@@ -123,6 +131,14 @@ mod tests {
123
131
);
124
132
}
125
133
134
#[test]
135
fn chat_link_opens_the_conversation() {
136
assert_eq!(
137
chat_link("19:abc@thread.v2"),
138
"https://teams.microsoft.com/l/chat/19:abc@thread.v2/conversations?context=%7B%22contextType%22%3A%22chat%22%7D"
139
);
140
}
141
126
142
#[test]
127
143
fn outlook_compose_link_encodes_subject_and_body() {
128
144
assert_eq!(
@@ -57,6 +57,14 @@ pub fn chat_message_link(57
)57
)58
}58
}59
59
60
pub fn chat_link(conversation_id: &str) -> String {61
let context = json!({"contextType": "chat"});62
format!(63
"{LINK_HOST}/l/chat/{conversation_id}/conversations?context={}",64
encode(&context.to_string())65
)66
}67
60
pub fn channel_message_link(input: &ChannelLinkInput) -> String {68
pub fn channel_message_link(input: &ChannelLinkInput) -> String {61
format!(69
format!(62
"{LINK_HOST}/l/message/{}/{}?tenantId={}&groupId={}&parentMessageId={}&teamName={}&channelName={}&createdTime={}",70
"{LINK_HOST}/l/message/{}/{}?tenantId={}&groupId={}&parentMessageId={}&teamName={}&channelName={}&createdTime={}",@@ -123,6 +131,14 @@ mod tests {123
);131
);124
}132
}125
133
134
#[test]135
fn chat_link_opens_the_conversation() {136
assert_eq!(137
chat_link("19:abc@thread.v2"),138
"https://teams.microsoft.com/l/chat/19:abc@thread.v2/conversations?context=%7B%22contextType%22%3A%22chat%22%7D"139
);140
}141
126
#[test]142
#[test]127
fn outlook_compose_link_encodes_subject_and_body() {143
fn outlook_compose_link_encodes_subject_and_body() {128
assert_eq!(144
assert_eq!(