mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-10-26 11:38:32 +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[] }>;
|
||||
|
||||
@@ -69,4 +69,17 @@ export namespace LibraryPackage {
|
||||
return left.name === right.name && left.author === right.author;
|
||||
}
|
||||
|
||||
export function groupByLocation(packages: LibraryPackage[]): { user: LibraryPackage[], rest: LibraryPackage[] } {
|
||||
const user: LibraryPackage[] = [];
|
||||
const rest: LibraryPackage[] = [];
|
||||
for (const pkg of packages) {
|
||||
if (pkg.location === LibraryLocation.USER) {
|
||||
user.push(pkg);
|
||||
} else {
|
||||
rest.push(pkg);
|
||||
}
|
||||
}
|
||||
return { user, rest };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user