diff --git a/CHANGELOG.md b/CHANGELOG.md index aff74f6b..c969bdb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,18 @@ see the notices in the README. ## [Unreleased] ### Added +- **Desktop: "Support us on Ko-fi" tag** (#403). Once per start of the app the + status bar shows a small tag; a click opens the Ko-fi page of the + association that develops TeamCraft (`https://ko-fi.com/warr_ev`, fixed in + the app) in the browser and hides it, *×* only hides it. Reconnecting, + switching server or reloading the window does not show it again (held in + memory only). Nothing is loaded from ko-fi.com and nothing is sent or + counted before the click. *Settings → Support TeamCraft* switches it off + (`donate_tag` in the settings file); the new desktop policy `ShowDonateTag` + turns it off (`0`) or keeps it on (`1`) – in the ADMX with English and + German ADML, the macOS profile and the Linux `policies.json`. Texts in + English and German. + - **3D preview of E57 point clouds** (#373). Laser-scanner exports (`.e57`, ASTM E2807) open in the viewer like LAS: every scan is placed by its pose (rotation and translation), so multi-station scans line up; cartesian or diff --git a/README.md b/README.md index 6dc4a6cd..e951530a 100755 --- a/README.md +++ b/README.md @@ -420,7 +420,7 @@ there is no separate enterprise edition. - **Desktop rollout** – policies per computer or user with the operating system's tools (Group Policy/Intune ADMX templates, a macOS configuration profile, `/etc/teamcraft/policies.json`): a fixed server, update checks, - crash-report prompts, the default working folder and *Managed by …*; see + crash-report prompts, the default working folder, the *Support us on Ko-fi* tag and *Managed by …*; see [Deploying the desktop app](https://warr-ev.github.io/TeamCraft/admin/desktop-deployment.html). **Planned** – what is left of the issues above (all their steps are built): diff --git a/deploy/desktop-policies/linux/policies.json b/deploy/desktop-policies/linux/policies.json index a38143cf..3593725d 100755 --- a/deploy/desktop-policies/linux/policies.json +++ b/deploy/desktop-policies/linux/policies.json @@ -6,5 +6,6 @@ "WorkspaceRoot": "/srv/cad", "ReportUrl": "https://helpdesk.example.org/issues/new", "OrganizationName": "Example Lab", - "UsageStatistics": 0 + "UsageStatistics": 0, + "ShowDonateTag": 0 } diff --git a/deploy/desktop-policies/macos/teamcraft-policies.mobileconfig b/deploy/desktop-policies/macos/teamcraft-policies.mobileconfig index 0346a51f..09ef3f6d 100755 --- a/deploy/desktop-policies/macos/teamcraft-policies.mobileconfig +++ b/deploy/desktop-policies/macos/teamcraft-policies.mobileconfig @@ -35,6 +35,8 @@ Example Lab UsageStatistics 0 + ShowDonateTag + 0 PayloadType diff --git a/deploy/desktop-policies/windows/TeamCraft.admx b/deploy/desktop-policies/windows/TeamCraft.admx index 54d183e9..d49397be 100755 --- a/deploy/desktop-policies/windows/TeamCraft.admx +++ b/deploy/desktop-policies/windows/TeamCraft.admx @@ -51,6 +51,12 @@ + + + + + + diff --git a/deploy/desktop-policies/windows/de-DE/TeamCraft.adml b/deploy/desktop-policies/windows/de-DE/TeamCraft.adml index bac28e30..8c777bfe 100644 --- a/deploy/desktop-policies/windows/de-DE/TeamCraft.adml +++ b/deploy/desktop-policies/windows/de-DE/TeamCraft.adml @@ -17,6 +17,8 @@ Deaktiviert: Absturzberichte bleiben nur auf dem Computer und werden nie zum Teilen angeboten. Aktiviert: Die App fragt nach jedem Absturz. Nicht konfiguriert: Jeder Benutzer entscheidet selbst (Einstellungen → Absturzberichte). Berichte werden nie gesendet, ohne dass der Benutzer das Formular für die Meldung öffnet. Anonyme Nutzungsstatistik Deaktiviert: Es wird keine Nutzungsstatistik gesendet oder gespeichert, kein Hinweis angezeigt, und Benutzer können sie nicht einschalten. Aktiviert: Die Statistik wird gesendet, und Benutzer können sie nicht ausschalten. Nicht konfiguriert: Jeder Benutzer entscheidet selbst. (Gelesen von App-Versionen mit Nutzungsstatistik, #383.) + Hinweis „Unterstützen Sie uns auf Ko-fi“ + Deaktiviert: Der kleine Hinweis „Unterstützen Sie uns auf Ko-fi“ in der Statusleiste wird nie angezeigt, und Benutzer können ihn nicht einschalten. Aktiviert: Er wird einmal pro Start der App angezeigt, und Benutzer können ihn nicht ausschalten. Nicht konfiguriert: Er wird einmal pro Start angezeigt, und jeder Benutzer kann ihn in den Einstellungen ausschalten. Der Hinweis verlinkt auf die feste Ko-fi-Seite des Vereins, der TeamCraft entwickelt (https://ko-fi.com/warr_ev); vor einem Klick wird nichts gesendet. (Gelesen von App-Versionen mit dem Hinweis, #403.) Standard-Arbeitsordner Der Ordner, in dem neue Arbeitsordner angelegt werden (ein absoluter Pfad wie D:\CAD oder \\fileserver\cad; Umgebungsvariablen werden nicht aufgelöst). Benutzer können in den Einstellungen trotzdem einen anderen Ordner wählen. Probleme melden an diff --git a/deploy/desktop-policies/windows/en-US/TeamCraft.adml b/deploy/desktop-policies/windows/en-US/TeamCraft.adml index ceafb092..e9f7f5cd 100755 --- a/deploy/desktop-policies/windows/en-US/TeamCraft.adml +++ b/deploy/desktop-policies/windows/en-US/TeamCraft.adml @@ -17,6 +17,8 @@ Disabled: crash reports are kept on the computer only and never offered for sharing. Enabled: the app always asks after a crash. Not configured: each user chooses (Settings → Crash reports). Reports are never sent without the user opening the issue form. Anonymous usage statistics Disabled: no usage statistics are sent or kept, no notice is shown, and users cannot turn them on. Enabled: statistics are sent and users cannot turn them off. Not configured: each user chooses. (Read by app versions with usage statistics, #383.) + “Support us on Ko-fi” tag + Disabled: the small “Support us on Ko-fi” tag in the status bar is never shown, and users cannot turn it on. Enabled: it is shown once per start of the app, and users cannot turn it off. Not configured: it is shown once per start and each user can turn it off in Settings. The tag links to the fixed Ko-fi page of the association that develops TeamCraft (https://ko-fi.com/warr_ev); nothing is sent before a click. (Read by app versions with the tag, #403.) Default working folder The folder new working folders are created in (an absolute path such as D:\CAD or \\fileserver\cad; environment variables are not expanded). Users can still choose another folder in Settings. Report problems to diff --git a/desktop/README.md b/desktop/README.md index e11c5fd5..5b576e77 100755 --- a/desktop/README.md +++ b/desktop/README.md @@ -1,3 +1,4 @@ +| Ko-fi tag | *Support us on Ko-fi* in the status bar once per start of the app (#403): `donate_tag_due` in `src/commands.rs` answers yes once per process (in memory only, so reconnecting, switching server or reloading the window does not show it again); a click opens the fixed `DONATE_URL` (`https://ko-fi.com/warr_ev`) with the opener from Rust (`open_donate_page`, the web view cannot pass another address) and hides it, *×* only hides it. Static text, nothing loaded from ko-fi.com, no counting. *Settings → Support TeamCraft* switches it off (`donate_tag` in the settings file); the policy `ShowDonateTag` fixes it. Texts in `shared/i18n` | # TeamCraft Desktop The rich client of TeamCraft for **Linux, macOS and Windows**: a navigation @@ -61,7 +62,7 @@ TeamCraft server – it is a client, not an offline copy. | Pack and Go, STL | ZIP of a revision and its structure, with a progress dialog and *Cancel* (also while the server packs); written as `.teamcraft-download` and renamed when complete, removed on cancel or error; **Export STL…** from the 3D viewer | | Report a problem | *Help → Report a Problem…* and *Report…* on every error message (toasts and dialog errors, #381): one review dialog with the title ": " (cut at a word, `…`), a description with the action, its key inputs (`run(text, fn, inputs)`, `toast(…, action, inputs)`, `dialog(…, { inputs })`: group, item, revision, file and format, import options – names only, a path reduced to its file name, at most 12 values of 200 characters; `ui/js/report-inputs.js`, tested by `scripts/desktop-report-inputs.test.mjs`), the error and the versions, "What were you trying to do?" (left out when empty) and, ticked, the last 50 error messages of the session – all redacted in Rust like crash reports (`src/report.rs`: home folder → `~`, addresses → `[url]`, tokens → `[token]`). Nothing leaves the app without a click: *Open issue form* (GitHub, or *Settings → Report problems to*: the operator's own form, which gets `title` and `body`, or the policy `ReportUrl`; a long text is cut in the link and copied in full), *Copy report*, *Save report…* (work offline). The web UI's error pages have *Copy details* (status, message, page, time, version, request id = the `x-request-id` header and the server log's `request_id`) | | Usage report | Once a day of use the app sends its own TeamCraft server (`POST /api/v1/usage`) an anonymous report of the day before (`src/usage.rs`, #383): a random installation id, versions, OS, architecture, package type, minutes with the window in front, and counts of fixed actions (checkout, checkin, park, cancel_checkout, get_files, open_cad, open_3d_preview, import_bom, import_folder, new_item, release, search, assistant – a test checks each has a count site) and STEP exports per program – never names, numbers, paths or anything typed. *Settings → Privacy → Show what is sent* shows it. The server shares an aggregate with the developers only if its administrator turns that on (admin guide: *Privacy*) | -| Managed deployment | Policies per computer or user, read once at start and never sent (`src/policy.rs`, #378): `ServerUrl` (+ `AllowOtherServers`), `CheckForUpdates`, `CrashReportPrompt`, `WorkspaceRoot`, `OrganizationName`, `UsageStatistics` – Windows registry `Software\Policies\TeamCraft` (HKLM wins over HKCU; ADMX/ADML in `deploy/desktop-policies/windows`), macOS managed preferences of `io.github.rudalabs.teamcraft` (`plutil`), Linux `/etc/teamcraft/policies.json`. Wrong types and out-of-range values count as not set; fixed settings show *Set by your organization* and are disabled; *Managed by …* in Settings and About. Admin guide: *Deploying the desktop app* | +| Managed deployment | Policies per computer or user, read once at start and never sent (`src/policy.rs`, #378): `ServerUrl` (+ `AllowOtherServers`), `CheckForUpdates`, `CrashReportPrompt`, `WorkspaceRoot`, `OrganizationName`, `UsageStatistics`, `ReportUrl`, `ShowDonateTag` – Windows registry `Software\Policies\TeamCraft` (HKLM wins over HKCU; ADMX/ADML in `deploy/desktop-policies/windows`), macOS managed preferences of `io.github.rudalabs.teamcraft` (`plutil`), Linux `/etc/teamcraft/policies.json`. Wrong types and out-of-range values count as not set; fixed settings show *Set by your organization* and are disabled; *Managed by …* in Settings and About. Admin guide: *Deploying the desktop app* | | Crash reports | Panics, uncaught UI errors and sessions that ended unexpectedly (web view crash, force-quit hang) are written to a local, redacted report (no home folder, server addresses, tokens or item data). At the next start the app shows it and asks: *Report on GitHub…* (a prefilled issue you submit yourself), *Copy* or *Delete report*. Nothing is sent without that choice; *Settings → Crash reports* turns the question off | | Language | *Settings → Language* (#379): *As the system* (`navigator.languages`: exactly, then by base language, else English), *English*, *Deutsch* – kept on this computer, applied at the next start. Messages come from `shared/i18n/.json` through `shared/js/i18n.js` (`t(id, params)`, English fallback); translated so far: the *Settings* dialog and the empty states (#423) | | Empty states | An empty list names the next step, by role (#423, `ui/js/empty-rules.js`, tested by `scripts/desktop-empty-rules.test.mjs`): no project group → *Create a project group* (CAD editors) or "ask a manager of a group to add you" (viewers, with the viewer note); an empty group on *Home* (Files, All items, Structure) → *Import CAD folder…* / *New item* for those who may create items in it, "ask a manager to add you" for CAD editors outside the group; *New on this computer* without suggestions → *Get…* (the dialog starts with the active group ticked); empty worklist sections and the review and check-out cards of the *Home* tab say how work arrives there; an empty working folder of a revision names the next step by check-out (holder, may check out, neither). Viewers see a note at the top of the worklist and of the *Home* tab: editing needs the CAD editor role – ask an administrator of the server. The texts come from the i18n catalogs (`empty.*`); the catalog is loaded before the first view draws | diff --git a/desktop/src/commands.rs b/desktop/src/commands.rs index 5c9d9f80..afde2d1f 100755 --- a/desktop/src/commands.rs +++ b/desktop/src/commands.rs @@ -109,6 +109,9 @@ pub struct Session { pub checkout_parts: bool, /// After a crash, ask at the next start whether to share the report. pub crash_prompt: bool, + /// Show the *Support us on Ko-fi* tag once at this start (#403): the + /// policy, else the user's choice. + pub donate_tag: bool, /// *Settings → Report problems to* (#381); `None` = GitHub. pub report_url: Option, /// A *with local server* installation: the connect screen offers *Try @@ -133,6 +136,7 @@ pub fn session(app: AppHandle, state: State<'_, AppState>) -> Session { checkout_parts: s.checkout_parts != Some(false), report_url: policy::current().report_target(s.report_url.clone()), crash_prompt: policy::current().crash_prompt(s.crash_prompt), + donate_tag: policy::current().donate_tag(s.donate_tag), server_url: s.server_url.clone(), signed_in: s.token.is_some(), skin: s.skin.clone().unwrap_or_else(|| "teamcraft".into()), @@ -1380,6 +1384,52 @@ pub fn open_release_page(app: AppHandle) -> CmdResult<()> { .map_err(|e| ApiError::local(format!("The browser could not be opened: {e}"))) } +// ------------------------------------------------------------ Ko-fi tag (#403) + +/// The Ko-fi page of the association that develops TeamCraft. Fixed in the +/// app, not configurable: a policy can only switch the tag off. +pub const DONATE_URL: &str = "https://ko-fi.com/warr_ev"; + +/// The *Support us on Ko-fi* tag: opens [`DONATE_URL`] in the default +/// browser. The web view cannot pass another address; nothing is sent before +/// the click and nothing is counted. +#[tauri::command] +pub fn open_donate_page(app: AppHandle) -> CmdResult<()> { + app.opener() + .open_url(DONATE_URL, None::<&str>) + .map_err(|e| ApiError::local(format!("The browser could not be opened: {e}"))) +} + +/// Whether the tag was shown in this run of the app – held in memory only, +/// so reconnecting, switching server or reloading the window does not show +/// it again, and the next start does. +static DONATE_TAG_SHOWN: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); + +/// Show the tag now? Only when it is on (the policy, else the setting) and +/// not yet shown in this run; a `true` answer marks it shown. +fn donate_tag_due_once(enabled: bool, shown: &std::sync::atomic::AtomicBool) -> bool { + enabled && !shown.swap(true, std::sync::atomic::Ordering::SeqCst) +} + +/// Asked by the main window when it opens (ui/js/shell.js): `true` once per +/// start of the app while the tag is on. +#[tauri::command] +pub fn donate_tag_due(state: State<'_, AppState>) -> bool { + let enabled = policy::current().donate_tag(snapshot(&state).donate_tag); + donate_tag_due_once(enabled, &DONATE_TAG_SHOWN) +} + +/// *Settings → Show the "Support us on Ko-fi" tag at start*; refused while a +/// policy (`ShowDonateTag`) fixes it. +#[tauri::command] +pub fn set_donate_tag(state: State<'_, AppState>, enabled: bool) -> CmdResult<()> { + if policy::current().show_donate_tag.is_some() { + return Err(ApiError::local(MANAGED)); + } + update_settings(&state, |s| s.donate_tag = Some(enabled))?; + Ok(()) +} + /// Smallest and largest zoom factor of the user interface. pub const ZOOM_RANGE: (f64, f64) = (0.5, 2.5); @@ -1417,6 +1467,29 @@ mod tests { assert_eq!(clamp_zoom(f64::NAN), 1.0); } + /// The Ko-fi tag (#403) opens one fixed https address of ko-fi.com, and + /// the web view's content security policy does not let ko-fi.com in: + /// nothing is loaded from there inside the app. + #[test] + fn the_donate_link_is_fixed_and_not_in_the_csp() { + assert_eq!(DONATE_URL, "https://ko-fi.com/warr_ev"); + let conf = include_str!("../tauri.conf.json"); + assert!(conf.contains("\"csp\""), "tauri.conf.json has a CSP"); + assert!(!conf.contains("ko-fi.com"), "ko-fi.com is not in the CSP"); + } + + /// Once per start: the first question while it is on says yes, every + /// later one no; switched off it never shows and is not used up. + #[test] + fn the_donate_tag_is_due_once_per_start() { + use std::sync::atomic::AtomicBool; + let shown = AtomicBool::new(false); + assert!(!donate_tag_due_once(false, &shown), "off: not shown"); + assert!(donate_tag_due_once(true, &shown), "first time"); + assert!(!donate_tag_due_once(true, &shown), "not a second time"); + assert!(!donate_tag_due_once(false, &shown)); + } + #[test] fn only_an_offered_agent_backend_can_be_picked() { use acp::AgentBackend::{Company, Local}; diff --git a/desktop/src/main.rs b/desktop/src/main.rs index cc217c07..a4aedbaf 100755 --- a/desktop/src/main.rs +++ b/desktop/src/main.rs @@ -303,6 +303,9 @@ fn main() { commands::set_update_check, commands::set_checkout_parts, commands::open_release_page, + commands::open_donate_page, + commands::set_donate_tag, + commands::donate_tag_due, commands::save_package, commands::cancel_package, commands::save_stl, diff --git a/desktop/src/policy.rs b/desktop/src/policy.rs index dd95d5c3..be20c34d 100755 --- a/desktop/src/policy.rs +++ b/desktop/src/policy.rs @@ -12,6 +12,7 @@ //! | `OrganizationName` | shown as *Managed by …* (one line, at most 64 characters) | //! | `UsageStatistics` | 0: never sent, kept or asked; 1: sent, cannot be turned off (#383) | //! | `ReportUrl` | where *Report a problem* sends reports: the organisation's tracker (`https://…`) | +//! | `ShowDonateTag` | 0: the *Support us on Ko-fi* tag is never shown; 1: shown once per start, cannot be turned off (#403) | //! //! Where they come from: //! @@ -57,6 +58,7 @@ pub struct Policies { pub organization_name: Option, pub usage_statistics: Option, pub report_url: Option, + pub show_donate_tag: Option, } /// One raw value as a source stores it. @@ -125,6 +127,7 @@ impl Policies { organization_name: organization(get("OrganizationName").as_ref()), usage_statistics: switch(get("UsageStatistics").as_ref()), report_url: report_url(get("ReportUrl").as_ref()), + show_donate_tag: switch(get("ShowDonateTag").as_ref()), } } @@ -150,6 +153,7 @@ impl Policies { organization_name: self.organization_name.or(other.organization_name), usage_statistics: self.usage_statistics.or(other.usage_statistics), report_url: self.report_url.or(other.report_url), + show_donate_tag: self.show_donate_tag.or(other.show_donate_tag), } } @@ -189,6 +193,12 @@ impl Policies { self.crash_report_prompt.unwrap_or(user != Some(false)) } + /// The *Support us on Ko-fi* tag at start (#403): the policy, else the + /// user's choice (`None` = shown). + pub fn donate_tag(&self, user: Option) -> bool { + self.show_donate_tag.unwrap_or(user != Some(false)) + } + /// What the UI shows: the organisation and which settings are fixed. pub fn view(&self) -> PolicyView { let mut managed = Vec::new(); @@ -207,6 +217,9 @@ impl Policies { if self.report_url.is_some() { managed.push("report_url"); } + if self.show_donate_tag.is_some() { + managed.push("donate_tag"); + } PolicyView { managed: self.any(), organization: self.organization_name.clone(), @@ -479,6 +492,47 @@ mod tests { ); } + #[test] + fn the_donate_tag_policy_wins_over_the_user() { + let none = Policies::default(); + assert!(none.donate_tag(None), "shown unless switched off"); + assert!(none.donate_tag(Some(true))); + assert!(!none.donate_tag(Some(false))); + assert!(!none.view().fixed.contains(&"donate_tag")); + + let off = Policies::from_json(r#"{"ShowDonateTag": 0}"#); + assert_eq!(off.show_donate_tag, Some(false)); + assert!(!off.donate_tag(None) && !off.donate_tag(Some(true))); + assert_eq!(off.view().fixed, vec!["donate_tag"]); + assert!(off.any()); + + let on = Policies::from_json(r#"{"ShowDonateTag": true}"#); + assert!(on.donate_tag(Some(false))); + assert_eq!(on.view().fixed, vec!["donate_tag"]); + + for bad in [r#""0""#, "2", "-1", "0.5", "null"] { + let p = Policies::from_json(&format!(r#"{{"ShowDonateTag": {bad}}}"#)); + assert_eq!(p.show_donate_tag, None, "{bad}"); + assert!(!p.view().fixed.contains(&"donate_tag"), "{bad}"); + } + + // the registry: a REG_DWORD switch, not REG_SZ + let out = "\r\nHKEY_LOCAL_MACHINE\\Software\\Policies\\TeamCraft\r\n ShowDonateTag REG_DWORD 0x0\r\n\r\n"; + assert_eq!( + from_pairs(parse_reg_query(out)).show_donate_tag, + Some(false) + ); + let text = "\r\n ShowDonateTag REG_SZ 0\r\n"; + assert_eq!(from_pairs(parse_reg_query(text)).show_donate_tag, None); + + // the computer wins over the user, value by value + let machine = Policies::from_json(r#"{"ShowDonateTag": 0}"#); + let user = Policies::from_json(r#"{"ShowDonateTag": 1}"#); + assert_eq!(machine.or(user).show_donate_tag, Some(false)); + let user_only = Policies::default().or(Policies::from_json(r#"{"ShowDonateTag": 1}"#)); + assert_eq!(user_only.show_donate_tag, Some(true)); + } + #[test] fn a_fixed_server_refuses_others_unless_allowed() { let p = Policies::from_json(r#"{"ServerUrl": "https://plm.example.org"}"#); diff --git a/desktop/src/settings.rs b/desktop/src/settings.rs index 07deb369..e3441b9e 100755 --- a/desktop/src/settings.rs +++ b/desktop/src/settings.rs @@ -211,6 +211,10 @@ pub struct Settings { /// After a crash, ask at the next start whether to share the crash report /// (src/crash.rs); `None` = ask. Reports are never sent without asking. pub crash_prompt: Option, + /// *Settings → Show the "Support us on Ko-fi" tag at start* (#403); + /// `None` = shown once per start. Older settings files have no field. + #[serde(default)] + pub donate_tag: Option, /// The port of the local test server (*Try TeamCraft on this computer*, /// src/localserver.rs). While `server_url` is `http://127.0.0.1:`, the app starts that server when it starts. @@ -789,6 +793,19 @@ mod tests { Some("https://plm.example.org") ); assert_eq!(loaded.onboarding, None); + assert_eq!(loaded.donate_tag, None, "the Ko-fi tag stays on (#403)"); + } + + #[test] + fn the_donate_tag_choice_is_saved_and_loaded() { + let dir = tempfile::tempdir().unwrap(); + let s = Settings { + donate_tag: Some(false), + ..Settings::default() + }; + s.save(dir.path()).unwrap(); + let loaded = Settings::load_with(dir.path(), &FakeKeychain::new(true)); + assert_eq!(loaded.donate_tag, Some(false)); } #[test] diff --git a/desktop/ui/app.css b/desktop/ui/app.css index f30ae696..490a9ef7 100755 --- a/desktop/ui/app.css +++ b/desktop/ui/app.css @@ -414,6 +414,11 @@ tr.row-conflict td:first-child, tr.row-clash td:first-child { box-shadow: inset .status-update { display: inline-flex; align-items: center; gap: 2px; } .status-update button { height: 18px; font-size: 12px; padding: 0 6px; } #status-update-open { color: var(--link); } +/* the Ko-fi tag (#403): once per start, a small chip that opens ko-fi.com in the + browser – static text, nothing loaded from there */ +.status-donate { display: inline-flex; align-items: center; gap: 2px; } +.status-donate button { height: 18px; font-size: 12px; padding: 0 6px; } +#status-donate-open { color: var(--link); border-radius: 9px; } /* ---------------------------------------------------------------- navigator */ diff --git a/desktop/ui/index.html b/desktop/ui/index.html index a8679469..c3210f8b 100755 --- a/desktop/ui/index.html +++ b/desktop/ui/index.html @@ -131,6 +131,7 @@ + diff --git a/desktop/ui/js/settings.js b/desktop/ui/js/settings.js index 3ab59553..f9ba18a0 100755 --- a/desktop/ui/js/settings.js +++ b/desktop/ui/js/settings.js @@ -7,7 +7,7 @@ import { label } from "/static/shared/js/format.js"; import { LANGUAGES, negotiate, t } from "/static/shared/js/i18n.js"; import { applySkin } from "./skins.js"; import { checkServerUrl, showConnect } from "./connect.js"; -import { atRisk, checkUpdate, checkoutsWithChanges, localChangesList, refreshWorklistCount, sendLocalChanges } from "./shell.js"; +import { atRisk, checkUpdate, checkoutsWithChanges, localChangesList, refreshWorklistCount, sendLocalChanges, showDonateTag } from "./shell.js"; import { resetCompanyAi } from "./assistant.js"; import { agent, agentSettingsDialog, endAgentPermissions, localAgentsAllowed, localAgentsOffText } from "./agent.js"; @@ -43,8 +43,9 @@ function languageSelector() { } /** Managed deployment policies (#378): is this setting (`server`, - * `update_check`, `crash_prompt`, `usage_statistics`) fixed by the - * organisation? Such a setting is shown disabled. */ + * `update_check`, `crash_prompt`, `usage_statistics`, `report_url`, + * `donate_tag`) fixed by the organisation? Such a setting is shown + * disabled. */ export function fixedByPolicy(key) { var p = state.session && state.session.policy; return !!(p && p.fixed && p.fixed.indexOf(key) !== -1); @@ -84,6 +85,14 @@ export function openSettings() { call("set_crash_prompt", { enabled: on }).then(function () { state.session.crash_prompt = on; }, function (e) { crashPrompt.checked = !on; toast(errorText(e), "error"); }); } } }); + // the Ko-fi tag at start (#403); switched off, a tag shown now goes too + var donateTag = h("input", { type: "checkbox", checked: state.session.donate_tag !== false, disabled: fixedByPolicy("donate_tag"), on: { change: function () { + var on = donateTag.checked; + call("set_donate_tag", { enabled: on }).then(function () { + state.session.donate_tag = on; + if (!on) showDonateTag(false); + }, function (e) { donateTag.checked = !on; toast(errorText(e), "error"); }); + } } }); // *Report a problem* (#381): the operator's own tracker instead of GitHub var reportUrl = h("input", { type: "url", value: state.session.report_url || "", spellcheck: "false", disabled: fixedByPolicy("report_url"), placeholder: "https://github.com/WARR-eV/TeamCraft/issues/new", on: { change: function () { var url = reportUrl.value.trim(); @@ -142,6 +151,10 @@ export function openSettings() { h("p.hint", { text: "Crashes and uncaught errors are written to a report on this computer (in the app's settings folder, without your home folder, server addresses or tokens). It is only shared when you open the GitHub issue yourself. Switched off, the reports stay on this computer and are never shown." }), field("Report problems to", reportUrl, "empty = the TeamCraft issue form on GitHub; your help desk's form address, which gets title and body"), managedNote("report_url"), + h("h3", { text: t("settings.support") }), + h("label.check", null, [donateTag, t("settings.donate_tag")]), + managedNote("donate_tag"), + h("p.hint", { text: t("settings.donate_tag.hint") }), h("h3", { text: t("settings.account") }), h("p", null, ["Signed in to ", h("strong", { text: state.session.server_url }), " as ", h("strong", { text: state.me.display_name }), " (" + label(state.me.role) + ") on ", h("span", { text: state.session.device })]), state.session.token_storage === "file" diff --git a/desktop/ui/js/shell.js b/desktop/ui/js/shell.js index 093cd1e2..772d4c22 100755 --- a/desktop/ui/js/shell.js +++ b/desktop/ui/js/shell.js @@ -4,6 +4,7 @@ import { $, ICONS, api, badge, call, clear, dialog, enc, errorText, h, invoke, run, setStatus, state, svgIcon, toast, tool } from "./core.js"; import { fmtDate, fmtSize, label } from "/static/shared/js/format.js"; +import { t } from "/static/shared/js/i18n.js"; import { checkServerVersion, showConnect } from "./connect.js"; import { drawWorklist, navHead, selectView } from "./navigator.js"; import { activeTab, closeTab, renderActive, renderTabs, tabShortcut } from "./tabs.js"; @@ -135,6 +136,8 @@ export function enterShell() { checkWorkspaceLayout(); checkTokenStorage(); checkUpdate(); + // the Ko-fi tag (#403): once per start of the app, unless switched off + checkDonateTag(); // the first start after the sign-in: *Getting started* (#422) maybeStartOnboarding(); }).catch(function (err) { @@ -188,6 +191,37 @@ export function initUpdateNotice() { }, 60 * 1000); } +// ====================================================================== +// Ko-fi tag (#403): "Support us on Ko-fi" in the status bar, once per start +// of the app (src/commands.rs donate_tag_due decides and remembers it in +// memory). A click opens the fixed Ko-fi page in the browser and hides the +// tag; × only hides it. Nothing is loaded from ko-fi.com inside the app. +// ====================================================================== + +export function checkDonateTag() { + invoke("donate_tag_due").then(function (due) { if (due) showDonateTag(true); }, function () {}); +} + +export function showDonateTag(show) { + if (show) { + // the texts here, not at start: the catalogs are loaded by then + var open = $("status-donate-open"), dismiss = $("status-donate-dismiss"); + open.textContent = t("donate.tag"); + open.title = t("donate.tag.title"); + dismiss.title = t("donate.dismiss"); + dismiss.setAttribute("aria-label", t("donate.dismiss")); + } + $("status-donate").classList.toggle("hidden", !show); +} + +function initDonateTag() { + $("status-donate-open").addEventListener("click", function () { + showDonateTag(false); + call("open_donate_page").catch(function (e) { toast(errorText(e), "error"); }); + }); + $("status-donate-dismiss").addEventListener("click", function () { showDonateTag(false); }); +} + /** What *Update now* does for each kind of installation (#377). */ var INSTALL_TEXT = { "windows-msi": "Downloads the installer, checks it against the release's checksums, then closes TeamCraft and starts it.", @@ -284,6 +318,7 @@ export function checkUpdateNow() { export function initShell() { initUpdateNotice(); + initDonateTag(); if (/Mac/.test(navigator.platform)) $("search-kbd").textContent = "⌘F"; // the View → Search shortcut document.querySelectorAll(".rail button[data-view]").forEach(function (btn) { btn.addEventListener("click", function () { diff --git a/docs/OPEN_WORK.md b/docs/OPEN_WORK.md index ebde741d..94bd6a86 100755 --- a/docs/OPEN_WORK.md +++ b/docs/OPEN_WORK.md @@ -174,8 +174,12 @@ feature milestone – the features in *What works* are enough; what is missing i test script per install type for each RC - [x] Desktop: managed deployment policies (#378) – Windows registry with ADMX/ADML templates, macOS configuration profile, `/etc/teamcraft/policies.json`; fixed server, updates, crash prompts, working folder, organisation name, - `UsageStatistics` (read for #383), `ReportUrl` (the problem-report tracker, #381), English and German ADML. Left: a manual test per OS (Group Policy, Intune, an MDM profile), + `UsageStatistics` (read for #383), `ReportUrl` (the problem-report tracker, #381), `ShowDonateTag` (the Ko-fi tag, #403), English and German ADML. Left: a manual test per OS (Group Policy, Intune, an MDM profile), a per-machine MSI checked for silent installs +- [x] Desktop: optional *Support us on Ko-fi* tag (#403) – once per start in the status bar, fixed link + `https://ko-fi.com/warr_ev`, *Settings → Support TeamCraft*, policy `ShowDonateTag`, English and German texts. Left: + a manual check on each OS that the click opens the system browser; the web UI has no such link (open question of the + issue) - [ ] Desktop app run and tested on Windows x64/ARM64, macOS and Linux for each RC (a short manual test script in `docs/src/dev/release-checklist.md`) - [x] (**paused for the next releases since 2026-11-22**, to make releases faster: the installers below and the diff --git a/docs/src/admin/desktop-deployment.md b/docs/src/admin/desktop-deployment.md index a56327b6..9595dc13 100755 --- a/docs/src/admin/desktop-deployment.md +++ b/docs/src/admin/desktop-deployment.md @@ -1,3 +1,4 @@ +| `ShowDonateTag` | switch | `0`: the *Support us on Ko-fi* tag is never shown and users cannot turn it on; `1`: it shows once per start of the app and users cannot turn it off; not set: it shows once per start and each user can switch it off in *Settings → Support TeamCraft*. The link (`https://ko-fi.com/warr_ev`) is fixed in the app and cannot be changed (#403) | # Deploying the desktop app An IT department that rolls TeamCraft Desktop out to many computers can preset diff --git a/docs/src/admin/privacy.md b/docs/src/admin/privacy.md index 60c966d4..0fc7cf15 100755 --- a/docs/src/admin/privacy.md +++ b/docs/src/admin/privacy.md @@ -1,3 +1,4 @@ +| *Support us on Ko-fi* tag | nothing | a static note in the desktop status bar, once per start; nothing is loaded from ko-fi.com, and only a click opens `https://ko-fi.com/warr_ev` in the browser (#403) | shown once per start | *Settings → Support TeamCraft*; desktop policy `ShowDonateTag = 0` | # Privacy: what TeamCraft sends Everything TeamCraft sends over the network **by itself** – not as an action diff --git a/docs/src/dev/threat-model.md b/docs/src/dev/threat-model.md index a497a964..438da7c5 100755 --- a/docs/src/dev/threat-model.md +++ b/docs/src/dev/threat-model.md @@ -180,6 +180,7 @@ enial of service, **E**levation of privilege. | Usage statistics leak content | I | the desktop report (#383) has fixed fields only, built in `desktop/src/usage.rs` from counters of fixed action names; the server refuses any other field, accepts only short tokens and a day of the last 7, drops unknown action names and stores no user id (`services::usage::check_report`); the server's aggregate has sizes in classes and features on/off, is shown verbatim on the admin page, is **off** until an administrator turns it on, needs an https destination, and is never sent with `DO_NOT_TRACK`, `TEAMCRAFT_NO_TELEMETRY`, `teamcraft local` or a live demo (10 s, no redirects) | `src/services/usage.rs` `anything_but_the_documented_fields_is_refused`, `the_documented_report_is_read_and_unknown_actions_dropped`, `sharing_is_off_until_turned_on_and_never_with_do_not_track`, `the_desktop_app_counts_the_same_names`; `desktop/src/usage.rs` `the_report_has_exactly_the_documented_fields` | mitigated; the per-installation reports on the own server show when an installation was used (the random id links its days) | | Update download replaced or corrupted | T | *Update now* (#377) downloads only asset addresses of `github.com/WARR-eV/TeamCraft/releases/download/v/` from the release JSON (others are dropped), follows redirects over https only, stops at 1 GiB, and accepts the file only when its SHA-256 equals its one line in the same release's `SHA256SUMS.txt` – otherwise it is deleted; only the file verified last can be started (`update_install` takes no path from the web view), and an installer starts only after the user confirms | `desktop/src/update.rs` `checksums`, `release_assets_come_from_this_repository_only`, `the_asset_fits_the_install` | partly mitigated: the checksum list comes from the same release, so it proves integrity, not origin – until releases are signed (#377) | | Desktop policies abused or leaked | T / I | the policies (#378) are only read, once at start, and never sent; machine-wide sources (`HKLM`, the computer's managed preferences, `/etc/teamcraft/policies.json`) need administrator rights to change, and a machine value wins over the user's; every value is checked (an `http(s)` address normalised like a typed one, an absolute folder, one line of at most 64 characters) and anything else counts as not set; a fixed server is enforced in the app's commands (`set_server`, `switch_connection`, `local_server_start`), not only in the UI | `desktop/src/policy.rs` `wrong_types_and_ranges_count_as_not_set`, `the_registry_answer_is_read`, `the_computer_wins_value_by_value`, `a_fixed_server_refuses_others_unless_allowed` | mitigated; a user-level policy (`HKCU`, the user's profile) is only as strong as the user's own rights | +| Ko-fi tag opens another page or tracks users | T / I | the *Support us on Ko-fi* tag (#403) is static text; the address is the constant `DONATE_URL` (`https://ko-fi.com/warr_ev`) opened from Rust (`open_donate_page`) – the web view cannot pass an address; ko-fi.com is not in the CSP, nothing is loaded or sent before the click, nothing is counted; switched off in *Settings* or by the policy `ShowDonateTag` | `desktop/src/commands.rs` `the_donate_link_is_fixed_and_not_in_the_csp`, `the_donate_tag_is_due_once_per_start`; `desktop/src/policy.rs` `the_donate_tag_policy_wins_over_the_user` | mitigated | | Update notice abused | T / I | the daily release check (opt-out) asks only `api.github.com` for the latest release, without redirects and with a 10 s timeout; a version from the answer is used only if it is a plain `x.y.z`; the notice opens a fixed release page – the app downloads and installs nothing. GitHub sees the address and app version once a day (`desktop/src/update.rs`) | `desktop/src/update.rs` `newer_versions`, `tags`, `at_most_daily` | mitigated | | Dropped paths read the wrong things (#418) | T / I | the desktop app accepts absolute paths from the operating system's file drop (Tauri's native drag-drop event of the main window, no HTML5 drag and drop) – files the user dragged there, like files chosen in the file dialog; they take the same way as picked files with the same checks (duplicates, a name in another folder, copied – never moved – into the item's folder, nothing overwritten without a confirmation); only regular files are taken: `dropped_files` leaves folders and other entries out, `addfiles::plan`, `new_item_places` and `new_item_copy` refuse anything else; the drop only opens *New item* or *Add files…*, nothing is copied or uploaded before the user confirms the dialog | `desktop/src/addfiles.rs` `dropped_paths_keep_regular_files_only`, `refusals`; `scripts/desktop-drop-route.test.mjs` | mitigated | | Server writes outside the working folder | T | every server-supplied name goes through `safe_name` / `normalize_folder` (no `..`, no separators, reserved Windows names) before `join_rel` (`desktop/src/layout.rs` `local_rel`) | `desktop/src/layout.rs` `names`, `folders_like_the_server`, `layout_mapping` | mitigated | diff --git a/docs/src/guide/desktop.md b/docs/src/guide/desktop.md index 43f788a9..6fce7f18 100755 --- a/docs/src/guide/desktop.md +++ b/docs/src/guide/desktop.md @@ -900,6 +900,21 @@ available*. A click opens the **update window** with the release notes and: and says whether you are up to date. *Settings → Updates* switches the daily check off (for example on computers without internet access). +## Support us on Ko-fi + +TeamCraft is free software, developed by a non-profit association. Once per +start of the app, the status bar shows a small **Support us on Ko-fi** tag. +A click opens the association's Ko-fi page (`https://ko-fi.com/warr_ev`) in +your browser and hides the tag; *×* only hides it. It does not come back +until the app starts again – reconnecting or switching server does not show +it again. Nothing is loaded from ko-fi.com inside the app and nothing is +sent or counted; only your click opens the page. + +*Settings → Support TeamCraft* switches the tag off for good on this +computer. On a managed computer your organization may have switched it off +(or on) with the `ShowDonateTag` policy; the switch then shows *Set by your +organization*. + ## Report a problem Every error message has a **Report…** link, and *Help → Report a Problem…* @@ -972,8 +987,8 @@ app](../research/crash-reporting.md). On a computer your IT department manages, some settings can be fixed by *policies* (see [Deploying the desktop app](../admin/desktop-deployment.md)): -the server, the update check, the question after a crash and the default -working folder. *Settings* then shows *Managed by …* at the top, and a fixed +the server, the update check, the question after a crash, the default +working folder and the *Support us on Ko-fi* tag. *Settings* then shows *Managed by …* at the top, and a fixed setting is marked **Set by your organization** and cannot be changed. With a fixed server, the connect screen shows that server only, *Switch server…* is hidden and saved connections to other servers cannot be switched to. diff --git a/scripts/ci-changes.sh b/scripts/ci-changes.sh index fe274a05..7d149b7b 100755 --- a/scripts/ci-changes.sh +++ b/scripts/ci-changes.sh @@ -203,7 +203,7 @@ self_test() { check tests/fixtures/cad/nist/ctc-01/inventor/ctc_01.ipt server=true desktop_rust=true check clippy.toml server=true desktop_rust=true check scripts/desktop-tab-order.test.mjs server=false desktop_ui=true 'codeql=["javascript-typescript"]' - check scripts/desktop-local-changes.test.mjs,desktop/ui/js/local-changes.js server=false desktop_rust=false desktop_ui=true + check scripts/desktop-local-changes.test.mjs,desktop/ui/js/local-changes.js server=false desktop_rust=true desktop_ui=true check desktop/src/localchanges.rs server=false desktop_rust=true desktop_ui=false check src/services/lock_overview.rs server=true desktop_ui=true desktop_rust=false # documentation and examples read by the guard tests diff --git a/shared/i18n/de.json b/shared/i18n/de.json index b2c7849f..068b2e55 100755 --- a/shared/i18n/de.json +++ b/shared/i18n/de.json @@ -22,12 +22,18 @@ "settings.notifications": "Benachrichtigungen", "settings.updates": "Updates", "settings.crash_reports": "Absturzberichte", + "settings.support": "TeamCraft unterstützen", + "settings.donate_tag": "Beim Start den Hinweis „Unterstützen Sie uns auf Ko-fi“ zeigen", + "settings.donate_tag.hint": "TeamCraft ist freie Software, entwickelt von einem gemeinnützigen Verein. Der Hinweis erscheint einmal pro Start in der Statusleiste; ein Klick öffnet ko-fi.com/warr_ev in Ihrem Browser. Vor dem Klick wird nichts gesendet.", "settings.account": "Konto", "settings.connections": "Verbindungen", "settings.close": "Schließen", "settings.save": "Speichern", "language.en": "English", "language.de": "Deutsch", + "donate.tag": "Unterstützen Sie uns auf Ko-fi", + "donate.tag.title": "Öffnet die Ko-fi-Seite des Vereins, der TeamCraft entwickelt, in Ihrem Browser", + "donate.dismiss": "Bis zum nächsten Start ausblenden", "empty.no_groups.editor": "Noch keine Projektgruppen. Legen Sie eine an – Sie werden ihr Manager und nehmen die anderen auf.", "empty.no_groups.viewer": "Noch keine Projektgruppen. CAD-Bearbeiter legen sie an – bitten Sie einen Manager einer Gruppe, Sie aufzunehmen.", "empty.group_empty": "Diese Projektgruppe hat noch keine Artikel.", diff --git a/shared/i18n/en.json b/shared/i18n/en.json index 17e3b6aa..9e235085 100755 --- a/shared/i18n/en.json +++ b/shared/i18n/en.json @@ -22,12 +22,18 @@ "settings.notifications": "Notifications", "settings.updates": "Updates", "settings.crash_reports": "Crash reports", + "settings.support": "Support TeamCraft", + "settings.donate_tag": "Show the “Support us on Ko-fi” tag at start", + "settings.donate_tag.hint": "TeamCraft is free software, developed by a non-profit association. The tag appears once per start in the status bar; a click opens ko-fi.com/warr_ev in your browser. Nothing is sent before you click.", "settings.account": "Account", "settings.connections": "Connections", "settings.close": "Close", "settings.save": "Save", "language.en": "English", "language.de": "Deutsch", + "donate.tag": "Support us on Ko-fi", + "donate.tag.title": "Opens the Ko-fi page of the association that develops TeamCraft in your browser", + "donate.dismiss": "Hide until the next start", "empty.no_groups.editor": "No project groups yet. Create one – you become its manager and add the others.", "empty.no_groups.viewer": "No project groups yet. CAD editors create them – ask a manager of a group to add you.", "empty.group_empty": "This project group has no items yet.",