Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show only valid esp idf setups #908

Merged
merged 5 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/setup/existingIdfSetups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,32 @@ import { ESP } from "../config";
import { getEspIdfFromCMake } from "../utils";
import { IdfSetup } from "../views/setup/types";
import { getIdfMd5sum, loadEspIdfJson } from "./espIdfJson";
import { checkIdfSetup } from "./setupValidation/espIdfSetup";

export function getPreviousIdfSetups() {
export async function getPreviousIdfSetups() {
const setupKeys = ESP.GlobalConfiguration.store.getIdfSetupKeys();
const idfSetups: IdfSetup[] = [];
for (let idfSetupKey of setupKeys) {
let idfSetup = ESP.GlobalConfiguration.store.get<IdfSetup>(
idfSetupKey,
undefined
);
idfSetup.isValid = await checkIdfSetup(idfSetup);
idfSetup.version = await getEspIdfFromCMake(idfSetup.idfPath);
if (idfSetup) {
idfSetups.push(idfSetup);
}
}
return idfSetups;
}

export async function clearPreviousIdfSetups() {
const setupKeys = ESP.GlobalConfiguration.store.getIdfSetupKeys();
for (let idfSetupKey of setupKeys) {
ESP.GlobalConfiguration.store.clear(idfSetupKey);
}
}

export async function createIdfSetup(
idfPath: string,
toolsPath: string,
Expand All @@ -51,7 +61,9 @@ export async function createIdfSetup(
toolsPath,
python: pythonPath,
version: idfVersion,
isValid: false
};
newIdfSetup.isValid = await checkIdfSetup(newIdfSetup);
addIdfSetup(newIdfSetup);
}

Expand All @@ -73,14 +85,17 @@ export async function loadIdfSetupsFromEspIdfJson(toolsPath: string) {
) {
let idfSetups: IdfSetup[] = [];
for (let idfInstalledKey of Object.keys(espIdfJson.idfInstalled)) {
idfSetups.push({
let setupConf: IdfSetup = {
id: idfInstalledKey,
idfPath: espIdfJson.idfInstalled[idfInstalledKey].path,
gitPath: espIdfJson.gitPath,
python: espIdfJson.idfInstalled[idfInstalledKey].python,
version: espIdfJson.idfInstalled[idfInstalledKey].version,
toolsPath: toolsPath,
});
isValid: false
} as IdfSetup;
setupConf.isValid = await checkIdfSetup(setupConf);
idfSetups.push(setupConf);
}
return idfSetups;
}
Expand Down
2 changes: 1 addition & 1 deletion src/setup/setupInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export async function getSetupInitialValues(
const espIdfTagsList = await getEspIdfTags();
progress.report({ increment: 10, message: "Getting Python versions..." });
const pythonVersions = await getPythonList(extensionPath);
const idfSetups = getPreviousIdfSetups();
const idfSetups = await getPreviousIdfSetups();
const setupInitArgs = {
espIdfVersionsList,
espIdfTagsList,
Expand Down
48 changes: 32 additions & 16 deletions src/views/setup/ExistingSetup.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
<template>
<div class="centerize notification">
<div
class="notification install-choice"
v-for="(prevSetup, i) in idfSetups"
:key="prevSetup.id"
:data-config-id="prevSetup.idfPath"
@click="useIdfSetup(i)"
>
<label :for="prevSetup.id" class="subtitle">
{{ prevSetup.idfPath }}</label
<div class="notification">
<div class="notification install-choice" @click="goTo('/autoinstall', setupMode.express)">
<label class="subtitle"> Search ESP-IDF in system...</label>
</div>
<div v-for="(prevSetup, i) in idfSetups" :key="prevSetup.id" class="my-1">
<div
class="notification install-choice"
v-show="prevSetup.isValid"
:data-config-id="prevSetup.idfPath"
@click="useIdfSetup(i)"
>
<p>IDF Version {{ prevSetup.version }}</p>
<p>Python: {{ prevSetup.python }}</p>
<p>IDF Tools Path: {{ prevSetup.toolsPath }}</p>
<p>Git path: {{ prevSetup.gitPath }}</p>
<label :for="prevSetup.id" class="subtitle">
{{ prevSetup.idfPath }}</label
>
<p>IDF Version {{ prevSetup.version }}</p>
brianignacio5 marked this conversation as resolved.
Show resolved Hide resolved
<p>Python: {{ prevSetup.python }}</p>
brianignacio5 marked this conversation as resolved.
Show resolved Hide resolved
<p>IDF Tools Path: {{ prevSetup.toolsPath }}</p>
<p>Git path: {{ prevSetup.gitPath }}</p>
brianignacio5 marked this conversation as resolved.
Show resolved Hide resolved
<p>Is valid {{ prevSetup.isValid }}</p>
brianignacio5 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
</div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { Action, State } from "vuex-class";
import { IdfSetup } from "./types";
import { Action, Mutation, State } from "vuex-class";
import { IdfSetup, SetupMode } from "./types";
import { router } from "./main";

@Component
export default class existingSetup extends Vue {
@State("idfSetups") private storeIdfSetups: IdfSetup[];
@Action useIdfSetup: (id: number) => void;
@Mutation setSetupMode: (mode: SetupMode) => void;

get idfSetups() {
return this.storeIdfSetups;
}

get setupMode() {
return SetupMode;
}

goTo(route: string, setupMode: SetupMode) {
router.push(route);
this.setSetupMode(setupMode);
}
}
</script>
2 changes: 1 addition & 1 deletion src/views/setup/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<label for="existing" class="subtitle" data-config-id="existing-setup"
>USE EXISTING SETUP</label
>
<p>Select existing ESP-IDF setup saved in the extension.</p>
<p>Select existing ESP-IDF setup saved in the extension or find ESP-IDF in your system.</p>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/views/setup/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface IdfSetup {
toolsPath: string;
idfPath: string;
gitPath: string;
isValid: boolean;
}

export enum IdfMirror {
Expand Down