Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ jobs:
# main CAD file (Check out and open after Cancel, #348)
- name: Test the Get rules
run: node scripts/desktop-get-rules.test.mjs
# the steps of the first-start wizard *Getting started* (#422): which
# are skipped, when it shows by itself, the texts
- name: Test the first-start wizard rules
run: node scripts/desktop-onboarding-rules.test.mjs
# the empty states name the next step, by role (#423)
- name: Test the empty state rules
run: node scripts/desktop-empty-rules.test.mjs
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ see the notices in the README.

### Added

- **Getting started in the desktop app** (#422): after the first sign-in
TeamCraft Desktop opens a short wizard – server (skipped when a policy fixes
it), sign-in, the working folder (*Change…*, *Open folder*), *Get project
groups…* for your groups (latest revision, also in work; skipped without
groups or when they are already fetched), the CAD setup for information
(the Inventor `.ipj`, NX load options and Solid Edge search paths a later
version will create – nothing is created now) and the daily loop *Check out
and open* → save in CAD → *Check in…*, ending in *Finish and open* with
one of your groups: its files open in Home, ready for *Check out and open*
on the assembly. Every step but the last can be skipped; *Finish*
or *Don't show again* is kept in the settings (`onboarding`), and *Help →
Getting Started…* opens it again. The wizard creates no file or folder by
itself. Step rules in `desktop/ui/js/onboarding-rules.js`, tested by
`scripts/desktop-onboarding-rules.test.mjs`.
- **Check out several parts of an assembly at once** (#415): `POST /api/v1/checkouts`
takes a list of revisions (by id, or item and code) and checks them out in one
transaction with a result per revision – the ones that can be taken are checked
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ end-to-end tests against a real PostgreSQL.
*Settings → Language*. Empty lists name the next step, by role – viewers
learn why they see no editing buttons (#423).
- **Desktop app** – Linux, macOS and Windows client with a local working
folder, *Get* of whole assemblies, an import wizard, a *Files* view of each
folder, a *Getting started* wizard after the first sign-in (working folder,
*Get* of your project groups, the daily loop), *Get* of whole assemblies, an import wizard, a *Files* view of each
project group (with *New item here* on every folder, starting in a favourite folder, e.g. the one with the
Inventor project file, if you like), a navigable *Graph* of every revision (BOM children,
references and where-used, coloured by state, with quantities and preview
Expand Down
1 change: 1 addition & 0 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ TeamCraft server – it is a client, not an offline copy.
| Area | What the desktop app does |
|---|---|
| Sign-in | **Sign in with the browser** (single sign-on or password, confirmed on a TeamCraft page) or a personal access token; *cancel* stops the sign-in at once |
| Getting started | A short wizard after the **first sign-in** and from *Help → Getting Started…* (#422): server (skipped when a policy fixes it), sign-in (done), **working folder** (what it is, the path, *Change…* with the folder picker, *Open folder*), **project group** (the groups you are a member of, *Get project groups…* – latest revision, also in work; skipped without groups or when a complete Get on this computer – no failed item or name clash, *Latest revision* – already fetched them into this working folder), **CAD setup** (for information only: the Inventor `.ipj`, NX load options and Solid Edge search paths a later version will offer – nothing is created) and **your daily loop** (*Check out and open* → save in CAD → *Check in…*; *Finish and open* + group code makes that group active and shows its files in Home, a fetched group first – *Finish and show Projects* only without a group). Every step has *Don't show again*; *Back*, *Skip* and *Next* move between the steps, the last step has *Finish*; the step list marks skipped steps with a dash and done ones with a tick, also as hidden text for screen readers; the wizard creates no file or folder itself, only through the app's own confirmed actions. *Finish* or *Don't show again* is stored as `onboarding` in `settings.json`; an app that starts already signed in (an update from an older version) does not show it by itself. Step rules in `ui/js/onboarding-rules.js`, tested by `scripts/desktop-onboarding-rules.test.mjs` (`node`); the dialog in `ui/js/onboarding.js` |
| Connections | Several servers and several accounts on one server (#322, #323): *Settings → Connections* lists the saved ones (server, account, working folder) with *Switch* and *Remove*; *Add another account…* signs in a second account on the same server, *Switch server…* (and the connect screen) changes the server **without signing out**. The sign-in of the connection left behind is parked in the keychain (`api-token@<id>`, or a private `token-<id>` file without one) and comes back when you switch to it; the window reloads. Every connection after the first has its **own working folder** next to the default one (`TeamCraft-<server>`, numbered for a second account), never inside another, so files of servers with the same item numbers never mix; the first keeps its folder. At most 20 connections; removing one keeps its folder on disk (`src/profiles.rs`) A sign-in kept from an app version before the connections gets its account noted the first time the server confirms it (`GET /me`, #356) |
| Local test server | Downloads *with local server* only – an app of its own, *TeamCraft Local* (own identifier, settings and keychain entry): on its first start, with no server configured, and with *Try TeamCraft on this computer* on the connect screen it starts the bundled `teamcraft-server local` (private PostgreSQL + server on 127.0.0.1), signs in through the browser (the first start creates the administrator there) and starts the server again at every launch while it is the configured server; it stops when the app ends (`src/localserver.rs`, log in `local-server.log`) |
| Navigator | *Home*: a file browser of the **active project group** – *Files*: its folders and the files in them, as in the working folder (folders first, then the files by name – case-blind, digits by value; one folder per request from `GET /projects/{code}/files`, 500 entries at a time with *show … more*; items without files below the files of their own folder; **+** on a folder row = *New item here*; a checked-out row is marked with a bar in the lock colour and a light tint, also in *Structure* – #362; with an older server the items instead; a folder's ☆ makes it the group's **favourite folder**: Home starts there under a banner in the accent colour – *not the top of the group*, *Whole group*, *Remove favourite* – and the folder of the group's Inventor project file `.ipj` (`project_folders`) is suggested; kept per computer, server and group, #352), *All items*: every item in one list, or the *Structure* view. The name comes first (the number/revision dimmed after it); a small picture of the model replaces the type icon in *Files*, *All items*, *Structure* and the search (named by the list answers, fetched only for rows in view through an `IntersectionObserver`, kept per content hash – `js/list-thumbs.js`, #420); sorted by name, number, type or state (kept per computer); *Projects* (`Ctrl/Cmd+5`): choose the active group (mine first), create a group (*New*, CAD editors), *Get…* groups into the workspace, *Import CAD folder…*. Both are loaded again on *Refresh* (a group created in the web UI shows without a restart); *My Worklist* (check-outs, reviews, my open changes – updated at once after a check-out, cancelled check-out, check-in or acknowledgement in a tab, #347); change orders by status; full-text search |
Expand Down
13 changes: 13 additions & 0 deletions desktop/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ pub struct Session {
/// Managed deployment policies (#378): the organisation and the settings
/// fixed by a policy.
pub policy: policy::PolicyView,
/// The first-start wizard: `done`, `dismissed` or none (#422).
pub onboarding: Option<String>,
}

#[tauri::command]
Expand All @@ -141,6 +143,7 @@ pub fn session(app: AppHandle, state: State<'_, AppState>) -> Session {
local_server_available: localserver::sidecar().is_some(),
local_server_in_use: local_server_in_use(&s),
policy: policy::current().view(),
onboarding: s.onboarding.clone(),
}
}

Expand Down Expand Up @@ -1087,6 +1090,16 @@ pub fn dismiss_update(state: State<'_, AppState>, version: String) -> CmdResult<
Ok(())
}

/// *Getting started* (#422): the wizard was finished (`done`) or closed with
/// *Don't show again* (`dismissed`); it then no longer opens by itself.
#[tauri::command]
pub fn set_onboarding(state: State<'_, AppState>, value: String) -> CmdResult<()> {
let value = crate::settings::onboarding_value(&value)
.ok_or_else(|| ApiError::local(format!("'{value}' is not a state of the wizard.")))?;
update_settings(&state, |s| s.onboarding = Some(value.to_string()))?;
Ok(())
}

/// *Remind me later*: no notice for three days (#377).
#[tauri::command]
pub fn update_remind_later(state: State<'_, AppState>) -> CmdResult<()> {
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ fn build_menu(app: &tauri::App) -> tauri::Result<()> {
.item(&item("open-web", "Open in Browser", None)?)
.build()?;
let help = SubmenuBuilder::new(app, "Help")
.item(&item("getting-started", "Getting Started…", None)?)
.item(&item("import-help", "How to Import a CAD Folder", None)?)
.item(&item("report-problem", "Report a Problem…", None)?)
.item(&item("check-updates", "Check for Updates…", None)?)
Expand Down Expand Up @@ -290,6 +291,7 @@ fn main() {
commands::set_report_url,
commands::check_update,
commands::dismiss_update,
commands::set_onboarding,
commands::update_remind_later,
commands::check_update_now,
commands::update_offer,
Expand Down
54 changes: 54 additions & 0 deletions desktop/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ pub struct Settings {
/// Id of the active connection in [`Settings::profiles`].
#[serde(default)]
pub active_profile: Option<String>,
/// The first-start wizard *Getting started* (#422, ui/js/onboarding.js):
/// `"done"` or `"dismissed"` – it then no longer opens by itself (*Help →
/// Getting started…* still does). `None` in settings files of older
/// versions.
#[serde(default)]
pub onboarding: Option<String>,
/// Not stored in settings.json.
#[serde(skip)]
pub token: Option<String>,
Expand Down Expand Up @@ -282,6 +288,15 @@ pub(crate) fn write_private_file(dir: &Path, name: &str, content: &str) -> anyho
Ok(())
}

/// The values of [`Settings::onboarding`]; anything else is refused.
pub fn onboarding_value(value: &str) -> Option<&'static str> {
match value {
"done" => Some("done"),
"dismissed" => Some("dismissed"),
_ => None,
}
}

/// Most remembered Agent view backends (servers × users).
pub const MAX_AGENT_BACKENDS: usize = 32;

Expand Down Expand Up @@ -757,4 +772,43 @@ mod tests {
.unwrap();
assert!(s.save_token_with(dir.path(), &keychain, None).is_err());
}

/// A settings file of an older version has no `onboarding`: it still
/// loads, with the wizard not done (#422).
#[test]
fn settings_without_onboarding_still_load() {
let dir = tempfile::tempdir().unwrap();
fs::write(
dir.path().join(SETTINGS_FILE),
r#"{"server_url":"https://plm.example.org","skin":"teamcraft"}"#,
)
.unwrap();
let loaded = Settings::load_with(dir.path(), &FakeKeychain::new(true));
assert_eq!(
loaded.server_url.as_deref(),
Some("https://plm.example.org")
);
assert_eq!(loaded.onboarding, None);
}

#[test]
fn onboarding_is_saved_and_loaded() {
let dir = tempfile::tempdir().unwrap();
let s = Settings {
onboarding: Some("dismissed".into()),
..Settings::default()
};
s.save(dir.path()).unwrap();
let loaded = Settings::load_with(dir.path(), &FakeKeychain::new(true));
assert_eq!(loaded.onboarding.as_deref(), Some("dismissed"));
}

#[test]
fn only_done_and_dismissed_are_onboarding_values() {
assert_eq!(onboarding_value("done"), Some("done"));
assert_eq!(onboarding_value("dismissed"), Some("dismissed"));
for bad in ["", "Done", "later", "done ", "dismissed\n"] {
assert_eq!(onboarding_value(bad), None, "{bad:?}");
}
}
}
24 changes: 24 additions & 0 deletions desktop/ui/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
/* read by screen readers, not shown (e.g. the step status of Getting started) */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Distro skins paint their glow and texture here, behind the page; the house
skins set both to none. Nothing else reads --glow or --pattern. */
Expand Down Expand Up @@ -900,6 +902,28 @@ canvas.viewer-measuring { cursor: crosshair; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.dialog .error-text { color: var(--st-danger-fg); margin: 8px 0 0; }

/* Getting started (#422, js/onboarding.js): the steps on the left, the
current one on the right; narrow windows stack them. */
.onboarding { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 20px; }
.onboarding-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; align-content: start; counter-reset: onboarding; }
.onboarding-steps li {
counter-increment: onboarding;
display: grid; gap: 2px; padding: 6px 8px 6px 28px; position: relative;
border-radius: var(--radius); color: var(--text-dim);
}
.onboarding-steps li::before { content: counter(onboarding); position: absolute; left: 8px; top: 6px; font-variant-numeric: tabular-nums; }
.onboarding-steps li.current { color: var(--text); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.onboarding-steps li.done { color: var(--text); }
.onboarding-steps li.done::before { content: "\2713"; color: var(--st-ok-fg); }
.onboarding-steps li.skipped::before { content: "\2013"; }
.onboarding-body h3 { margin: 0; }
.onboarding-body p { margin: 0; }
.onboarding-path { display: block; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow-wrap: anywhere; }
.onboarding-cad { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
@media (max-width: 640px) {
.onboarding { grid-template-columns: minmax(0, 1fr); }
}

/* Appearance: the three house cards (System, Light, Dark) first and larger,
the distribution skins after them. Each card renders its own tokens. */
.skin-grid { display: grid; gap: 8px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
Expand Down
3 changes: 2 additions & 1 deletion desktop/ui/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export var state = {
viewer: null,
zoom: 1,
update: null, // the newer release the status bar tells about: {version, current}
tokenFileWarned: false // the "no keychain" warning shows once per start
tokenFileWarned: false, // the "no keychain" warning shows once per start
signedInAtStart: null // the app started signed in (false: the user signs in now – the first-start wizard, onboarding.js)
};

// ======================================================================
Expand Down
27 changes: 27 additions & 0 deletions desktop/ui/js/group-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,31 @@ export function projectItems(code) {
return page(0);
}

/** Key of the groups fetched with *Get project groups* into this working
* folder (per folder: each connection has its own). */
function gotGroupsKey() {
return "teamcraft.got-groups:" + String(state.session && state.session.workspace_dir || "");
}

/** Codes of the project groups a finished *Get project groups* copied into
* the current working folder on this computer – the first-start wizard
* (onboarding.js) skips its group step for them. Only a convenience: an
* empty answer (private window, cleared storage) just shows the step. */
export function gotGroups() {
try {
var list = JSON.parse(window.localStorage.getItem(gotGroupsKey()) || "[]");
return Array.isArray(list) ? list.filter(function (c) { return typeof c === "string"; }) : [];
} catch (e) { return []; }
}

/** Remembers the groups of a Get that ran to its end without a problem
* (not stopped, no failed item or name clash, rule *Latest revision*). */
export function rememberGotGroups(list) {
var all = gotGroups();
(list || []).forEach(function (c) { if (all.indexOf(c) === -1) all.push(c); });
try { window.localStorage.setItem(gotGroupsKey(), JSON.stringify(all.slice(-200))); } catch (e) { /* storage blocked: the step shows again */ }
}

/** For new team members or a fresh computer: copies the files of every item
* of the chosen project groups into the workspace, one folder per group.
* `opts.project` (a group code) ticks only that group – the *Get…* of an
Expand Down Expand Up @@ -87,6 +112,8 @@ export function openGetProjectsDialog(opts) {
}, Promise.resolve());
}).then(function () {
running = false;
// only a complete copy: no problems, no clashes, the latest revision of every item
if (!stop && !done.errors.length && rule.value === "latest") rememberGotGroups(codes);
var text = (stop ? "Stopped. " : "Done. ") + done.items + " items, " + done.files + " files copied" +
(done.kept ? ", " + done.kept + " locally modified files kept" : "") +
(done.skipped ? ", " + done.skipped + " items without a released revision skipped" : "") +
Expand Down
6 changes: 5 additions & 1 deletion desktop/ui/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Every server call goes through the Rust commands (src/commands.rs); data
// from the server is only ever inserted as text, never as HTML.
//
// Modules: core.js, skins.js, connect.js, shell.js, navigator.js, tabs.js, assistant.js, agent.js, revision.js, references.js, workspace.js, change.js, requests.js, dialogs.js, bom-import.js, bom-lines.js, group-sync.js, folder-import.js, settings.js, crash.js, main.js.
// Modules: core.js, skins.js, connect.js, shell.js, navigator.js, tabs.js, assistant.js, agent.js, revision.js, references.js, workspace.js, change.js, requests.js, dialogs.js, bom-import.js, bom-lines.js, group-sync.js, folder-import.js, settings.js, onboarding-rules.js, onboarding.js, crash.js, main.js.

import { $, TAURI, call, errorText, h, invoke, setStatus, state, toast } from "./core.js";
import { applySkin } from "./skins.js";
Expand All @@ -29,6 +29,7 @@ import { reportDialog } from "./report.js";
import { checkCrashReports, initCrashWatch } from "./crash.js";
import { onSolidcraftRequest } from "./solidcraft-bridge.js";
import { initItemMenu } from "./item-menu.js";
import { openOnboarding } from "./onboarding.js";

// ======================================================================
// Zoom: Ctrl + mouse wheel (trackpads: pinch), Ctrl/Cmd + + / - / 0
Expand Down Expand Up @@ -101,6 +102,7 @@ export function handleMenu(id) {
case "import-folder": importFolderDialog(); break;
case "import-bom": importBomDialog(null); break;
case "import-help": importTutorial(); break;
case "getting-started": openOnboarding(true); break;
case "settings": case "settings-app": openSettings(); break;
case "sign-out": signOut(); break;
case "refresh": selectView(state.view); reloadActive(); refreshWorklistCount(); break;
Expand Down Expand Up @@ -157,6 +159,8 @@ export function boot() {
var languageReady = loadLanguage(preferredLanguage()).catch(function () {});
languageReady.then(function () { return call("session"); }).then(function (s) {
state.session = s;
// signed in already: no first-start wizard (onboarding.js)
state.signedInAtStart = !!s.signed_in;
showAppVersion(s.version);
state.zoom = s.zoom || 1;
showZoom();
Expand Down
Loading
Loading