diff --git a/CHANGELOG.md b/CHANGELOG.md index c82c81f5..17a07dea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Release dates use Australia/Brisbane time (UTC+10). ## [Unreleased] +### Changed + +- Center the Body and Authentication empty-state messages below their type selectors. + ## [2.4.2] - 2026-11-04 ### Fixed diff --git a/crates/desktop/src/app/render/request_editor.rs b/crates/desktop/src/app/render/request_editor.rs index 71bfd88c..75f430bf 100644 --- a/crates/desktop/src/app/render/request_editor.rs +++ b/crates/desktop/src/app/render/request_editor.rs @@ -205,10 +205,11 @@ impl ProbeApp { } let section_kind = self.request_editor.section(key); - let section_scrolls = !matches!( - section_kind, - EditorSection::Body | EditorSection::Docs | EditorSection::WebSocketMessage - ) && !section_kind.is_graphql(); + let section_scrolls = match section_kind { + EditorSection::Body | EditorSection::Docs | EditorSection::WebSocketMessage => false, + EditorSection::Authentication => request.authentication.is_some(), + _ => !section_kind.is_graphql(), + }; let section_scroll = self.request_editor.scroll(key, section_kind); let list_scroll = section_scrolls.then_some(&self.request_list_scroll); let section = self.render_request_section(key, &request, theme, list_scroll, cx); diff --git a/crates/desktop/src/app/render/request_editor/authentication.rs b/crates/desktop/src/app/render/request_editor/authentication.rs index 4456269c..5562371b 100644 --- a/crates/desktop/src/app/render/request_editor/authentication.rs +++ b/crates/desktop/src/app/render/request_editor/authentication.rs @@ -20,7 +20,11 @@ impl ProbeApp { ("API Key", Some(AuthenticationKind::ApiKey)), ]; let choice_count = choices.len(); - let mut kind_buttons = div().flex().flex_wrap().gap(px(theme.metrics.spacing_1)); + let mut kind_buttons = div() + .flex_none() + .flex() + .flex_wrap() + .gap(px(theme.metrics.spacing_1)); for (index, (label, kind)) in choices.into_iter().enumerate() { let kind_view = cx.weak_entity(); kind_buttons = kind_buttons.child(components::editor_subtab( @@ -44,6 +48,16 @@ impl ProbeApp { .flex_col() .gap(px(theme.metrics.spacing_2)) .child(kind_buttons); + let Some(authentication) = &request.authentication else { + return editor + .size_full() + .min_h(px(0.0)) + .child(placeholder_message( + theme, + "This request does not use authentication.", + )) + .into_any_element(); + }; let mut form = div() .flex() .flex_col() @@ -51,117 +65,109 @@ impl ProbeApp { .max_w(px(560.0 + 2.0 * theme.metrics.spacing_2)) .px(px(theme.metrics.spacing_2)) .gap(px(theme.metrics.spacing_2)); - if let Some(authentication) = &request.authentication { - let fields: &[(&str, &str)] = match authentication.kind { - AuthenticationKind::Basic => &[("username", "Username"), ("password", "Password")], - AuthenticationKind::Bearer => &[("token", "Token")], - AuthenticationKind::ApiKey => &[("key", "Key"), ("value", "Value")], - _ => &[], - }; - for &(property, label) in fields { - let value_view = cx.weak_entity(); - let value = authentication - .properties - .get(property) - .map(auth_value) - .unwrap_or_default(); - form = form.child( - div() - .id(property) - .debug_selector(move || format!("authentication-{property}")) - .flex() - .flex_col() - .gap(px(theme.metrics.spacing_1)) - .child(label) - .child( - components::variable_text_input( - theme, - SharedString::from(format!("authentication-{key:?}-{property}")), - value, - label, - self.variable_context(cx), - move |value, _, input_cx| { - let _ = value_view.update(input_cx, |view, cx| { + let fields: &[(&str, &str)] = match authentication.kind { + AuthenticationKind::Basic => &[("username", "Username"), ("password", "Password")], + AuthenticationKind::Bearer => &[("token", "Token")], + AuthenticationKind::ApiKey => &[("key", "Key"), ("value", "Value")], + _ => &[], + }; + for &(property, label) in fields { + let value_view = cx.weak_entity(); + let value = authentication + .properties + .get(property) + .map(auth_value) + .unwrap_or_default(); + form = form.child( + div() + .id(property) + .debug_selector(move || format!("authentication-{property}")) + .flex() + .flex_col() + .gap(px(theme.metrics.spacing_1)) + .child(label) + .child( + components::variable_text_input( + theme, + SharedString::from(format!("authentication-{key:?}-{property}")), + value, + label, + self.variable_context(cx), + move |value, _, input_cx| { + let _ = value_view.update(input_cx, |view, cx| { + view.edit_request( + key, + |request| { + set_auth_property( + request, + property.to_owned(), + value.to_string(), + ) + }, + cx, + ); + }); + }, + ) + .password(property == "password") + .list_scroll(list_scroll), + ), + ); + } + if authentication.kind == AuthenticationKind::ApiKey { + let placement = authentication.properties.get("placement").map(auth_value); + let mut options = vec![ + ("header".to_owned(), "Header".to_owned()), + ("query".to_owned(), "Query Params".to_owned()), + ]; + if let Some(value) = &placement + && !matches!(value.as_str(), "header" | "query") + { + options.push((value.clone(), value.clone())); + } + let placement_view = cx.weak_entity(); + form = form.child( + div() + .flex() + .flex_col() + .gap(px(theme.metrics.spacing_1)) + .child("Add to") + .child( + components::dropdown( + theme, + "authentication-placement", + "Add to", + placement, + options, + 180.0, + move |placement, _, cx| { + if let Some(placement) = placement { + let _ = placement_view.update(cx, |view, cx| { view.edit_request( key, |request| { set_auth_property( request, - property.to_owned(), - value.to_string(), + "placement".to_owned(), + placement.clone(), ) }, cx, ); }); - }, - ) - .password(property == "password") - .list_scroll(list_scroll), - ), - ); - } - if authentication.kind == AuthenticationKind::ApiKey { - let placement = authentication.properties.get("placement").map(auth_value); - let mut options = vec![ - ("header".to_owned(), "Header".to_owned()), - ("query".to_owned(), "Query Params".to_owned()), - ]; - if let Some(value) = &placement - && !matches!(value.as_str(), "header" | "query") - { - options.push((value.clone(), value.clone())); - } - let placement_view = cx.weak_entity(); - form = form.child( - div() - .flex() - .flex_col() - .gap(px(theme.metrics.spacing_1)) - .child("Add to") - .child( - components::dropdown( - theme, - "authentication-placement", - "Add to", - placement, - options, - 180.0, - move |placement, _, cx| { - if let Some(placement) = placement { - let _ = placement_view.update(cx, |view, cx| { - view.edit_request( - key, - |request| { - set_auth_property( - request, - "placement".to_owned(), - placement.clone(), - ) - }, - cx, - ); - }); - } - }, - ) - .placeholder("Not set"), - ), - ); - } - if fields.is_empty() { - form = form.child(div().text_color(theme.colors.text.muted).child(format!( - "{} authentication is not supported for execution. Imported configuration is preserved.", - auth_label(&authentication.kind), - ))); - } - } else { - form = form.child( - div() - .text_color(theme.colors.text.muted) - .child("This request does not use authentication."), + } + }, + ) + .placeholder("Not set"), + ), ); } + if fields.is_empty() { + form = form.child(div().text_color(theme.colors.text.muted).child(format!( + "{} authentication is not supported for execution. Imported configuration is preserved.", + auth_label(&authentication.kind), + ))); + } editor.child(form).into_any_element() } } diff --git a/crates/desktop/src/app/render/request_editor/body.rs b/crates/desktop/src/app/render/request_editor/body.rs index 45eac30e..873f63ac 100644 --- a/crates/desktop/src/app/render/request_editor/body.rs +++ b/crates/desktop/src/app/render/request_editor/body.rs @@ -20,7 +20,11 @@ impl ProbeApp { ("File", BodyEditorKind::File), ]; let choice_count = choices.len(); - let mut kind_buttons = div().flex().flex_wrap().gap(px(theme.metrics.spacing_1)); + let mut kind_buttons = div() + .flex_none() + .flex() + .flex_wrap() + .gap(px(theme.metrics.spacing_1)); for (index, (label, kind)) in choices.into_iter().enumerate() { let kind_view = cx.weak_entity(); kind_buttons = kind_buttons.child(components::editor_subtab( @@ -118,11 +122,7 @@ impl ProbeApp { ); } None => { - editor = editor.child( - div() - .text_color(theme.colors.text.muted) - .child("This request has no body."), - ); + editor = editor.child(placeholder_message(theme, "This request has no body.")); } } editor.into_any_element()