Add dialog to insert user fields for board that require them to upload (#550)

* Rebuild gRPC protocol interfaces

* Implement methods to get user fields for board/port combination

* Implement dialog to input board user fields

* Add configure and upload step when uploading to board requiring user fields

* Disable Sketch > Configure and Upload menu if board doesn't support user fields

* Fix serial upload not working with all boards

* Update i18n source file

* fix user fields UI

* regenerate cli protocol

* fix localisation

* check if user fields are empty

Co-authored-by: Alberto Iannaccone <a.iannaccone@arduino.cc>
This commit is contained in:
Silvano Cerza
2021-11-25 18:22:51 +01:00
committed by GitHub
parent 74bfdc4c56
commit a090dfe99c
19 changed files with 568 additions and 679 deletions

View File

@@ -16,6 +16,7 @@ import {
NotificationServiceServer,
AvailablePorts,
BoardWithPackage,
BoardUserField,
} from '../common/protocol';
import {
PlatformInstallRequest,
@@ -36,6 +37,8 @@ import {
import {
ListProgrammersAvailableForUploadRequest,
ListProgrammersAvailableForUploadResponse,
SupportedUserFieldsRequest,
SupportedUserFieldsResponse,
} from './cli-protocol/cc/arduino/cli/commands/v1/upload_pb';
import { InstallWithProgress } from './grpc-installable';
@@ -244,6 +247,35 @@ export class BoardsServiceImpl
return boards;
}
async getBoardUserFields(options: { fqbn: string, protocol: string }): Promise<BoardUserField[]> {
await this.coreClientProvider.initialized;
const coreClient = await this.coreClient();
const { client, instance } = coreClient;
const supportedUserFieldsReq = new SupportedUserFieldsRequest();
supportedUserFieldsReq.setInstance(instance);
supportedUserFieldsReq.setFqbn(options.fqbn);
supportedUserFieldsReq.setProtocol(options.protocol);
const supportedUserFieldsResp = await new Promise<SupportedUserFieldsResponse>(
(resolve, reject) => {
client.supportedUserFields(supportedUserFieldsReq, (err, resp) => {
(!!err ? reject : resolve)(!!err ? err : resp)
})
}
);
return supportedUserFieldsResp.getUserFieldsList().map(e => {
return {
toolId: e.getToolId(),
name: e.getName(),
label: e.getLabel(),
secret: e.getSecret(),
value: "",
};
});
}
async search(options: { query?: string }): Promise<BoardsPackage[]> {
await this.coreClientProvider.initialized;
const coreClient = await this.coreClient();