agent_ui: Adjust settings UI for some providers (#56879)
Namely, makes the ChatGPT subscription settings item a bit tidier, as well as more consistent with the Copilot one. Release Notes: - N/A
This commit is contained in:
1 parent
cbed5c63dc
commit
b1a7f461a7
2 files changed
+36
-24
No files matched your search
@@ -535,23 +535,12 @@ impl ConfigurationView {
|
||||
label: impl Into<SharedString>,
|
||||
edit_prediction: bool,
|
||||
) -> impl IntoElement {
|
||||
ButtonLike::new("loading_button")
|
||||
Button::new("loading_button", label)
|
||||
.full_width()
|
||||
.disabled(true)
|
||||
.loading(true)
|
||||
.style(ButtonStyle::Outlined)
|
||||
.when(edit_prediction, |this| this.size(ButtonSize::Medium))
|
||||
.child(
|
||||
h_flex()
|
||||
.w_full()
|
||||
.gap_1()
|
||||
.justify_center()
|
||||
.child(
|
||||
Icon::new(IconName::ArrowCircle)
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted)
|
||||
.with_rotate_animation(4),
|
||||
)
|
||||
.child(Label::new(label)),
|
||||
)
|
||||
}
|
||||
|
||||
fn render_sign_in_button(&self, edit_prediction: bool) -> impl IntoElement {
|
||||
|
||||
@@ -1015,6 +1015,7 @@ impl Render for ConfigurationView {
|
||||
.unwrap_or_else(|| "Signed in".to_string());
|
||||
|
||||
let weak_state = self.state.downgrade();
|
||||
|
||||
return v_flex()
|
||||
.child(
|
||||
ConfiguredApiCard::new(SharedString::from(label))
|
||||
@@ -1026,30 +1027,52 @@ impl Render for ConfigurationView {
|
||||
.into_any_element();
|
||||
}
|
||||
|
||||
if state.is_signing_in() {
|
||||
return v_flex()
|
||||
.child(Label::new("Signing in…").color(Color::Muted))
|
||||
.into_any_element();
|
||||
}
|
||||
|
||||
let last_auth_error = state.last_auth_error.clone();
|
||||
let provider_state = self.state.clone();
|
||||
let http_client = self.http_client.clone();
|
||||
|
||||
let is_signing_in = state.is_signing_in();
|
||||
let button_label = if is_signing_in {
|
||||
"Signing in…"
|
||||
} else {
|
||||
"Sign in to use ChatGPT Subscription"
|
||||
};
|
||||
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.when_some(last_auth_error, |this, error| {
|
||||
this.child(Label::new(error).color(Color::Error))
|
||||
})
|
||||
.child(Label::new(
|
||||
"Sign in with your ChatGPT Plus or Pro subscription to use OpenAI models in Zed's agent.",
|
||||
))
|
||||
.child(
|
||||
Button::new("sign-in", "Sign in with ChatGPT")
|
||||
Button::new("sign-in", button_label)
|
||||
.full_width()
|
||||
.style(ButtonStyle::Outlined)
|
||||
.loading(is_signing_in)
|
||||
.disabled(is_signing_in)
|
||||
.when(!is_signing_in, |this| {
|
||||
this.start_icon(
|
||||
Icon::new(IconName::AiOpenAi)
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
})
|
||||
.on_click(move |_, _window, cx| {
|
||||
do_sign_in(&provider_state, &http_client, cx);
|
||||
}),
|
||||
)
|
||||
.when_some(last_auth_error, |this, error| {
|
||||
this.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.justify_center()
|
||||
.child(
|
||||
Icon::new(IconName::XCircle)
|
||||
.color(Color::Error)
|
||||
.size(IconSize::Small),
|
||||
)
|
||||
.child(Label::new(error).color(Color::Muted)),
|
||||
)
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user