mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-12 11:49:27 +00:00
ATL-938: Added menu group categories.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
@@ -5,6 +5,25 @@ import { Installable } from './installable';
|
||||
import { ArduinoComponent } from './arduino-component';
|
||||
|
||||
export type AvailablePorts = Record<string, [Port, Array<Board>]>;
|
||||
export namespace AvailablePorts {
|
||||
export function groupByProtocol(availablePorts: AvailablePorts): { serial: AvailablePorts, network: AvailablePorts, unknown: AvailablePorts } {
|
||||
const serial: AvailablePorts = {};
|
||||
const network: AvailablePorts = {};
|
||||
const unknown: AvailablePorts = {};
|
||||
for (const key of Object.keys(availablePorts)) {
|
||||
const [port, boards] = availablePorts[key];
|
||||
const { protocol } = port;
|
||||
if (protocol === 'serial') {
|
||||
serial[key] = [port, boards];
|
||||
} else if (protocol === 'network') {
|
||||
network[key] = [port, boards];
|
||||
} else {
|
||||
unknown[key] = [port, boards];
|
||||
}
|
||||
}
|
||||
return { serial, network, unknown };
|
||||
}
|
||||
}
|
||||
|
||||
export interface AttachedBoardsChangeEvent {
|
||||
readonly oldState: Readonly<{ boards: Board[], ports: Port[] }>;
|
||||
|
||||
Reference in New Issue
Block a user