diff --git a/rust/windows-client/src-tauri/src/client.rs b/rust/windows-client/src-tauri/src/client.rs index 5597ea2e0..b37e6bc4b 100644 --- a/rust/windows-client/src-tauri/src/client.rs +++ b/rust/windows-client/src-tauri/src/client.rs @@ -2,6 +2,7 @@ use anyhow::Result; use clap::{Args, Parser}; use std::{os::windows::process::CommandExt, process::Command}; +mod about; mod auth; mod crash_handling; mod debug_commands; @@ -35,7 +36,7 @@ pub const BUNDLE_ID: &str = "dev.firezone.client"; /// * `g` doesn't mean anything /// * `ed5437c88` is the Git commit hash /// * `-modified` is present if the working dir has any changes from that commit number -const GIT_VERSION: &str = +pub const GIT_VERSION: &str = git_version::git_version!(args = ["--always", "--dirty=-modified", "--tags"]); /// GuiParams prevents a problem where changing the args to `gui::run` breaks static analysis on non-Windows targets, where the gui is stubbed out diff --git a/rust/windows-client/src-tauri/src/client/about.rs b/rust/windows-client/src-tauri/src/client/about.rs new file mode 100644 index 000000000..e7c1cce9a --- /dev/null +++ b/rust/windows-client/src-tauri/src/client/about.rs @@ -0,0 +1,12 @@ +//! Everything related to the About window +use crate::client::GIT_VERSION; + +#[tauri::command] +pub(crate) fn get_cargo_version() -> String { + env!("CARGO_PKG_VERSION").to_string() +} + +#[tauri::command] +pub(crate) fn get_git_version() -> String { + GIT_VERSION.to_string() +} diff --git a/rust/windows-client/src-tauri/src/client/gui.rs b/rust/windows-client/src-tauri/src/client/gui.rs index 2109b90b9..78bf1b301 100644 --- a/rust/windows-client/src-tauri/src/client/gui.rs +++ b/rust/windows-client/src-tauri/src/client/gui.rs @@ -7,7 +7,7 @@ use crate::client::{self, deep_link, network_changes, AppLocalDataDir, BUNDLE_ID use anyhow::{anyhow, bail, Context, Result}; use arc_swap::ArcSwap; use client::{ - logging, + about, logging, settings::{self, AdvancedSettings}, }; use connlib_client_shared::{file_logger, ResourceDescription}; @@ -137,6 +137,8 @@ pub(crate) fn run(params: client::GuiParams) -> Result<()> { } }) .invoke_handler(tauri::generate_handler![ + about::get_cargo_version, + about::get_git_version, logging::clear_logs, logging::count_logs, logging::export_logs, diff --git a/rust/windows-client/src/about.html b/rust/windows-client/src/about.html index 1610e7ac6..595b99099 100644 --- a/rust/windows-client/src/about.html +++ b/rust/windows-client/src/about.html @@ -5,32 +5,18 @@ About Firezone - - + + - +
-

About Firezone

- -
- - firezone.dev - - -
- -
- - app link? - - -
- + Firezone Logo +

+ Version + + () +

diff --git a/rust/windows-client/src/about.ts b/rust/windows-client/src/about.ts new file mode 100644 index 000000000..93f4701dd --- /dev/null +++ b/rust/windows-client/src/about.ts @@ -0,0 +1,35 @@ +import "./tauri_stub.js"; + +const invoke = window.__TAURI__.tauri.invoke; + +const cargoVersionSpan = ( + document.getElementById("cargo-version") +); +const gitVersionSpan = document.getElementById("git-version"); + +function get_cargo_version() { + invoke("get_cargo_version") + .then((cargoVersion: string) => { + cargoVersionSpan.innerText = cargoVersion; + }) + .catch((e: Error) => { + cargoVersionSpan.innerText = "Unknown"; + console.error(e); + }); +} + +function get_git_version() { + invoke("get_git_version") + .then((gitVersion: string) => { + gitVersionSpan.innerText = gitVersion; + }) + .catch((e: Error) => { + gitVersionSpan.innerText = "Unknown"; + console.error(e); + }); +} + +document.addEventListener("DOMContentLoaded", () => { + get_cargo_version(); + get_git_version(); +}); diff --git a/rust/windows-client/src/logo.png b/rust/windows-client/src/logo.png new file mode 100644 index 000000000..12a2c97eb Binary files /dev/null and b/rust/windows-client/src/logo.png differ diff --git a/rust/windows-client/src/settings.html b/rust/windows-client/src/settings.html index a08da7db6..c488e1ae3 100644 --- a/rust/windows-client/src/settings.html +++ b/rust/windows-client/src/settings.html @@ -5,6 +5,7 @@ Settings + @@ -176,6 +177,5 @@ - diff --git a/rust/windows-client/src/settings.ts b/rust/windows-client/src/settings.ts index 8453d5db7..0671020b8 100644 --- a/rust/windows-client/src/settings.ts +++ b/rust/windows-client/src/settings.ts @@ -1,4 +1,8 @@ // Purpose: TypeScript file for the settings page. +import "./tauri_stub.js"; + +const invoke = window.__TAURI__.tauri.invoke; +const listen = window.__TAURI__.event.listen; // Custom types interface Settings { @@ -7,46 +11,11 @@ interface Settings { log_filter: string; } -interface TauriEvent { - type: string; - payload: any; -} - interface FileCount { files: number; bytes: number; } -// Stub Tauri API for TypeScript. Helpful when developing without Tauri running. -export {}; -declare global { - interface Window { - __TAURI__: { - tauri: { - invoke: (cmd: string, args?: any) => Promise; - }; - event: { - listen: (cmd: string, callback: (event: TauriEvent) => void) => void; - }; - }; - } -} -window.__TAURI__ = window.__TAURI__ || { - tauri: { - invoke: (_cmd: string, _args?: any) => { - return Promise.reject("Tauri API not initialized"); - }, - }, - event: { - listen: (_cmd: string, _callback: (event: TauriEvent) => void) => { - console.error("Tauri API not initialized"); - }, - }, -}; - -const { invoke } = window.__TAURI__.tauri; -const { listen } = window.__TAURI__.event; - // DOM elements const form = document.getElementById("advanced-settings-form"); const authBaseUrlInput = ( diff --git a/rust/windows-client/src/tauri_stub.ts b/rust/windows-client/src/tauri_stub.ts new file mode 100644 index 000000000..755786add --- /dev/null +++ b/rust/windows-client/src/tauri_stub.ts @@ -0,0 +1,32 @@ +// Stub Tauri API for TypeScript. Helpful when developing without Tauri running. + +interface TauriEvent { + type: string; + payload: any; +} + +export {}; +declare global { + interface Window { + __TAURI__: { + tauri: { + invoke: (cmd: string, args?: any) => Promise; + }; + event: { + listen: (cmd: string, callback: (event: TauriEvent) => void) => void; + }; + }; + } +} +window.__TAURI__ = window.__TAURI__ || { + tauri: { + invoke: (_cmd: string, _args?: any) => { + return Promise.reject("Tauri API not initialized"); + }, + }, + event: { + listen: (_cmd: string, _callback: (event: TauriEvent) => void) => { + console.error("Tauri API not initialized"); + }, + }, +};