settings_ui: Add "Edit in settings.json" button to subpage header (#42886)

Closes https://github.com/zed-industries/zed/issues/42094

This will make it consistent with the regular/main page. Also ended up
fixing a bug along the way where this button wouldn't work for subpage
items.

Release Notes:

- settings ui: Fixed a bug where the "Edit in settings.json" wouldn't
work for subpages like all the Language pages.
This commit is contained in:
Danilo Leal
2025-11-17 11:58:43 -03:00
committed by GitHub
parent b274f80dd9
commit bb46bc167a
+40 -18
View File
@@ -409,16 +409,25 @@ pub fn init(cx: &mut App) {
fn init_renderers(cx: &mut App) { fn init_renderers(cx: &mut App) {
cx.default_global::<SettingFieldRenderer>() cx.default_global::<SettingFieldRenderer>()
.add_basic_renderer::<UnimplementedSettingField>(|_, _, _, _, _| { .add_renderer::<UnimplementedSettingField>(
Button::new("open-in-settings-file", "Edit in settings.json") |settings_window, item, _, settings_file, _, sub_field, _, cx| {
.style(ButtonStyle::Outlined) render_settings_item(
.size(ButtonSize::Medium) settings_window,
.tab_index(0_isize) item,
.on_click(|_, window, cx| { settings_file,
window.dispatch_action(Box::new(OpenCurrentFile), cx); Button::new("open-in-settings-file", "Edit in settings.json")
}) .style(ButtonStyle::Outlined)
.into_any_element() .size(ButtonSize::Medium)
}) .tab_index(0_isize)
.on_click(cx.listener(|this, _, window, cx| {
this.open_current_settings_file(window, cx);
}))
.into_any_element(),
sub_field,
cx,
)
},
)
.add_basic_renderer::<bool>(render_toggle_button) .add_basic_renderer::<bool>(render_toggle_button)
.add_basic_renderer::<String>(render_text_field) .add_basic_renderer::<String>(render_text_field)
.add_basic_renderer::<SharedString>(render_text_field) .add_basic_renderer::<SharedString>(render_text_field)
@@ -2832,17 +2841,30 @@ impl SettingsWindow {
.into_any_element(); .into_any_element();
} else { } else {
page_header = h_flex() page_header = h_flex()
.ml_neg_1p5() .w_full()
.gap_1() .justify_between()
.child( .child(
IconButton::new("back-btn", IconName::ArrowLeft) h_flex()
.icon_size(IconSize::Small) .ml_neg_1p5()
.shape(IconButtonShape::Square) .gap_1()
.on_click(cx.listener(|this, _, _, cx| { .child(
this.pop_sub_page(cx); IconButton::new("back-btn", IconName::ArrowLeft)
.icon_size(IconSize::Small)
.shape(IconButtonShape::Square)
.on_click(cx.listener(|this, _, _, cx| {
this.pop_sub_page(cx);
})),
)
.child(self.render_sub_page_breadcrumbs()),
)
.child(
Button::new("open-in-settings-file", "Edit in settings.json")
.tab_index(0_isize)
.style(ButtonStyle::OutlinedGhost)
.on_click(cx.listener(|this, _, window, cx| {
this.open_current_settings_file(window, cx);
})), })),
) )
.child(self.render_sub_page_breadcrumbs())
.into_any_element(); .into_any_element();
let active_page_render_fn = sub_page_stack().last().unwrap().link.render.clone(); let active_page_render_fn = sub_page_stack().last().unwrap().link.render.clone();