Skip to main content

Mountain/Command/SourceControlManagement/
GetAllSourceControlManagementState.rs

1
2//! Tauri command - full snapshot of every registered SCM provider,
3//! its resource groups, and the resources within those groups.
4//! Drives the SCM viewlet's first paint.
5
6use std::sync::Arc;
7
8use serde_json::{Value, json};
9use tauri::{State, command};
10
11use crate::{
12	ApplicationState::State::ApplicationState::{ApplicationState, MapLockError},
13	dev_log,
14};
15
16#[command]
17pub async fn GetAllSourceControlManagementState(State:State<'_, Arc<ApplicationState>>) -> Result<Value, String> {
18	dev_log!("commands", "getting all SCM state for UI");
19
20	let Providers = State
21		.Feature
22		.Markers
23		.SourceControlManagementProviders
24		.lock()
25		.map_err(MapLockError)
26		.map_err(|Error| Error.to_string())?
27		.clone();
28
29	let Groups = State
30		.Feature
31		.Markers
32		.SourceControlManagementGroups
33		.lock()
34		.map_err(MapLockError)
35		.map_err(|Error| Error.to_string())?
36		.clone();
37
38	let Resources = State
39		.Feature
40		.Markers
41		.SourceControlManagementResources
42		.lock()
43		.map_err(MapLockError)
44		.map_err(|Error| Error.to_string())?
45		.clone();
46
47	Ok(json!({
48		"providers": Providers,
49		"groups": Groups,
50		"resources": Resources,
51	}))
52}