refactor(settings): fold the read-only Advanced page into its owning sections
This commit is contained in:
@@ -74,14 +74,11 @@ const NAV_GROUPS: &[NavGroup] = &[
|
|||||||
},
|
},
|
||||||
NavGroup {
|
NavGroup {
|
||||||
label: "POWER",
|
label: "POWER",
|
||||||
items: &[
|
items: &[NavItem {
|
||||||
NavItem { icon: IconName::Asterisk, label: "Plugins", route: "ely://settings/plugins" },
|
icon: IconName::Asterisk,
|
||||||
NavItem {
|
label: "Plugins",
|
||||||
icon: IconName::Inspector,
|
route: "ely://settings/plugins",
|
||||||
label: "Advanced",
|
}],
|
||||||
route: "ely://settings/advanced",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
NavGroup {
|
NavGroup {
|
||||||
label: "ABOUT",
|
label: "ABOUT",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
mod about;
|
mod about;
|
||||||
mod advanced;
|
|
||||||
mod appearance;
|
mod appearance;
|
||||||
mod auth_callback;
|
mod auth_callback;
|
||||||
mod bookmarks;
|
mod bookmarks;
|
||||||
@@ -84,10 +83,6 @@ impl ElyShell {
|
|||||||
}
|
}
|
||||||
"ely://about" => self.render_about_page(snapshot),
|
"ely://about" => self.render_about_page(snapshot),
|
||||||
"ely://settings" => self.render_settings_page(snapshot, cx),
|
"ely://settings" => self.render_settings_page(snapshot, cx),
|
||||||
url @ "ely://settings/advanced" => {
|
|
||||||
let content = self.render_advanced_page(snapshot);
|
|
||||||
render_settings_shell(snapshot, url, content, cx)
|
|
||||||
}
|
|
||||||
url @ "ely://settings/appearance" => {
|
url @ "ely://settings/appearance" => {
|
||||||
let content = self.render_appearance_page(snapshot, cx);
|
let content = self.render_appearance_page(snapshot, cx);
|
||||||
render_settings_shell(snapshot, url, content, cx)
|
render_settings_shell(snapshot, url, content, cx)
|
||||||
|
|||||||
@@ -1,150 +0,0 @@
|
|||||||
use ely_browser_core::BrowserSnapshot;
|
|
||||||
use ely_design_system::colors;
|
|
||||||
use ely_domain::{ArchivePolicy, Space};
|
|
||||||
use gpui::{AnyElement, IntoElement, ParentElement, Styled, div, px, rgb};
|
|
||||||
use gpui_component::{IconName, StyledExt, scroll::ScrollableElement};
|
|
||||||
|
|
||||||
use super::{ElyShell, download_labels::download_policy_label, render_canvas_surface};
|
|
||||||
|
|
||||||
impl ElyShell {
|
|
||||||
pub(super) fn render_advanced_page(&mut self, snapshot: &BrowserSnapshot) -> AnyElement {
|
|
||||||
render_canvas_surface(
|
|
||||||
div()
|
|
||||||
.size_full()
|
|
||||||
.p_8()
|
|
||||||
.flex()
|
|
||||||
.flex_col()
|
|
||||||
.gap_5()
|
|
||||||
.child(render_advanced_header())
|
|
||||||
.child(render_advanced_rows(snapshot)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_advanced_header() -> AnyElement {
|
|
||||||
div()
|
|
||||||
.flex()
|
|
||||||
.items_center()
|
|
||||||
.justify_between()
|
|
||||||
.gap_4()
|
|
||||||
.child(div().text_size(px(26.0)).text_color(rgb(colors::ink())).child("Advanced"))
|
|
||||||
.into_any_element()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_advanced_rows(snapshot: &BrowserSnapshot) -> AnyElement {
|
|
||||||
let active_space = snapshot.spaces.iter().find(|space| space.id() == &snapshot.active_space_id);
|
|
||||||
|
|
||||||
div()
|
|
||||||
.flex_1()
|
|
||||||
.min_h_0()
|
|
||||||
.flex()
|
|
||||||
.flex_col()
|
|
||||||
.overflow_y_scrollbar()
|
|
||||||
.border_t_1()
|
|
||||||
.border_color(rgb(colors::hairline()))
|
|
||||||
.child(advanced_row(
|
|
||||||
IconName::Eye,
|
|
||||||
"History Recording",
|
|
||||||
snapshot.history_recording_policy.status(),
|
|
||||||
snapshot.history_recording_policy.detail(),
|
|
||||||
))
|
|
||||||
.child(advanced_row(
|
|
||||||
IconName::Star,
|
|
||||||
"Favorite Limit",
|
|
||||||
snapshot.favorite_limit.label(),
|
|
||||||
snapshot.favorite_limit.detail(),
|
|
||||||
))
|
|
||||||
.child(render_sidebar_width_row(active_space))
|
|
||||||
.child(render_archive_policy_row(active_space))
|
|
||||||
.child(advanced_row(
|
|
||||||
IconName::Folder,
|
|
||||||
"Download Policy",
|
|
||||||
download_policy_label(&snapshot.active_download_policy),
|
|
||||||
"Active Profile download destination policy",
|
|
||||||
))
|
|
||||||
.into_any_element()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_sidebar_width_row(active_space: Option<&Space>) -> AnyElement {
|
|
||||||
let value = active_space
|
|
||||||
.map(|space| format!("{} px", space.sidebar_width_px()))
|
|
||||||
.unwrap_or_else(|| "Unavailable".to_string());
|
|
||||||
advanced_row(IconName::PanelLeft, "Sidebar Width", value, "Current Space sidebar width")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_archive_policy_row(active_space: Option<&Space>) -> AnyElement {
|
|
||||||
let value = active_space
|
|
||||||
.map(|space| archive_policy_label(space.archive_policy()).to_string())
|
|
||||||
.unwrap_or_else(|| "Unavailable".to_string());
|
|
||||||
advanced_row(IconName::Inbox, "Auto Archive", value, "Current Space idle unpinned tab policy")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn advanced_row(
|
|
||||||
icon: IconName,
|
|
||||||
label: &'static str,
|
|
||||||
value: impl Into<String>,
|
|
||||||
detail: impl Into<String>,
|
|
||||||
) -> AnyElement {
|
|
||||||
let value = value.into();
|
|
||||||
let detail = detail.into();
|
|
||||||
|
|
||||||
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(colors::muted_soft())).child(icon))
|
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.min_w_0()
|
|
||||||
.flex()
|
|
||||||
.flex_col()
|
|
||||||
.gap_1()
|
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.text_sm()
|
|
||||||
.font_semibold()
|
|
||||||
.truncate()
|
|
||||||
.text_color(rgb(colors::ink()))
|
|
||||||
.child(label),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.text_xs()
|
|
||||||
.truncate()
|
|
||||||
.text_color(rgb(colors::muted()))
|
|
||||||
.child(detail),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.max_w(px(280.0))
|
|
||||||
.truncate()
|
|
||||||
.text_sm()
|
|
||||||
.font_semibold()
|
|
||||||
.text_color(rgb(colors::ink()))
|
|
||||||
.child(value),
|
|
||||||
)
|
|
||||||
.into_any_element()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn archive_policy_label(policy: &ArchivePolicy) -> &'static str {
|
|
||||||
match policy {
|
|
||||||
ArchivePolicy::Manual => "Manual",
|
|
||||||
ArchivePolicy::IdleDays(0) => "Today",
|
|
||||||
ArchivePolicy::IdleDays(1) => "1 day",
|
|
||||||
ArchivePolicy::IdleDays(7) => "7 days",
|
|
||||||
ArchivePolicy::IdleDays(30) => "30 days",
|
|
||||||
ArchivePolicy::IdleDays(_) => "Custom",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -430,10 +430,10 @@ mod tests {
|
|||||||
SpaceId::new(),
|
SpaceId::new(),
|
||||||
ProfileId::new(),
|
ProfileId::new(),
|
||||||
"Settings",
|
"Settings",
|
||||||
UrlText::parse("ely://settings/advanced")?,
|
UrlText::parse("ely://settings/general")?,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(diagnostic_url_scope(&tab), "ely://settings/advanced");
|
assert_eq!(diagnostic_url_scope(&tab), "ely://settings/general");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ fn internal_page_title(url: &str) -> Option<&'static str> {
|
|||||||
url if SiteOrigin::from_site_route(url).ok().flatten().is_some() => Some("Site Settings"),
|
url if SiteOrigin::from_site_route(url).ok().flatten().is_some() => Some("Site Settings"),
|
||||||
"ely://about" => Some("About ELY Browser"),
|
"ely://about" => Some("About ELY Browser"),
|
||||||
"ely://settings" => Some("Settings"),
|
"ely://settings" => Some("Settings"),
|
||||||
"ely://settings/advanced" => Some("Advanced Settings"),
|
|
||||||
"ely://settings/general" => Some("General Settings"),
|
"ely://settings/general" => Some("General Settings"),
|
||||||
"ely://settings/appearance" => Some("Appearance Settings"),
|
"ely://settings/appearance" => Some("Appearance Settings"),
|
||||||
"ely://settings/sidebar-tabs" => Some("Sidebar & Tabs Settings"),
|
"ely://settings/sidebar-tabs" => Some("Sidebar & Tabs Settings"),
|
||||||
@@ -266,26 +265,6 @@ const SETTINGS_ROUTE_MATCHES: &[SettingsRouteMatch] = &[
|
|||||||
exact_terms: &["settings"],
|
exact_terms: &["settings"],
|
||||||
search_terms: &["Settings center", "all browser settings"],
|
search_terms: &["Settings center", "all browser settings"],
|
||||||
},
|
},
|
||||||
SettingsRouteMatch {
|
|
||||||
route: "ely://settings/advanced",
|
|
||||||
exact_terms: &[
|
|
||||||
"advanced",
|
|
||||||
"advanced settings",
|
|
||||||
"runtime",
|
|
||||||
"diagnostics",
|
|
||||||
"diagnostic",
|
|
||||||
"compatibility",
|
|
||||||
"site compatibility",
|
|
||||||
],
|
|
||||||
search_terms: &[
|
|
||||||
"Advanced",
|
|
||||||
"Local runtime policies and audit counters.",
|
|
||||||
"runtime policy",
|
|
||||||
"audit counters",
|
|
||||||
"diagnostics",
|
|
||||||
"site compatibility",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
SettingsRouteMatch {
|
SettingsRouteMatch {
|
||||||
route: "ely://settings/general",
|
route: "ely://settings/general",
|
||||||
exact_terms: &["general", "browser", "new tab", "new-tab", "startup"],
|
exact_terms: &["general", "browser", "new tab", "new-tab", "startup"],
|
||||||
|
|||||||
@@ -66,27 +66,6 @@ fn settings_scoped_search_opens_appearance_page() -> Result<(), Box<dyn Error>>
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn settings_scoped_search_opens_advanced_page() -> Result<(), Box<dyn Error>> {
|
|
||||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
|
||||||
|
|
||||||
core.set_command_query("@settings advanced");
|
|
||||||
let intent = core.submit_command()?;
|
|
||||||
let active_tab = core.active_tab()?;
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
intent,
|
|
||||||
Some(CommandIntent::ScopedSearch {
|
|
||||||
scope: CommandScope::Settings,
|
|
||||||
query: "advanced".to_string(),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
assert_eq!(active_tab.title(), "Advanced Settings");
|
|
||||||
assert_eq!(active_tab.url().as_str(), "ely://settings/advanced");
|
|
||||||
assert_eq!(core.snapshot()?.command_query, "");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn settings_scoped_search_opens_shortcuts_page() -> Result<(), Box<dyn Error>> {
|
fn settings_scoped_search_opens_shortcuts_page() -> Result<(), Box<dyn Error>> {
|
||||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user