wraith/src-tauri/src/commands/connections.rs
Vantz Stockwell 0c6a4b8109
Some checks failed
Build & Sign Wraith / Build Windows + Sign (push) Failing after 2m55s
feat: Tauri auto-updater + RDP vault credentials + sidebar persist
Tauri auto-updater:
- Signing pubkey in tauri.conf.json
- tauri-plugin-updater initialized in lib.rs
- CI workflow passes TAURI_SIGNING_PRIVATE_KEY env vars to cargo tauri build
- CI generates update.json manifest with signature and uploads to
  packages/latest/update.json endpoint
- Frontend checks for updates on startup via @tauri-apps/plugin-updater
- Downloads, installs, and relaunches seamlessly
- Settings → About button uses native updater too

RDP vault credentials:
- RDP connections now resolve credentials from vault via credentialId
- Same path as SSH: list_credentials → find by ID → decrypt_password
- Falls back to conn.options JSON if no vault credential linked
- Fixes blank username in RDP connect

Sidebar drag persist:
- reorder_connections and reorder_groups Tauri commands
- Batch-update sort_order in database on drop
- Order survives app restart

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 12:42:01 -04:00

111 lines
3.1 KiB
Rust

use tauri::State;
use crate::connections::{
ConnectionGroup, ConnectionRecord, CreateConnectionInput, UpdateConnectionInput,
};
use crate::AppState;
/// Return all connections ordered by group then sort_order.
#[tauri::command]
pub fn list_connections(state: State<'_, AppState>) -> Result<Vec<ConnectionRecord>, String> {
state.connections.list_connections()
}
/// Create a new connection and return the persisted record.
#[tauri::command]
pub fn create_connection(
input: CreateConnectionInput,
state: State<'_, AppState>,
) -> Result<ConnectionRecord, String> {
state.connections.create_connection(input)
}
/// Fetch a single connection by id.
#[tauri::command]
pub fn get_connection(id: i64, state: State<'_, AppState>) -> Result<ConnectionRecord, String> {
state.connections.get_connection(id)
}
/// Apply a partial update to a connection.
///
/// Only fields present (i.e. `Some`) in `input` are written; all others are
/// left unchanged. Returns `Err` if the connection id does not exist.
#[tauri::command]
pub fn update_connection(
id: i64,
input: UpdateConnectionInput,
state: State<'_, AppState>,
) -> Result<(), String> {
state.connections.update_connection(id, input)
}
/// Delete a connection by id.
///
/// Returns `Err` if the id does not exist.
#[tauri::command]
pub fn delete_connection(id: i64, state: State<'_, AppState>) -> Result<(), String> {
state.connections.delete_connection(id)
}
/// Return all connection groups ordered by parent then sort_order.
#[tauri::command]
pub fn list_groups(state: State<'_, AppState>) -> Result<Vec<ConnectionGroup>, String> {
state.connections.list_groups()
}
/// Create a new connection group.
///
/// `parent_id` is `None` for top-level groups.
#[tauri::command]
pub fn create_group(
name: String,
parent_id: Option<i64>,
state: State<'_, AppState>,
) -> Result<ConnectionGroup, String> {
state.connections.create_group(&name, parent_id)
}
/// Delete a connection group by id.
///
/// Connections in the deleted group have their `group_id` set to NULL by the
/// database's `ON DELETE SET NULL` constraint.
#[tauri::command]
pub fn delete_group(id: i64, state: State<'_, AppState>) -> Result<(), String> {
state.connections.delete_group(id)
}
/// Rename a connection group.
///
/// Returns `Err` if the id does not exist.
#[tauri::command]
pub fn rename_group(id: i64, name: String, state: State<'_, AppState>) -> Result<(), String> {
state.connections.rename_group(id, &name)
}
/// Search connections across name, hostname, tags, and notes.
///
/// Uses case-insensitive LIKE matching. Returns results ordered by name.
#[tauri::command]
pub fn search_connections(
query: String,
state: State<'_, AppState>,
) -> Result<Vec<ConnectionRecord>, String> {
state.connections.search(&query)
}
#[tauri::command]
pub fn reorder_connections(
ids: Vec<i64>,
state: State<'_, AppState>,
) -> Result<(), String> {
state.connections.reorder_connections(&ids)
}
#[tauri::command]
pub fn reorder_groups(
ids: Vec<i64>,
state: State<'_, AppState>,
) -> Result<(), String> {
state.connections.reorder_groups(&ids)
}