Add sync settings status page

This commit is contained in:
2026-05-08 00:16:56 -04:00
parent f10a2349f6
commit 479737a8b2
10 changed files with 358 additions and 2 deletions
@@ -90,6 +90,10 @@ pub(crate) fn settings_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://settings")
}
pub(crate) fn sync_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://settings/sync")
}
pub(crate) fn settings_page_url(query: &str) -> Result<Option<UrlText>, CoreError> {
let normalized_query = query.trim().to_ascii_lowercase();
let Some(url) = settings_page_route(&normalized_query) else {
+4 -1
View File
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use ely_domain::{
ArchivedTab, BrowserTab, DomainError, DownloadEntry, DownloadPolicy, HistoryEntry, Profile,
ProfileId, ProfileKind, Space, SpaceId, TabId, UrlText,
ProfileId, ProfileKind, Space, SpaceId, SyncStatus, TabId, UrlText,
};
use crate::CoreError;
@@ -12,6 +12,7 @@ mod downloads;
mod history;
mod plugins;
mod profiles;
mod sync;
mod tabs;
pub use plugins::{InstalledPlugin, PluginAuditAction, PluginAuditEvent};
@@ -47,6 +48,7 @@ pub struct BrowserSnapshot {
pub plugin_audit_events: Vec<PluginAuditEvent>,
pub spaces: Vec<Space>,
pub profiles: Vec<Profile>,
pub sync_status: SyncStatus,
pub active_tab_id: TabId,
pub active_space_id: SpaceId,
pub active_profile_id: ProfileId,
@@ -201,6 +203,7 @@ impl BrowserCore {
plugin_audit_events: self.plugin_audit_events.clone(),
spaces: self.spaces.clone(),
profiles: self.profiles.clone(),
sync_status: self.sync_status(),
tabs: self.visible_tabs(),
active_tab_id: self.active_tab_id.clone(),
active_space_id: self.active_space_id.clone(),
@@ -4,7 +4,7 @@ use crate::{
CoreError,
navigation::{
downloads_url, history_url, move_tab_space_name, new_profile_name, new_space_name,
search_url, settings_page_url, settings_url, space_icon, switch_profile_name,
search_url, settings_page_url, settings_url, space_icon, switch_profile_name, sync_url,
},
};
@@ -109,6 +109,10 @@ impl BrowserCore {
self.open_tab(settings_url()?);
Ok(true)
}
"sync" | "open-sync-status" | "open sync status" => {
self.open_tab(sync_url()?);
Ok(true)
}
"close-tab" => {
self.close_active_tab()?;
Ok(true)
+35
View File
@@ -0,0 +1,35 @@
use ely_domain::{SyncObjectKind, SyncObjectState, SyncObjectStatus, SyncStatus};
use super::BrowserCore;
impl BrowserCore {
pub(super) fn sync_status(&self) -> SyncStatus {
SyncStatus::signed_out(vec![
SyncObjectStatus::new(
SyncObjectKind::Spaces,
self.spaces.len(),
SyncObjectState::LocalOnly,
),
SyncObjectStatus::new(
SyncObjectKind::Tabs,
self.tabs.len(),
SyncObjectState::LocalOnly,
),
SyncObjectStatus::new(
SyncObjectKind::Profiles,
self.profiles.len(),
SyncObjectState::LocalOnly,
),
SyncObjectStatus::new(
SyncObjectKind::History,
self.history_entries.len(),
SyncObjectState::PrivacyControlled,
),
SyncObjectStatus::new(
SyncObjectKind::PluginSettings,
self.installed_plugins.len(),
SyncObjectState::LocalOnly,
),
])
}
}
+15
View File
@@ -96,6 +96,21 @@ fn open_settings_command_opens_settings_page() -> Result<(), Box<dyn Error>> {
Ok(())
}
#[test]
fn open_sync_status_command_opens_sync_settings_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.set_command_query(">open-sync-status");
let intent = core.submit_command()?;
let active_tab = core.active_tab()?;
assert_eq!(intent, Some(CommandIntent::Command("open-sync-status".to_string())));
assert_eq!(active_tab.title(), "Sync Settings");
assert_eq!(active_tab.url().as_str(), "ely://settings/sync");
assert_eq!(core.snapshot()?.command_query, "");
Ok(())
}
#[test]
fn settings_scoped_search_opens_matching_settings_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
+29
View File
@@ -0,0 +1,29 @@
use std::error::Error;
use ely_browser_core::{BrowserCore, InitialBrowserConfig};
use ely_domain::{SyncConnectionState, SyncObjectKind, SyncObjectState, SyncObjectStatus, UrlText};
#[test]
fn default_sync_status_reflects_local_browser_state() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.create_space("Research", "R", 0xf54e00)?;
core.open_tab(UrlText::parse("https://example.com/research")?);
let snapshot = core.snapshot()?;
let status = &snapshot.sync_status;
assert_eq!(status.connection(), &SyncConnectionState::SignedOut);
assert_eq!(status.pending_objects(), 0);
assert_eq!(status.failed_objects(), 0);
assert_eq!(
status.objects(),
&[
SyncObjectStatus::new(SyncObjectKind::Spaces, 2, SyncObjectState::LocalOnly),
SyncObjectStatus::new(SyncObjectKind::Tabs, 3, SyncObjectState::LocalOnly),
SyncObjectStatus::new(SyncObjectKind::Profiles, 1, SyncObjectState::LocalOnly),
SyncObjectStatus::new(SyncObjectKind::History, 1, SyncObjectState::PrivacyControlled),
SyncObjectStatus::new(SyncObjectKind::PluginSettings, 0, SyncObjectState::LocalOnly),
],
);
Ok(())
}