Open history and settings pages

This commit is contained in:
2026-05-07 21:00:51 -04:00
parent 4d50946072
commit 3fe737adad
6 changed files with 90 additions and 14 deletions
+15 -1
View File
@@ -17,6 +17,8 @@ fn internal_page_title(url: &str) -> Option<&'static str> {
match url {
"ely://new-tab" => Some("New Tab"),
"ely://downloads" => Some("Downloads"),
"ely://history" => Some("History"),
"ely://settings" => Some("Settings"),
_ => None,
}
}
@@ -69,5 +71,17 @@ pub(crate) fn search_url(query: &str) -> Result<UrlText, CoreError> {
}
pub(crate) fn downloads_url() -> Result<UrlText, CoreError> {
UrlText::parse("ely://downloads").map_err(CoreError::from)
internal_page_url("ely://downloads")
}
pub(crate) fn history_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://history")
}
pub(crate) fn settings_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://settings")
}
fn internal_page_url(value: &str) -> Result<UrlText, CoreError> {
UrlText::parse(value).map_err(CoreError::from)
}
+10 -2
View File
@@ -3,8 +3,8 @@ use ely_domain::{CommandIntent, CommandScope, ProfileId, ProfileKind, SpaceId};
use crate::{
CoreError,
navigation::{
downloads_url, move_tab_space_name, new_profile_name, new_space_name, search_url,
space_icon, switch_profile_name,
downloads_url, history_url, move_tab_space_name, new_profile_name, new_space_name,
search_url, settings_url, space_icon, switch_profile_name,
},
};
@@ -89,6 +89,14 @@ impl BrowserCore {
self.open_tab(downloads_url()?);
Ok(true)
}
"history" | "open-history" | "open history" => {
self.open_tab(history_url()?);
Ok(true)
}
"settings" | "open-settings" | "open settings" => {
self.open_tab(settings_url()?);
Ok(true)
}
"close-tab" => {
self.close_active_tab()?;
Ok(true)
+30
View File
@@ -66,6 +66,36 @@ fn open_downloads_command_opens_downloads_page() -> Result<(), Box<dyn Error>> {
Ok(())
}
#[test]
fn open_history_command_opens_history_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.set_command_query(">open-history");
let intent = core.submit_command()?;
let active_tab = core.active_tab()?;
assert_eq!(intent, Some(CommandIntent::Command("open-history".to_string())));
assert_eq!(active_tab.title(), "History");
assert_eq!(active_tab.url().as_str(), "ely://history");
assert_eq!(core.snapshot()?.command_query, "");
Ok(())
}
#[test]
fn open_settings_command_opens_settings_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.set_command_query(">open-settings");
let intent = core.submit_command()?;
let active_tab = core.active_tab()?;
assert_eq!(intent, Some(CommandIntent::Command("open-settings".to_string())));
assert_eq!(active_tab.title(), "Settings");
assert_eq!(active_tab.url().as_str(), "ely://settings");
assert_eq!(core.snapshot()?.command_query, "");
Ok(())
}
#[test]
fn new_space_command_creates_and_selects_named_space() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;