Files
zed/crates/ui/src/components/button/button_link.rs
T
Danilo LealandBen Kunkle 0283bfb049 Enable configuring edit prediction providers through the settings UI (#44505)
- Edit prediction providers can now be configured through the settings
UI
- Cleaned up the status bar menu to only show _configured_ providers
- Added to the status bar icon button tooltip the name of the active
provider
- Only display the data collection functionality under "Privacy" for the
Zed models
- Moved the Codestral edit prediction provider out of the Mistral
section in the agent panel into the settings UI
- Refined and improved UI and states for configuring GitHub Copilot as
both an agent and edit prediction provider

#### Todos before merge:

- [x] UI: Unify with settings UI style and tidy it all up
- [x] Unify Copilot modal `impl`s to use separate window
- [x] Remove stop light icons from GitHub modal
- [x] Make dismiss events work on GitHub modal
- [ ] Investigate workarounds to tell if Copilot authenticated even when
LSP not running


Release Notes:

- settings_ui: Added a section for configuring edit prediction providers
under AI > Edit Predictions, including Codestral and GitHub Copilot.
Once you've updated you can use the following link to open it:
zed://settings/edit_predictions.providers

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
2025-12-13 11:06:30 -05:00

103 lines
2.8 KiB
Rust

use gpui::{IntoElement, Window, prelude::*};
use crate::{ButtonLike, prelude::*};
/// A button that takes an underline to look like a regular web link.
/// It also contains an arrow icon to communicate the link takes you out of Zed.
///
/// # Usage Example
///
/// ```
/// use ui::ButtonLink;
///
/// let button_link = ButtonLink::new("Click me", "https://example.com");
/// ```
#[derive(IntoElement, RegisterComponent)]
pub struct ButtonLink {
label: SharedString,
label_size: LabelSize,
label_color: Color,
link: String,
no_icon: bool,
}
impl ButtonLink {
pub fn new(label: impl Into<SharedString>, link: impl Into<String>) -> Self {
Self {
link: link.into(),
label: label.into(),
label_size: LabelSize::Default,
label_color: Color::Default,
no_icon: false,
}
}
pub fn no_icon(mut self, no_icon: bool) -> Self {
self.no_icon = no_icon;
self
}
pub fn label_size(mut self, label_size: LabelSize) -> Self {
self.label_size = label_size;
self
}
pub fn label_color(mut self, label_color: Color) -> Self {
self.label_color = label_color;
self
}
}
impl RenderOnce for ButtonLink {
fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
let id = format!("{}-{}", self.label, self.link);
ButtonLike::new(id)
.size(ButtonSize::None)
.child(
h_flex()
.gap_0p5()
.child(
Label::new(self.label)
.size(self.label_size)
.color(self.label_color)
.underline(),
)
.when(!self.no_icon, |this| {
this.child(
Icon::new(IconName::ArrowUpRight)
.size(IconSize::Small)
.color(Color::Muted),
)
}),
)
.on_click(move |_, _, cx| cx.open_url(&self.link))
.into_any_element()
}
}
impl Component for ButtonLink {
fn scope() -> ComponentScope {
ComponentScope::Navigation
}
fn description() -> Option<&'static str> {
Some("A button that opens a URL.")
}
fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
Some(
v_flex()
.gap_6()
.child(
example_group(vec![single_example(
"Simple",
ButtonLink::new("zed.dev", "https://zed.dev").into_any_element(),
)])
.vertical(),
)
.into_any_element(),
)
}
}