From 61cd515860b1a6feca3834edfd7c200e707f781a Mon Sep 17 00:00:00 2001 From: Luis E <35935591+luisecm@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:13:43 -0600 Subject: [PATCH 01/18] update(aria): add aria labels for settings and recovery screens (#1693) --- kit/src/elements/select/mod.rs | 2 ++ ui/src/components/debug_logger/mod.rs | 9 ++++++++ ui/src/components/settings/mod.rs | 8 +++++-- ui/src/components/settings/sub_pages/about.rs | 5 ++++ .../settings/sub_pages/accessibility.rs | 1 + ui/src/components/settings/sub_pages/audio.rs | 9 ++++++++ .../settings/sub_pages/developer.rs | 8 +++++++ ui/src/components/settings/sub_pages/files.rs | 1 + .../components/settings/sub_pages/general.rs | 5 ++++ .../components/settings/sub_pages/keybinds.rs | 1 + .../components/settings/sub_pages/licenses.rs | 2 ++ .../components/settings/sub_pages/messages.rs | 2 ++ .../settings/sub_pages/notifications.rs | 4 ++++ .../settings/sub_pages/profile/mod.rs | 23 +++++++++++++++---- ui/src/extension_browser/mod.rs | 2 ++ ui/src/layouts/log_in/copy_seed_words.rs | 22 ++++++++++++++---- ui/src/layouts/log_in/create_or_recover.rs | 3 +++ ui/src/layouts/log_in/enter_seed_words.rs | 3 +++ ui/src/layouts/log_in/enter_username.rs | 1 + 19 files changed, 100 insertions(+), 11 deletions(-) diff --git a/kit/src/elements/select/mod.rs b/kit/src/elements/select/mod.rs index 8672a5333af..5ccd3092abd 100644 --- a/kit/src/elements/select/mod.rs +++ b/kit/src/elements/select/mod.rs @@ -110,9 +110,11 @@ pub fn FancySelect<'a>(cx: Scope<'a, FancySelectProps<'a>>) -> Element<'a> { rsx!( div { class: "fancy-select-options", + aria_label: "selector-options-list", iter.map(|(val, element)| rsx!(div { class: "fancy-select-option", + aria_label: "selector-option", onclick: move |e| { if let Some(f) = &cx.props.onselect { f.call(val.clone()) diff --git a/ui/src/components/debug_logger/mod.rs b/ui/src/components/debug_logger/mod.rs index e404a8e7d2a..9dc7bac3cf0 100644 --- a/ui/src/components/debug_logger/mod.rs +++ b/ui/src/components/debug_logger/mod.rs @@ -69,6 +69,7 @@ pub fn DebugLogger(cx: Scope) -> Element { aria_label: "debug-logger-nav", Button { text: "Logs".into(), + aria_label: "logs-button".into(), icon: Icon::CommandLine, appearance: if *active_tab.get() == Tab::Logs { Appearance::Primary } else { Appearance::Secondary }, onpress: |_| { @@ -77,11 +78,14 @@ pub fn DebugLogger(cx: Scope) -> Element { }, (active_tab.get() == &Tab::Logs).then(|| cx.render(rsx!{ div { + aria_label: "filter-section", class: "section", Label { + aria_label: "filter-label".into(), text: "Filter:".into(), }, Button { + aria_label: "debug-level-button".into(), icon: Icon::BugAnt, appearance: Appearance::Secondary, onpress: |_| { @@ -95,6 +99,7 @@ pub fn DebugLogger(cx: Scope) -> Element { )), }, Button { + aria_label: "info-level-button".into(), icon: Icon::InformationCircle, appearance: if *filter_level.get() == Level::Info { Appearance::Info } else { Appearance::Secondary }, onpress: |_| { @@ -108,6 +113,7 @@ pub fn DebugLogger(cx: Scope) -> Element { )), }, Button { + aria_label: "error-level-button".into(), icon: Icon::ExclamationTriangle, appearance: if *filter_level.get() == Level::Error { Appearance::Danger } else { Appearance::Secondary }, onpress: |_| { @@ -121,6 +127,7 @@ pub fn DebugLogger(cx: Scope) -> Element { )), }, Button { + aria_label: "trace-level-button".into(), icon: Icon::Eye, appearance: Appearance::Secondary, onpress: |_| { @@ -136,6 +143,7 @@ pub fn DebugLogger(cx: Scope) -> Element { } })), Button { + aria_label: "state-button".into(), text: "State".into(), icon: Icon::Square3Stack3d, appearance: if *active_tab.get() == Tab::State { Appearance::Primary } else { Appearance::Secondary }, @@ -144,6 +152,7 @@ pub fn DebugLogger(cx: Scope) -> Element { } }, Button { + aria_label: "web-inspector-button".into(), text: "Web Inspector".into(), icon: Icon::ArrowTopRightOnSquare, appearance: Appearance::Secondary, diff --git a/ui/src/components/settings/mod.rs b/ui/src/components/settings/mod.rs index 71eea94001c..1c2ca94e997 100644 --- a/ui/src/components/settings/mod.rs +++ b/ui/src/components/settings/mod.rs @@ -9,6 +9,7 @@ pub mod sub_pages; pub struct SectionProps<'a> { section_label: String, section_description: String, + aria_label: Option, #[props(default)] no_border: bool, children: Element<'a>, @@ -16,6 +17,7 @@ pub struct SectionProps<'a> { #[allow(non_snake_case)] pub fn SettingSection<'a>(cx: Scope<'a, SectionProps<'a>>) -> Element<'a> { + let aria_label = cx.props.aria_label.clone().unwrap_or_default(); let no_border = cx .props .no_border @@ -25,7 +27,7 @@ pub fn SettingSection<'a>(cx: Scope<'a, SectionProps<'a>>) -> Element<'a> { cx.render(rsx!( div { class: "settings-section disable-select {no_border}", - aria_label: "settings-section", + aria_label: "{aria_label}", div { class: "settings-info", aria_label: "settings-info", @@ -49,14 +51,16 @@ pub fn SettingSection<'a>(cx: Scope<'a, SectionProps<'a>>) -> Element<'a> { #[derive(Props)] pub struct SectionSimpleProps<'a> { + aria_label: Option, children: Element<'a>, } #[allow(non_snake_case)] pub fn SettingSectionSimple<'a>(cx: Scope<'a, SectionSimpleProps<'a>>) -> Element<'a> { + let aria_label = cx.props.aria_label.clone().unwrap_or_default(); cx.render(rsx!( div { class: "settings-section simple disable-select", - aria_label: "settings-section", + aria_label: "{aria_label}", cx.props.children.is_some().then(|| rsx!( div { class: "settings-control", diff --git a/ui/src/components/settings/sub_pages/about.rs b/ui/src/components/settings/sub_pages/about.rs index b52be913b7a..abeef9daaf8 100644 --- a/ui/src/components/settings/sub_pages/about.rs +++ b/ui/src/components/settings/sub_pages/about.rs @@ -171,6 +171,7 @@ pub fn AboutPage(cx: Scope) -> Element { div { id: "settings-about", SettingSection { + aria_label: "about-info-section".into(), section_label: get_local_text("settings-about.info"), section_description: app_name.into(), }, @@ -187,6 +188,7 @@ pub fn AboutPage(cx: Scope) -> Element { } }, SettingSection { + aria_label: "about-version-section".into(), section_label: get_local_text("settings-about.version"), section_description: version.into(), div { @@ -195,6 +197,7 @@ pub fn AboutPage(cx: Scope) -> Element { }, } SettingSection { + aria_label: "open-website-section".into(), section_label: get_local_text("settings-about.open-website"), section_description: get_local_text("settings-about.open-website-description"), Button { @@ -208,6 +211,7 @@ pub fn AboutPage(cx: Scope) -> Element { } }, SettingSection { + aria_label: "open-codebase-section".into(), section_label: get_local_text("settings-about.open-codebase"), section_description: get_local_text("settings-about.open-codebase-description"), Button { @@ -221,6 +225,7 @@ pub fn AboutPage(cx: Scope) -> Element { } }, SettingSection { + aria_label: "made-in-section".into(), section_label: get_local_text("settings-about.made-in"), section_description: get_local_text("settings-about.team"), div { diff --git a/ui/src/components/settings/sub_pages/accessibility.rs b/ui/src/components/settings/sub_pages/accessibility.rs index 7aa824007bb..82d2dec8bb7 100644 --- a/ui/src/components/settings/sub_pages/accessibility.rs +++ b/ui/src/components/settings/sub_pages/accessibility.rs @@ -19,6 +19,7 @@ pub fn AccessibilitySettings(cx: Scope) -> Element { div { class: format_args!("{}", if state.read().configuration.general.dyslexia_support {"open-dyslexic-activated"} else {"open-dyslexic"}), SettingSection { + aria_label: "open-dyslexic-section".into(), section_label: get_local_text("settings-accessibility.dyslexia"), section_description: get_local_text("settings-accessibility.dyslexia-description"), Switch { diff --git a/ui/src/components/settings/sub_pages/audio.rs b/ui/src/components/settings/sub_pages/audio.rs index c1af921877b..a894f087dda 100644 --- a/ui/src/components/settings/sub_pages/audio.rs +++ b/ui/src/components/settings/sub_pages/audio.rs @@ -248,6 +248,7 @@ pub fn AudioSettings(cx: Scope) -> Element { id: "settings-audio", aria_label: "settings-audio", SettingSection { + aria_label: "input-device-section".into(), section_label: get_local_text("settings-audio.input-device"), section_description: get_local_text("settings-audio.input-device-description"), Select { @@ -271,6 +272,7 @@ pub fn AudioSettings(cx: Scope) -> Element { // } // } SettingSectionSimple { + aria_label: "test-device-input-section".into(), Button { text: get_local_text("settings-audio.device-test"), disabled: false, @@ -283,6 +285,7 @@ pub fn AudioSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "output-device-section".into(), section_label: get_local_text("settings-audio.output-device"), section_description: get_local_text("settings-audio.output-device-description"), Select { @@ -306,6 +309,7 @@ pub fn AudioSettings(cx: Scope) -> Element { // } // } SettingSectionSimple { + aria_label: "test-device-output-section".into(), Button { text: get_local_text("settings-audio.device-test"), disabled: false, @@ -344,6 +348,7 @@ pub fn AudioSettings(cx: Scope) -> Element { //} SettingSection { + aria_label: "echo-cancellation-section".into(), section_label: get_local_text("settings-audio.echo-cancellation"), section_description: get_local_text("settings-audio.echo-cancellation-description"), Switch { @@ -361,6 +366,7 @@ pub fn AudioSettings(cx: Scope) -> Element { }, SettingSection { + aria_label: "interface-sounds-section".into(), section_label: get_local_text("settings-audio.interface-sounds"), section_description: get_local_text("settings-audio.interface-sounds-description"), Switch { @@ -374,6 +380,7 @@ pub fn AudioSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "media-sounds-section".into(), section_label: get_local_text("settings-audio.media-sounds"), section_description: get_local_text("settings-audio.media-sounds-description"), Switch { @@ -387,6 +394,7 @@ pub fn AudioSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "message-sounds-section".into(), section_label: get_local_text("settings-audio.message-sounds"), section_description: get_local_text("settings-audio.message-sounds-description"), Switch { @@ -400,6 +408,7 @@ pub fn AudioSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "call-timer-section".into(), section_label: get_local_text("settings-audio.call-timer"), section_description: get_local_text("settings-audio.call-timer-description"), Switch {} diff --git a/ui/src/components/settings/sub_pages/developer.rs b/ui/src/components/settings/sub_pages/developer.rs index 063365b67c1..6a3afb77474 100644 --- a/ui/src/components/settings/sub_pages/developer.rs +++ b/ui/src/components/settings/sub_pages/developer.rs @@ -61,6 +61,7 @@ pub fn DeveloperSettings(cx: Scope) -> Element { id: "settings-developer", aria_label: "settings-developer", SettingSection { + aria_label: "experimental-features-section".into(), section_label: get_local_text("settings-developer.experimental-features"), section_description: get_local_text("settings-developer.experimental-features-description"), Switch { @@ -71,6 +72,7 @@ pub fn DeveloperSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "developer-mode-section".into(), section_label: get_local_text("settings-developer.developer-mode"), section_description: get_local_text("settings-developer.developer-mode-description"), Switch { @@ -85,6 +87,7 @@ pub fn DeveloperSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "test-notification-section".into(), section_label: get_local_text("settings-developer.test-notification"), section_description: get_local_text("settings-developer.test-notification-description"), Button { @@ -107,6 +110,7 @@ pub fn DeveloperSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "open-cache-section".into(), section_label: get_local_text("settings-developer.open-cache"), section_description: get_local_text("settings-developer.open-cache-description"), Button { @@ -120,6 +124,7 @@ pub fn DeveloperSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "compress-download-cache-section".into(), section_label: get_local_text("settings-developer.compress-download-cache"), section_description: get_local_text("settings-developer.compress-download-cache-description"), Button { @@ -135,6 +140,7 @@ pub fn DeveloperSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "print-state-section".into(), section_label: get_local_text("settings-developer.print-state"), section_description: get_local_text("settings-developer.print-state-description"), Button { @@ -148,6 +154,7 @@ pub fn DeveloperSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "clear-cache-section".into(), section_label: get_local_text("settings-developer.clear-cache"), section_description: get_local_text("settings-developer.clear-cache-description"), Button { @@ -161,6 +168,7 @@ pub fn DeveloperSettings(cx: Scope) -> Element { } } SettingSection { + aria_label: "save-logs-section".into(), section_label: get_local_text("settings-developer.save-logs-to-file"), section_description: get_local_text("settings-developer.save-logs-to-file-description"), Switch { diff --git a/ui/src/components/settings/sub_pages/files.rs b/ui/src/components/settings/sub_pages/files.rs index 269183f06f5..212713e32e5 100644 --- a/ui/src/components/settings/sub_pages/files.rs +++ b/ui/src/components/settings/sub_pages/files.rs @@ -15,6 +15,7 @@ pub fn FilesSettings(cx: Scope) -> Element { id: "settings-files", aria_label: "settings-files", SettingSection { + aria_label: "local-sync-section".into(), section_label: get_local_text("settings-files.local-sync"), section_description: get_local_text("settings-files.local-sync-description"), Switch { diff --git a/ui/src/components/settings/sub_pages/general.rs b/ui/src/components/settings/sub_pages/general.rs index 6b62f099439..fb66c3017d0 100644 --- a/ui/src/components/settings/sub_pages/general.rs +++ b/ui/src/components/settings/sub_pages/general.rs @@ -66,6 +66,7 @@ pub fn GeneralSettings(cx: Scope) -> Element { } },*/ SettingSection { + aria_label: "app-language-section".into(), section_label: get_local_text("settings-general.app-language"), section_description: get_local_text("settings-general.change-language"), Select { @@ -78,6 +79,7 @@ pub fn GeneralSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "font-section".into(), section_label: get_local_text("settings-general.font"), section_description: get_local_text("settings-general.font-description"), Select { @@ -108,6 +110,7 @@ pub fn GeneralSettings(cx: Scope) -> Element { }, }, SettingSection { + aria_label: "font-scaling-section".into(), section_label: get_local_text("settings-general.font-scaling"), section_description: get_local_text("settings-general.font-scaling-description"), SlideSelector { @@ -120,6 +123,7 @@ pub fn GeneralSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "theme-section".into(), section_label: get_local_text("settings-general.theme"), section_description: get_local_text("settings-general.theme-description"), no_border: true, @@ -169,6 +173,7 @@ pub fn GeneralSettings(cx: Scope) -> Element { }, }, SettingSectionSimple { + aria_label: "color-section".into(), div { class: "color-swatches", Button { diff --git a/ui/src/components/settings/sub_pages/keybinds.rs b/ui/src/components/settings/sub_pages/keybinds.rs index 2bace058148..783b9d06ed5 100644 --- a/ui/src/components/settings/sub_pages/keybinds.rs +++ b/ui/src/components/settings/sub_pages/keybinds.rs @@ -253,6 +253,7 @@ pub fn KeybindSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "reset-keybinds-section".into(), section_label: get_local_text("settings-keybinds.reset-keybinds"), section_description: get_local_text("settings-keybinds.reset-keybinds-description"), Button { diff --git a/ui/src/components/settings/sub_pages/licenses.rs b/ui/src/components/settings/sub_pages/licenses.rs index 044d74fba46..095a9d3ed86 100644 --- a/ui/src/components/settings/sub_pages/licenses.rs +++ b/ui/src/components/settings/sub_pages/licenses.rs @@ -16,9 +16,11 @@ pub fn Licenses(cx: Scope) -> Element { id: "settings-licenses", aria_label: "settings-licenses", SettingSection { + aria_label: "licenses-section".into(), section_label: "Uplink".into(), section_description: "Both code and icons are under the MIT license.".into(), Button { + aria_label: "licenses-button".into(), text: "License Description".into(), appearance: Appearance::Secondary, icon: Icon::DocumentText, diff --git a/ui/src/components/settings/sub_pages/messages.rs b/ui/src/components/settings/sub_pages/messages.rs index aa64fdd86e5..ac4bae39dbb 100644 --- a/ui/src/components/settings/sub_pages/messages.rs +++ b/ui/src/components/settings/sub_pages/messages.rs @@ -17,6 +17,7 @@ pub fn Messages(cx: Scope) -> Element { id: "settings-messages", aria_label: "settings-messages", SettingSection { + aria_label: "emoji-conversion-section".into(), section_label: get_local_text("settings-messages.emoji-conversion"), section_description: get_local_text("settings-messages.emoji-conversion-description"), Switch { @@ -27,6 +28,7 @@ pub fn Messages(cx: Scope) -> Element { } }, SettingSection { + aria_label: "markdown-support-section".into(), section_label: get_local_text("settings-messages.markdown-support"), section_description: get_local_text("settings-messages.markdown-support-description"), Switch { diff --git a/ui/src/components/settings/sub_pages/notifications.rs b/ui/src/components/settings/sub_pages/notifications.rs index 4c9f9b61187..ebbbc384a89 100644 --- a/ui/src/components/settings/sub_pages/notifications.rs +++ b/ui/src/components/settings/sub_pages/notifications.rs @@ -30,6 +30,7 @@ pub fn NotificationSettings(cx: Scope) -> Element { } },*/ SettingSection { + aria_label: "enabled-notifications-section".into(), section_label: get_local_text("settings-notifications.enabled"), section_description: get_local_text("settings-notifications.enabled-description"), Switch { @@ -45,6 +46,7 @@ pub fn NotificationSettings(cx: Scope) -> Element { div { class: format_args!("{}", if state.read().configuration.notifications.enabled { "enabled" } else { "disabled" }), SettingSection { + aria_label: "friends-notifications-section".into(), section_label: get_local_text("friends"), section_description: get_local_text("settings-notifications.friends-description"), Switch { @@ -59,6 +61,7 @@ pub fn NotificationSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "messages-notifications-section".into(), section_label: get_local_text("messages"), section_description: get_local_text("settings-notifications.messages-description"), Switch { @@ -73,6 +76,7 @@ pub fn NotificationSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "settings-notifications-section".into(), section_label: get_local_text("settings"), section_description: get_local_text("settings-notifications.settings-description"), Switch { diff --git a/ui/src/components/settings/sub_pages/profile/mod.rs b/ui/src/components/settings/sub_pages/profile/mod.rs index a09dae97e38..6c53c731b4e 100644 --- a/ui/src/components/settings/sub_pages/profile/mod.rs +++ b/ui/src/components/settings/sub_pages/profile/mod.rs @@ -570,6 +570,7 @@ pub fn ProfileSettings(cx: Scope) -> Element { } }, SettingSection { + aria_label: "online-status-section".into(), section_label: get_local_text("settings-profile.online-status"), section_description: get_local_text("settings-profile.online-status-description"), FancySelect { @@ -584,6 +585,7 @@ pub fn ProfileSettings(cx: Scope) -> Element { }, if *phrase_exists.get() {rsx!( SettingSection { + aria_label: "recovery-seed-section".into(), section_label: get_local_text("settings-profile.recovery-seed"), section_description: get_local_text("settings-profile.recovery-seed-description"), Button { @@ -604,6 +606,7 @@ pub fn ProfileSettings(cx: Scope) -> Element { let words = phrase.split_whitespace().collect::>(); render!( SettingSectionSimple { + aria_label: "seed-words-section".into(), div { class: "seed-words", words.chunks_exact(2).enumerate().map(|(idx, vals)| rsx! { @@ -611,13 +614,25 @@ pub fn ProfileSettings(cx: Scope) -> Element { class: "row", div { class: "col", - span { class: "num", ((idx * 2) + 1).to_string() }, - span { class: "val", vals.first().cloned().unwrap_or_default() } + span { + aria_label: "seed-word-number-{((idx * 2) + 1).to_string()}", + class: "num", ((idx * 2) + 1).to_string() + }, + span { + aria_label: "seed-word-value-{((idx * 2) + 1).to_string()}", + class: "val", vals.first().cloned().unwrap_or_default() + } }, div { class: "col", - span { class: "num", ((idx * 2) + 2).to_string() }, - span { class: "val", vals.get(1).cloned().unwrap_or_default() } + span { + aria_label: "seed-word-number-{((idx * 2) + 2).to_string()}", + class: "num", ((idx * 2) + 2).to_string() + }, + span { + aria_label: "seed-word-value-{((idx * 2) + 2).to_string()}", + class: "val", vals.get(1).cloned().unwrap_or_default() + } } } }) diff --git a/ui/src/extension_browser/mod.rs b/ui/src/extension_browser/mod.rs index 0cfcc0eb642..b438be2c6e3 100644 --- a/ui/src/extension_browser/mod.rs +++ b/ui/src/extension_browser/mod.rs @@ -22,6 +22,7 @@ pub fn Settings(cx: Scope) -> Element { div { class: "extensions-settings", SettingSection { + aria_label: "open-extensions-section".into(), section_label: get_local_text("settings-extensions.open-extensions-folder"), section_description: get_local_text("settings-extensions.open-folder-description"), Button { @@ -34,6 +35,7 @@ pub fn Settings(cx: Scope) -> Element { }, }, SettingSection { + aria_label: "auto-enable-section".into(), section_label: get_local_text("settings-extensions.auto-enable"), section_description: get_local_text("settings-extensions.auto-enable-description"), Switch { diff --git a/ui/src/layouts/log_in/copy_seed_words.rs b/ui/src/layouts/log_in/copy_seed_words.rs index a15f8a7bd5d..ae362aa5cc2 100644 --- a/ui/src/layouts/log_in/copy_seed_words.rs +++ b/ui/src/layouts/log_in/copy_seed_words.rs @@ -67,14 +67,25 @@ fn SeedWords(cx: Scope, page: UseState, words: Vec) -> Elemen div { class: "col", - span { class: "num", ((idx * 2) + 1).to_string() }, - span { class: "val", vals.get(0).cloned().unwrap_or_default() } + span { + aria_label: "seed-word-number-{((idx * 2) + 1).to_string()}", + class: "num", ((idx * 2) + 1).to_string() + }, + span { + aria_label: "seed-word-value-{((idx * 2) + 1).to_string()}", + class: "val", vals.get(0).cloned().unwrap_or_default() + } }, div { class: "col", - - span { class: "num", ((idx * 2) + 2).to_string() }, - span { class: "val", vals.get(1).cloned().unwrap_or_default() } + span { + aria_label: "seed-word-number-{((idx * 2) + 2).to_string()}", + class: "num", ((idx * 2) + 2).to_string() + }, + span { + aria_label: "seed-word-value-{((idx * 2) + 2).to_string()}", + class: "val", vals.get(1).cloned().unwrap_or_default() + } } } }) @@ -89,6 +100,7 @@ fn SeedWords(cx: Scope, page: UseState, words: Vec) -> Elemen appearance: Appearance::Secondary }, Button { + aria_label: "i-saved-it-button".into(), text: get_local_text("copy-seed-words.finished"), onpress: move |_| { page.set(AuthPages::EnterUserName); diff --git a/ui/src/layouts/log_in/create_or_recover.rs b/ui/src/layouts/log_in/create_or_recover.rs index 7d29649fdd7..95019d94430 100644 --- a/ui/src/layouts/log_in/create_or_recover.rs +++ b/ui/src/layouts/log_in/create_or_recover.rs @@ -30,17 +30,20 @@ pub fn Layout(cx: Scope, page: UseState) -> Element { } div { class: "instructions", + aria_label: "create-or-recover-instructions", get_local_text("create-or-recover.instructions") }, div { class: "button-container", Button { + aria_label: "create-button".into(), text: get_local_text("create-or-recover.create"), onpress: move |_| { page.set(AuthPages::CopySeedWords); } }, Button { + aria_label: "recover-button".into(), text: get_local_text("create-or-recover.recover"), onpress: move |_| { page.set(AuthPages::EnterSeedWords); diff --git a/ui/src/layouts/log_in/enter_seed_words.rs b/ui/src/layouts/log_in/enter_seed_words.rs index f844d547191..19a2257f57a 100644 --- a/ui/src/layouts/log_in/enter_seed_words.rs +++ b/ui/src/layouts/log_in/enter_seed_words.rs @@ -90,9 +90,11 @@ pub fn Layout(cx: Scope, pin: UseRef, page: UseState) -> Elem }, div { class: "instructions", + aria_label: "instructions", get_local_text("enter-seed-words.instructions") }, input::Input { + aria_label: "recovery-seed-input".into(), placeholder: get_local_text("enter-seed-words.placeholder"), onchange: move |(x, is_valid)| { if is_valid { @@ -111,6 +113,7 @@ pub fn Layout(cx: Scope, pin: UseRef, page: UseState) -> Elem appearance: Appearance::Secondary }, Button { + aria_label: "recover-account-button".into(), text: get_local_text("enter-seed-words.submit"), disabled: *loading.get(), onpress: move |_| { diff --git a/ui/src/layouts/log_in/enter_username.rs b/ui/src/layouts/log_in/enter_username.rs index 86e0a6824eb..18874aeae2c 100644 --- a/ui/src/layouts/log_in/enter_username.rs +++ b/ui/src/layouts/log_in/enter_username.rs @@ -116,6 +116,7 @@ pub fn Layout( }, div { class: "instructions", + aria_label: "instructions", get_local_text("auth.enter-username-subtext") }, Input { From fb443dd7def7d109970f1c9582123d6a08c9b3bf Mon Sep 17 00:00:00 2001 From: Tinrii <94868652+Tinrii@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:26:41 +0100 Subject: [PATCH 02/18] update(locales): change/update Croatian, Bosnian, Serbian (#1696) --- common/locales/bs-BA/bs-BA.ftl | 71 ++++++++++++++++++++++++---------- common/locales/hr-HR/hr-HR.ftl | 71 ++++++++++++++++++++++++---------- common/locales/sr-RS/sr-RS.ftl | 58 ++++++++++++++++++++------- 3 files changed, 146 insertions(+), 54 deletions(-) diff --git a/common/locales/bs-BA/bs-BA.ftl b/common/locales/bs-BA/bs-BA.ftl index dc8e8591129..24ecc06834b 100644 --- a/common/locales/bs-BA/bs-BA.ftl +++ b/common/locales/bs-BA/bs-BA.ftl @@ -45,6 +45,7 @@ uplink = Uplink .copy-text = Kopiraj text .copy = Kopiraj .paste = Zalijepi + .go-back = Idi nazad community = Zajednica .invited = Pozvan si! @@ -224,6 +225,13 @@ settings-profile = Postavke profila .status-idle = Neaktivan .status-do-not-disturb = Nemoj ometati .status-offline = Offline + .recovery-seed = Ključ za oporavak + .recovery-seed-description = Ovaj ključ predstavlja "glavni ključ" za vaš račun. Čuvajte ga sigurno na mjestu kako biste održali ispravnu kontrolu i sigurnost nad svojim Uplink računom. + .reveal-recovery-seed = Otkrij Ključ za Oporavak + .hide-recovery-seed = Sakrij Ključ za Oporavak + .store-on-account = Spremi ključ za oporavak na račun (onemogući ovo radi povećane sigurnosti) + .remove-recovery-seed = Ukloni Ključnu Riječ za Oporavak + .remove-recovery-seed-description = Uklanjanje ključne riječi iz pohrane može povećati sigurnost vašeg računa. Međutim, ova radnja je nepovratna, i ako niste prethodno napravili sigurnosnu kopiju ključne riječi, trebali biste odabrati 'Otkaži' ispod. settings-general = Opće postavke .overlay = Uplink Overlay @@ -277,10 +285,19 @@ settings-files = Postavke datoteka .open-sync-folder = Otvori mapu za sinkronizaciju .open-sync-folder-description = Otvori mapu gdje su vaše datoteke sinkronizirane. -settings-keybinds = Postavke tipkovnih prečaca +settings-keybinds = Postavke Tipkovnih Prečaca + .reset = Vrati na prethodno + .reset-keybinds = Vrati Tipkovne Prečace + .reset-keybinds-description = Vrati tipkovne prečace na zadane postavke. + .info = Globalni tipkovni prečaci su onemogućeni dok ste na ovoj stranici. Kliknite za uređivanje tipkovnih prečaca, pritisnite tipkovni prečac za označavanje i pronalaženje određenih prečaca. .increase-font-size = Povećaj veličinu fonta unutar Uplinka. .decrease-font-size = Smanji veličinu fonta unutar Uplinka. + .toggle-mute = Uključi/isključi mikrofon. + .toggle-deafen = Uključi/isključi sve zvukove, uključujući mikrofon i slušalice. + .conflicting-keybinds = Sukobljeni Tipkovni Prečaci. .change-keybind = Snimi novi tipkovni prečac + .open-dev-tools = Otvori Web Inspektora + .toggle-devmode = Uključi/isključi Razvojni Način .cancel-change-keybind = Odustani od snimanja settings-extensions = Postavke proširenja @@ -342,38 +359,53 @@ settings-about = O postavkama .made-in = Napravljeno u .team = Naš tim je širom svijeta s različitim pozadinama i svakodnevnim životima, svi rade na zajedničkom cilju izgradnje Uplinka i Satelita zajedno. -media-player = Media Player - .enable-camera = Omogući kameru +media-player = Multimedijski Preglednik + .enable-camera = Omogući Kameru .fullscreen = Puni zaslon - .popout-player = Iskočni player - .screenshare = Dijeljenje ekrana - -remote-controls = Daljinski upravljači - .mute = Bez zvuka - .unmute = Uključi zvuk + .popout-player = Izdvojeni Preglednik + .screenshare = Dijeljenje zaslona + +remote-controls = Daljinski Upravljači + .mute = Isključi zvuk + .unmute = Uključi zvuk .listen = Slušaj - .silence = Tišina - .start-recording = Počni snimati + .silence = Utihni + .start-recording = Počni snimanje .stop-recording = Zaustavi snimanje - .incoming-call = Dolazna prijenos ... - .outgoing-call = Odlazna prijenos ... + .incoming-call = Dolazni prijenos ... + .outgoing-call = Odlazni prijenos ... .empty = Nitko nije ovdje unlock = Otključaj - .notice = (ovo se koristi za šifriranje svih podataka koje Uplink pohranjuje na vašem računalu kad ga ne koristite, tako da nitko ne može čitati vaše podatke.) + .notice = (Ovo se koristi za šifriranje svih podataka koje Uplink pohranjuje na vašem računalu kada ga ne koristite kako nitko ne bi mogao čitati vaše podatke.) .enter-pin = Unesite PIN - .create-account = Stvori račun - .unlock-account = Otključaj račun + .create-account = Kreiraj Račun + .unlock-account = Otključaj Račun .welcome = Dobrodošli natrag, { $name } .create-password = Odaberite svoju lozinku - .error-pin = Nešto nije u redu s PIN-om koji ste naveli. - .invalid-pin = Hmm, taj PIN nije radio. - .error-unknown-pin = Dogodila se nepoznata pogreška. + .error-pin = Nešto nije u redu s unesenim PIN-om. + .invalid-pin = Hmm, taj PIN ne radi. + .error-unknown-pin = Došlo je do nepoznate pogreške. .help = Pomoć (desni klik) .logging-in = Prijavljivanje... +create-or-recover = Stvaranje Računa + .create = Stvori Novi Račun + .instructions = Kreirat ćemo račun za vas. Na sljedećem zaslonu vidjet ćete niz riječi. Screenshotajte ili ih zapišite. Ovo je jedini način za sigurnosnu kopiju vašeg računa. + .recover = Uvezi Račun + +copy-seed-words = Recovery Seed + .instructions = Zapišite ove riječi u redoslijedu u kojem se pojavljuju. Točan redoslijed je ključan prilikom obnavljanja računa. + .finished = Spremio Sam + +enter-seed-words = Recovery Seed + .instructions = Upišite vaš recovery seed ovdje. Možete unijeti jednu riječ po jednu ili sve odjednom razdvojene razmacima. + .submit = Obnovi Račun + .placeholder = Unesite Recovery Seed... + auth = Stvaranje računa .enter-username = Unesite korisničko ime + .enter-username-subtext = Vrijeme je da odaberete svoje korisničko ime, možete ga kasnije promijeniti u postavkama. sidebar = Bočna traka .subtext = { $user } poslao je više privitaka @@ -396,4 +428,3 @@ toast_actions = Akcije obavijesti .DisplayChat = Otvori razgovor .FriendListPending = Lista prijatelja .Dummy = Dummy akcija - \ No newline at end of file diff --git a/common/locales/hr-HR/hr-HR.ftl b/common/locales/hr-HR/hr-HR.ftl index dc8e8591129..24ecc06834b 100644 --- a/common/locales/hr-HR/hr-HR.ftl +++ b/common/locales/hr-HR/hr-HR.ftl @@ -45,6 +45,7 @@ uplink = Uplink .copy-text = Kopiraj text .copy = Kopiraj .paste = Zalijepi + .go-back = Idi nazad community = Zajednica .invited = Pozvan si! @@ -224,6 +225,13 @@ settings-profile = Postavke profila .status-idle = Neaktivan .status-do-not-disturb = Nemoj ometati .status-offline = Offline + .recovery-seed = Ključ za oporavak + .recovery-seed-description = Ovaj ključ predstavlja "glavni ključ" za vaš račun. Čuvajte ga sigurno na mjestu kako biste održali ispravnu kontrolu i sigurnost nad svojim Uplink računom. + .reveal-recovery-seed = Otkrij Ključ za Oporavak + .hide-recovery-seed = Sakrij Ključ za Oporavak + .store-on-account = Spremi ključ za oporavak na račun (onemogući ovo radi povećane sigurnosti) + .remove-recovery-seed = Ukloni Ključnu Riječ za Oporavak + .remove-recovery-seed-description = Uklanjanje ključne riječi iz pohrane može povećati sigurnost vašeg računa. Međutim, ova radnja je nepovratna, i ako niste prethodno napravili sigurnosnu kopiju ključne riječi, trebali biste odabrati 'Otkaži' ispod. settings-general = Opće postavke .overlay = Uplink Overlay @@ -277,10 +285,19 @@ settings-files = Postavke datoteka .open-sync-folder = Otvori mapu za sinkronizaciju .open-sync-folder-description = Otvori mapu gdje su vaše datoteke sinkronizirane. -settings-keybinds = Postavke tipkovnih prečaca +settings-keybinds = Postavke Tipkovnih Prečaca + .reset = Vrati na prethodno + .reset-keybinds = Vrati Tipkovne Prečace + .reset-keybinds-description = Vrati tipkovne prečace na zadane postavke. + .info = Globalni tipkovni prečaci su onemogućeni dok ste na ovoj stranici. Kliknite za uređivanje tipkovnih prečaca, pritisnite tipkovni prečac za označavanje i pronalaženje određenih prečaca. .increase-font-size = Povećaj veličinu fonta unutar Uplinka. .decrease-font-size = Smanji veličinu fonta unutar Uplinka. + .toggle-mute = Uključi/isključi mikrofon. + .toggle-deafen = Uključi/isključi sve zvukove, uključujući mikrofon i slušalice. + .conflicting-keybinds = Sukobljeni Tipkovni Prečaci. .change-keybind = Snimi novi tipkovni prečac + .open-dev-tools = Otvori Web Inspektora + .toggle-devmode = Uključi/isključi Razvojni Način .cancel-change-keybind = Odustani od snimanja settings-extensions = Postavke proširenja @@ -342,38 +359,53 @@ settings-about = O postavkama .made-in = Napravljeno u .team = Naš tim je širom svijeta s različitim pozadinama i svakodnevnim životima, svi rade na zajedničkom cilju izgradnje Uplinka i Satelita zajedno. -media-player = Media Player - .enable-camera = Omogući kameru +media-player = Multimedijski Preglednik + .enable-camera = Omogući Kameru .fullscreen = Puni zaslon - .popout-player = Iskočni player - .screenshare = Dijeljenje ekrana - -remote-controls = Daljinski upravljači - .mute = Bez zvuka - .unmute = Uključi zvuk + .popout-player = Izdvojeni Preglednik + .screenshare = Dijeljenje zaslona + +remote-controls = Daljinski Upravljači + .mute = Isključi zvuk + .unmute = Uključi zvuk .listen = Slušaj - .silence = Tišina - .start-recording = Počni snimati + .silence = Utihni + .start-recording = Počni snimanje .stop-recording = Zaustavi snimanje - .incoming-call = Dolazna prijenos ... - .outgoing-call = Odlazna prijenos ... + .incoming-call = Dolazni prijenos ... + .outgoing-call = Odlazni prijenos ... .empty = Nitko nije ovdje unlock = Otključaj - .notice = (ovo se koristi za šifriranje svih podataka koje Uplink pohranjuje na vašem računalu kad ga ne koristite, tako da nitko ne može čitati vaše podatke.) + .notice = (Ovo se koristi za šifriranje svih podataka koje Uplink pohranjuje na vašem računalu kada ga ne koristite kako nitko ne bi mogao čitati vaše podatke.) .enter-pin = Unesite PIN - .create-account = Stvori račun - .unlock-account = Otključaj račun + .create-account = Kreiraj Račun + .unlock-account = Otključaj Račun .welcome = Dobrodošli natrag, { $name } .create-password = Odaberite svoju lozinku - .error-pin = Nešto nije u redu s PIN-om koji ste naveli. - .invalid-pin = Hmm, taj PIN nije radio. - .error-unknown-pin = Dogodila se nepoznata pogreška. + .error-pin = Nešto nije u redu s unesenim PIN-om. + .invalid-pin = Hmm, taj PIN ne radi. + .error-unknown-pin = Došlo je do nepoznate pogreške. .help = Pomoć (desni klik) .logging-in = Prijavljivanje... +create-or-recover = Stvaranje Računa + .create = Stvori Novi Račun + .instructions = Kreirat ćemo račun za vas. Na sljedećem zaslonu vidjet ćete niz riječi. Screenshotajte ili ih zapišite. Ovo je jedini način za sigurnosnu kopiju vašeg računa. + .recover = Uvezi Račun + +copy-seed-words = Recovery Seed + .instructions = Zapišite ove riječi u redoslijedu u kojem se pojavljuju. Točan redoslijed je ključan prilikom obnavljanja računa. + .finished = Spremio Sam + +enter-seed-words = Recovery Seed + .instructions = Upišite vaš recovery seed ovdje. Možete unijeti jednu riječ po jednu ili sve odjednom razdvojene razmacima. + .submit = Obnovi Račun + .placeholder = Unesite Recovery Seed... + auth = Stvaranje računa .enter-username = Unesite korisničko ime + .enter-username-subtext = Vrijeme je da odaberete svoje korisničko ime, možete ga kasnije promijeniti u postavkama. sidebar = Bočna traka .subtext = { $user } poslao je više privitaka @@ -396,4 +428,3 @@ toast_actions = Akcije obavijesti .DisplayChat = Otvori razgovor .FriendListPending = Lista prijatelja .Dummy = Dummy akcija - \ No newline at end of file diff --git a/common/locales/sr-RS/sr-RS.ftl b/common/locales/sr-RS/sr-RS.ftl index b8714e4076c..171077ac939 100644 --- a/common/locales/sr-RS/sr-RS.ftl +++ b/common/locales/sr-RS/sr-RS.ftl @@ -45,6 +45,7 @@ uplink = Uplink .copy-text = Копирај текст .copy = Копирај .paste = Залепи + .go-back = Врати се community = Заједница .invited = Позвани сте! @@ -224,6 +225,13 @@ settings-profile = Подешавања профила .status-idle = Неактиван .status-do-not-disturb = Не ометај .status-offline = Изван мреже + .recovery-seed = Семе за обнављање + .recovery-seed-description = Ово семе представља "главни клуч" за ваш налог. Сачувајте га на безбедном и сигурном месту како бисте одржали контролу и безбедност свог Uplink налога. + .reveal-recovery-seed = Откриј Семе за обнављање + .hide-recovery-seed = Сакриј Семе за обнављање + .store-on-account = Сачувај семе за обнављање на налогу (онемогућите ово за повећану безбедност) + .remove-recovery-seed = Уклони Семе фразе за обнављање + .remove-recovery-seed-description = Уклањање семена фразе из складишта може повећати безбедност на вашем налогу. Међутим, ова радња је неопозива и ако још увек нисте направили резервну копију своје семена фразе, требало би да изаберете 'Откажи' испод. settings-general = Генерална подешавања .overlay = Uplink Overlay @@ -277,21 +285,30 @@ settings-files = Подешавања Фајлова .open-sync-folder = Отвори фолдер синхронизације .open-sync-folder-description = Отвори фолдер где су твоји фајлови синхронизовани. -settings-keybinds = Подешавања Пречица Тастатуре - .increase-font-size = Увећај величину фонтова у Уплинку. - .decrease-font-size = Смањи величину фонтова у Уплинку. - .change-keybind = Сними нову пречицу тастатуре - .cancel-change-keybind = Откажи снимање +settings-keybinds = Поставке тастатурских пречица + .reset = Поништи + .reset-keybinds = Поништи тастатурске пречице + .reset-keybinds-description = Вратите тастатурске пречице на подразумеване мапинге. + .info = Глобалне тастатурске пречице су онемогућене на овој страници. Кликните да бисте изменели тастатурску пречицу, притисните тастатурску пречицу да бисте је истакли и пронашли одређени скраћеница. + .increase-font-size = Увећајте величину фонта у Уплинку. + .decrease-font-size = Смањите величину фонта у Уплинку. + .toggle-mute = Искључите и укључите микрофон. + .toggle-deafen = Промените искључивање свих звукова, укључујући микрофон и слушалице. + .conflicting-keybinds = Сукоб тастатурских пречица. + .change-keybind = Запиши нову тастатурску пречицу + .open-dev-tools = Отвори веб инспектор + .toggle-devmode = Промени режим програмера + .cancel-change-keybind = Откажи записivanje -settings-extensions = Подешавања Екстензија - .open-extensions-folder = Отвори фолдер за екстензије +settings-extensions = Поставке додатака + .open-extensions-folder = Отвори фасциклу са додацима .auto-enable = Аутоматско омогућавање - .auto-enable-description = Када је укључено, нове екстензије ће аутоматски бити укључене као подразумеване. - .banner = Екстензије су претпроцесиране на спољнем хардверу. Ради додатне безбедности, можете компајлирати екстензије из изворног кода и поставити их у фолдер `extensions`. - .open-folder-description = Отвори локални директоријум са инсталираним екстензијама. - .installed = Инсталиране + .auto-enable-description = Када је укључено, нови додаци ће аутоматски бити омогућени као подразумевано. + .banner = Додаци су претходно компајлирани на спољним хардверима. Ради додатне безбедности, можете компајлирати додатке из изворног кода и ставити их у фасциклу extensions. + .open-folder-description = Отвори локални директоријум са инсталираним додацима. + .installed = Инсталирани .explore = Истражи - .settings = Подешавања + .settings = Поставке settings-accessibility = Подешавања Приступачности .dyslexia = Отвори Дислексични фонт @@ -306,7 +323,6 @@ settings-notifications = Подешавања Обавештења .messages-description = Омогући обавештења за нове поруке. .settings-description = Омогући обавештења за ажурирања и важна обавештења. - settings-developer = Подешавања за Развијача .developer-mode = Режим развијача .developer-mode-description = Укључивање режима развијача додаје записивање и приказ корисних информација за дебагирање на корисничком интерфејсу. @@ -373,8 +389,23 @@ unlock = Откључај .help = Помоћ (десни клик) .logging-in = Пријављивање... +create-or-recover = Креирање Налога + .create = Креирај Нови Налог + .instructions = Креираћемо налог за тебе. На следећем екрану видећеш сет речи. Ухвати слику или их запиши. Ово је једини начин за бекап твог налога. + .recover = Увези Налог + +copy-seed-words = Речи За Повратак Налога + .instructions = Запиши ове речи у редоследу у коме се појављују. Имати тачан редослед је битан када повраћаш свој налог. + .finished = Сачувано + +enter-seed-words = Речи За Повратак Налога + .instructions = Унеси твоје речи за повратак овде. Можеш уносити по једну реч или све одједном, раздвојене размаком. + .submit = Поврати Налог + .placeholder = Унеси Речи За Повратак... + auth = Креирај Налог .enter-username = Унесите Корисничко Име + .enter-username-subtext = Време је да изаберете своје корисничко име, можете касније променити ово у било које време у поставкама. sidebar = Бочна Трака .subtext = { $user } послао је више прилога @@ -397,4 +428,3 @@ toast_actions = Акције Тоста .DisplayChat = Отвори Ћасканје .FriendListPending = Листа Пријатеља .Dummy = Лажна Акција - \ No newline at end of file From fe90712b8a86cbcd9c90803a82b497c5a213edec Mon Sep 17 00:00:00 2001 From: Jeff Kristian Date: Wed, 10 Jan 2024 17:36:07 -0700 Subject: [PATCH 03/18] fix(textarea): add checks for height bug in chat input (#1691) --- kit/src/elements/textarea/event_listeners.js | 51 -------------------- kit/src/elements/textarea/script.js | 10 +++- 2 files changed, 8 insertions(+), 53 deletions(-) delete mode 100644 kit/src/elements/textarea/event_listeners.js diff --git a/kit/src/elements/textarea/event_listeners.js b/kit/src/elements/textarea/event_listeners.js deleted file mode 100644 index f2d509a3001..00000000000 --- a/kit/src/elements/textarea/event_listeners.js +++ /dev/null @@ -1,51 +0,0 @@ -var MULTI_LINE = $MULTI_LINE; - -var sendButton = document.getElementsByClassName("controls") -var textareas = document.getElementsByClassName("input_textarea") -for (let i = 0; i < textareas.length; i++) { - var txt = textareas[i]; - //Update the height on load - updateHeight(txt); - if (!txt.event_listener) { - txt.addEventListener("input", inputListener); - txt.addEventListener("keypress", keyPressListener); - txt.addEventListener("keydown", arrowHandlerListener); - txt.event_listener = true; - if (i == 0) { - txt.addEventListener("keypress", (event) => { - if (event.keyCode === 13 && !event.shiftKey) { - textareas[0].style.height = "22px"; - textareas[0].value = ""; - } - }); - } - } -} - -sendButton[1].addEventListener("click", (event) => { - textareas[0].style.height = "22px"; - textareas[0].value = ""; -}) - -function inputListener(e) { - updateHeight(this); -} - -function updateHeight(element) { - element.style.height = "auto"; - if (!element.value || MULTI_LINE) { - element.style.height = "0px"; - } - element.style.height = element.scrollHeight + "px"; -} -function keyPressListener(e) { - if (e.key == "Enter" && MULTI_LINE && !e.shiftKey) { - e.preventDefault(); - } -} - -function arrowHandlerListener(e) { - if (this.classList.contains("up-down-disabled") && (e.key == "ArrowUp" || e.key == "ArrowDown")) { - e.preventDefault(); - } -} diff --git a/kit/src/elements/textarea/script.js b/kit/src/elements/textarea/script.js index 68c39fa80cd..2417cecd068 100644 --- a/kit/src/elements/textarea/script.js +++ b/kit/src/elements/textarea/script.js @@ -27,8 +27,14 @@ sendButton[1].addEventListener("click", (event) => { textareas[0].value = ""; }) -if (textareas[0].style.height === "66px") { - textareas[0].style.height = "22px"; +switch (textareas[0].style.height) { + case "66px": + case "44px": + case "330px": + textareas[0].style.height = "22px"; + break; + default: + break; } function inputListener(e) { From 372e703dedef97e6bf7e1b5e531533b26932b8c9 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 12:51:36 -0300 Subject: [PATCH 04/18] Commit to test on windows with Phill --- kit/src/components/embeds/file_embed/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kit/src/components/embeds/file_embed/mod.rs b/kit/src/components/embeds/file_embed/mod.rs index f96301e67b6..4589b74e4b9 100644 --- a/kit/src/components/embeds/file_embed/mod.rs +++ b/kit/src/components/embeds/file_embed/mod.rs @@ -164,6 +164,10 @@ pub fn FileEmbed<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { let file_name_with_extension = cx.props.filename.to_string(); let temp_dir = STATIC_ARGS.temp_files.join(file_name_with_extension); let temp_dir2 = temp_dir.clone(); + println!( + "PHILL SHOW ME THIS PRINT HERE ON WINDWOS -> temp_dir: {:?}", + temp_dir + ); use_component_lifecycle( cx, From a92565abb224f5eb4b9e2d1d6608c6991f6dbc4c Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 13:15:17 -0300 Subject: [PATCH 05/18] refactor(Files): Not load full image on Windows OS for now, just thumbail --- kit/src/components/embeds/file_embed/mod.rs | 8 +++----- ui/src/components/files/file_preview.rs | 4 +++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kit/src/components/embeds/file_embed/mod.rs b/kit/src/components/embeds/file_embed/mod.rs index 4589b74e4b9..5746a09bb17 100644 --- a/kit/src/components/embeds/file_embed/mod.rs +++ b/kit/src/components/embeds/file_embed/mod.rs @@ -164,10 +164,6 @@ pub fn FileEmbed<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { let file_name_with_extension = cx.props.filename.to_string(); let temp_dir = STATIC_ARGS.temp_files.join(file_name_with_extension); let temp_dir2 = temp_dir.clone(); - println!( - "PHILL SHOW ME THIS PRINT HERE ON WINDWOS -> temp_dir: {:?}", - temp_dir - ); use_component_lifecycle( cx, @@ -219,7 +215,9 @@ pub fn FileEmbed<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { img { id: "image-preview-modal-file-embed", aria_label: "image-preview-modal-file-embed", - src: format_args!("{}", if temp_dir.exists() { temp_path_as_string} else {large_thumbnail} ), + src: format_args!("{}", if temp_dir.exists() && !cfg!(target_os = "windows") + { temp_path_as_string} + else {large_thumbnail} ), max_height: IMAGE_MAX_HEIGHT, max_width: IMAGE_MAX_WIDTH, onclick: move |e| e.stop_propagation(), diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index 509d9571183..fff61030fdb 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -56,7 +56,9 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { aria_label: "file-preview-image", max_height: IMAGE_MAX_HEIGHT, max_width: IMAGE_MAX_WIDTH, - src: format_args!("{}", if temp_dir.exists() { temp_file_path_as_string } else {thumbnail} ), + src: format_args!("{}", if temp_dir.exists() && !cfg!(target_os = "windows") + { temp_file_path_as_string } + else {thumbnail} ), }, }, )) From ea3c0b45437e6242175db5e1861c9879e54eae04 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 13:25:08 -0300 Subject: [PATCH 06/18] Commit to test on windows with Phill 2 --- ui/src/components/files/file_preview.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index fff61030fdb..c0c47961092 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -37,6 +37,8 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { }, ); + println!("PHILL ---> temp_dir: {}", temp_dir.to_string_lossy()); + cx.render(rsx!( ContextMenu { id: "file-preview-context-menu".into(), @@ -56,8 +58,8 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { aria_label: "file-preview-image", max_height: IMAGE_MAX_HEIGHT, max_width: IMAGE_MAX_WIDTH, - src: format_args!("{}", if temp_dir.exists() && !cfg!(target_os = "windows") - { temp_file_path_as_string } + src: format_args!("{}", if temp_dir.exists() + { String::from("C:\\Users\\phil\\.uplink\\temp_files\\test_with_lucas.png") } else {thumbnail} ), }, }, From a092616f89f63154e111d32a0c3b737311c14097 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 13:30:26 -0300 Subject: [PATCH 07/18] Commit to test on windows with Phill 3 --- ui/src/components/files/file_preview.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index c0c47961092..295dec2c25c 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -38,7 +38,6 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { ); println!("PHILL ---> temp_dir: {}", temp_dir.to_string_lossy()); - cx.render(rsx!( ContextMenu { id: "file-preview-context-menu".into(), @@ -59,7 +58,7 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { max_height: IMAGE_MAX_HEIGHT, max_width: IMAGE_MAX_WIDTH, src: format_args!("{}", if temp_dir.exists() - { String::from("C:\\Users\\phil\\.uplink\\temp_files\\test_with_lucas.png") } + { String::from("C:/Users/phil/.uplink/temp_files/test_with_lucas.png") } else {thumbnail} ), }, }, From a4a82b198e140224dc0785948b1ca74a8c6a02d6 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 13:43:20 -0300 Subject: [PATCH 08/18] Commit to test on windows with Phill 4 --- ui/src/components/files/file_preview.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index 295dec2c25c..b6f3c112a0c 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -27,8 +27,7 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { if !temp_dir.exists() { cx.props.on_download.call(Some(temp_dir.clone())); } - let temp_file_path_as_string = temp_dir.clone().to_string_lossy().to_string(); - + let temp_file_path_as_string = temp_dir.to_string_lossy().to_string().replace("\\", "/"); use_component_lifecycle( cx, || {}, @@ -37,7 +36,11 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { }, ); - println!("PHILL ---> temp_dir: {}", temp_dir.to_string_lossy()); + println!( + "PHILL ---> File Exist: {}, temp_file_path_as_string: {}", + temp_dir.exists(), + temp_file_path_as_string, + ); cx.render(rsx!( ContextMenu { id: "file-preview-context-menu".into(), @@ -58,7 +61,7 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { max_height: IMAGE_MAX_HEIGHT, max_width: IMAGE_MAX_WIDTH, src: format_args!("{}", if temp_dir.exists() - { String::from("C:/Users/phil/.uplink/temp_files/test_with_lucas.png") } + { temp_file_path_as_string } else {thumbnail} ), }, }, From 409db76a9cd7c3bb53d1972baf26e1f58ee9d72e Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 15:28:24 -0300 Subject: [PATCH 09/18] Commit to test on windows with Phill 5 --- ui/src/components/files/file_preview.rs | 49 ++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index b6f3c112a0c..98d5ed2fa75 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -9,6 +9,7 @@ use common::STATIC_ARGS; use common::{icons::outline::Shape as Icon, warp_runner::thumbnail_to_base64}; use dioxus::prelude::*; use kit::components::context_menu::{ContextItem, ContextMenu}; +use mime::{IMAGE_JPEG, IMAGE_PNG, IMAGE_SVG}; use warp::constellation::file::File; #[derive(Props)] @@ -27,7 +28,12 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { if !temp_dir.exists() { cx.props.on_download.call(Some(temp_dir.clone())); } - let temp_file_path_as_string = temp_dir.to_string_lossy().to_string().replace("\\", "/"); + let temp_file_path_as_string = if !cfg!(target_os = "windows") { + temp_dir.to_string_lossy().to_string() + } else { + format!("file://{}", temp_dir.to_string_lossy().to_string()) + }; + use_component_lifecycle( cx, || {}, @@ -36,11 +42,6 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { }, ); - println!( - "PHILL ---> File Exist: {}, temp_file_path_as_string: {}", - temp_dir.exists(), - temp_file_path_as_string, - ); cx.render(rsx!( ContextMenu { id: "file-preview-context-menu".into(), @@ -67,3 +68,39 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { }, )) } + +fn get_file_thumbnail_if_is_image(filepath: PathBuf, filename: String) -> String { + let file = match std::fs::read(filepath) { + Ok(file) => file, + Err(_) => { + return String::new(); + } + }; + + let parts_of_filename: Vec<&str> = filename.split('.').collect(); + let mime = match parts_of_filename.last() { + Some(m) => match *m { + "png" => IMAGE_PNG.to_string(), + "jpg" => IMAGE_JPEG.to_string(), + "jpeg" => IMAGE_JPEG.to_string(), + "svg" => IMAGE_SVG.to_string(), + &_ => "".to_string(), + }, + None => "".to_string(), + }; + + if mime.is_empty() { + return String::new(); + } + + let image = match &file.len() { + 0 => "".to_string(), + _ => { + let prefix = format!("data:{mime};base64,"); + let base64_image = base64::encode(&file); + let img = prefix + base64_image.as_str(); + img + } + }; + image +} From 07ebf60d5b8906f28ee1e30e44b5db89f78938f4 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 15:34:11 -0300 Subject: [PATCH 10/18] Commit to test on windows with Phill 6 --- ui/src/components/files/file_preview.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index 98d5ed2fa75..3f99cae5092 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -31,7 +31,10 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { let temp_file_path_as_string = if !cfg!(target_os = "windows") { temp_dir.to_string_lossy().to_string() } else { - format!("file://{}", temp_dir.to_string_lossy().to_string()) + format!( + "file://{}", + temp_dir.to_string_lossy().to_string().replace("\\", "/") + ) }; use_component_lifecycle( From 12399d20c01e11980c235ffd1870b5064ece1853 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 15:44:46 -0300 Subject: [PATCH 11/18] Commit to test on windows with Phill 7 --- ui/src/components/files/file_preview.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index 3f99cae5092..483ed938d9a 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -32,11 +32,14 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { temp_dir.to_string_lossy().to_string() } else { format!( - "file://{}", + "dioxus://{}", temp_dir.to_string_lossy().to_string().replace("\\", "/") ) }; - + println!( + "Phill -> temp_file_path_as_string: {}", + temp_file_path_as_string + ); use_component_lifecycle( cx, || {}, From 05c107c9362012e5c51413fa93dd839df768e217 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 16:22:07 -0300 Subject: [PATCH 12/18] Commit to test on windows with Sheldon 1 --- ui/src/components/files/file_preview.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index 483ed938d9a..f0e6b5ece16 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -32,7 +32,7 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { temp_dir.to_string_lossy().to_string() } else { format!( - "dioxus://{}", + "{}", temp_dir.to_string_lossy().to_string().replace("\\", "/") ) }; From 54ad2311f856001b19cc730a7f2403f1746bad04 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 16:36:52 -0300 Subject: [PATCH 13/18] Commit to test on windows with Sheldon 2 --- ui/src/components/files/file_preview.rs | 43 ++----------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index f0e6b5ece16..a70c1c81c8f 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -32,14 +32,11 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { temp_dir.to_string_lossy().to_string() } else { format!( - "{}", + "http://dioxus.{}", temp_dir.to_string_lossy().to_string().replace("\\", "/") ) }; - println!( - "Phill -> temp_file_path_as_string: {}", - temp_file_path_as_string - ); + use_component_lifecycle( cx, || {}, @@ -74,39 +71,3 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { }, )) } - -fn get_file_thumbnail_if_is_image(filepath: PathBuf, filename: String) -> String { - let file = match std::fs::read(filepath) { - Ok(file) => file, - Err(_) => { - return String::new(); - } - }; - - let parts_of_filename: Vec<&str> = filename.split('.').collect(); - let mime = match parts_of_filename.last() { - Some(m) => match *m { - "png" => IMAGE_PNG.to_string(), - "jpg" => IMAGE_JPEG.to_string(), - "jpeg" => IMAGE_JPEG.to_string(), - "svg" => IMAGE_SVG.to_string(), - &_ => "".to_string(), - }, - None => "".to_string(), - }; - - if mime.is_empty() { - return String::new(); - } - - let image = match &file.len() { - 0 => "".to_string(), - _ => { - let prefix = format!("data:{mime};base64,"); - let base64_image = base64::encode(&file); - let img = prefix + base64_image.as_str(); - img - } - }; - image -} From 20f81aaa8d7b85fc8affee96b487e5a79a4ea23c Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 17:31:12 -0300 Subject: [PATCH 14/18] refactor(Files): Fix paths to work on Windows OS --- common/src/utils/lifecycle.rs | 3 +++ common/src/utils/mod.rs | 1 + .../utils/treat_paths_to_load_local_files.rs | 18 ++++++++++++++++++ kit/src/components/embeds/file_embed/mod.rs | 7 ++++--- ui/src/components/files/file_preview.rs | 11 ++--------- 5 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 common/src/utils/treat_paths_to_load_local_files.rs diff --git a/common/src/utils/lifecycle.rs b/common/src/utils/lifecycle.rs index da57918be2c..2665bd6a2e6 100644 --- a/common/src/utils/lifecycle.rs +++ b/common/src/utils/lifecycle.rs @@ -4,6 +4,9 @@ pub struct LifeCycle { ondestroy: Option, } +/// It works like a useEffect hook, but it will be called only once +/// when the component is mounted +/// and when the component is unmounted pub fn use_component_lifecycle( cx: &ScopeState, create: C, diff --git a/common/src/utils/mod.rs b/common/src/utils/mod.rs index 962bac9440d..56a43b99c9d 100644 --- a/common/src/utils/mod.rs +++ b/common/src/utils/mod.rs @@ -1,2 +1,3 @@ pub mod img_dimensions_preview; pub mod lifecycle; +pub mod treat_paths_to_load_local_files; diff --git a/common/src/utils/treat_paths_to_load_local_files.rs b/common/src/utils/treat_paths_to_load_local_files.rs new file mode 100644 index 00000000000..67258f3396d --- /dev/null +++ b/common/src/utils/treat_paths_to_load_local_files.rs @@ -0,0 +1,18 @@ +use std::path::PathBuf; + +/// It will work to load local files in img or video tags, but will ignore drive +const PREFIX_TO_WORK_ON_WINDOWS_OS: &str = "http://dioxus."; + +/// This function is used to treat local file path if it needs +/// to be loaded in img or video tags for example +pub fn treat_paths_to_load_local_files(path: PathBuf) -> String { + if !cfg!(target_os = "windows") { + path.to_string_lossy().to_string() + } else { + format!( + "{}{}", + PREFIX_TO_WORK_ON_WINDOWS_OS, + path.to_string_lossy().to_string().replace("\\", "/") + ) + } +} diff --git a/kit/src/components/embeds/file_embed/mod.rs b/kit/src/components/embeds/file_embed/mod.rs index 5746a09bb17..0495d27e8b6 100644 --- a/kit/src/components/embeds/file_embed/mod.rs +++ b/kit/src/components/embeds/file_embed/mod.rs @@ -11,6 +11,7 @@ use common::utils::img_dimensions_preview::IMAGE_MAX_HEIGHT; use common::utils::img_dimensions_preview::IMAGE_MAX_WIDTH; use common::utils::lifecycle::use_component_lifecycle; use common::STATIC_ARGS; +use common::utils::treat_paths_to_load_local_files::treat_paths_to_load_local_files; use dioxus_html::input_data::keyboard_types::Modifiers; use dioxus::prelude::*; @@ -204,7 +205,7 @@ pub fn FileEmbed<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { if !temp_dir.exists() { cx.props.on_press.call(Some(temp_dir.clone())); } - let temp_path_as_string = temp_dir.clone().to_string_lossy().to_string(); + let temp_file_path_as_string = treat_paths_to_load_local_files(temp_dir.clone()); rsx!( Modal { open: *fullscreen_preview.clone(), @@ -215,8 +216,8 @@ pub fn FileEmbed<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { img { id: "image-preview-modal-file-embed", aria_label: "image-preview-modal-file-embed", - src: format_args!("{}", if temp_dir.exists() && !cfg!(target_os = "windows") - { temp_path_as_string} + src: format_args!("{}", if temp_dir.exists() + { temp_file_path_as_string} else {large_thumbnail} ), max_height: IMAGE_MAX_HEIGHT, max_width: IMAGE_MAX_WIDTH, diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index a70c1c81c8f..b398dd4aec6 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -5,11 +5,11 @@ use common::language::get_local_text; use common::state::State; use common::utils::img_dimensions_preview::{IMAGE_MAX_HEIGHT, IMAGE_MAX_WIDTH}; use common::utils::lifecycle::use_component_lifecycle; +use common::utils::treat_paths_to_load_local_files::treat_paths_to_load_local_files; use common::STATIC_ARGS; use common::{icons::outline::Shape as Icon, warp_runner::thumbnail_to_base64}; use dioxus::prelude::*; use kit::components::context_menu::{ContextItem, ContextMenu}; -use mime::{IMAGE_JPEG, IMAGE_PNG, IMAGE_SVG}; use warp::constellation::file::File; #[derive(Props)] @@ -28,14 +28,7 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { if !temp_dir.exists() { cx.props.on_download.call(Some(temp_dir.clone())); } - let temp_file_path_as_string = if !cfg!(target_os = "windows") { - temp_dir.to_string_lossy().to_string() - } else { - format!( - "http://dioxus.{}", - temp_dir.to_string_lossy().to_string().replace("\\", "/") - ) - }; + let temp_file_path_as_string = treat_paths_to_load_local_files(temp_dir.clone()); use_component_lifecycle( cx, From 7bace9295c68214dd0ebf20b7a69da99cc1bc9f6 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 17:34:07 -0300 Subject: [PATCH 15/18] refactor(Files): Improve function name --- ...{treat_paths_to_load_local_files.rs => local_file_path.rs} | 2 +- common/src/utils/mod.rs | 2 +- kit/src/components/embeds/file_embed/mod.rs | 4 ++-- ui/src/components/files/file_preview.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename common/src/utils/{treat_paths_to_load_local_files.rs => local_file_path.rs} (88%) diff --git a/common/src/utils/treat_paths_to_load_local_files.rs b/common/src/utils/local_file_path.rs similarity index 88% rename from common/src/utils/treat_paths_to_load_local_files.rs rename to common/src/utils/local_file_path.rs index 67258f3396d..f9083c5e940 100644 --- a/common/src/utils/treat_paths_to_load_local_files.rs +++ b/common/src/utils/local_file_path.rs @@ -5,7 +5,7 @@ const PREFIX_TO_WORK_ON_WINDOWS_OS: &str = "http://dioxus."; /// This function is used to treat local file path if it needs /// to be loaded in img or video tags for example -pub fn treat_paths_to_load_local_files(path: PathBuf) -> String { +pub fn get_fixed_path_to_load_local_file(path: PathBuf) -> String { if !cfg!(target_os = "windows") { path.to_string_lossy().to_string() } else { diff --git a/common/src/utils/mod.rs b/common/src/utils/mod.rs index 56a43b99c9d..fb50c1ebf1b 100644 --- a/common/src/utils/mod.rs +++ b/common/src/utils/mod.rs @@ -1,3 +1,3 @@ pub mod img_dimensions_preview; pub mod lifecycle; -pub mod treat_paths_to_load_local_files; +pub mod local_file_path; diff --git a/kit/src/components/embeds/file_embed/mod.rs b/kit/src/components/embeds/file_embed/mod.rs index 0495d27e8b6..d56c0459d9a 100644 --- a/kit/src/components/embeds/file_embed/mod.rs +++ b/kit/src/components/embeds/file_embed/mod.rs @@ -11,7 +11,7 @@ use common::utils::img_dimensions_preview::IMAGE_MAX_HEIGHT; use common::utils::img_dimensions_preview::IMAGE_MAX_WIDTH; use common::utils::lifecycle::use_component_lifecycle; use common::STATIC_ARGS; -use common::utils::treat_paths_to_load_local_files::treat_paths_to_load_local_files; +use common::utils::local_file_path::get_fixed_path_to_load_local_file; use dioxus_html::input_data::keyboard_types::Modifiers; use dioxus::prelude::*; @@ -205,7 +205,7 @@ pub fn FileEmbed<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { if !temp_dir.exists() { cx.props.on_press.call(Some(temp_dir.clone())); } - let temp_file_path_as_string = treat_paths_to_load_local_files(temp_dir.clone()); + let temp_file_path_as_string = get_fixed_path_to_load_local_file(temp_dir.clone()); rsx!( Modal { open: *fullscreen_preview.clone(), diff --git a/ui/src/components/files/file_preview.rs b/ui/src/components/files/file_preview.rs index b398dd4aec6..2827ef57b68 100644 --- a/ui/src/components/files/file_preview.rs +++ b/ui/src/components/files/file_preview.rs @@ -5,7 +5,7 @@ use common::language::get_local_text; use common::state::State; use common::utils::img_dimensions_preview::{IMAGE_MAX_HEIGHT, IMAGE_MAX_WIDTH}; use common::utils::lifecycle::use_component_lifecycle; -use common::utils::treat_paths_to_load_local_files::treat_paths_to_load_local_files; +use common::utils::local_file_path::get_fixed_path_to_load_local_file; use common::STATIC_ARGS; use common::{icons::outline::Shape as Icon, warp_runner::thumbnail_to_base64}; use dioxus::prelude::*; @@ -28,7 +28,7 @@ pub fn FilePreview<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { if !temp_dir.exists() { cx.props.on_download.call(Some(temp_dir.clone())); } - let temp_file_path_as_string = treat_paths_to_load_local_files(temp_dir.clone()); + let temp_file_path_as_string = get_fixed_path_to_load_local_file(temp_dir.clone()); use_component_lifecycle( cx, From ae88525b557f1ffe64b61e45f2307eec3161788f Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 17:43:30 -0300 Subject: [PATCH 16/18] refactor(Files): Hide download status toast notification if download is to preview the file --- ui/src/layouts/storage/functions.rs | 71 +++++++++++++++++------------ 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/ui/src/layouts/storage/functions.rs b/ui/src/layouts/storage/functions.rs index c53ba350a4c..38a4cdfba0f 100644 --- a/ui/src/layouts/storage/functions.rs +++ b/ui/src/layouts/storage/functions.rs @@ -164,12 +164,15 @@ pub fn download_file( None => return, } } else { - temp_path_to_download_file_to_preview.unwrap_or_default() + temp_path_to_download_file_to_preview + .clone() + .unwrap_or_default() }; ch.send(ChanCmd::DownloadFile { file_name: file_name.to_string(), local_path_to_save_file: file_path_buf, + notification_download_status: temp_path_to_download_file_to_preview.is_none(), }); } @@ -226,6 +229,7 @@ pub enum ChanCmd { DownloadFile { file_name: String, local_path_to_save_file: PathBuf, + notification_download_status: bool, }, RenameItem { old_name: String, @@ -344,6 +348,7 @@ pub fn init_coroutine<'a>( ChanCmd::DownloadFile { file_name, local_path_to_save_file, + notification_download_status, } => { let (local_path_to_save_file, on_finish) = get_download_path(local_path_to_save_file); @@ -356,49 +361,55 @@ pub fn init_coroutine<'a>( rsp: tx, }, )) { - state.write().mutate(Action::AddToastNotification( - ToastNotification::init( - "".into(), - get_local_text_with_args( - "files.download-failed", - vec![("file", file_name)], - ), - None, - 2, - ), - )); - log::error!("failed to download file {}", e); - continue; - } - - let rsp = rx.await.expect("command canceled"); - match rsp { - Ok(_) => { + if notification_download_status { state.write().mutate(Action::AddToastNotification( ToastNotification::init( "".into(), get_local_text_with_args( - "files.download-success", + "files.download-failed", vec![("file", file_name)], ), None, 2, ), )); + } + log::error!("failed to download file {}", e); + continue; + } + + let rsp = rx.await.expect("command canceled"); + match rsp { + Ok(_) => { + if notification_download_status { + state.write().mutate(Action::AddToastNotification( + ToastNotification::init( + "".into(), + get_local_text_with_args( + "files.download-success", + vec![("file", file_name)], + ), + None, + 2, + ), + )); + } on_finish.await } Err(error) => { - state.write().mutate(Action::AddToastNotification( - ToastNotification::init( - "".into(), - get_local_text_with_args( - "files.download-failed", - vec![("file", file_name)], + if notification_download_status { + state.write().mutate(Action::AddToastNotification( + ToastNotification::init( + "".into(), + get_local_text_with_args( + "files.download-failed", + vec![("file", file_name)], + ), + None, + 2, ), - None, - 2, - ), - )); + )); + } log::error!("failed to download file: {}", error); on_finish.await; continue; From c0ee8ec2fd1c1c85741b41239be78aa8c8aa082b Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 17:45:20 -0300 Subject: [PATCH 17/18] fix clippy --- common/src/utils/local_file_path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/utils/local_file_path.rs b/common/src/utils/local_file_path.rs index f9083c5e940..1a6c06faaf7 100644 --- a/common/src/utils/local_file_path.rs +++ b/common/src/utils/local_file_path.rs @@ -12,7 +12,7 @@ pub fn get_fixed_path_to_load_local_file(path: PathBuf) -> String { format!( "{}{}", PREFIX_TO_WORK_ON_WINDOWS_OS, - path.to_string_lossy().to_string().replace("\\", "/") + path.to_string_lossy().to_string().replace('\\', "/") ) } } From 730d98823e3d7c58617f004d4e97a7514d560572 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 11 Jan 2024 17:45:57 -0300 Subject: [PATCH 18/18] fix fmt --- kit/src/components/embeds/file_embed/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kit/src/components/embeds/file_embed/mod.rs b/kit/src/components/embeds/file_embed/mod.rs index d56c0459d9a..dd0cf6b33d9 100644 --- a/kit/src/components/embeds/file_embed/mod.rs +++ b/kit/src/components/embeds/file_embed/mod.rs @@ -10,8 +10,8 @@ use common::icons::Icon as IconElement; use common::utils::img_dimensions_preview::IMAGE_MAX_HEIGHT; use common::utils::img_dimensions_preview::IMAGE_MAX_WIDTH; use common::utils::lifecycle::use_component_lifecycle; -use common::STATIC_ARGS; use common::utils::local_file_path::get_fixed_path_to_load_local_file; +use common::STATIC_ARGS; use dioxus_html::input_data::keyboard_types::Modifiers; use dioxus::prelude::*; @@ -217,7 +217,7 @@ pub fn FileEmbed<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { id: "image-preview-modal-file-embed", aria_label: "image-preview-modal-file-embed", src: format_args!("{}", if temp_dir.exists() - { temp_file_path_as_string} + { temp_file_path_as_string} else {large_thumbnail} ), max_height: IMAGE_MAX_HEIGHT, max_width: IMAGE_MAX_WIDTH,