diff --git a/assets/locales/pending/web-update-preferences.json b/assets/locales/pending/web-update-preferences.json new file mode 100644 index 000000000..63c2d7a39 --- /dev/null +++ b/assets/locales/pending/web-update-preferences.json @@ -0,0 +1,17 @@ +{ + "en": { + "update.prefs_web": "Reload the page to get the latest web app. If the network is unavailable or the update cannot finish downloading in time, the saved version opens instead; a download in progress continues for the next reload." + }, + "de": { + "update.prefs_web": "Laden Sie die Seite neu, um die neueste Web-App zu erhalten. Ist das Netzwerk nicht verfügbar oder kann das Update nicht rechtzeitig vollständig heruntergeladen werden, wird die gespeicherte Version geöffnet. Ein laufender Download wird für das nächste Neuladen fortgesetzt." + }, + "ja": { + "update.prefs_web": "ページを再読み込みすると、最新のウェブアプリを取得します。ネットワークが利用できない場合や、更新のダウンロードが時間内に完了しない場合は、保存済みのバージョンを開きます。進行中のダウンロードは次回の再読み込みに向けて続行されます。" + }, + "ko": { + "update.prefs_web": "페이지를 새로고침하면 최신 웹 앱을 가져옵니다. 네트워크를 사용할 수 없거나 업데이트 다운로드가 제한 시간 안에 완료되지 않으면 저장된 버전이 열립니다. 진행 중인 다운로드는 다음 새로고침을 위해 계속됩니다." + }, + "zh": { + "update.prefs_web": "重新加载页面以获取最新的网页应用。如果网络不可用或更新无法及时下载完成,则打开已保存的版本;正在进行的下载会继续,供下次重新加载时使用。" + } +} diff --git a/crates/ui-egui/src/update.rs b/crates/ui-egui/src/update.rs index 1bf5b1744..a7ee2442d 100644 --- a/crates/ui-egui/src/update.rs +++ b/crates/ui-egui/src/update.rs @@ -952,28 +952,33 @@ enum State { pub fn prefs_rows(app: &mut SolveApp, ui: &mut egui::Ui) { let can = available(app); let kind = app.updater.kind().clone(); - ui.add_enabled_ui(can, |ui| ui_kit::checkbox(ui, crate::i18n::tr("update.check_automatically"), &mut app.preferences.check_updates)); - ui.horizontal_wrapped(|ui| { - let busy = app.updater.status == Status::Checking; - let (status, warning) = match (&app.updater.status, offered_or_newer(app)) { - _ if !can => (String::new(), false), - (Status::Checking, _) => (crate::i18n::tr("update.checking").to_string(), false), - (Status::Failed(e), _) => (crate::i18n::format("update.failed", &[("error", e)]), true), - (_, Some(v)) => (crate::i18n::format("update.available", &[("version", &v)]), false), - (Status::UpToDate, None) => (crate::i18n::tr("update.up_to_date").to_string(), false), - (Status::Idle, None) => (String::new(), false), - }; - if !status.is_empty() { - ui_kit::settings_badge(ui, &status, warning); - } - let r = ui_kit::button(ui, crate::i18n::tr("update.check_now"), ui_kit::Button::Enabled(can && !busy)); - crate::scenario::publish_rect("prefs:check_now", r.rect); - if r.clicked() { - let ctx = ui.ctx().clone(); - check_now(app, &ctx); - } - }); - let note = if can { + // Where nothing can check (the browser app, development builds, the Flatpak), the box and + // Check now would do nothing: the note below says how this copy updates instead. + if can { + ui_kit::checkbox(ui, crate::i18n::tr("update.check_automatically"), &mut app.preferences.check_updates); + ui.horizontal_wrapped(|ui| { + let busy = app.updater.status == Status::Checking; + let (status, warning) = match (&app.updater.status, offered_or_newer(app)) { + (Status::Checking, _) => (crate::i18n::tr("update.checking").to_string(), false), + (Status::Failed(e), _) => (crate::i18n::format("update.failed", &[("error", e)]), true), + (_, Some(v)) => (crate::i18n::format("update.available", &[("version", &v)]), false), + (Status::UpToDate, None) => (crate::i18n::tr("update.up_to_date").to_string(), false), + (Status::Idle, None) => (String::new(), false), + }; + if !status.is_empty() { + ui_kit::settings_badge(ui, &status, warning); + } + let r = ui_kit::button(ui, crate::i18n::tr("update.check_now"), ui_kit::Button::Enabled(!busy)); + crate::scenario::publish_rect("prefs:check_now", r.rect); + if r.clicked() { + let ctx = ui.ctx().clone(); + check_now(app, &ctx); + } + }); + } + let note = if kind == InstallKind::Web { + crate::i18n::tr("update.prefs_web").to_string() + } else if can { crate::i18n::format("update.prefs_note", &[("version", current_version()), ("kind", kind.label())]) } else if let InstallKind::Flatpak(id) = &kind { crate::i18n::format("update.prefs_flatpak", &[("version", current_version()), ("command", &format!("flatpak update {id}"))]) diff --git a/crates/ui-egui/src/update/tests.rs b/crates/ui-egui/src/update/tests.rs index 0e31bc494..c86ecc2ce 100644 --- a/crates/ui-egui/src/update/tests.rs +++ b/crates/ui-egui/src/update/tests.rs @@ -529,3 +529,20 @@ fn the_version_links_to_its_release_notes() { // Anything that is not a version never ends up in a URL. assert_eq!(release_notes_url("0.1/../../x", true), "https://github.com/tangency-labs/solidcraft/releases"); } + +#[test] +fn web_preferences_explain_reload_without_update_controls() { + let mut h = crate::scenario::Harness::new(); + h.app.updater.kind = Some(InstallKind::Web); + let mut texts = Vec::new(); + for _ in 0..2 { + let mut output = h.ctx.run_ui(egui::RawInput::default(), |ui| prefs_rows(&mut h.app, ui)); + output.textures_delta.clear(); + texts = + output.shapes.iter().filter_map(|s| if let egui::Shape::Text(t) = &s.shape { Some(t.galley.text().to_string()) } else { None }).collect(); + } + assert!(!texts.iter().any(|t| t.contains("development build")), "{texts:?}"); + assert!(!texts.iter().any(|t| t == crate::i18n::tr("update.check_automatically")), "{texts:?}"); + assert!(!texts.iter().any(|t| t == crate::i18n::tr("update.check_now")), "{texts:?}"); + assert!(texts.iter().any(|t| t == crate::i18n::tr("update.prefs_web")), "{texts:?}"); +} diff --git a/docs/book/src/guide/updates.md b/docs/book/src/guide/updates.md index dc8890d9f..0444c2f81 100644 --- a/docs/book/src/guide/updates.md +++ b/docs/book/src/guide/updates.md @@ -85,7 +85,10 @@ SolidCraft compares the answer with its own version on your computer. - Setting the environment variable `SOLIDCRAFT_UPDATE_CHECK=0` turns all checks off, for example on managed machines. -Builds you compile yourself, the Flatpak and the browser app (which updates itself) never check. +Builds you compile yourself, the Flatpak and the browser app never check, and Preferences shows +no check controls for them. The browser app updates itself: reload the page to get the latest +version. When the network is unavailable, or the update can't finish downloading in time, the +saved version opens instead, and the download continues for the next reload. ## Which file Download gets