Add downloads settings page
This commit is contained in:
@@ -29,6 +29,7 @@ fn internal_page_title(url: &str) -> Option<&'static str> {
|
||||
"ely://settings/sidebar-tabs" => Some("Sidebar & Tabs Settings"),
|
||||
"ely://settings/search" => Some("Search Settings"),
|
||||
"ely://settings/privacy-security" => Some("Privacy & Security Settings"),
|
||||
"ely://settings/downloads" => Some("Downloads Settings"),
|
||||
"ely://settings/spaces" => Some("Space Settings"),
|
||||
"ely://settings/shortcuts" => Some("Shortcut Settings"),
|
||||
"ely://settings/plugins" => Some("Plugin Settings"),
|
||||
@@ -167,6 +168,9 @@ fn settings_page_route(query: &str) -> Option<&'static str> {
|
||||
}
|
||||
"privacy" | "security" | "privacy security" | "privacy & security" | "history"
|
||||
| "history recording" => Some("ely://settings/privacy-security"),
|
||||
"download" | "downloads" | "download settings" | "downloads settings" => {
|
||||
Some("ely://settings/downloads")
|
||||
}
|
||||
"space" | "spaces" | "space settings" | "spaces settings" => Some("ely://settings/spaces"),
|
||||
"shortcut" | "shortcuts" | "keyboard" | "keyboard shortcuts" => {
|
||||
Some("ely://settings/shortcuts")
|
||||
|
||||
@@ -81,4 +81,12 @@ impl BrowserCore {
|
||||
profile.set_download_policy(download_policy);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_active_profile_download_policy(
|
||||
&mut self,
|
||||
download_policy: DownloadPolicy,
|
||||
) -> Result<(), CoreError> {
|
||||
let profile_id = self.active_profile_id.clone();
|
||||
self.set_profile_download_policy(&profile_id, download_policy)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +176,26 @@ fn records_active_profile_download_policy_on_started_entry() -> Result<(), Box<d
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn active_profile_download_policy_updates_started_entries() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
let policy = DownloadPolicy::fixed_directory("/tmp/ely-active-downloads")?;
|
||||
|
||||
core.set_active_profile_download_policy(policy.clone())?;
|
||||
core.record_download_started(
|
||||
UrlText::parse("https://example.com/manual.pdf")?,
|
||||
"manual.pdf",
|
||||
Some(1024),
|
||||
)?;
|
||||
|
||||
let snapshot = core.snapshot()?;
|
||||
let entry = active_download(&core)?;
|
||||
assert_eq!(snapshot.active_download_policy, policy);
|
||||
assert_eq!(entry.destination(), policy.destination());
|
||||
assert_eq!(entry.target_file_path(), Some(Path::new("/tmp/ely-active-downloads/manual.pdf")));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn confirms_dangerous_download_security_prompt() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
@@ -128,3 +128,24 @@ fn settings_scoped_search_opens_privacy_security_page() -> Result<(), Box<dyn Er
|
||||
assert_eq!(core.snapshot()?.command_query, "");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settings_scoped_search_opens_downloads_page() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
core.set_command_query("@settings downloads");
|
||||
let intent = core.submit_command()?;
|
||||
let active_tab = core.active_tab()?;
|
||||
|
||||
assert_eq!(
|
||||
intent,
|
||||
Some(CommandIntent::ScopedSearch {
|
||||
scope: CommandScope::Settings,
|
||||
query: "downloads".to_string(),
|
||||
})
|
||||
);
|
||||
assert_eq!(active_tab.title(), "Downloads Settings");
|
||||
assert_eq!(active_tab.url().as_str(), "ely://settings/downloads");
|
||||
assert_eq!(core.snapshot()?.command_query, "");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user