Skip to content

Commit 756d5a9

Browse files
committed
Added the features selection to the GUI wizard
1 parent 731aff1 commit 756d5a9

File tree

6 files changed

+589
-14
lines changed

6 files changed

+589
-14
lines changed

src-tauri/src/gui/commands/idf_tools.rs

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
use crate::gui::ui::{emit_installation_event, emit_log_message, send_message, send_tools_message, InstallationProgress, InstallationStage, MessageLevel, ProgressBar};
1+
use crate::gui::{app_state::{get_settings_non_blocking, update_settings}, ui::{emit_installation_event, emit_log_message, send_message, send_tools_message, InstallationProgress, InstallationStage, MessageLevel, ProgressBar}};
22
use anyhow::{anyhow, Context, Result};
33

44
use idf_im_lib::{
5-
add_path_to_path,ensure_path,
6-
idf_tools::{self, get_tools_export_paths},
7-
DownloadProgress,
8-
settings::Settings,
5+
add_path_to_path, ensure_path, idf_features::{get_requirements_json_url, FeatureInfo, RequirementsMetadata}, idf_tools::{self, get_tools_export_paths}, settings::Settings, DownloadProgress
96
};
10-
use log::{ error, info};
7+
use log::{ error, info, warn};
118
use std::{
129
path::{Path, PathBuf}, sync::{Arc, Mutex},
1310
};
@@ -419,3 +416,55 @@ pub async fn setup_tools(
419416

420417
Ok(export_paths)
421418
}
419+
420+
#[tauri::command]
421+
pub async fn get_features_list(
422+
app_handle: AppHandle,
423+
) -> Result<Vec<FeatureInfo>, String> {
424+
let settings = get_settings_non_blocking(&app_handle)?;
425+
let first_version = match &settings.idf_versions {
426+
Some(versions) if !versions.is_empty() => versions.first().unwrap(),
427+
_ => {
428+
let msg = t!("wizard.requirements.no_idf_version_specified").to_string();
429+
warn!("{}", msg);
430+
return Err(msg);
431+
}
432+
};
433+
let req_url = get_requirements_json_url(settings.repo_stub.clone().as_deref(), &first_version.to_string(), settings.idf_mirror.clone().as_deref());
434+
println!("Requirements URL: {}", req_url);
435+
let requirements_files = match RequirementsMetadata::from_url_async(&req_url).await {
436+
Ok(files) => files,
437+
Err(err) => {
438+
warn!("{}: {}. {}", t!("wizard.requirements.read_failure"), err, t!("wizard.features.selection_unavailable"));
439+
return Err(err.to_string());
440+
}
441+
};
442+
443+
Ok(requirements_files.features.clone())
444+
}
445+
446+
/// Sets the selected ESP-IDF features
447+
#[tauri::command]
448+
pub fn set_selected_features(
449+
app_handle: AppHandle,
450+
features: Vec<String>,
451+
) -> Result<(), String> {
452+
info!("Setting selected features: {:?}", features);
453+
update_settings(&app_handle, |settings| {
454+
settings.idf_features = Some(features);
455+
})?;
456+
457+
send_message(
458+
&app_handle,
459+
t!("gui.settings.features_updated").to_string(),
460+
"info".to_string(),
461+
);
462+
Ok(())
463+
}
464+
465+
/// Gets the currently selected features from settings
466+
#[tauri::command]
467+
pub fn get_selected_features(app_handle: AppHandle) -> Result<Vec<String>, String> {
468+
let settings = get_settings_non_blocking(&app_handle)?;
469+
Ok(settings.idf_features.clone().unwrap_or_default())
470+
}

src-tauri/src/gui/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ pub fn run() {
270270
open_terminal_with_script,
271271
get_pypi_mirror_list,
272272
set_pypi_mirror,
273+
get_features_list,
274+
set_selected_features,
275+
get_selected_features,
273276
])
274277
.run(tauri::generate_context!())
275278
.expect("error while running tauri application");

src/components/WizardStep.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<div v-for="(step, index) in steps" :key="index" class="step-item" :class="{
1414
'active': currentStep === index + 1,
1515
'completed': currentStep > index + 1,
16-
'disabled': currentStep === 7 || currentStep === 8,
17-
'clickable': currentStep > index + 1 && currentStep < 7
16+
'disabled': currentStep === 8 || currentStep === 9,
17+
'clickable': currentStep > index + 1 && currentStep < 8
1818
}" @click="handleStepClick(index + 1)" :data-id="`step-item-${index + 1}`">
1919
<div class="step-number" :data-id="`step-number-${index + 1}`">
2020
<template v-if="currentStep > index + 1">
@@ -39,9 +39,10 @@
3939
<TargetSelect :nextstep=nextStep v-if="currentStep === 3" data-id="target-select" />
4040
<VersionSelect :nextstep=nextStep v-if="currentStep === 4" data-id="version-select" />
4141
<MirrorSelect :nextstep=nextStep v-if="currentStep === 5" data-id="mirror-select" />
42-
<InstallationPathSelect :nextstep=nextStep v-if="currentStep === 6" data-id="installation-path-select" />
43-
<InstalationProgress :nextstep=nextStep v-if="currentStep === 7" data-id="installation-progress" />
44-
<Complete v-if="currentStep === 8" data-id="complete" />
42+
<FeaturesSelect :nextstep=nextStep v-if="currentStep === 6" data-id="features-select" />
43+
<InstallationPathSelect :nextstep=nextStep v-if="currentStep === 7" data-id="installation-path-select" />
44+
<InstalationProgress :nextstep=nextStep v-if="currentStep === 8" data-id="installation-progress" />
45+
<Complete v-if="currentStep === 9" data-id="complete" />
4546
</div>
4647
</div>
4748
</div>
@@ -59,6 +60,7 @@ import PythonSanitycheck from './wizard_steps/PythonSanitycheck.vue';
5960
import TargetSelect from './wizard_steps/TargetSelect.vue';
6061
import VersionSelect from './wizard_steps/VersionSelect.vue';
6162
import MirrorSelect from './wizard_steps/MirrorSelect.vue';
63+
import FeaturesSelect from './wizard_steps/FeaturesSelect.vue';
6264
import InstallationPathSelect from './wizard_steps/InstallationPathSelect.vue';
6365
import InstalationProgress from './wizard_steps/InstalationProgress.vue';
6466
import Complete from './wizard_steps/Complete.vue';
@@ -75,6 +77,7 @@ export default {
7577
TargetSelect,
7678
VersionSelect,
7779
MirrorSelect,
80+
FeaturesSelect,
7881
InstallationPathSelect,
7982
InstalationProgress,
8083
},
@@ -90,6 +93,7 @@ export default {
9093
{ titleKey: "wizardStep.steps.selectTarget" },
9194
{ titleKey: "wizardStep.steps.selectVersion" },
9295
{ titleKey: "wizardStep.steps.selectMirror" },
96+
{ titleKey: "wizardStep.steps.selectFeatures" },
9397
{ titleKey: "wizardStep.steps.selectPath" },
9498
{ titleKey: "wizardStep.steps.installationProgress" },
9599
{ titleKey: "wizardStep.steps.installationComplete" }
@@ -118,6 +122,7 @@ export default {
118122
{ titleKey: "wizardStep.steps.selectTarget" },
119123
{ titleKey: "wizardStep.steps.selectVersion" },
120124
{ titleKey: "wizardStep.steps.selectMirror" },
125+
{ titleKey: "wizardStep.steps.selectFeatures" },
121126
{ titleKey: "wizardStep.steps.selectPath" },
122127
{ titleKey: "wizardStep.steps.installationProgress" },
123128
{ titleKey: "wizardStep.steps.installationComplete" }
@@ -126,9 +131,9 @@ export default {
126131
handleStepClick(stepNumber) {
127132
// Only allow navigation if:
128133
// 1. The step has been completed (currentStep > stepNumber)
129-
// 2. We're not in the installation or completion steps (currentStep < 7)
134+
// 2. We're not in the installation or completion steps (currentStep < 8)
130135
// 3. We're not trying to navigate to a step after our current position
131-
if (this.currentStep > stepNumber && this.currentStep < 7) {
136+
if (this.currentStep > stepNumber && this.currentStep < 8) {
132137
this.store.goToStep(stepNumber);
133138
}
134139
},
@@ -312,4 +317,3 @@ export default {
312317
transition: all 0.3s ease;
313318
}
314319
</style>
315-

0 commit comments

Comments
 (0)