Mountain/Command/
SourceControlManagement.rs

1//! # SourceControlManagement Commands
2//!
3//! Defines the specific Tauri command handlers for SourceControlManagement data
4//! requests that originate from the `Sky` frontend UI.
5
6#![allow(non_snake_case, non_camel_case_types)]
7
8use std::sync::Arc;
9
10use serde_json::{Value, json};
11use tauri::{State, command};
12
13use crate::ApplicationState::ApplicationState::{ApplicationState, MapLockError};
14
15/// Retrieves the complete state of all Source Control Management providers,
16/// groups, and resources for rendering in the UI.
17///
18/// This command is called by the frontend to get a full snapshot of the SCM
19/// view.
20#[command]
21pub async fn GetAllSourceControlManagementState(State:State<'_, Arc<ApplicationState>>) -> Result<Value, String> {
22	log::debug!("[SourceControlManagement Command] Getting all SCM state for UI.");
23
24	let Providers = State
25		.SourceControlManagementProviders
26		.lock()
27		.map_err(MapLockError)
28		.map_err(|Error| Error.to_string())?
29		.clone();
30
31	let Groups = State
32		.SourceControlManagementGroups
33		.lock()
34		.map_err(MapLockError)
35		.map_err(|Error| Error.to_string())?
36		.clone();
37
38	let Resources = State
39		.SourceControlManagementResources
40		.lock()
41		.map_err(MapLockError)
42		.map_err(|Error| Error.to_string())?
43		.clone();
44
45	Ok(json!({
46		"providers": Providers,
47		"groups": Groups,
48		"resources": Resources,
49	}))
50}