Add setting to hide user menu in the title bar (#44466)
Closes #44417 Release Notes: - Added a setting `show_user_menu` (defaulting to true) which shows or hides the user menu (the one with the user avatar) in title bar. --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
@@ -436,6 +436,8 @@
|
||||
"show_onboarding_banner": true,
|
||||
// Whether to show user picture in the titlebar.
|
||||
"show_user_picture": true,
|
||||
// Whether to show the user menu in the titlebar.
|
||||
"show_user_menu": true,
|
||||
// Whether to show the sign in button in the titlebar.
|
||||
"show_sign_in": true,
|
||||
// Whether to show the menus in the titlebar.
|
||||
|
||||
@@ -286,6 +286,10 @@ pub struct TitleBarSettingsContent {
|
||||
///
|
||||
/// Default: true
|
||||
pub show_sign_in: Option<bool>,
|
||||
/// Whether to show the user menu button in the title bar.
|
||||
///
|
||||
/// Default: true
|
||||
pub show_user_menu: Option<bool>,
|
||||
/// Whether to show the menus in the title bar.
|
||||
///
|
||||
/// Default: false
|
||||
|
||||
@@ -2912,6 +2912,42 @@ pub(crate) fn settings_data(cx: &App) -> Vec<SettingsPage> {
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Show Sign In",
|
||||
description: "Show the sign in button in the titlebar.",
|
||||
field: Box::new(SettingField {
|
||||
json_path: Some("title_bar.show_sign_in"),
|
||||
pick: |settings_content| {
|
||||
settings_content.title_bar.as_ref()?.show_sign_in.as_ref()
|
||||
},
|
||||
write: |settings_content, value| {
|
||||
settings_content
|
||||
.title_bar
|
||||
.get_or_insert_default()
|
||||
.show_sign_in = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Show User Menu",
|
||||
description: "Show the user menu button in the titlebar.",
|
||||
field: Box::new(SettingField {
|
||||
json_path: Some("title_bar.show_user_menu"),
|
||||
pick: |settings_content| {
|
||||
settings_content.title_bar.as_ref()?.show_user_menu.as_ref()
|
||||
},
|
||||
write: |settings_content, value| {
|
||||
settings_content
|
||||
.title_bar
|
||||
.get_or_insert_default()
|
||||
.show_user_menu = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Show User Picture",
|
||||
description: "Show user picture in the titlebar.",
|
||||
@@ -2934,24 +2970,6 @@ pub(crate) fn settings_data(cx: &App) -> Vec<SettingsPage> {
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Show Sign In",
|
||||
description: "Show the sign in button in the titlebar.",
|
||||
field: Box::new(SettingField {
|
||||
json_path: Some("title_bar.show_sign_in"),
|
||||
pick: |settings_content| {
|
||||
settings_content.title_bar.as_ref()?.show_sign_in.as_ref()
|
||||
},
|
||||
write: |settings_content, value| {
|
||||
settings_content
|
||||
.title_bar
|
||||
.get_or_insert_default()
|
||||
.show_sign_in = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Show Menus",
|
||||
description: "Show the menus in the titlebar.",
|
||||
|
||||
@@ -202,9 +202,11 @@ impl Render for TitleBar {
|
||||
.children(self.render_connection_status(status, cx))
|
||||
.when(
|
||||
user.is_none() && TitleBarSettings::get_global(cx).show_sign_in,
|
||||
|el| el.child(self.render_sign_in_button(cx)),
|
||||
|this| this.child(self.render_sign_in_button(cx)),
|
||||
)
|
||||
.child(self.render_app_menu_button(cx))
|
||||
.when(TitleBarSettings::get_global(cx).show_user_menu, |this| {
|
||||
this.child(self.render_user_menu_button(cx))
|
||||
})
|
||||
.into_any_element(),
|
||||
);
|
||||
|
||||
@@ -685,7 +687,7 @@ impl TitleBar {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn render_app_menu_button(&mut self, cx: &mut Context<Self>) -> impl Element {
|
||||
pub fn render_user_menu_button(&mut self, cx: &mut Context<Self>) -> impl Element {
|
||||
let user_store = self.user_store.read(cx);
|
||||
let user = user_store.current_user();
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ pub struct TitleBarSettings {
|
||||
pub show_branch_name: bool,
|
||||
pub show_project_items: bool,
|
||||
pub show_sign_in: bool,
|
||||
pub show_user_menu: bool,
|
||||
pub show_menus: bool,
|
||||
}
|
||||
|
||||
@@ -21,6 +22,7 @@ impl Settings for TitleBarSettings {
|
||||
show_branch_name: content.show_branch_name.unwrap(),
|
||||
show_project_items: content.show_project_items.unwrap(),
|
||||
show_sign_in: content.show_sign_in.unwrap(),
|
||||
show_user_menu: content.show_user_menu.unwrap(),
|
||||
show_menus: content.show_menus.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4309,6 +4309,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
|
||||
"show_project_items": true,
|
||||
"show_onboarding_banner": true,
|
||||
"show_user_picture": true,
|
||||
"show_user_menu": true,
|
||||
"show_sign_in": true,
|
||||
"show_menus": false
|
||||
}
|
||||
@@ -4321,6 +4322,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
|
||||
- `show_project_items`: Whether to show the project host and name in the titlebar
|
||||
- `show_onboarding_banner`: Whether to show onboarding banners in the titlebar
|
||||
- `show_user_picture`: Whether to show user picture in the titlebar
|
||||
- `show_user_menu`: Whether to show the user menu button in the titlebar (the one that displays your avatar by default and contains options like Settings, Keymap, Themes, etc.)
|
||||
- `show_sign_in`: Whether to show the sign in button in the titlebar
|
||||
- `show_menus`: Whether to show the menus in the titlebar
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ To disable this behavior use:
|
||||
"show_project_items": true, // Show/hide project host and name
|
||||
"show_onboarding_banner": true, // Show/hide onboarding banners
|
||||
"show_user_picture": true, // Show/hide user avatar
|
||||
"show_user_menu": true, // Show/hide app user button
|
||||
"show_sign_in": true, // Show/hide sign-in button
|
||||
"show_menus": false // Show/hide menus
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user