fix fw tool source (#1690)

This commit is contained in:
lucas lelievre
2026-01-05 16:20:45 +01:00
committed by GitHub
parent a3bcc61892
commit 686499f8dd
2 changed files with 39 additions and 27 deletions

View File

@@ -1399,6 +1399,9 @@ firmware_tool-select_source-firmware = Firmware Source
firmware_tool-select_source-version = Firmware Version
firmware_tool-select_source-official = Official
firmware_tool-select_source-dev = Dev
firmware_tool-select_source-not_selected = No source selected
firmware_tool-select_source-no_boards = No available boards for this source
firmware_tool-select_source-no_versions = No available versions for this source
firmware_tool-board_defaults = Configure your board
firmware_tool-board_defaults-description = Set the pins or settings relative to your hardware

View File

@@ -101,13 +101,10 @@ export function SelectSourceSetep({
curr.push({
name: source.source,
official: source.official,
disabled:
!partialBoard?.board ||
!source.availableBoards.includes(partialBoard.board),
});
return curr;
},
[] as { name: string; official: boolean; disabled: boolean }[]
[] as { name: string; official: boolean }[]
)
.sort((a, b) => {
if (a.official !== b.official) return a.official ? -1 : 1;
@@ -115,6 +112,7 @@ export function SelectSourceSetep({
}),
possibleBoards: sources
?.reduce((curr, source) => {
if (source.source !== partialBoard?.source) return curr;
const unknownBoards = source.availableBoards.filter(
(b) => !curr.includes(b)
);
@@ -136,6 +134,7 @@ export function SelectSourceSetep({
possibleVersions: sources
?.reduce(
(curr, source) => {
if (source.source !== partialBoard?.source) return curr;
if (!curr.find(({ name }) => source.version === name))
curr.push({
disabled:
@@ -193,6 +192,25 @@ export function SelectSourceSetep({
{!isFetching && !isError && (
<div className="flex flex-col gap-2">
<div className="grid md:grid-cols-3 gap-4">
<div className="flex flex-col gap-1 w-full">
<Localized id="firmware_tool-select_source-firmware">
<Typography variant="section-title" />
</Localized>
<div className="flex flex-col gap-4 md:max-h-[305px] overflow-y-auto bg-background-80 rounded-lg p-4">
{sourcesGroupped?.map(({ name, official }) => (
<Selector
active={partialBoard?.source === name}
key={`${name}`}
tag={official ? 'official' : undefined}
onClick={() => {
if (partialBoard?.source !== name)
setPartialBoard({ source: name });
}}
text={formatSource(name, official)}
/>
))}
</div>
</div>
<div className="flex flex-col gap-1 w-full">
<Localized id="firmware_tool-select_source-board_type">
<Typography variant="section-title" />
@@ -203,7 +221,7 @@ export function SelectSourceSetep({
active={partialBoard?.board === board}
key={`${board}`}
onClick={() => {
setPartialBoard({ board });
setPartialBoard((curr) => ({ ...curr, board }));
}}
tag={
board.startsWith('BOARD_SLIMEVR')
@@ -219,30 +237,15 @@ export function SelectSourceSetep({
}
/>
))}
{partialBoard?.source && possibleBoards?.length === 0 && (
<Typography id="firmware_tool-select_source-no_boards" />
)}
{!partialBoard?.source && (
<Typography id="firmware_tool-select_source-not_selected" />
)}
</div>
</div>
<div className="flex flex-col gap-1 w-full">
<Localized id="firmware_tool-select_source-firmware">
<Typography variant="section-title" />
</Localized>
<div className="flex flex-col gap-4 md:max-h-[305px] overflow-y-auto bg-background-80 rounded-lg p-4">
{sourcesGroupped?.map(({ name, official, disabled }) => (
<Selector
active={partialBoard?.source === name}
disabled={disabled}
key={`${name}`}
tag={official ? 'official' : undefined}
onClick={() => {
setPartialBoard((curr) => ({
...curr,
source: name,
}));
}}
text={formatSource(name, official)}
/>
))}
</div>
</div>
<div className="flex flex-col gap-1 w-full">
<Localized id="firmware_tool-select_source-version">
<Typography variant="section-title" />
@@ -268,6 +271,12 @@ export function SelectSourceSetep({
text={name}
/>
))}
{partialBoard?.source && possibleVersions?.length === 0 && (
<Typography id="firmware_tool-select_source-no_versions" />
)}
{!partialBoard?.source && (
<Typography id="firmware_tool-select_source-not_selected" />
)}
</div>
</div>
</div>