BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / profile_card.rs

profile_card.rs

profile_card.rs 26.6 KiB Download Raw
1use std::sync::Arc;
2
3use chrono::Utc;
4use gpui_kit::assets::IconName;
5use gpui_kit::base::GlobalState;
6use gpui_kit::component::scroll::ScrollableElement as _;
7use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
8use gpui_kit::prelude::FluentBuilder as _;
9use gpui_kit::*;
10use teams_core::{OrgPerson, PROFILE_LINK_PREFIX, PersonProfile, WorkLocationKind};
11
12use super::avatar::{person_avatar, with_presence};
13use super::new_chat::Pick;
14use super::new_meeting_dialog::open_new_meeting_with;
15use super::widgets::icon;
16use crate::app_state::{AppHandle, AppState};
17use crate::data::{Presence, PresenceKind, presence_kind_of};
18use crate::people::resolve_names;
19use crate::presence_follow::{NOTIFY_WHEN_AVAILABLE, TURN_OFF_NOTIFICATIONS};
20use crate::profile_model::{
21 ContactKind, ContactRow, StatusBox, contact_rows, has_organization, local_time_label,
22 mailto_url, status_box, status_line, work_location_label,
23};
24use crate::theme::{self, ElevatedSurface as _};
25
26const CARD_WIDTH: f32 = 340.;
27const CARD_RADIUS: f32 = 10.;
28const CARD_PADDING: f32 = 16.;
29const CARD_GAP: f32 = 12.;
30const CARD_MARGIN: f32 = 8.;
31const CLICK_OFFSET: f32 = 4.;
32const PHOTO_SIZE: f32 = 56.;
33const PERSON_ROW_AVATAR: f32 = 22.;
34const STATUS_LINES: usize = 3;
35const REPORTS_MAX_HEIGHT: f32 = 168.;
36const ACTION_HEIGHT: f32 = 30.;
37const SKELETON_HEIGHT: f32 = 10.;
38const SCHEDULE_MEETING: &str = "Schedule meeting";
39const EMAIL: &str = "Email";
40const COPY_EMAIL: &str = "Copy email";
41
42pub enum ProfileCardEvent {
43 Close,
44}
45
46pub struct ProfileCard {
47 app: Entity<AppState>,
48 user_id: String,
49 history: Vec<String>,
50 anchor: Point<Pixels>,
51 contact_open: bool,
52 organization_open: bool,
53 reports_open: bool,
54 focus_handle: FocusHandle,
55 _observation: Subscription,
56}
57
58impl EventEmitter<ProfileCardEvent> for ProfileCard {}
59
60pub fn open_profile(user_id: &str, position: Point<Pixels>, cx: &mut App) {
61 let Some(handle) = cx.try_global::<AppHandle>() else {
62 return;
63 };
64 let (app, user_id) = (handle.0.clone(), user_id.to_owned());
65 app.update(cx, |state, cx| {
66 state.open_profile_card(&user_id, position, cx)
67 });
68}
69
70/// `true` when the link was a profile link and has been handled.
71pub fn open_profile_link(url: &str, position: Point<Pixels>, cx: &mut App) -> bool {
72 match url.strip_prefix(PROFILE_LINK_PREFIX) {
73 Some(user_id) => {
74 open_profile(user_id, position, cx);
75 true
76 }
77 None => false,
78 }
79}
80
81pub fn opens_profile(element: Stateful<Div>, user_id: Option<&str>) -> Stateful<Div> {
82 match user_id {
83 Some(user_id) => {
84 let user_id = user_id.to_owned();
85 element.cursor_pointer().on_click(move |event, _, cx| {
86 cx.stop_propagation();
87 open_profile(&user_id, event.position(), cx)
88 })
89 }
90 None => element,
91 }
92}
93
94impl ProfileCard {
95 pub fn new(
96 app: Entity<AppState>,
97 user_id: String,
98 anchor: Point<Pixels>,
99 window: &mut Window,
100 cx: &mut Context<Self>,
101 ) -> Self {
102 let focus_handle = cx.focus_handle();
103 window.focus(&focus_handle, cx);
104 let observation = cx.observe(&app, |_, _, cx| cx.notify());
105 ProfileCard {
106 app,
107 user_id,
108 history: Vec::new(),
109 anchor,
110 contact_open: true,
111 organization_open: true,
112 reports_open: false,
113 focus_handle,
114 _observation: observation,
115 }
116 }
117
118 pub fn move_to(&mut self, user_id: String, anchor: Point<Pixels>, cx: &mut Context<Self>) {
119 self.history.clear();
120 self.anchor = anchor;
121 self.show(user_id, false, cx);
122 }
123
124 fn show(&mut self, user_id: String, remember: bool, cx: &mut Context<Self>) {
125 if remember {
126 self.history
127 .push(std::mem::replace(&mut self.user_id, user_id));
128 } else {
129 self.user_id = user_id;
130 }
131 self.reports_open = false;
132 let id = self.user_id.clone();
133 self.app.update(cx, |state, cx| {
134 state.request_profile(&id, false, cx);
135 state.request_avatars(vec![id.clone()], cx);
136 });
137 cx.notify();
138 }
139
140 fn go_back(&mut self, cx: &mut Context<Self>) {
141 if let Some(previous) = self.history.pop() {
142 self.show(previous, false, cx);
143 }
144 }
145
146 fn on_key_down(&mut self, event: &KeyDownEvent, _: &mut Window, cx: &mut Context<Self>) {
147 if event.keystroke.key == "escape" {
148 cx.emit(ProfileCardEvent::Close);
149 }
150 }
151
152 fn display_name(&self, profile: Option<&PersonProfile>, cx: &App) -> String {
153 profile
154 .and_then(|profile| profile.display_name.clone())
155 .or_else(|| {
156 resolve_names(self.app.read(cx), std::slice::from_ref(&self.user_id))
157 .remove(&self.user_id)
158 })
159 .unwrap_or_else(|| "Unknown person".to_owned())
160 }
161
162 fn presence(&self, profile: Option<&PersonProfile>, cx: &App) -> Presence {
163 let directory = self.app.read(cx).directory.presence_of(&self.user_id);
164 match (directory, profile.and_then(|profile| profile.availability)) {
165 (Presence::Live(kind), _) if kind != PresenceKind::Unknown => directory,
166 (_, Some(availability)) => Presence::Live(presence_kind_of(availability)),
167 _ => directory,
168 }
169 }
170
171 fn header(&self, profile: Option<&PersonProfile>, failed: bool, cx: &App) -> Div {
172 let name = self.display_name(profile, cx);
173 let presence = self.presence(profile, cx);
174 let directory = &self.app.read(cx).directory;
175 let photo = with_presence(
176 person_avatar(directory, Some(&self.user_id), &name, PHOTO_SIZE),
177 presence,
178 PHOTO_SIZE,
179 theme::surface_raised(),
180 );
181 let availability = directory.status_label(&self.user_id, presence);
182 let local_time = profile.and_then(|profile| local_time_label(profile, Utc::now()));
183 let subline = status_line(availability, local_time.as_deref());
184 let details = v_flex()
185 .gap(px(1.))
186 .children(profile.into_iter().flat_map(|profile| {
187 [&profile.job_title, &profile.department]
188 .into_iter()
189 .flatten()
190 .filter(|text| !text.trim().is_empty())
191 .map(|text| muted_line(text.clone()))
192 .collect::<Vec<_>>()
193 }));
194 let work_location = profile
195 .and_then(|profile| profile.work_location)
196 .map(|location| {
197 let glyph = match location.kind {
198 WorkLocationKind::Office => IconName::Building2,
199 WorkLocationKind::Remote => IconName::House,
200 };
201 h_flex()
202 .gap(px(5.))
203 .items_center()
204 .child(icon(glyph, 13., theme::text_muted()))
205 .child(muted_line(work_location_label(location).to_owned()))
206 });
207 let loading = profile.is_none() && !failed;
208 h_flex().gap(px(12.)).items_center().child(photo).child(
209 v_flex()
210 .flex_1()
211 .min_w_0()
212 .gap(px(2.))
213 .child(
214 div()
215 .truncate()
216 .text_size(px(15.))
217 .font_weight(FontWeight::SEMIBOLD)
218 .text_color(theme::text())
219 .child(name),
220 )
221 .when(!subline.is_empty(), |column| {
222 column.child(muted_line(subline))
223 })
224 .children(work_location)
225 .child(details)
226 .when(loading, |column| column.child(skeleton(0.6))),
227 )
228 }
229
230 fn status_box(&self, status: &StatusBox) -> AnyElement {
231 let (background, foreground) = if status.out_of_office {
232 (theme::amber().opacity(0.12), theme::amber())
233 } else {
234 (theme::surface(), theme::text_soft())
235 };
236 let full_text = status.text.clone();
237 div()
238 .id("profile-status")
239 .w_full()
240 .px(px(10.))
241 .py(px(8.))
242 .rounded(px(6.))
243 .bg(background)
244 .text_color(foreground)
245 .text_size(px(12.))
246 .line_height(relative(1.4))
247 .child(
248 div()
249 .line_clamp(STATUS_LINES)
250 .text_ellipsis()
251 .child(status.text.clone()),
252 )
253 .tooltip(move |window, cx| Tooltip::new(full_text.clone()).build(window, cx))
254 .into_any_element()
255 }
256
257 fn actions(&self, email: Option<String>, cx: &mut Context<Self>) -> Div {
258 let is_me = self
259 .app
260 .read(cx)
261 .directory
262 .me
263 .as_ref()
264 .is_some_and(|me| me.user_id == self.user_id);
265 let profile = self
266 .app
267 .read(cx)
268 .profiles
269 .get(&self.user_id)
270 .and_then(|entry| entry.profile.clone());
271 let name = self.display_name(profile.as_deref(), cx);
272 let user_id = self.user_id.clone();
273 let (mail_email, copy_email) = (email.clone(), email.clone());
274 let invitee = Pick {
275 user_id: user_id.clone(),
276 name: name.clone(),
277 mail: email,
278 organization: None,
279 };
280 let chat_id = user_id.clone();
281 let (video_id, audio_id) = (user_id.clone(), user_id.clone());
282 let followed = self.app.read(cx).is_presence_followed(&user_id);
283 let (follow_id, follow_name) = (user_id.clone(), name.clone());
284 h_flex()
285 .gap(px(8.))
286 .when(!is_me, |row| {
287 row.child(
288 action_button("profile-chat", "Chat", IconName::MessageSquare, true).on_click(
289 cx.listener(move |this, _, _, cx| {
290 let user_id = chat_id.clone();
291 this.app
292 .update(cx, |state, cx| state.open_chat_with(&user_id, cx));
293 cx.emit(ProfileCardEvent::Close);
294 }),
295 ),
296 )
297 .child(
298 icon_action(
299 "profile-video-call",
300 IconName::Video,
301 video_call_tooltip(&name),
302 )
303 .on_click(cx.listener(move |this, _, _, cx| {
304 let user_id = video_id.clone();
305 this.app
306 .update(cx, |state, cx| state.call_person(&user_id, true, cx));
307 cx.emit(ProfileCardEvent::Close);
308 })),
309 )
310 .child(
311 icon_action(
312 "profile-audio-call",
313 IconName::Phone,
314 audio_call_tooltip(&name),
315 )
316 .on_click(cx.listener(move |this, _, _, cx| {
317 let user_id = audio_id.clone();
318 this.app
319 .update(cx, |state, cx| state.call_person(&user_id, false, cx));
320 cx.emit(ProfileCardEvent::Close);
321 })),
322 )
323 .child(
324 icon_action(
325 "profile-schedule-meeting",
326 IconName::Calendar,
327 SCHEDULE_MEETING.to_owned(),
328 )
329 .on_click(cx.listener(move |this, _, window, cx| {
330 open_new_meeting_with(this.app.clone(), vec![invitee.clone()], window, cx);
331 cx.emit(ProfileCardEvent::Close);
332 })),
333 )
334 .child(
335 icon_action(
336 "profile-follow-presence",
337 if followed {
338 IconName::BellOff
339 } else {
340 IconName::BellRing
341 },
342 if followed {
343 TURN_OFF_NOTIFICATIONS
344 } else {
345 NOTIFY_WHEN_AVAILABLE
346 }
347 .to_owned(),
348 )
349 .on_click(cx.listener(move |this, _, _, cx| {
350 let (user_id, name) = (follow_id.clone(), follow_name.clone());
351 this.app.update(cx, |state, cx| {
352 state.set_presence_followed(&user_id, &name, !followed, cx)
353 });
354 })),
355 )
356 })
357 .when_some(mail_email, |row, address| {
358 row.child(
359 icon_action("profile-email", IconName::Mail, EMAIL.to_owned()).on_click(
360 cx.listener(move |_, _, _, cx| {
361 app_base::open_link::open_url(cx, &mailto_url(&address));
362 cx.emit(ProfileCardEvent::Close);
363 }),
364 ),
365 )
366 })
367 .when_some(copy_email, |row, address| {
368 row.child(
369 icon_action("profile-copy-email", IconName::Copy, COPY_EMAIL.to_owned())
370 .on_click(cx.listener(move |this, _, _, cx| {
371 this.app
372 .update(cx, |state, cx| state.copy_profile_email(&address, cx));
373 cx.emit(ProfileCardEvent::Close);
374 })),
375 )
376 })
377 }
378
379 fn section_header(
380 &self,
381 id: &'static str,
382 label: &'static str,
383 open: bool,
384 cx: &mut Context<Self>,
385 ) -> Stateful<Div> {
386 h_flex()
387 .id(id)
388 .gap(px(4.))
389 .items_center()
390 .cursor_pointer()
391 .text_size(px(12.))
392 .font_weight(FontWeight::SEMIBOLD)
393 .text_color(theme::text_muted())
394 .child(icon(
395 if open {
396 IconName::ChevronDown
397 } else {
398 IconName::ChevronRight
399 },
400 14.,
401 theme::text_muted(),
402 ))
403 .child(label)
404 .on_click(cx.listener(move |this, _, _, cx| {
405 match id {
406 "profile-contact-header" => this.contact_open = !this.contact_open,
407 _ => this.organization_open = !this.organization_open,
408 }
409 cx.notify();
410 }))
411 }
412
413 fn contact_section(&self, rows: Vec<ContactRow>, cx: &mut Context<Self>) -> Div {
414 let open = self.contact_open;
415 v_flex()
416 .gap(px(6.))
417 .child(self.section_header("profile-contact-header", "Contact", open, cx))
418 .when(open, |section| {
419 section.children(rows.into_iter().map(contact_row))
420 })
421 }
422
423 fn person_row(
424 &self,
425 id: String,
426 person: &OrgPerson,
427 caption: Option<&'static str>,
428 cx: &mut Context<Self>,
429 ) -> Stateful<Div> {
430 let name = person.display_name.clone().unwrap_or_default();
431 let subtitle = caption
432 .map(str::to_owned)
433 .or_else(|| person.job_title.clone())
434 .filter(|text| !text.is_empty());
435 let target = person.id.clone();
436 let directory = &self.app.read(cx).directory;
437 h_flex()
438 .id(ElementId::Name(id.into()))
439 .gap(px(8.))
440 .px(px(4.))
441 .py(px(3.))
442 .items_center()
443 .rounded(px(6.))
444 .cursor_pointer()
445 .hover(|row| row.bg(theme::row_hover()))
446 .child(person_avatar(
447 directory,
448 Some(&person.id),
449 &name,
450 PERSON_ROW_AVATAR,
451 ))
452 .child(
453 div()
454 .truncate()
455 .text_size(px(12.5))
456 .text_color(theme::text())
457 .child(name),
458 )
459 .children(
460 subtitle.map(|text| div().flex_1().min_w_0().truncate().child(muted_text(text))),
461 )
462 .on_click(cx.listener(move |this, _, _, cx| this.show(target.clone(), true, cx)))
463 }
464
465 fn organization_section(&self, profile: &PersonProfile, cx: &mut Context<Self>) -> Div {
466 let open = self.organization_open;
467 let mut section = v_flex().gap(px(4.)).child(self.section_header(
468 "profile-organization-header",
469 "Organization",
470 open,
471 cx,
472 ));
473 if !open {
474 return section;
475 }
476 if let Some(manager) = &profile.manager {
477 section = section.child(self.person_row(
478 "profile-manager".to_owned(),
479 manager,
480 Some("Manager"),
481 cx,
482 ));
483 }
484 let count = profile.direct_reports.len();
485 if count > 0 {
486 let label = match count {
487 1 => "1 direct report".to_owned(),
488 count => format!("{count} direct reports"),
489 };
490 let reports_open = self.reports_open;
491 section = section.child(
492 h_flex()
493 .id("profile-reports-toggle")
494 .gap(px(4.))
495 .px(px(4.))
496 .py(px(3.))
497 .items_center()
498 .cursor_pointer()
499 .text_size(px(12.5))
500 .text_color(theme::text_soft())
501 .child(label)
502 .child(icon(
503 if reports_open {
504 IconName::ChevronDown
505 } else {
506 IconName::ChevronRight
507 },
508 14.,
509 theme::text_muted(),
510 ))
511 .on_click(cx.listener(|this, _, _, cx| {
512 this.reports_open = !this.reports_open;
513 cx.notify();
514 })),
515 );
516 if reports_open {
517 let rows: Vec<Stateful<Div>> = profile
518 .direct_reports
519 .iter()
520 .enumerate()
521 .map(|(index, person)| {
522 self.person_row(format!("profile-report-{index}"), person, None, cx)
523 })
524 .collect();
525 section = section.child(
526 v_flex()
527 .id("profile-reports")
528 .max_h(px(REPORTS_MAX_HEIGHT))
529 .overflow_y_scrollbar()
530 .children(rows),
531 );
532 }
533 }
534 section
535 }
536
537 fn loading_sections(&self) -> Div {
538 v_flex()
539 .gap(px(8.))
540 .child(skeleton(1.))
541 .child(skeleton(0.8))
542 .child(skeleton(0.5))
543 }
544
545 fn failure(&self, cx: &mut Context<Self>) -> Div {
546 h_flex()
547 .gap(px(6.))
548 .text_size(px(12.))
549 .text_color(theme::red_soft())
550 .child("Profile details could not be loaded.")
551 .child(
552 div()
553 .id("profile-retry")
554 .cursor_pointer()
555 .underline()
556 .text_color(theme::red_tint())
557 .child("Retry")
558 .on_click(cx.listener(|this, _, _, cx| {
559 let id = this.user_id.clone();
560 this.app
561 .update(cx, |state, cx| state.request_profile(&id, true, cx));
562 })),
563 )
564 }
565
566 fn body(&self, entry_state: EntryState, cx: &mut Context<Self>) -> Vec<AnyElement> {
567 let EntryState { profile, failed } = entry_state;
568 let mut parts: Vec<AnyElement> = Vec::new();
569 let Some(profile) = profile else {
570 parts.push(self.actions(None, cx).into_any_element());
571 parts.push(if failed {
572 self.failure(cx).into_any_element()
573 } else {
574 self.loading_sections().into_any_element()
575 });
576 return parts;
577 };
578 if let Some(status) = status_box(&profile) {
579 parts.push(self.status_box(&status));
580 }
581 parts.push(self.actions(profile.email.clone(), cx).into_any_element());
582 let rows = contact_rows(&profile);
583 if !rows.is_empty() {
584 parts.push(self.contact_section(rows, cx).into_any_element());
585 }
586 if has_organization(&profile) {
587 parts.push(self.organization_section(&profile, cx).into_any_element());
588 }
589 if failed {
590 parts.push(self.failure(cx).into_any_element());
591 }
592 parts
593 }
594}
595
596struct EntryState {
597 profile: Option<Arc<PersonProfile>>,
598 failed: bool,
599}
600
601fn muted_text(text: String) -> Div {
602 div()
603 .text_size(px(12.))
604 .text_color(theme::text_muted())
605 .child(text)
606}
607
608fn muted_line(text: String) -> Div {
609 muted_text(text).truncate()
610}
611
612fn skeleton(width_ratio: f32) -> Div {
613 div()
614 .h(px(SKELETON_HEIGHT))
615 .w(relative(width_ratio))
616 .rounded(px(4.))
617 .bg(theme::popup_hover())
618}
619
620fn contact_row(row: ContactRow) -> Div {
621 let glyph = match row.kind {
622 ContactKind::Email => IconName::Mail,
623 ContactKind::WorkPhone => IconName::Phone,
624 ContactKind::MobilePhone => IconName::Smartphone,
625 ContactKind::Office => IconName::MapPin,
626 };
627 h_flex()
628 .gap(px(8.))
629 .px(px(4.))
630 .items_center()
631 .child(icon(glyph, 14., theme::text_muted()))
632 .child(
633 div()
634 .flex_1()
635 .min_w_0()
636 .truncate()
637 .text_size(px(12.5))
638 .text_color(theme::text())
639 .child(row.value),
640 )
641}
642
643pub fn video_call_tooltip(name: &str) -> String {
644 format!("Start a video call with {name}")
645}
646
647pub fn audio_call_tooltip(name: &str) -> String {
648 format!("Start an audio call with {name}")
649}
650
651fn icon_action(id: &'static str, glyph: IconName, tooltip: String) -> Stateful<Div> {
652 div()
653 .id(id)
654 .size(px(ACTION_HEIGHT))
655 .flex()
656 .flex_none()
657 .items_center()
658 .justify_center()
659 .rounded(px(6.))
660 .cursor_pointer()
661 .bg(theme::popup_hover())
662 .hover(|button| button.opacity(0.9))
663 .child(icon(glyph, 14., theme::text_soft()))
664 .tooltip(move |window, cx| Tooltip::new(tooltip.clone()).build(window, cx))
665}
666
667fn action_button(
668 id: &'static str,
669 label: &'static str,
670 glyph: IconName,
671 filled: bool,
672) -> Stateful<Div> {
673 let (foreground, background) = if filled {
674 (theme::on_accent(), theme::accent())
675 } else {
676 (theme::text_soft(), theme::popup_hover())
677 };
678 h_flex()
679 .id(id)
680 .h(px(ACTION_HEIGHT))
681 .px(px(10.))
682 .gap(px(6.))
683 .items_center()
684 .justify_center()
685 .rounded(px(6.))
686 .cursor_pointer()
687 .bg(background)
688 .text_color(foreground)
689 .text_size(px(12.5))
690 .font_weight(FontWeight::SEMIBOLD)
691 .hover(|button| button.opacity(0.9))
692 .child(icon(glyph, 14., foreground))
693 .child(label)
694}
695
696impl Render for ProfileCard {
697 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
698 let entry_state = self
699 .app
700 .read(cx)
701 .profiles
702 .get(&self.user_id)
703 .map(|entry| EntryState {
704 profile: entry.profile.clone(),
705 failed: entry.failed,
706 })
707 .unwrap_or(EntryState {
708 profile: None,
709 failed: false,
710 });
711 let profile = entry_state.profile.clone();
712 let header = self.header(profile.as_deref(), entry_state.failed, cx);
713 let body = self.body(entry_state, cx);
714 let back = (!self.history.is_empty()).then(|| {
715 h_flex()
716 .id("profile-back")
717 .gap(px(4.))
718 .items_center()
719 .cursor_pointer()
720 .text_size(px(12.))
721 .text_color(theme::text_muted())
722 .hover(|button| button.text_color(theme::text()))
723 .child(icon(IconName::ArrowLeft, 14., theme::text_muted()))
724 .child("Back")
725 .on_click(cx.listener(|this, _, _, cx| this.go_back(cx)))
726 });
727 let card = v_flex()
728 .id("profile-card")
729 .track_focus(&self.focus_handle)
730 .w(px(CARD_WIDTH))
731 .p(px(CARD_PADDING))
732 .gap(px(CARD_GAP))
733 .rounded(px(CARD_RADIUS))
734 .flyout_surface()
735 .text_color(theme::text())
736 .occlude()
737 .on_key_down(cx.listener(Self::on_key_down))
738 .on_mouse_down(MouseButton::Left, |_, _, cx| {
739 GlobalState::suppress_text_selection(cx);
740 cx.stop_propagation();
741 })
742 .on_mouse_down(MouseButton::Right, |_, _, cx| cx.stop_propagation())
743 .children(back)
744 .child(header)
745 .children(body);
746 let offset = point(px(CLICK_OFFSET), px(CLICK_OFFSET));
747 div()
748 .id("profile-layer")
749 .absolute()
750 .top_0()
751 .left_0()
752 .size_full()
753 .occlude()
754 .on_mouse_down(
755 MouseButton::Left,
756 cx.listener(|_, _, _, cx| cx.emit(ProfileCardEvent::Close)),
757 )
758 .on_mouse_down(
759 MouseButton::Right,
760 cx.listener(|_, _, _, cx| cx.emit(ProfileCardEvent::Close)),
761 )
762 .child(
763 deferred(
764 anchored()
765 .position(self.anchor + offset)
766 .anchor(Anchor::TopLeft)
767 .snap_to_window_with_margin(px(CARD_MARGIN))
768 .child(card),
769 )
770 .with_priority(2),
771 )
772 }
773}
774
775#[cfg(test)]
776mod tests {
777 use super::{audio_call_tooltip, video_call_tooltip};
778
779 #[test]
780 fn call_tooltips_use_the_teams_wording() {
781 assert_eq!(video_call_tooltip("Ann"), "Start a video call with Ann");
782 assert_eq!(audio_call_tooltip("Ann"), "Start an audio call with Ann");
783 }
784}