refactor(privacy): drop the diagnostics reporting toggle until a reporter exists
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use ely_browser_core::BrowserSnapshot;
|
||||
use ely_design_system::colors;
|
||||
use ely_domain::{DiagnosticsReportingPolicy, HistoryRecordingPolicy};
|
||||
use ely_domain::HistoryRecordingPolicy;
|
||||
use gpui::prelude::FluentBuilder;
|
||||
use gpui::{AnyElement, Context, IntoElement, ParentElement, Styled, div, px, rgb};
|
||||
use gpui_component::{
|
||||
@@ -148,8 +148,6 @@ fn render_privacy_settings_rows(
|
||||
.flex_col()
|
||||
.child(section_label("History"))
|
||||
.child(render_history_policy_rows(snapshot.history_recording_policy, cx))
|
||||
.child(section_label("Diagnostics"))
|
||||
.child(render_diagnostics_policy_rows(snapshot.diagnostics_reporting_policy, cx))
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
@@ -181,85 +179,6 @@ fn render_history_policy_rows(
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn render_diagnostics_policy_rows(
|
||||
active_policy: DiagnosticsReportingPolicy,
|
||||
cx: &mut Context<ElyShell>,
|
||||
) -> AnyElement {
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.children(
|
||||
DiagnosticsReportingPolicy::ALL.iter().copied().enumerate().map(|(index, policy)| {
|
||||
render_diagnostics_policy_row(index, policy, active_policy, cx)
|
||||
}),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn render_diagnostics_policy_row(
|
||||
index: usize,
|
||||
policy: DiagnosticsReportingPolicy,
|
||||
active_policy: DiagnosticsReportingPolicy,
|
||||
cx: &mut Context<ElyShell>,
|
||||
) -> AnyElement {
|
||||
let selected = policy == active_policy;
|
||||
|
||||
div()
|
||||
.py_3()
|
||||
.border_b_1()
|
||||
.border_color(rgb(colors::hairline()))
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_between()
|
||||
.gap_4()
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.text_color(rgb(diagnostics_policy_icon_color(policy, selected)))
|
||||
.child(diagnostics_policy_icon(policy, selected)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.truncate()
|
||||
.text_color(rgb(colors::ink()))
|
||||
.child(policy.name()),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.truncate()
|
||||
.text_color(rgb(colors::muted()))
|
||||
.child(policy.detail()),
|
||||
),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
Button::new(("diagnostics-reporting-policy", index))
|
||||
.ghost()
|
||||
.xsmall()
|
||||
.selected(selected)
|
||||
.label(diagnostics_policy_button_label(policy, selected))
|
||||
.tooltip(policy.name())
|
||||
.on_click(cx.listener(move |shell, _, _, cx| {
|
||||
shell.set_diagnostics_reporting_policy(policy, cx);
|
||||
})),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn render_history_policy_row(
|
||||
index: usize,
|
||||
policy: HistoryRecordingPolicy,
|
||||
@@ -331,13 +250,6 @@ fn privacy_icon(policy: HistoryRecordingPolicy) -> IconName {
|
||||
}
|
||||
}
|
||||
|
||||
fn diagnostics_icon(policy: DiagnosticsReportingPolicy) -> IconName {
|
||||
match policy {
|
||||
DiagnosticsReportingPolicy::Minimal => IconName::Info,
|
||||
DiagnosticsReportingPolicy::Paused => IconName::EyeOff,
|
||||
}
|
||||
}
|
||||
|
||||
fn policy_color(policy: HistoryRecordingPolicy) -> u32 {
|
||||
match policy {
|
||||
HistoryRecordingPolicy::Record => colors::success(),
|
||||
@@ -345,29 +257,14 @@ fn policy_color(policy: HistoryRecordingPolicy) -> u32 {
|
||||
}
|
||||
}
|
||||
|
||||
fn diagnostics_policy_color(policy: DiagnosticsReportingPolicy) -> u32 {
|
||||
match policy {
|
||||
DiagnosticsReportingPolicy::Minimal => colors::success(),
|
||||
DiagnosticsReportingPolicy::Paused => colors::primary(),
|
||||
}
|
||||
}
|
||||
|
||||
fn history_policy_icon(policy: HistoryRecordingPolicy, selected: bool) -> IconName {
|
||||
if selected { IconName::CircleCheck } else { privacy_icon(policy) }
|
||||
}
|
||||
|
||||
fn diagnostics_policy_icon(policy: DiagnosticsReportingPolicy, selected: bool) -> IconName {
|
||||
if selected { IconName::CircleCheck } else { diagnostics_icon(policy) }
|
||||
}
|
||||
|
||||
fn history_policy_icon_color(policy: HistoryRecordingPolicy, selected: bool) -> u32 {
|
||||
if selected { policy_color(policy) } else { colors::muted_soft() }
|
||||
}
|
||||
|
||||
fn diagnostics_policy_icon_color(policy: DiagnosticsReportingPolicy, selected: bool) -> u32 {
|
||||
if selected { diagnostics_policy_color(policy) } else { colors::muted_soft() }
|
||||
}
|
||||
|
||||
fn history_policy_button_label(policy: HistoryRecordingPolicy, selected: bool) -> &'static str {
|
||||
match (policy, selected) {
|
||||
(HistoryRecordingPolicy::Record, true) => "Default",
|
||||
@@ -375,14 +272,3 @@ fn history_policy_button_label(policy: HistoryRecordingPolicy, selected: bool) -
|
||||
_ => "Select",
|
||||
}
|
||||
}
|
||||
|
||||
fn diagnostics_policy_button_label(
|
||||
policy: DiagnosticsReportingPolicy,
|
||||
selected: bool,
|
||||
) -> &'static str {
|
||||
match (policy, selected) {
|
||||
(DiagnosticsReportingPolicy::Minimal, true) => "Default",
|
||||
(_, true) => "Active",
|
||||
_ => "Select",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +345,6 @@ fn diagnostic_report(
|
||||
format!("Space: {}", snapshot.active_space_name),
|
||||
format!("Profile: {}", snapshot.active_profile_name),
|
||||
format!("Profile kind: {}", profile_kind_label(&snapshot.active_profile_kind)),
|
||||
format!("Diagnostics reporting: {}", snapshot.diagnostics_reporting_policy.status()),
|
||||
format!("Local diagnostics: {}", snapshot.diagnostic_events.len()),
|
||||
format!("URL scope: {}", diagnostic_url_scope(active_tab)),
|
||||
format!("Tab title: {}", active_tab.title()),
|
||||
@@ -439,8 +438,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diagnostic_report_includes_privacy_and_local_event_count()
|
||||
-> Result<(), Box<dyn std::error::Error>> {
|
||||
fn diagnostic_report_includes_local_event_count() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
let snapshot = core.snapshot()?;
|
||||
let active_tab = active_tab(&snapshot)
|
||||
@@ -448,8 +446,8 @@ mod tests {
|
||||
let origin = origin_for_tab(active_tab);
|
||||
let report = diagnostic_report(&snapshot, active_tab, origin.as_ref());
|
||||
|
||||
assert!(report.contains("Diagnostics reporting: Diagnostics reporting is on"));
|
||||
assert!(report.contains("Local diagnostics: 1"));
|
||||
assert!(!report.contains("Diagnostics reporting:"));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use ely_browser_core::SyncEngine;
|
||||
use ely_domain::{
|
||||
ArchivePolicy, DEFAULT_TRANSLUCENCY_PCT, DiagnosticsReportingPolicy, DownloadPolicy,
|
||||
FavoriteLimit, HistoryRecordingPolicy, NewTabDestination, ProfileId, ProfileSyncPolicy,
|
||||
SearchEngine, SyncObjectKind, SyncObjectPolicy, ThemeMode, WallpaperTheme,
|
||||
ArchivePolicy, DEFAULT_TRANSLUCENCY_PCT, DownloadPolicy, FavoriteLimit, HistoryRecordingPolicy,
|
||||
NewTabDestination, ProfileId, ProfileSyncPolicy, SearchEngine, SyncObjectKind,
|
||||
SyncObjectPolicy, ThemeMode, WallpaperTheme,
|
||||
};
|
||||
use gpui::Context;
|
||||
use gpui_component::slider::SliderValue;
|
||||
@@ -149,17 +149,6 @@ impl ElyShell {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn set_diagnostics_reporting_policy(
|
||||
&mut self,
|
||||
policy: DiagnosticsReportingPolicy,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let ShellState::Ready(core) = &mut self.state {
|
||||
core.set_diagnostics_reporting_policy(policy);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn reset_privacy_settings(&mut self, cx: &mut Context<Self>) {
|
||||
if let ShellState::Ready(core) = &mut self.state {
|
||||
core.reset_privacy_settings();
|
||||
|
||||
@@ -2,10 +2,10 @@ use std::{collections::BTreeMap, time::SystemTime};
|
||||
|
||||
use ely_domain::{
|
||||
AppearanceSettings, ArchivePolicy, ArchivedTab, BookmarkEntry, BrowserTab, DiagnosticEvent,
|
||||
DiagnosticsReportingPolicy, DomainError, DownloadEntry, DownloadPolicy, FavoriteLimit,
|
||||
HistoryEntry, HistoryRecordingPolicy, NewTabDestination, NoteEntry, Profile, ProfileId,
|
||||
ProfileKind, ReadingListEntry, SearchEngine, SitePermissionAuditEvent, SitePermissionEntry,
|
||||
Space, SpaceId, SplitLayout, SyncStatus, TabGroup, TabId, UrlText,
|
||||
DomainError, DownloadEntry, DownloadPolicy, FavoriteLimit, HistoryEntry,
|
||||
HistoryRecordingPolicy, NewTabDestination, NoteEntry, Profile, ProfileId, ProfileKind,
|
||||
ReadingListEntry, SearchEngine, SitePermissionAuditEvent, SitePermissionEntry, Space, SpaceId,
|
||||
SplitLayout, SyncStatus, TabGroup, TabId, UrlText,
|
||||
};
|
||||
|
||||
use crate::{CoreError, navigation::tab_title};
|
||||
@@ -136,7 +136,6 @@ pub struct BrowserSnapshot {
|
||||
pub search_engine: SearchEngine,
|
||||
pub new_tab_destination: NewTabDestination,
|
||||
pub history_recording_policy: HistoryRecordingPolicy,
|
||||
pub diagnostics_reporting_policy: DiagnosticsReportingPolicy,
|
||||
pub favorite_limit: FavoriteLimit,
|
||||
pub appearance: AppearanceSettings,
|
||||
pub command_query: String,
|
||||
@@ -177,7 +176,6 @@ pub struct BrowserCore {
|
||||
search_engine: SearchEngine,
|
||||
new_tab_destination: NewTabDestination,
|
||||
history_recording_policy: HistoryRecordingPolicy,
|
||||
diagnostics_reporting_policy: DiagnosticsReportingPolicy,
|
||||
favorite_limit: FavoriteLimit,
|
||||
appearance: AppearanceSettings,
|
||||
sync_object_policies: SyncObjectPolicies,
|
||||
@@ -229,7 +227,6 @@ impl BrowserCore {
|
||||
search_engine: SearchEngine::default(),
|
||||
new_tab_destination,
|
||||
history_recording_policy: HistoryRecordingPolicy::default(),
|
||||
diagnostics_reporting_policy: DiagnosticsReportingPolicy::default(),
|
||||
favorite_limit: FavoriteLimit::default(),
|
||||
appearance: AppearanceSettings::default(),
|
||||
sync_object_policies: SyncObjectPolicies::default(),
|
||||
@@ -381,7 +378,6 @@ impl BrowserCore {
|
||||
search_engine: self.search_engine,
|
||||
new_tab_destination: self.new_tab_destination,
|
||||
history_recording_policy: self.history_recording_policy,
|
||||
diagnostics_reporting_policy: self.diagnostics_reporting_policy,
|
||||
favorite_limit: self.favorite_limit,
|
||||
appearance: self.appearance,
|
||||
command_query: self.command_query.clone(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ely_domain::{DiagnosticsReportingPolicy, HistoryRecordingPolicy};
|
||||
use ely_domain::HistoryRecordingPolicy;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::BrowserCore;
|
||||
@@ -82,13 +82,8 @@ impl BrowserCore {
|
||||
self.history_recording_policy = policy;
|
||||
}
|
||||
|
||||
pub fn set_diagnostics_reporting_policy(&mut self, policy: DiagnosticsReportingPolicy) {
|
||||
self.diagnostics_reporting_policy = policy;
|
||||
}
|
||||
|
||||
pub fn reset_privacy_settings(&mut self) {
|
||||
self.set_history_recording_policy(HistoryRecordingPolicy::default());
|
||||
self.set_diagnostics_reporting_policy(DiagnosticsReportingPolicy::default());
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -96,11 +91,6 @@ impl BrowserCore {
|
||||
self.history_recording_policy
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn diagnostics_reporting_policy(&self) -> DiagnosticsReportingPolicy {
|
||||
self.diagnostics_reporting_policy
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn active_profile_local_data_inventory(&self) -> LocalDataInventory {
|
||||
let profile_id = &self.active_profile_id;
|
||||
|
||||
@@ -2,9 +2,9 @@ use std::{error::Error, path::PathBuf};
|
||||
|
||||
use ely_browser_core::{BrowserCore, InitialBrowserConfig};
|
||||
use ely_domain::{
|
||||
ArchivePolicy, DEFAULT_SIDEBAR_WIDTH_PX, DiagnosticsReportingPolicy, DownloadPolicy,
|
||||
FavoriteLimit, HistoryRecordingPolicy, NewTabDestination, ProfileKind, ProfileSyncPolicy,
|
||||
SearchEngine, SyncObjectKind, SyncObjectPolicy,
|
||||
ArchivePolicy, DEFAULT_SIDEBAR_WIDTH_PX, DownloadPolicy, FavoriteLimit, HistoryRecordingPolicy,
|
||||
NewTabDestination, ProfileKind, ProfileSyncPolicy, SearchEngine, SyncObjectKind,
|
||||
SyncObjectPolicy,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -20,11 +20,9 @@ fn section_resets_restore_settings_defaults() -> Result<(), Box<dyn Error>> {
|
||||
assert_eq!(core.snapshot()?.search_engine, SearchEngine::DuckDuckGo);
|
||||
|
||||
core.set_history_recording_policy(HistoryRecordingPolicy::Pause);
|
||||
core.set_diagnostics_reporting_policy(DiagnosticsReportingPolicy::Paused);
|
||||
core.reset_privacy_settings();
|
||||
let snapshot = core.snapshot()?;
|
||||
assert_eq!(snapshot.history_recording_policy, HistoryRecordingPolicy::Record);
|
||||
assert_eq!(snapshot.diagnostics_reporting_policy, DiagnosticsReportingPolicy::Minimal);
|
||||
|
||||
let active_space_id = snapshot.active_space_id;
|
||||
core.set_active_space_archive_policy(ArchivePolicy::IdleDays(30))?;
|
||||
|
||||
@@ -49,7 +49,7 @@ pub use plugin::{
|
||||
PluginContributionPoint, PluginId, PluginManifest, PluginPermission, PluginPermissionRisk,
|
||||
PluginSignature, PluginSignatureAlgorithm,
|
||||
};
|
||||
pub use privacy::{DiagnosticsReportingPolicy, HistoryRecordingPolicy};
|
||||
pub use privacy::HistoryRecordingPolicy;
|
||||
pub use profile::{Profile, ProfileKind, ProfileSyncPolicy};
|
||||
pub use reading_list::{ReadingListEntry, ReadingProgress, ReadingProgressPercent};
|
||||
pub use search::SearchEngine;
|
||||
|
||||
@@ -37,45 +37,3 @@ impl HistoryRecordingPolicy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub enum DiagnosticsReportingPolicy {
|
||||
#[default]
|
||||
Minimal,
|
||||
Paused,
|
||||
}
|
||||
|
||||
impl DiagnosticsReportingPolicy {
|
||||
pub const ALL: &[Self] = &[Self::Minimal, Self::Paused];
|
||||
|
||||
#[must_use]
|
||||
pub fn reports_diagnostics(self) -> bool {
|
||||
matches!(self, Self::Minimal)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
Self::Minimal => "Minimal Diagnostics",
|
||||
Self::Paused => "Paused Diagnostics",
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn detail(self) -> &'static str {
|
||||
match self {
|
||||
Self::Minimal => {
|
||||
"Send startup, crash, WebView crash, sync error, plugin crash, and update result codes."
|
||||
}
|
||||
Self::Paused => "Keep diagnostics local for review and privacy exports.",
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn status(self) -> &'static str {
|
||||
match self {
|
||||
Self::Minimal => "Diagnostics reporting is on",
|
||||
Self::Paused => "Diagnostics reporting is paused",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user