edit predictions: Show user if current project is open source (#24587)

Release Notes:

- N/A

---------

Co-authored-by: João Marcos <marcospb19@hotmail.com>
This commit is contained in:
Danilo Leal 2025-02-10 22:28:56 -03:00 committed by GitHub
parent 3d9f70946c
commit c89ad65782
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 31 deletions

View file

@ -456,17 +456,56 @@ impl InlineCompletionButton {
if data_collection.is_supported() {
let provider = provider.clone();
let enabled = data_collection.is_enabled();
let is_open_source = data_collection.is_project_open_source();
let is_collecting = data_collection.is_enabled();
menu = menu.item(
// TODO: We want to add something later that communicates whether
// the current project is open-source.
ContextMenuEntry::new("Share Training Data")
.toggleable(IconPosition::Start, data_collection.is_enabled())
.documentation_aside(|_| {
Label::new(indoc!{"
Help us improve our open model by sharing data from open source repositories. \
Zed must detect a license file in your repo for this setting to take effect.\
"}).into_any_element()
.icon_color(if is_open_source && is_collecting {
Color::Success
} else {
Color::Accent
})
.documentation_aside(move |cx| {
let (msg, label_color, icon_name, icon_color) = match (is_open_source, is_collecting) {
(true, true) => (
"Project identified as open-source, and you're sharing data.",
Color::Default,
IconName::Check,
Color::Success,
),
(true, false) => (
"Project identified as open-source, but you're not sharing data.",
Color::Muted,
IconName::XCircle,
Color::Muted,
),
(false, _) => (
"Project not identified as open-source. No data captured.",
Color::Muted,
IconName::XCircle,
Color::Muted,
),
};
v_flex()
.gap_2()
.child(
Label::new(indoc!{
"Help us improve our open model by sharing data from open source repositories. \
Zed must detect a license file in your repo for this setting to take effect."
})
)
.child(
h_flex()
.pt_2()
.gap_1p5()
.border_t_1()
.border_color(cx.theme().colors().border_variant)
.child(Icon::new(icon_name).size(IconSize::XSmall).color(icon_color))
.child(div().child(Label::new(msg).size(LabelSize::Small).color(label_color)))
)
.into_any_element()
})
.handler(move |_, cx| {
provider.toggle_data_collection(cx);
@ -483,7 +522,7 @@ impl InlineCompletionButton {
);
}
})
)
);
}
}