Skip to main content

Mountain/Command/SourceControlManagement/
GetAllSourceControlManagementState.rs

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