1mod application_menu;
2mod collab;
3mod onboarding_banner;
4pub mod platform_title_bar;
5mod platforms;
6mod system_window_tabs;
7mod title_bar_settings;
8
9#[cfg(feature = "stories")]
10mod stories;
11
12use crate::{
13 application_menu::{ApplicationMenu, show_menus},
14 platform_title_bar::PlatformTitleBar,
15 system_window_tabs::SystemWindowTabs,
16};
17
18#[cfg(not(target_os = "macos"))]
19use crate::application_menu::{
20 ActivateDirection, ActivateMenuLeft, ActivateMenuRight, OpenApplicationMenu,
21};
22
23use auto_update::AutoUpdateStatus;
24use call::ActiveCall;
25use client::{Client, UserStore, zed_urls};
26use cloud_llm_client::{Plan, PlanV1, PlanV2};
27use gpui::{
28 Action, AnyElement, App, Context, Corner, Element, Entity, Focusable, InteractiveElement,
29 IntoElement, MouseButton, ParentElement, Render, StatefulInteractiveElement, Styled,
30 Subscription, WeakEntity, Window, actions, div,
31};
32use onboarding_banner::OnboardingBanner;
33use project::{
34 Project, WorktreeSettings,
35 git_store::{GitStoreEvent, RepositoryEvent},
36};
37use remote::RemoteConnectionOptions;
38use settings::{Settings, SettingsLocation};
39use std::sync::Arc;
40use theme::ActiveTheme;
41use title_bar_settings::TitleBarSettings;
42use ui::{
43 Avatar, Button, ButtonLike, ButtonStyle, Chip, ContextMenu, Icon, IconName, IconSize,
44 IconWithIndicator, Indicator, PopoverMenu, PopoverMenuHandle, Tooltip, h_flex, prelude::*,
45};
46use util::{ResultExt, rel_path::RelPath};
47use workspace::{Workspace, notifications::NotifyResultExt};
48use zed_actions::{OpenRecent, OpenRemote};
49
50pub use onboarding_banner::restore_banner;
51
52#[cfg(feature = "stories")]
53pub use stories::*;
54
55const MAX_PROJECT_NAME_LENGTH: usize = 40;
56const MAX_BRANCH_NAME_LENGTH: usize = 40;
57const MAX_SHORT_SHA_LENGTH: usize = 8;
58
59actions!(
60 collab,
61 [
62 /// Toggles the user menu dropdown.
63 ToggleUserMenu,
64 /// Toggles the project menu dropdown.
65 ToggleProjectMenu,
66 /// Switches to a different git branch.
67 SwitchBranch
68 ]
69);
70
71pub fn init(cx: &mut App) {
72 TitleBarSettings::register(cx);
73 SystemWindowTabs::init(cx);
74
75 cx.observe_new(|workspace: &mut Workspace, window, cx| {
76 let Some(window) = window else {
77 return;
78 };
79 let item = cx.new(|cx| TitleBar::new("title-bar", workspace, window, cx));
80 workspace.set_titlebar_item(item.into(), window, cx);
81
82 #[cfg(not(target_os = "macos"))]
83 workspace.register_action(|workspace, action: &OpenApplicationMenu, window, cx| {
84 if let Some(titlebar) = workspace
85 .titlebar_item()
86 .and_then(|item| item.downcast::<TitleBar>().ok())
87 {
88 titlebar.update(cx, |titlebar, cx| {
89 if let Some(ref menu) = titlebar.application_menu {
90 menu.update(cx, |menu, cx| menu.open_menu(action, window, cx));
91 }
92 });
93 }
94 });
95
96 #[cfg(not(target_os = "macos"))]
97 workspace.register_action(|workspace, _: &ActivateMenuRight, window, cx| {
98 if let Some(titlebar) = workspace
99 .titlebar_item()
100 .and_then(|item| item.downcast::<TitleBar>().ok())
101 {
102 titlebar.update(cx, |titlebar, cx| {
103 if let Some(ref menu) = titlebar.application_menu {
104 menu.update(cx, |menu, cx| {
105 menu.navigate_menus_in_direction(ActivateDirection::Right, window, cx)
106 });
107 }
108 });
109 }
110 });
111
112 #[cfg(not(target_os = "macos"))]
113 workspace.register_action(|workspace, _: &ActivateMenuLeft, window, cx| {
114 if let Some(titlebar) = workspace
115 .titlebar_item()
116 .and_then(|item| item.downcast::<TitleBar>().ok())
117 {
118 titlebar.update(cx, |titlebar, cx| {
119 if let Some(ref menu) = titlebar.application_menu {
120 menu.update(cx, |menu, cx| {
121 menu.navigate_menus_in_direction(ActivateDirection::Left, window, cx)
122 });
123 }
124 });
125 }
126 });
127 })
128 .detach();
129}
130
131pub struct TitleBar {
132 platform_titlebar: Entity<PlatformTitleBar>,
133 project: Entity<Project>,
134 user_store: Entity<UserStore>,
135 client: Arc<Client>,
136 workspace: WeakEntity<Workspace>,
137 application_menu: Option<Entity<ApplicationMenu>>,
138 _subscriptions: Vec<Subscription>,
139 banner: Entity<OnboardingBanner>,
140 screen_share_popover_handle: PopoverMenuHandle<ContextMenu>,
141}
142
143impl Render for TitleBar {
144 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
145 let title_bar_settings = *TitleBarSettings::get_global(cx);
146
147 let show_menus = show_menus(cx);
148
149 let mut children = Vec::new();
150
151 children.push(
152 h_flex()
153 .gap_1()
154 .map(|title_bar| {
155 let mut render_project_items = title_bar_settings.show_branch_name
156 || title_bar_settings.show_project_items;
157 title_bar
158 .when_some(
159 self.application_menu.clone().filter(|_| !show_menus),
160 |title_bar, menu| {
161 render_project_items &=
162 !menu.update(cx, |menu, cx| menu.all_menus_shown(cx));
163 title_bar.child(menu)
164 },
165 )
166 .when(render_project_items, |title_bar| {
167 title_bar
168 .when(title_bar_settings.show_project_items, |title_bar| {
169 title_bar
170 .children(self.render_project_host(cx))
171 .child(self.render_project_name(cx))
172 })
173 .when(title_bar_settings.show_branch_name, |title_bar| {
174 title_bar.children(self.render_project_branch(cx))
175 })
176 })
177 })
178 .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
179 .into_any_element(),
180 );
181
182 children.push(self.render_collaborator_list(window, cx).into_any_element());
183
184 if title_bar_settings.show_onboarding_banner {
185 children.push(self.banner.clone().into_any_element())
186 }
187
188 let status = self.client.status();
189 let status = &*status.borrow();
190 let user = self.user_store.read(cx).current_user();
191
192 let signed_in = user.is_some();
193
194 children.push(
195 h_flex()
196 .map(|this| {
197 if signed_in {
198 this.pr_1p5()
199 } else {
200 this.pr_1()
201 }
202 })
203 .gap_1()
204 .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
205 .children(self.render_call_controls(window, cx))
206 .children(self.render_connection_status(status, cx))
207 .when(
208 user.is_none() && TitleBarSettings::get_global(cx).show_sign_in,
209 |el| el.child(self.render_sign_in_button(cx)),
210 )
211 .child(self.render_app_menu_button(cx))
212 .into_any_element(),
213 );
214
215 if show_menus {
216 self.platform_titlebar.update(cx, |this, _| {
217 this.set_children(
218 self.application_menu
219 .clone()
220 .map(|menu| menu.into_any_element()),
221 );
222 });
223
224 let height = PlatformTitleBar::height(window);
225 let title_bar_color = self.platform_titlebar.update(cx, |platform_titlebar, cx| {
226 platform_titlebar.title_bar_color(window, cx)
227 });
228
229 v_flex()
230 .w_full()
231 .child(self.platform_titlebar.clone().into_any_element())
232 .child(
233 h_flex()
234 .bg(title_bar_color)
235 .h(height)
236 .pl_2()
237 .justify_between()
238 .w_full()
239 .children(children),
240 )
241 .into_any_element()
242 } else {
243 self.platform_titlebar.update(cx, |this, _| {
244 this.set_children(children);
245 });
246 self.platform_titlebar.clone().into_any_element()
247 }
248 }
249}
250
251impl TitleBar {
252 pub fn new(
253 id: impl Into<ElementId>,
254 workspace: &Workspace,
255 window: &mut Window,
256 cx: &mut Context<Self>,
257 ) -> Self {
258 let project = workspace.project().clone();
259 let git_store = project.read(cx).git_store().clone();
260 let user_store = workspace.app_state().user_store.clone();
261 let client = workspace.app_state().client.clone();
262 let active_call = ActiveCall::global(cx);
263
264 let platform_style = PlatformStyle::platform();
265 let application_menu = match platform_style {
266 PlatformStyle::Mac => {
267 if option_env!("ZED_USE_CROSS_PLATFORM_MENU").is_some() {
268 Some(cx.new(|cx| ApplicationMenu::new(window, cx)))
269 } else {
270 None
271 }
272 }
273 PlatformStyle::Linux | PlatformStyle::Windows => {
274 Some(cx.new(|cx| ApplicationMenu::new(window, cx)))
275 }
276 };
277
278 let mut subscriptions = Vec::new();
279 subscriptions.push(
280 cx.observe(&workspace.weak_handle().upgrade().unwrap(), |_, _, cx| {
281 cx.notify()
282 }),
283 );
284 subscriptions.push(cx.subscribe(&project, |_, _, _: &project::Event, cx| cx.notify()));
285 subscriptions.push(cx.observe(&active_call, |this, _, cx| this.active_call_changed(cx)));
286 subscriptions.push(cx.observe_window_activation(window, Self::window_activation_changed));
287 subscriptions.push(
288 cx.subscribe(&git_store, move |_, _, event, cx| match event {
289 GitStoreEvent::ActiveRepositoryChanged(_)
290 | GitStoreEvent::RepositoryUpdated(_, RepositoryEvent::Updated { .. }, _)
291 | GitStoreEvent::RepositoryAdded(_)
292 | GitStoreEvent::RepositoryRemoved(_) => {
293 cx.notify();
294 }
295 _ => {}
296 }),
297 );
298 subscriptions.push(cx.observe(&user_store, |_, _, cx| cx.notify()));
299
300 let banner = cx.new(|cx| {
301 OnboardingBanner::new(
302 "ACP Claude Code Onboarding",
303 IconName::AiClaude,
304 "Claude Code",
305 Some("Introducing:".into()),
306 zed_actions::agent::OpenClaudeCodeOnboardingModal.boxed_clone(),
307 cx,
308 )
309 // When updating this to a non-AI feature release, remove this line.
310 .visible_when(|cx| !project::DisableAiSettings::get_global(cx).disable_ai)
311 });
312
313 let platform_titlebar = cx.new(|cx| PlatformTitleBar::new(id, cx));
314
315 Self {
316 platform_titlebar,
317 application_menu,
318 workspace: workspace.weak_handle(),
319 project,
320 user_store,
321 client,
322 _subscriptions: subscriptions,
323 banner,
324 screen_share_popover_handle: Default::default(),
325 }
326 }
327
328 fn render_remote_project_connection(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
329 let options = self.project.read(cx).remote_connection_options(cx)?;
330 let host: SharedString = options.display_name().into();
331
332 let (nickname, icon) = match options {
333 RemoteConnectionOptions::Ssh(options) => {
334 (options.nickname.map(|nick| nick.into()), IconName::Server)
335 }
336 RemoteConnectionOptions::Wsl(_) => (None, IconName::Linux),
337 };
338 let nickname = nickname.unwrap_or_else(|| host.clone());
339
340 let (indicator_color, meta) = match self.project.read(cx).remote_connection_state(cx)? {
341 remote::ConnectionState::Connecting => (Color::Info, format!("Connecting to: {host}")),
342 remote::ConnectionState::Connected => (Color::Success, format!("Connected to: {host}")),
343 remote::ConnectionState::HeartbeatMissed => (
344 Color::Warning,
345 format!("Connection attempt to {host} missed. Retrying..."),
346 ),
347 remote::ConnectionState::Reconnecting => (
348 Color::Warning,
349 format!("Lost connection to {host}. Reconnecting..."),
350 ),
351 remote::ConnectionState::Disconnected => {
352 (Color::Error, format!("Disconnected from {host}"))
353 }
354 };
355
356 let icon_color = match self.project.read(cx).remote_connection_state(cx)? {
357 remote::ConnectionState::Connecting => Color::Info,
358 remote::ConnectionState::Connected => Color::Default,
359 remote::ConnectionState::HeartbeatMissed => Color::Warning,
360 remote::ConnectionState::Reconnecting => Color::Warning,
361 remote::ConnectionState::Disconnected => Color::Error,
362 };
363
364 let meta = SharedString::from(meta);
365
366 Some(
367 ButtonLike::new("ssh-server-icon")
368 .child(
369 h_flex()
370 .gap_2()
371 .max_w_32()
372 .child(
373 IconWithIndicator::new(
374 Icon::new(icon).size(IconSize::Small).color(icon_color),
375 Some(Indicator::dot().color(indicator_color)),
376 )
377 .indicator_border_color(Some(cx.theme().colors().title_bar_background))
378 .into_any_element(),
379 )
380 .child(Label::new(nickname).size(LabelSize::Small).truncate()),
381 )
382 .tooltip(move |_window, cx| {
383 Tooltip::with_meta(
384 "Remote Project",
385 Some(&OpenRemote {
386 from_existing_connection: false,
387 create_new_window: false,
388 }),
389 meta.clone(),
390 cx,
391 )
392 })
393 .on_click(|_, window, cx| {
394 window.dispatch_action(
395 OpenRemote {
396 from_existing_connection: false,
397 create_new_window: false,
398 }
399 .boxed_clone(),
400 cx,
401 );
402 })
403 .into_any_element(),
404 )
405 }
406
407 pub fn render_project_host(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
408 if self.project.read(cx).is_via_remote_server() {
409 return self.render_remote_project_connection(cx);
410 }
411
412 if self.project.read(cx).is_disconnected(cx) {
413 return Some(
414 Button::new("disconnected", "Disconnected")
415 .disabled(true)
416 .color(Color::Disabled)
417 .style(ButtonStyle::Subtle)
418 .label_size(LabelSize::Small)
419 .into_any_element(),
420 );
421 }
422
423 let host = self.project.read(cx).host()?;
424 let host_user = self.user_store.read(cx).get_cached_user(host.user_id)?;
425 let participant_index = self
426 .user_store
427 .read(cx)
428 .participant_indices()
429 .get(&host_user.id)?;
430 Some(
431 Button::new("project_owner_trigger", host_user.github_login.clone())
432 .color(Color::Player(participant_index.0))
433 .style(ButtonStyle::Subtle)
434 .label_size(LabelSize::Small)
435 .tooltip(Tooltip::text(format!(
436 "{} is sharing this project. Click to follow.",
437 host_user.github_login
438 )))
439 .on_click({
440 let host_peer_id = host.peer_id;
441 cx.listener(move |this, _, window, cx| {
442 this.workspace
443 .update(cx, |workspace, cx| {
444 workspace.follow(host_peer_id, window, cx);
445 })
446 .log_err();
447 })
448 })
449 .into_any_element(),
450 )
451 }
452
453 pub fn render_project_name(&self, cx: &mut Context<Self>) -> impl IntoElement {
454 let name = self
455 .project
456 .read(cx)
457 .visible_worktrees(cx)
458 .map(|worktree| {
459 let worktree = worktree.read(cx);
460 let settings_location = SettingsLocation {
461 worktree_id: worktree.id(),
462 path: RelPath::empty(),
463 };
464
465 let settings = WorktreeSettings::get(Some(settings_location), cx);
466 match &settings.project_name {
467 Some(name) => name.as_str(),
468 None => worktree.root_name_str(),
469 }
470 })
471 .next();
472 let is_project_selected = name.is_some();
473 let name = if let Some(name) = name {
474 util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH)
475 } else {
476 "Open recent project".to_string()
477 };
478
479 Button::new("project_name_trigger", name)
480 .when(!is_project_selected, |b| b.color(Color::Muted))
481 .style(ButtonStyle::Subtle)
482 .label_size(LabelSize::Small)
483 .tooltip(move |_window, cx| {
484 Tooltip::for_action(
485 "Recent Projects",
486 &zed_actions::OpenRecent {
487 create_new_window: false,
488 },
489 cx,
490 )
491 })
492 .on_click(cx.listener(move |_, _, window, cx| {
493 window.dispatch_action(
494 OpenRecent {
495 create_new_window: false,
496 }
497 .boxed_clone(),
498 cx,
499 );
500 }))
501 }
502
503 pub fn render_project_branch(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
504 let settings = TitleBarSettings::get_global(cx);
505 let repository = self.project.read(cx).active_repository(cx)?;
506 let workspace = self.workspace.upgrade()?;
507 let repo = repository.read(cx);
508 let branch_name = repo
509 .branch
510 .as_ref()
511 .map(|branch| branch.name())
512 .map(|name| util::truncate_and_trailoff(name, MAX_BRANCH_NAME_LENGTH))
513 .or_else(|| {
514 repo.head_commit.as_ref().map(|commit| {
515 commit
516 .sha
517 .chars()
518 .take(MAX_SHORT_SHA_LENGTH)
519 .collect::<String>()
520 })
521 })?;
522
523 Some(
524 Button::new("project_branch_trigger", branch_name)
525 .color(Color::Muted)
526 .style(ButtonStyle::Subtle)
527 .label_size(LabelSize::Small)
528 .tooltip(move |_window, cx| {
529 Tooltip::with_meta(
530 "Recent Branches",
531 Some(&zed_actions::git::Branch),
532 "Local branches only",
533 cx,
534 )
535 })
536 .on_click(move |_, window, cx| {
537 let _ = workspace.update(cx, |this, cx| {
538 window.focus(&this.active_pane().focus_handle(cx));
539 window.dispatch_action(zed_actions::git::Branch.boxed_clone(), cx);
540 });
541 })
542 .when(settings.show_branch_icon, |branch_button| {
543 let (icon, icon_color) = {
544 let status = repo.status_summary();
545 let tracked = status.index + status.worktree;
546 if status.conflict > 0 {
547 (IconName::Warning, Color::VersionControlConflict)
548 } else if tracked.modified > 0 {
549 (IconName::SquareDot, Color::VersionControlModified)
550 } else if tracked.added > 0 || status.untracked > 0 {
551 (IconName::SquarePlus, Color::VersionControlAdded)
552 } else if tracked.deleted > 0 {
553 (IconName::SquareMinus, Color::VersionControlDeleted)
554 } else {
555 (IconName::GitBranch, Color::Muted)
556 }
557 };
558
559 branch_button
560 .icon(icon)
561 .icon_position(IconPosition::Start)
562 .icon_color(icon_color)
563 .icon_size(IconSize::Indicator)
564 }),
565 )
566 }
567
568 fn window_activation_changed(&mut self, window: &mut Window, cx: &mut Context<Self>) {
569 if window.is_window_active() {
570 ActiveCall::global(cx)
571 .update(cx, |call, cx| call.set_location(Some(&self.project), cx))
572 .detach_and_log_err(cx);
573 } else if cx.active_window().is_none() {
574 ActiveCall::global(cx)
575 .update(cx, |call, cx| call.set_location(None, cx))
576 .detach_and_log_err(cx);
577 }
578 self.workspace
579 .update(cx, |workspace, cx| {
580 workspace.update_active_view_for_followers(window, cx);
581 })
582 .ok();
583 }
584
585 fn active_call_changed(&mut self, cx: &mut Context<Self>) {
586 cx.notify();
587 }
588
589 fn share_project(&mut self, cx: &mut Context<Self>) {
590 let active_call = ActiveCall::global(cx);
591 let project = self.project.clone();
592 active_call
593 .update(cx, |call, cx| call.share_project(project, cx))
594 .detach_and_log_err(cx);
595 }
596
597 fn unshare_project(&mut self, _: &mut Window, cx: &mut Context<Self>) {
598 let active_call = ActiveCall::global(cx);
599 let project = self.project.clone();
600 active_call
601 .update(cx, |call, cx| call.unshare_project(project, cx))
602 .log_err();
603 }
604
605 fn render_connection_status(
606 &self,
607 status: &client::Status,
608 cx: &mut Context<Self>,
609 ) -> Option<AnyElement> {
610 match status {
611 client::Status::ConnectionError
612 | client::Status::ConnectionLost
613 | client::Status::Reauthenticating
614 | client::Status::Reconnecting
615 | client::Status::ReconnectionError { .. } => Some(
616 div()
617 .id("disconnected")
618 .child(Icon::new(IconName::Disconnected).size(IconSize::Small))
619 .tooltip(Tooltip::text("Disconnected"))
620 .into_any_element(),
621 ),
622 client::Status::UpgradeRequired => {
623 let auto_updater = auto_update::AutoUpdater::get(cx);
624 let label = match auto_updater.map(|auto_update| auto_update.read(cx).status()) {
625 Some(AutoUpdateStatus::Updated { .. }) => "Please restart Zed to Collaborate",
626 Some(AutoUpdateStatus::Installing { .. })
627 | Some(AutoUpdateStatus::Downloading { .. })
628 | Some(AutoUpdateStatus::Checking) => "Updating...",
629 Some(AutoUpdateStatus::Idle)
630 | Some(AutoUpdateStatus::Errored { .. })
631 | None => "Please update Zed to Collaborate",
632 };
633
634 Some(
635 Button::new("connection-status", label)
636 .label_size(LabelSize::Small)
637 .on_click(|_, window, cx| {
638 if let Some(auto_updater) = auto_update::AutoUpdater::get(cx)
639 && auto_updater.read(cx).status().is_updated()
640 {
641 workspace::reload(cx);
642 return;
643 }
644 auto_update::check(&Default::default(), window, cx);
645 })
646 .into_any_element(),
647 )
648 }
649 _ => None,
650 }
651 }
652
653 pub fn render_sign_in_button(&mut self, _: &mut Context<Self>) -> Button {
654 let client = self.client.clone();
655 Button::new("sign_in", "Sign in")
656 .label_size(LabelSize::Small)
657 .on_click(move |_, window, cx| {
658 let client = client.clone();
659 window
660 .spawn(cx, async move |cx| {
661 client
662 .sign_in_with_optional_connect(true, cx)
663 .await
664 .notify_async_err(cx);
665 })
666 .detach();
667 })
668 }
669
670 pub fn render_app_menu_button(&mut self, cx: &mut Context<Self>) -> impl Element {
671 let user_store = self.user_store.read(cx);
672 let user = user_store.current_user();
673
674 let user_avatar = user.as_ref().map(|u| u.avatar_uri.clone());
675 let user_login = user.as_ref().map(|u| u.github_login.clone());
676
677 let is_signed_in = user.is_some();
678
679 let has_subscription_period = user_store.subscription_period().is_some();
680 let plan = user_store.plan().filter(|_| {
681 // Since the user might be on the legacy free plan we filter based on whether we have a subscription period.
682 has_subscription_period
683 });
684
685 let free_chip_bg = cx
686 .theme()
687 .colors()
688 .editor_background
689 .opacity(0.5)
690 .blend(cx.theme().colors().text_accent.opacity(0.05));
691
692 let pro_chip_bg = cx
693 .theme()
694 .colors()
695 .editor_background
696 .opacity(0.5)
697 .blend(cx.theme().colors().text_accent.opacity(0.2));
698
699 PopoverMenu::new("user-menu")
700 .anchor(Corner::TopRight)
701 .menu(move |window, cx| {
702 ContextMenu::build(window, cx, |menu, _, _cx| {
703 let user_login = user_login.clone();
704
705 let (plan_name, label_color, bg_color) = match plan {
706 None | Some(Plan::V1(PlanV1::ZedFree) | Plan::V2(PlanV2::ZedFree)) => {
707 ("Free", Color::Default, free_chip_bg)
708 }
709 Some(Plan::V1(PlanV1::ZedProTrial) | Plan::V2(PlanV2::ZedProTrial)) => {
710 ("Pro Trial", Color::Accent, pro_chip_bg)
711 }
712 Some(Plan::V1(PlanV1::ZedPro) | Plan::V2(PlanV2::ZedPro)) => {
713 ("Pro", Color::Accent, pro_chip_bg)
714 }
715 };
716
717 menu.when(is_signed_in, |this| {
718 this.custom_entry(
719 move |_window, _cx| {
720 let user_login = user_login.clone().unwrap_or_default();
721
722 h_flex()
723 .w_full()
724 .justify_between()
725 .child(Label::new(user_login))
726 .child(
727 Chip::new(plan_name.to_string())
728 .bg_color(bg_color)
729 .label_color(label_color),
730 )
731 .into_any_element()
732 },
733 move |_, cx| {
734 cx.open_url(&zed_urls::account_url(cx));
735 },
736 )
737 .separator()
738 })
739 .action("Settings", zed_actions::OpenSettings.boxed_clone())
740 .action("Keymap", Box::new(zed_actions::OpenKeymap))
741 .action(
742 "Themes…",
743 zed_actions::theme_selector::Toggle::default().boxed_clone(),
744 )
745 .action(
746 "Icon Themes…",
747 zed_actions::icon_theme_selector::Toggle::default().boxed_clone(),
748 )
749 .action(
750 "Extensions",
751 zed_actions::Extensions::default().boxed_clone(),
752 )
753 .when(is_signed_in, |this| {
754 this.separator()
755 .action("Sign Out", client::SignOut.boxed_clone())
756 })
757 })
758 .into()
759 })
760 .map(|this| {
761 if is_signed_in && TitleBarSettings::get_global(cx).show_user_picture {
762 this.trigger_with_tooltip(
763 ButtonLike::new("user-menu")
764 .children(user_avatar.clone().map(|avatar| Avatar::new(avatar))),
765 Tooltip::text("Toggle User Menu"),
766 )
767 } else {
768 this.trigger_with_tooltip(
769 IconButton::new("user-menu", IconName::ChevronDown)
770 .icon_size(IconSize::Small),
771 Tooltip::text("Toggle User Menu"),
772 )
773 }
774 })
775 .anchor(gpui::Corner::TopRight)
776 }
777}