BlueGit

ict rusty-teams

feat(parity): profile menu and settings menu like Teams

- Profile menu: status, Pause notifications (30 min to this week, resume), work location, status message, View account link
- Paused notifications stay silent, also urgent ones; pause survives a restart
- New ... button next to the avatar: Settings, chat list, translation, notifications, test call, zoom

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-08 · 3 weeks ago

Hash
78ae3e37c833899495f90d002de9c4034a5a3416
Parent
5a8ed057
7 files changed +193 −24
crates/app-state/src/app_state.rs +3 −0
@@ -164,6 +164,7 @@ pub struct AppState {
164 164 pub forward_selection: Option<ForwardSelection>,
165 165 pub image_viewer_request: Option<ViewerRequest>,
166 166 pub own_status: PresenceStatus,
167 pub notifications_paused_until: Option<chrono::DateTime<chrono::Utc>>,
167 168 pub own_email: String,
168 169 pub own_time_zone: Option<String>,
169 170 pub own_time_zone_requested: bool,
@@ -264,6 +265,7 @@ impl AppState {
264 265 pub fn new(store: Arc<Store>, mode: Mode) -> Self {
265 266 let sidebar = store.sidebar().unwrap_or_default();
266 267 let speed_dial = crate::call::speed_dial::load(&store);
268 let notifications_paused_until = crate::notify::pause::load(&store);
267 269 let chat_settings = teams_core::stored_chat_settings(&store);
268 270 let markdown_mode = crate::chat_settings_actions::stored_markdown_mode(&store);
269 271 let actions_on_right_click =
@@ -322,6 +324,7 @@ impl AppState {
322 324 forward_selection: None,
323 325 image_viewer_request: None,
324 326 own_status: PresenceStatus::default(),
327 notifications_paused_until,
325 328 own_email: String::new(),
326 329 own_time_zone: None,
327 330 own_time_zone_requested: false,
@@ -164,6 +164,7 @@ pub struct AppState {
164 pub forward_selection: Option<ForwardSelection>,
164 pub forward_selection: Option<ForwardSelection>,
165 pub image_viewer_request: Option<ViewerRequest>,
165 pub image_viewer_request: Option<ViewerRequest>,
166 pub own_status: PresenceStatus,
166 pub own_status: PresenceStatus,
167 pub notifications_paused_until: Option<chrono::DateTime<chrono::Utc>>,
167 pub own_email: String,
168 pub own_email: String,
168 pub own_time_zone: Option<String>,
169 pub own_time_zone: Option<String>,
169 pub own_time_zone_requested: bool,
170 pub own_time_zone_requested: bool,
@@ -264,6 +265,7 @@ impl AppState {
264 pub fn new(store: Arc<Store>, mode: Mode) -> Self {
265 pub fn new(store: Arc<Store>, mode: Mode) -> Self {
265 let sidebar = store.sidebar().unwrap_or_default();
266 let sidebar = store.sidebar().unwrap_or_default();
266 let speed_dial = crate::call::speed_dial::load(&store);
267 let speed_dial = crate::call::speed_dial::load(&store);
268 let notifications_paused_until = crate::notify::pause::load(&store);
267 let chat_settings = teams_core::stored_chat_settings(&store);
269 let chat_settings = teams_core::stored_chat_settings(&store);
268 let markdown_mode = crate::chat_settings_actions::stored_markdown_mode(&store);
270 let markdown_mode = crate::chat_settings_actions::stored_markdown_mode(&store);
269 let actions_on_right_click =
271 let actions_on_right_click =
@@ -322,6 +324,7 @@ impl AppState {
322 forward_selection: None,
324 forward_selection: None,
323 image_viewer_request: None,
325 image_viewer_request: None,
324 own_status: PresenceStatus::default(),
326 own_status: PresenceStatus::default(),
327 notifications_paused_until,
325 own_email: String::new(),
328 own_email: String::new(),
326 own_time_zone: None,
329 own_time_zone: None,
327 own_time_zone_requested: false,
330 own_time_zone_requested: false,
crates/app-state/src/notify/mod.rs +1 −0
@@ -1,5 +1,6 @@
1 1 pub mod incoming;
2 2 pub mod layout;
3 pub mod pause;
3 4 pub mod rules;
4 5 pub mod settings;
5 6 pub mod stack;
@@ -1,5 +1,6 @@
1pub mod incoming;
1pub mod incoming;
2pub mod layout;
2pub mod layout;
3pub mod pause;
3pub mod rules;
4pub mod rules;
4pub mod settings;
5pub mod settings;
5pub mod stack;
6pub mod stack;
crates/app-state/src/notify/pause.rs added +65 −0
@@ -0,0 +1,65 @@
1 use chrono::{DateTime, Local, Utc};
2 use gpui_kit::Context;
3 use store::Store;
4
5 use crate::app_state::AppState;
6 use crate::own_status::until_label;
7
8 const META_KEY: &str = "notify_paused_until";
9 pub const PAUSE_LABEL: &str = "Pause notifications";
10
11 pub fn load(store: &Store) -> Option<DateTime<Utc>> {
12 store
13 .meta(META_KEY)
14 .ok()
15 .flatten()
16 .and_then(|text| DateTime::parse_from_rfc3339(&text).ok())
17 .map(|until| until.with_timezone(&Utc))
18 }
19
20 pub fn is_paused(until: Option<DateTime<Utc>>, now: DateTime<Utc>) -> bool {
21 until.is_some_and(|until| now < until)
22 }
23
24 pub fn menu_label(until: Option<DateTime<Utc>>, now: DateTime<Local>) -> String {
25 match until.filter(|until| now.with_timezone(&Utc) < *until) {
26 Some(until) => format!("Paused {}", until_label(until, &now)),
27 None => PAUSE_LABEL.to_owned(),
28 }
29 }
30
31 impl AppState {
32 pub fn notifications_paused(&self, now: DateTime<Utc>) -> bool {
33 is_paused(self.notifications_paused_until, now)
34 }
35
36 pub fn pause_notifications(&mut self, until: DateTime<Utc>, cx: &mut Context<Self>) {
37 let _ = self.store.set_meta(META_KEY, &until.to_rfc3339());
38 self.notifications_paused_until = Some(until);
39 cx.notify();
40 }
41
42 pub fn resume_notifications(&mut self, cx: &mut Context<Self>) {
43 let _ = self.store.set_meta(META_KEY, "");
44 self.notifications_paused_until = None;
45 cx.notify();
46 }
47 }
48
49 #[cfg(test)]
50 mod tests {
51 use chrono::TimeZone;
52
53 use super::*;
54
55 #[test]
56 fn a_pause_ends_at_its_time() {
57 let until = Utc.with_ymd_and_hms(2026, 11, 8, 15, 0, 0).unwrap();
58 let before = Utc.with_ymd_and_hms(2026, 11, 8, 14, 59, 0).unwrap();
59 assert!(is_paused(Some(until), before));
60 assert!(!is_paused(Some(until), until));
61 assert!(!is_paused(None, before));
62 let later = Local.from_utc_datetime(&until.naive_utc());
63 assert_eq!(menu_label(Some(until), later), PAUSE_LABEL);
64 }
65 }
@@ -0,0 +1,65 @@
1use chrono::{DateTime, Local, Utc};
2use gpui_kit::Context;
3use store::Store;
4
5use crate::app_state::AppState;
6use crate::own_status::until_label;
7
8const META_KEY: &str = "notify_paused_until";
9pub const PAUSE_LABEL: &str = "Pause notifications";
10
11pub fn load(store: &Store) -> Option<DateTime<Utc>> {
12 store
13 .meta(META_KEY)
14 .ok()
15 .flatten()
16 .and_then(|text| DateTime::parse_from_rfc3339(&text).ok())
17 .map(|until| until.with_timezone(&Utc))
18}
19
20pub fn is_paused(until: Option<DateTime<Utc>>, now: DateTime<Utc>) -> bool {
21 until.is_some_and(|until| now < until)
22}
23
24pub fn menu_label(until: Option<DateTime<Utc>>, now: DateTime<Local>) -> String {
25 match until.filter(|until| now.with_timezone(&Utc) < *until) {
26 Some(until) => format!("Paused {}", until_label(until, &now)),
27 None => PAUSE_LABEL.to_owned(),
28 }
29}
30
31impl AppState {
32 pub fn notifications_paused(&self, now: DateTime<Utc>) -> bool {
33 is_paused(self.notifications_paused_until, now)
34 }
35
36 pub fn pause_notifications(&mut self, until: DateTime<Utc>, cx: &mut Context<Self>) {
37 let _ = self.store.set_meta(META_KEY, &until.to_rfc3339());
38 self.notifications_paused_until = Some(until);
39 cx.notify();
40 }
41
42 pub fn resume_notifications(&mut self, cx: &mut Context<Self>) {
43 let _ = self.store.set_meta(META_KEY, "");
44 self.notifications_paused_until = None;
45 cx.notify();
46 }
47}
48
49#[cfg(test)]
50mod tests {
51 use chrono::TimeZone;
52
53 use super::*;
54
55 #[test]
56 fn a_pause_ends_at_its_time() {
57 let until = Utc.with_ymd_and_hms(2026, 11, 8, 15, 0, 0).unwrap();
58 let before = Utc.with_ymd_and_hms(2026, 11, 8, 14, 59, 0).unwrap();
59 assert!(is_paused(Some(until), before));
60 assert!(!is_paused(Some(until), until));
61 assert!(!is_paused(None, before));
62 let later = Local.from_utc_datetime(&until.naive_utc());
63 assert_eq!(menu_label(Some(until), later), PAUSE_LABEL);
64 }
65}
crates/app-state/src/notify/rules.rs +14 −0
@@ -156,6 +156,7 @@ pub struct Environment {
156 156 pub chat_in_foreground: bool,
157 157 pub system_quiet: bool,
158 158 pub own_do_not_disturb: bool,
159 pub paused: bool,
159 160 pub own_busy: bool,
160 161 pub in_call: bool,
161 162 }
@@ -260,6 +261,7 @@ pub fn decide(settings: &Settings, incoming: &Incoming, environment: Environment
260 261 || environment.chat_in_foreground
261 262 || environment.system_quiet
262 263 || (environment.own_do_not_disturb && !urgent)
264 || environment.paused
263 265 || settings.do_not_disturb
264 266 || (settings.mute_in_calls && environment.in_call)
265 267 || (!urgent && !account_toasts(&settings.account, incoming));
@@ -284,6 +286,7 @@ pub fn decide_proposal(
284 286 || environment.chat_in_foreground
285 287 || environment.system_quiet
286 288 || environment.own_do_not_disturb
289 || environment.paused
287 290 || settings.do_not_disturb
288 291 || (settings.mute_in_calls && environment.in_call);
289 292 if suppressed {
@@ -372,6 +375,17 @@ mod tests {
372 375 incoming(ChatKind::Group { member_count: 5 })
373 376 }
374 377
378 #[test]
379 fn paused_notifications_stay_silent_even_when_urgent() {
380 let mut incoming = incoming(ChatKind::Direct);
381 incoming.importance = MessageImportance::Urgent;
382 let paused = Environment {
383 paused: true,
384 ..Environment::default()
385 };
386 assert_eq!(decide(&Settings::default(), &incoming, paused), SILENT);
387 }
388
375 389 #[test]
376 390 fn plain_message_gets_toast_and_sound() {
377 391 let decision = decide(&Settings::default(), &group(), Environment::default());
@@ -156,6 +156,7 @@ pub struct Environment {
156 pub chat_in_foreground: bool,
156 pub chat_in_foreground: bool,
157 pub system_quiet: bool,
157 pub system_quiet: bool,
158 pub own_do_not_disturb: bool,
158 pub own_do_not_disturb: bool,
159 pub paused: bool,
159 pub own_busy: bool,
160 pub own_busy: bool,
160 pub in_call: bool,
161 pub in_call: bool,
161}
162}
@@ -260,6 +261,7 @@ pub fn decide(settings: &Settings, incoming: &Incoming, environment: Environment
260 || environment.chat_in_foreground
261 || environment.chat_in_foreground
261 || environment.system_quiet
262 || environment.system_quiet
262 || (environment.own_do_not_disturb && !urgent)
263 || (environment.own_do_not_disturb && !urgent)
264 || environment.paused
263 || settings.do_not_disturb
265 || settings.do_not_disturb
264 || (settings.mute_in_calls && environment.in_call)
266 || (settings.mute_in_calls && environment.in_call)
265 || (!urgent && !account_toasts(&settings.account, incoming));
267 || (!urgent && !account_toasts(&settings.account, incoming));
@@ -284,6 +286,7 @@ pub fn decide_proposal(
284 || environment.chat_in_foreground
286 || environment.chat_in_foreground
285 || environment.system_quiet
287 || environment.system_quiet
286 || environment.own_do_not_disturb
288 || environment.own_do_not_disturb
289 || environment.paused
287 || settings.do_not_disturb
290 || settings.do_not_disturb
288 || (settings.mute_in_calls && environment.in_call);
291 || (settings.mute_in_calls && environment.in_call);
289 if suppressed {
292 if suppressed {
@@ -372,6 +375,17 @@ mod tests {
372 incoming(ChatKind::Group { member_count: 5 })
375 incoming(ChatKind::Group { member_count: 5 })
373 }
376 }
374
377
378 #[test]
379 fn paused_notifications_stay_silent_even_when_urgent() {
380 let mut incoming = incoming(ChatKind::Direct);
381 incoming.importance = MessageImportance::Urgent;
382 let paused = Environment {
383 paused: true,
384 ..Environment::default()
385 };
386 assert_eq!(decide(&Settings::default(), &incoming, paused), SILENT);
387 }
388
375 #[test]
389 #[test]
376 fn plain_message_gets_toast_and_sound() {
390 fn plain_message_gets_toast_and_sound() {
377 let decision = decide(&Settings::default(), &group(), Environment::default());
391 let decision = decide(&Settings::default(), &group(), Environment::default());
crates/app/src/notify/center.rs +2 −0
@@ -439,10 +439,12 @@ impl NotificationCenter {
439 439 _ => false,
440 440 };
441 441 let in_call = in_call(server_in_call, state.call.as_ref().map(|call| &call.model));
442 let paused = state.notifications_paused(chrono::Utc::now());
442 443 Environment {
443 444 chat_in_foreground: selected && self.main_window_active(cx),
444 445 system_quiet: platform::system_quiet(),
445 446 own_do_not_disturb,
447 paused,
446 448 own_busy,
447 449 in_call,
448 450 }
@@ -439,10 +439,12 @@ impl NotificationCenter {
439 _ => false,
439 _ => false,
440 };
440 };
441 let in_call = in_call(server_in_call, state.call.as_ref().map(|call| &call.model));
441 let in_call = in_call(server_in_call, state.call.as_ref().map(|call| &call.model));
442 let paused = state.notifications_paused(chrono::Utc::now());
442 Environment {
443 Environment {
443 chat_in_foreground: selected && self.main_window_active(cx),
444 chat_in_foreground: selected && self.main_window_active(cx),
444 system_quiet: platform::system_quiet(),
445 system_quiet: platform::system_quiet(),
445 own_do_not_disturb,
446 own_do_not_disturb,
447 paused,
446 own_busy,
448 own_busy,
447 in_call,
449 in_call,
448 }
450 }
crates/app/src/views/shell.rs +2 −1
@@ -40,7 +40,7 @@ use app_ui_kit::render::hooks::RenderHooks;
40 40 use app_ui_kit::layout::{ISLAND_GAP, RAIL_WIDTH, SIDEBAR_WIDTH};
41 41 use super::connection_banner::render_connection_banner;
42 42 use super::notice_toast::NoticeToasts;
43 use super::status_menu::own_status_button;
43 use super::status_menu::{own_status_button, settings_more_button};
44 44 use super::status_message_dialog::{StatusMessageDialog, StatusMessageDialogEvent};
45 45 use super::switcher::{Switcher, SwitcherEvent, candidates_from};
46 46 use super::title_bar::{mode_label, render_title_bar, update_button};
@@ -1069,6 +1069,7 @@ impl Render for AppShell {
1069 1069 &self.update,
1070 1070 cx.listener(|this, _, _, cx| this.restart_into_update(cx)),
1071 1071 ),
1072 Some(settings_more_button(&self.state)),
1072 1073 own_status_button(&self.state, state),
1073 1074 ]
1074 1075 .into_iter()
@@ -40,7 +40,7 @@ use app_ui_kit::render::hooks::RenderHooks;
40use app_ui_kit::layout::{ISLAND_GAP, RAIL_WIDTH, SIDEBAR_WIDTH};
40use app_ui_kit::layout::{ISLAND_GAP, RAIL_WIDTH, SIDEBAR_WIDTH};
41use super::connection_banner::render_connection_banner;
41use super::connection_banner::render_connection_banner;
42use super::notice_toast::NoticeToasts;
42use super::notice_toast::NoticeToasts;
43use super::status_menu::own_status_button;
43use super::status_menu::{own_status_button, settings_more_button};
44use super::status_message_dialog::{StatusMessageDialog, StatusMessageDialogEvent};
44use super::status_message_dialog::{StatusMessageDialog, StatusMessageDialogEvent};
45use super::switcher::{Switcher, SwitcherEvent, candidates_from};
45use super::switcher::{Switcher, SwitcherEvent, candidates_from};
46use super::title_bar::{mode_label, render_title_bar, update_button};
46use super::title_bar::{mode_label, render_title_bar, update_button};
@@ -1069,6 +1069,7 @@ impl Render for AppShell {
1069 &self.update,
1069 &self.update,
1070 cx.listener(|this, _, _, cx| this.restart_into_update(cx)),
1070 cx.listener(|this, _, _, cx| this.restart_into_update(cx)),
1071 ),
1071 ),
1072 Some(settings_more_button(&self.state)),
1072 own_status_button(&self.state, state),
1073 own_status_button(&self.state, state),
1073 ]
1074 ]
1074 .into_iter()
1075 .into_iter()
crates/app/src/views/status_menu.rs +106 −23
@@ -1,4 +1,4 @@
1 use chrono::Local;
1 use chrono::{Local, Utc};
2 2 use gpui_kit::assets::IconName;
3 3 use gpui_kit::component::{
4 4 Side,
@@ -13,6 +13,7 @@ use teams_core::{ForcedAvailability, ForcedKind, PresenceStatus, WorkLocationKin
13 13 use super::avatar::{person_avatar, status_glyph, with_presence, with_presence_badge};
14 14 use super::widgets::{menu_icon, symbol};
15 15 use crate::app_state::AppState;
16 use crate::notify::pause;
16 17 use crate::data::{Person, PresenceKind};
17 18 use crate::own_status::{
18 19 STATUS_CHOICES, STATUS_DURATIONS, StateSummary, StatusDuration, choice_label, duration_target,
@@ -24,6 +25,10 @@ use crate::theme;
24 25 pub const MENU_WIDTH: f32 = 250.;
25 26 pub(crate) const TITLE_AVATAR_SIZE: f32 = 28.;
26 27 pub(crate) const OWN_AVATAR_DISC: &str = "shell/title-bar/own-status/avatar/disc";
28 pub(crate) const SETTINGS_MORE_TAG: &str = "shell/title-bar/settings-more";
29 const SETTINGS_MORE_TITLE: &str = "Settings and more";
30 const VIEW_ACCOUNT_LABEL: &str = "View account";
31 const VIEW_ACCOUNT_URL: &str = "https://myaccount.microsoft.com";
27 32 const TITLE_PRESENCE_SIZE: f32 = 14.;
28 33 const HEADER_AVATAR_SIZE: f32 = 40.;
29 34 const PRESENCE_OVERHANG: f32 = 2.;
@@ -156,6 +161,19 @@ fn header(context: &MenuContext, cx: &App) -> Div {
156 161 .child(context.person.display_name.clone()),
157 162 )
158 163 .child(line(context.email.clone(), theme::text_muted()))
164 .child(
165 h_flex()
166 .id("status-menu-view-account")
167 .gap(px(4.))
168 .items_center()
169 .cursor_pointer()
170 .text_size(px(12.))
171 .text_color(theme::text_soft())
172 .hover(|link| link.text_color(theme::accent_text()))
173 .child(VIEW_ACCOUNT_LABEL)
174 .child(menu_icon(IconName::ExternalLink).size(px(12.)))
175 .on_click(|_, _, cx| cx.open_url(VIEW_ACCOUNT_URL)),
176 )
159 177 .children(
160 178 context
161 179 .note
@@ -173,20 +191,12 @@ fn status_menu(
173 191 ) -> PopupMenu {
174 192 let header_context = context.clone();
175 193 let message_app = context.app.clone();
176 let settings_app = context.app.clone();
177 let chat_list_app = context.app.clone();
178 let translation_app = context.app.clone();
179 let general_app = context.app.clone();
180 let call_app = context.app.clone();
181 let zoom_app = context.app.clone();
182 194 let row_label = match &context.summary.until {
183 195 Some(until) => format!("{} {until}", context.summary.label),
184 196 None => context.summary.label.to_owned(),
185 197 };
186 198 let submenu_context = context.clone();
187 let ring_app = context.app.clone();
188 let demo = context.app.read(cx).mode.demo;
189 let popup = popup
199 popup
190 200 .min_w(px(MENU_WIDTH))
191 201 .item(PopupMenuItem::element(move |_, cx| {
192 202 header(&header_context, cx)
@@ -199,6 +209,7 @@ fn status_menu(
199 209 cx,
200 210 move |submenu, window, cx| state_menu(submenu, window, cx, &submenu_context),
201 211 )
212 .item(pause_item(&context.app, window, cx))
202 213 .item(work_location_item(context, window, cx))
203 214 .item(
204 215 PopupMenuItem::new("Set status message")
@@ -207,6 +218,87 @@ fn status_menu(
207 218 message_app.update(cx, |state, cx| state.request_status_message(cx));
208 219 }),
209 220 )
221 }
222
223 fn pause_item(
224 app: &Entity<AppState>,
225 window: &mut Window,
226 cx: &mut Context<PopupMenu>,
227 ) -> PopupMenuItem {
228 let paused_until = app.read(cx).notifications_paused_until;
229 let paused = pause::is_paused(paused_until, Utc::now());
230 let label = pause::menu_label(paused_until, Local::now());
231 let app = app.clone();
232 let submenu = PopupMenu::build(window, cx, move |menu, _, _| {
233 let resume_app = app.clone();
234 let menu = STATUS_DURATIONS.iter().fold(menu, |menu, duration| {
235 let app = app.clone();
236 let duration = *duration;
237 menu.item(PopupMenuItem::new(duration.label()).on_click(move |_, _, cx| {
238 let until = duration.expires_at(Local::now());
239 app.update(cx, |state, cx| state.pause_notifications(until, cx));
240 }))
241 });
242 if !paused {
243 return menu;
244 }
245 menu.separator().item(
246 PopupMenuItem::new("Resume notifications")
247 .icon(menu_icon(IconName::BellRing))
248 .on_click(move |_, _, cx| {
249 resume_app.update(cx, |state, cx| state.resume_notifications(cx));
250 }),
251 )
252 });
253 PopupMenuItem::submenu(label, submenu).icon(menu_icon(if paused {
254 IconName::BellOff
255 } else {
256 IconName::Bell
257 }))
258 }
259
260 pub fn settings_more_button(app: &Entity<AppState>) -> AnyElement {
261 let app = app.clone();
262 div()
263 .debug_selector(|| SETTINGS_MORE_TAG.into())
264 .flex_none()
265 .child(
266 Button::new("title-settings-more")
267 .ghost()
268 .icon(IconName::Ellipsis)
269 .tooltip(SETTINGS_MORE_TITLE)
270 .dropdown_menu_with_anchor(Anchor::TopRight, move |popup, window, cx| {
271 settings_more_menu(popup, window, cx, &app)
272 }),
273 )
274 .into_any_element()
275 }
276
277 fn settings_more_menu(
278 popup: PopupMenu,
279 _window: &mut Window,
280 cx: &mut Context<PopupMenu>,
281 app: &Entity<AppState>,
282 ) -> PopupMenu {
283 let settings_app = app.clone();
284 let chat_list_app = app.clone();
285 let translation_app = app.clone();
286 let notification_app = app.clone();
287 let call_app = app.clone();
288 let zoom_app = app.clone();
289 let ring_app = app.clone();
290 let demo = app.read(cx).mode.demo;
291 let popup = popup
292 .min_w(px(MENU_WIDTH))
293 .item(
294 PopupMenuItem::new("Settings")
295 .icon(menu_icon(IconName::Settings))
296 .on_click(move |_, _, cx| {
297 settings_app.update(cx, |state, cx| {
298 state.open_settings(SettingsSection::General, cx)
299 });
300 }),
301 )
210 302 .separator()
211 303 .item(
212 304 PopupMenuItem::new("Chat list")
@@ -226,29 +318,20 @@ fn status_menu(
226 318 });
227 319 }),
228 320 )
229 .item(
230 PopupMenuItem::new("Make a test call")
231 .icon(menu_icon(IconName::Phone))
232 .on_click(move |_, _, cx| {
233 call_app.update(cx, |state, cx| state.start_test_call(cx));
234 }),
235 )
236 321 .item(
237 322 PopupMenuItem::new("Notification settings")
238 323 .icon(menu_icon(IconName::Bell))
239 324 .on_click(move |_, _, cx| {
240 settings_app.update(cx, |state, cx| {
325 notification_app.update(cx, |state, cx| {
241 326 state.open_settings(SettingsSection::Notifications, cx)
242 327 });
243 328 }),
244 329 )
245 330 .item(
246 PopupMenuItem::new("Settings")
247 .icon(menu_icon(IconName::Settings))
331 PopupMenuItem::new("Make a test call")
332 .icon(menu_icon(IconName::Phone))
248 333 .on_click(move |_, _, cx| {
249 general_app.update(cx, |state, cx| {
250 state.open_settings(SettingsSection::General, cx)
251 });
334 call_app.update(cx, |state, cx| state.start_test_call(cx));
252 335 }),
253 336 )
254 337 .item(PopupMenuItem::element(move |_, cx| {
@@ -1,4 +1,4 @@
1use chrono::Local;
1use chrono::{Local, Utc};
2use gpui_kit::assets::IconName;
2use gpui_kit::assets::IconName;
3use gpui_kit::component::{
3use gpui_kit::component::{
4 Side,
4 Side,
@@ -13,6 +13,7 @@ use teams_core::{ForcedAvailability, ForcedKind, PresenceStatus, WorkLocationKin
13use super::avatar::{person_avatar, status_glyph, with_presence, with_presence_badge};
13use super::avatar::{person_avatar, status_glyph, with_presence, with_presence_badge};
14use super::widgets::{menu_icon, symbol};
14use super::widgets::{menu_icon, symbol};
15use crate::app_state::AppState;
15use crate::app_state::AppState;
16use crate::notify::pause;
16use crate::data::{Person, PresenceKind};
17use crate::data::{Person, PresenceKind};
17use crate::own_status::{
18use crate::own_status::{
18 STATUS_CHOICES, STATUS_DURATIONS, StateSummary, StatusDuration, choice_label, duration_target,
19 STATUS_CHOICES, STATUS_DURATIONS, StateSummary, StatusDuration, choice_label, duration_target,
@@ -24,6 +25,10 @@ use crate::theme;
24pub const MENU_WIDTH: f32 = 250.;
25pub const MENU_WIDTH: f32 = 250.;
25pub(crate) const TITLE_AVATAR_SIZE: f32 = 28.;
26pub(crate) const TITLE_AVATAR_SIZE: f32 = 28.;
26pub(crate) const OWN_AVATAR_DISC: &str = "shell/title-bar/own-status/avatar/disc";
27pub(crate) const OWN_AVATAR_DISC: &str = "shell/title-bar/own-status/avatar/disc";
28pub(crate) const SETTINGS_MORE_TAG: &str = "shell/title-bar/settings-more";
29const SETTINGS_MORE_TITLE: &str = "Settings and more";
30const VIEW_ACCOUNT_LABEL: &str = "View account";
31const VIEW_ACCOUNT_URL: &str = "https://myaccount.microsoft.com";
27const TITLE_PRESENCE_SIZE: f32 = 14.;
32const TITLE_PRESENCE_SIZE: f32 = 14.;
28const HEADER_AVATAR_SIZE: f32 = 40.;
33const HEADER_AVATAR_SIZE: f32 = 40.;
29const PRESENCE_OVERHANG: f32 = 2.;
34const PRESENCE_OVERHANG: f32 = 2.;
@@ -156,6 +161,19 @@ fn header(context: &MenuContext, cx: &App) -> Div {
156 .child(context.person.display_name.clone()),
161 .child(context.person.display_name.clone()),
157 )
162 )
158 .child(line(context.email.clone(), theme::text_muted()))
163 .child(line(context.email.clone(), theme::text_muted()))
164 .child(
165 h_flex()
166 .id("status-menu-view-account")
167 .gap(px(4.))
168 .items_center()
169 .cursor_pointer()
170 .text_size(px(12.))
171 .text_color(theme::text_soft())
172 .hover(|link| link.text_color(theme::accent_text()))
173 .child(VIEW_ACCOUNT_LABEL)
174 .child(menu_icon(IconName::ExternalLink).size(px(12.)))
175 .on_click(|_, _, cx| cx.open_url(VIEW_ACCOUNT_URL)),
176 )
159 .children(
177 .children(
160 context
178 context
161 .note
179 .note
@@ -173,20 +191,12 @@ fn status_menu(
173) -> PopupMenu {
191) -> PopupMenu {
174 let header_context = context.clone();
192 let header_context = context.clone();
175 let message_app = context.app.clone();
193 let message_app = context.app.clone();
176 let settings_app = context.app.clone();
177 let chat_list_app = context.app.clone();
178 let translation_app = context.app.clone();
179 let general_app = context.app.clone();
180 let call_app = context.app.clone();
181 let zoom_app = context.app.clone();
182 let row_label = match &context.summary.until {
194 let row_label = match &context.summary.until {
183 Some(until) => format!("{} {until}", context.summary.label),
195 Some(until) => format!("{} {until}", context.summary.label),
184 None => context.summary.label.to_owned(),
196 None => context.summary.label.to_owned(),
185 };
197 };
186 let submenu_context = context.clone();
198 let submenu_context = context.clone();
187 let ring_app = context.app.clone();
199 popup
188 let demo = context.app.read(cx).mode.demo;
189 let popup = popup
190 .min_w(px(MENU_WIDTH))
200 .min_w(px(MENU_WIDTH))
191 .item(PopupMenuItem::element(move |_, cx| {
201 .item(PopupMenuItem::element(move |_, cx| {
192 header(&header_context, cx)
202 header(&header_context, cx)
@@ -199,6 +209,7 @@ fn status_menu(
199 cx,
209 cx,
200 move |submenu, window, cx| state_menu(submenu, window, cx, &submenu_context),
210 move |submenu, window, cx| state_menu(submenu, window, cx, &submenu_context),
201 )
211 )
212 .item(pause_item(&context.app, window, cx))
202 .item(work_location_item(context, window, cx))
213 .item(work_location_item(context, window, cx))
203 .item(
214 .item(
204 PopupMenuItem::new("Set status message")
215 PopupMenuItem::new("Set status message")
@@ -207,6 +218,87 @@ fn status_menu(
207 message_app.update(cx, |state, cx| state.request_status_message(cx));
218 message_app.update(cx, |state, cx| state.request_status_message(cx));
208 }),
219 }),
209 )
220 )
221}
222
223fn pause_item(
224 app: &Entity<AppState>,
225 window: &mut Window,
226 cx: &mut Context<PopupMenu>,
227) -> PopupMenuItem {
228 let paused_until = app.read(cx).notifications_paused_until;
229 let paused = pause::is_paused(paused_until, Utc::now());
230 let label = pause::menu_label(paused_until, Local::now());
231 let app = app.clone();
232 let submenu = PopupMenu::build(window, cx, move |menu, _, _| {
233 let resume_app = app.clone();
234 let menu = STATUS_DURATIONS.iter().fold(menu, |menu, duration| {
235 let app = app.clone();
236 let duration = *duration;
237 menu.item(PopupMenuItem::new(duration.label()).on_click(move |_, _, cx| {
238 let until = duration.expires_at(Local::now());
239 app.update(cx, |state, cx| state.pause_notifications(until, cx));
240 }))
241 });
242 if !paused {
243 return menu;
244 }
245 menu.separator().item(
246 PopupMenuItem::new("Resume notifications")
247 .icon(menu_icon(IconName::BellRing))
248 .on_click(move |_, _, cx| {
249 resume_app.update(cx, |state, cx| state.resume_notifications(cx));
250 }),
251 )
252 });
253 PopupMenuItem::submenu(label, submenu).icon(menu_icon(if paused {
254 IconName::BellOff
255 } else {
256 IconName::Bell
257 }))
258}
259
260pub fn settings_more_button(app: &Entity<AppState>) -> AnyElement {
261 let app = app.clone();
262 div()
263 .debug_selector(|| SETTINGS_MORE_TAG.into())
264 .flex_none()
265 .child(
266 Button::new("title-settings-more")
267 .ghost()
268 .icon(IconName::Ellipsis)
269 .tooltip(SETTINGS_MORE_TITLE)
270 .dropdown_menu_with_anchor(Anchor::TopRight, move |popup, window, cx| {
271 settings_more_menu(popup, window, cx, &app)
272 }),
273 )
274 .into_any_element()
275}
276
277fn settings_more_menu(
278 popup: PopupMenu,
279 _window: &mut Window,
280 cx: &mut Context<PopupMenu>,
281 app: &Entity<AppState>,
282) -> PopupMenu {
283 let settings_app = app.clone();
284 let chat_list_app = app.clone();
285 let translation_app = app.clone();
286 let notification_app = app.clone();
287 let call_app = app.clone();
288 let zoom_app = app.clone();
289 let ring_app = app.clone();
290 let demo = app.read(cx).mode.demo;
291 let popup = popup
292 .min_w(px(MENU_WIDTH))
293 .item(
294 PopupMenuItem::new("Settings")
295 .icon(menu_icon(IconName::Settings))
296 .on_click(move |_, _, cx| {
297 settings_app.update(cx, |state, cx| {
298 state.open_settings(SettingsSection::General, cx)
299 });
300 }),
301 )
210 .separator()
302 .separator()
211 .item(
303 .item(
212 PopupMenuItem::new("Chat list")
304 PopupMenuItem::new("Chat list")
@@ -226,29 +318,20 @@ fn status_menu(
226 });
318 });
227 }),
319 }),
228 )
320 )
229 .item(
230 PopupMenuItem::new("Make a test call")
231 .icon(menu_icon(IconName::Phone))
232 .on_click(move |_, _, cx| {
233 call_app.update(cx, |state, cx| state.start_test_call(cx));
234 }),
235 )
236 .item(
321 .item(
237 PopupMenuItem::new("Notification settings")
322 PopupMenuItem::new("Notification settings")
238 .icon(menu_icon(IconName::Bell))
323 .icon(menu_icon(IconName::Bell))
239 .on_click(move |_, _, cx| {
324 .on_click(move |_, _, cx| {
240 settings_app.update(cx, |state, cx| {
325 notification_app.update(cx, |state, cx| {
241 state.open_settings(SettingsSection::Notifications, cx)
326 state.open_settings(SettingsSection::Notifications, cx)
242 });
327 });
243 }),
328 }),
244 )
329 )
245 .item(
330 .item(
246 PopupMenuItem::new("Settings")
331 PopupMenuItem::new("Make a test call")
247 .icon(menu_icon(IconName::Settings))
332 .icon(menu_icon(IconName::Phone))
248 .on_click(move |_, _, cx| {
333 .on_click(move |_, _, cx| {
249 general_app.update(cx, |state, cx| {
334 call_app.update(cx, |state, cx| state.start_test_call(cx));
250 state.open_settings(SettingsSection::General, cx)
251 });
252 }),
335 }),
253 )
336 )
254 .item(PopupMenuItem::element(move |_, cx| {
337 .item(PopupMenuItem::element(move |_, cx| {