Add a note on how to check the telemetry

This commit is contained in:
Mikayla Maki 2023-03-08 18:47:52 -08:00
parent a65dd0fd98
commit 943ea61452
5 changed files with 47 additions and 8 deletions

View file

@ -869,6 +869,7 @@ pub struct WelcomeStyle {
pub page_width: f32,
pub logo: IconStyle,
pub logo_subheading: ContainedText,
pub usage_note: ContainedText,
pub checkbox: CheckboxStyle,
pub checkbox_container: ContainerStyle,
pub button: Interactive<ContainedText>,

View file

@ -4,7 +4,7 @@ use gpui::{
ConstrainedBox, Container, ContainerStyle, Empty, Flex, KeystrokeLabel, Label,
MouseEventHandler, ParentElement, Svg,
},
Action, Element, EventContext, RenderContext, View,
Action, Element, ElementBox, EventContext, RenderContext, View,
};
use serde::Deserialize;
@ -26,6 +26,21 @@ pub fn checkbox<T: 'static, V: View>(
checked: bool,
cx: &mut RenderContext<V>,
change: fn(checked: bool, cx: &mut EventContext) -> (),
) -> MouseEventHandler<T> {
let label = Label::new(label, style.label.text.clone())
.contained()
.with_style(style.label.container)
.boxed();
checkbox_with_label(label, style, checked, cx, change)
}
pub fn checkbox_with_label<T: 'static, V: View>(
label: ElementBox,
style: &CheckboxStyle,
checked: bool,
cx: &mut RenderContext<V>,
change: fn(checked: bool, cx: &mut EventContext) -> (),
) -> MouseEventHandler<T> {
MouseEventHandler::<T>::new(0, cx, |state, _| {
let indicator = if checked {
@ -55,10 +70,7 @@ pub fn checkbox<T: 'static, V: View>(
}
})
.boxed(),
Label::new(label, style.label.text.clone())
.contained()
.with_style(style.label.container)
.boxed(),
label,
])
.align_children_center()
.boxed()

View file

@ -124,8 +124,25 @@ impl View for WelcomePage {
.boxed(),
Flex::column()
.with_children([
theme::ui::checkbox::<Metrics, Self>(
"Send anonymous usage data to improve Zed (View what we're sending via Help > View Telemetry Log)",
theme::ui::checkbox_with_label::<Metrics, Self>(
Flex::column()
.with_children([
Label::new(
"Send anonymous usage data",
theme.welcome.checkbox.label.text.clone(),
)
.contained()
.with_style(theme.welcome.checkbox.label.container)
.boxed(),
Label::new(
"Help > View Telemetry",
theme.welcome.usage_note.text.clone(),
)
.contained()
.with_style(theme.welcome.usage_note.container)
.boxed(),
])
.boxed(),
&theme.welcome.checkbox,
metrics,
cx,

View file

@ -137,7 +137,7 @@ pub fn menus() -> Vec<Menu<'static>> {
items: vec![
MenuItem::action("Command Palette", command_palette::Toggle),
MenuItem::separator(),
MenuItem::action("View Telemetry Log", crate::OpenTelemetryLog),
MenuItem::action("View Telemetry", crate::OpenTelemetryLog),
MenuItem::action("View Dependency Licenses", crate::OpenLicenses),
MenuItem::separator(),
MenuItem::action(

View file

@ -86,10 +86,19 @@ export default function welcome(colorScheme: ColorScheme) {
border: border(layer, "active"),
},
},
usageNote: {
...text(layer, "sans", "variant", { size: "2xs" }),
margin: {
top: -4
}
},
checkboxContainer: {
margin: {
top: 4,
},
padding: {
bottom: 8,
}
},
checkbox: {
label: {