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:
@@ -409,16 +409,25 @@ pub fn init(cx: &mut App) {
|
||||
|
||||
fn init_renderers(cx: &mut App) {
|
||||
cx.default_global::<SettingFieldRenderer>()
|
||||
.add_basic_renderer::<UnimplementedSettingField>(|_, _, _, _, _| {
|
||||
Button::new("open-in-settings-file", "Edit in settings.json")
|
||||
.style(ButtonStyle::Outlined)
|
||||
.size(ButtonSize::Medium)
|
||||
.tab_index(0_isize)
|
||||
.on_click(|_, window, cx| {
|
||||
window.dispatch_action(Box::new(OpenCurrentFile), cx);
|
||||
})
|
||||
.into_any_element()
|
||||
})
|
||||
.add_renderer::<UnimplementedSettingField>(
|
||||
|settings_window, item, _, settings_file, _, sub_field, _, cx| {
|
||||
render_settings_item(
|
||||
settings_window,
|
||||
item,
|
||||
settings_file,
|
||||
Button::new("open-in-settings-file", "Edit in settings.json")
|
||||
.style(ButtonStyle::Outlined)
|
||||
.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::<String>(render_text_field)
|
||||
.add_basic_renderer::<SharedString>(render_text_field)
|
||||
@@ -2832,17 +2841,30 @@ impl SettingsWindow {
|
||||
.into_any_element();
|
||||
} else {
|
||||
page_header = h_flex()
|
||||
.ml_neg_1p5()
|
||||
.gap_1()
|
||||
.w_full()
|
||||
.justify_between()
|
||||
.child(
|
||||
IconButton::new("back-btn", IconName::ArrowLeft)
|
||||
.icon_size(IconSize::Small)
|
||||
.shape(IconButtonShape::Square)
|
||||
.on_click(cx.listener(|this, _, _, cx| {
|
||||
this.pop_sub_page(cx);
|
||||
h_flex()
|
||||
.ml_neg_1p5()
|
||||
.gap_1()
|
||||
.child(
|
||||
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();
|
||||
|
||||
let active_page_render_fn = sub_page_stack().last().unwrap().link.render.clone();
|
||||
|
||||
Reference in New Issue
Block a user