Skip to content

Commit 5be4001

Browse files
committed
Added the features selection to the GUI wizard
1 parent 1813339 commit 5be4001

File tree

6 files changed

+589
-13
lines changed

6 files changed

+589
-13
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 & 7 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">
@@ -40,9 +40,10 @@
4040
<TargetSelect :nextstep="nextStep" v-if="currentStep === 3" data-id="target-select" />
4141
<VersionSelect :nextstep="nextStep" v-if="currentStep === 4" data-id="version-select" />
4242
<MirrorSelect :nextstep="nextStep" v-if="currentStep === 5" data-id="mirror-select" />
43-
<InstallationPathSelect :nextstep="nextStep" v-if="currentStep === 6" data-id="installation-path-select" />
44-
<InstalationProgress :nextstep="nextStep" v-if="currentStep === 7" data-id="installation-progress" />
45-
<Complete v-if="currentStep === 8" data-id="complete" />
43+
<FeaturesSelect :nextstep=nextStep v-if="currentStep === 6" data-id="features-select" />
44+
<InstallationPathSelect :nextstep=nextStep v-if="currentStep === 7" data-id="installation-path-select" />
45+
<InstalationProgress :nextstep=nextStep v-if="currentStep === 8" data-id="installation-progress" />
46+
<Complete v-if="currentStep === 9" data-id="complete" />
4647
</div>
4748
</transition>
4849
</div>
@@ -61,6 +62,7 @@ import PythonSanitycheck from './wizard_steps/PythonSanitycheck.vue';
6162
import TargetSelect from './wizard_steps/TargetSelect.vue';
6263
import VersionSelect from './wizard_steps/VersionSelect.vue';
6364
import MirrorSelect from './wizard_steps/MirrorSelect.vue';
65+
import FeaturesSelect from './wizard_steps/FeaturesSelect.vue';
6466
import InstallationPathSelect from './wizard_steps/InstallationPathSelect.vue';
6567
import InstalationProgress from './wizard_steps/InstalationProgress.vue';
6668
import Complete from './wizard_steps/Complete.vue';
@@ -77,6 +79,7 @@ export default {
7779
TargetSelect,
7880
VersionSelect,
7981
MirrorSelect,
82+
FeaturesSelect,
8083
InstallationPathSelect,
8184
InstalationProgress,
8285
},
@@ -92,6 +95,7 @@ export default {
9295
{ titleKey: "wizardStep.steps.selectTarget" },
9396
{ titleKey: "wizardStep.steps.selectVersion" },
9497
{ titleKey: "wizardStep.steps.selectMirror" },
98+
{ titleKey: "wizardStep.steps.selectFeatures" },
9599
{ titleKey: "wizardStep.steps.selectPath" },
96100
{ titleKey: "wizardStep.steps.installationProgress" },
97101
{ titleKey: "wizardStep.steps.installationComplete" }
@@ -128,6 +132,7 @@ export default {
128132
{ titleKey: "wizardStep.steps.selectTarget" },
129133
{ titleKey: "wizardStep.steps.selectVersion" },
130134
{ titleKey: "wizardStep.steps.selectMirror" },
135+
{ titleKey: "wizardStep.steps.selectFeatures" },
131136
{ titleKey: "wizardStep.steps.selectPath" },
132137
{ titleKey: "wizardStep.steps.installationProgress" },
133138
{ titleKey: "wizardStep.steps.installationComplete" }
@@ -136,9 +141,9 @@ export default {
136141
handleStepClick(stepNumber) {
137142
// Only allow navigation if:
138143
// 1. The step has been completed (currentStep > stepNumber)
139-
// 2. We're not in the installation or completion steps (currentStep < 7)
144+
// 2. We're not in the installation or completion steps (currentStep < 8)
140145
// 3. We're not trying to navigate to a step after our current position
141-
if (this.currentStep > stepNumber && this.currentStep < 7) {
146+
if (this.currentStep > stepNumber && this.currentStep < 8) {
142147
this.store.goToStep(stepNumber);
143148
}
144149
},

0 commit comments

Comments
 (0)