Skip to content

Commit 4b0be00

Browse files
Merge branch 'main' into include-hardwareId-in-auto-selection
2 parents 08203d8 + cf6f83c commit 4b0be00

File tree

87 files changed

+3184
-987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+3184
-987
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ on:
2929

3030
env:
3131
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
32-
GO_VERSION: "1.17"
32+
GO_VERSION: "1.19"
3333
JOB_TRANSFER_ARTIFACT: build-artifacts
3434
CHANGELOG_ARTIFACTS: changelog
3535

.github/workflows/check-i18n-task.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Check Internationalization
22

33
env:
44
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
5-
GO_VERSION: "1.17"
5+
GO_VERSION: "1.19"
66

77
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
88
on:

.github/workflows/i18n-nightly-push.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: i18n-nightly-push
22

33
env:
44
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
5-
GO_VERSION: "1.17"
5+
GO_VERSION: "1.19"
66

77
on:
88
schedule:

.github/workflows/i18n-weekly-pull.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: i18n-weekly-pull
22

33
env:
44
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
5-
GO_VERSION: "1.17"
5+
GO_VERSION: "1.19"
66

77
on:
88
schedule:

.github/workflows/themes-weekly-pull.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
11-
GO_VERSION: "1.17"
11+
GO_VERSION: "1.19"
1212
NODE_VERSION: 16.x
1313

1414
jobs:

.vscode/launch.json

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
".",
1515
"--log-level=debug",
1616
"--hostname=localhost",
17-
"--no-cluster",
1817
"--app-project-path=${workspaceRoot}/electron-app",
1918
"--remote-debugging-port=9222",
2019
"--no-app-auto-install",
@@ -52,7 +51,6 @@
5251
".",
5352
"--log-level=debug",
5453
"--hostname=localhost",
55-
"--no-cluster",
5654
"--app-project-path=${workspaceRoot}/electron-app",
5755
"--remote-debugging-port=9222",
5856
"--no-app-auto-install",

arduino-ide-extension/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@
6767
"auth0-js": "^9.14.0",
6868
"btoa": "^1.2.1",
6969
"classnames": "^2.3.1",
70+
"cross-fetch": "^3.1.5",
7071
"dateformat": "^3.0.3",
7172
"deepmerge": "2.0.1",
7273
"electron-updater": "^4.6.5",
7374
"fast-json-stable-stringify": "^2.1.0",
7475
"fast-safe-stringify": "^2.1.1",
76+
"filename-reserved-regex": "^2.0.0",
7577
"glob": "^7.1.6",
7678
"google-protobuf": "^3.20.1",
7779
"hash.js": "^1.1.7",

arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import {
1010
MenuContribution,
1111
MenuModelRegistry,
1212
} from '@theia/core';
13-
import {
14-
FrontendApplication,
15-
FrontendApplicationContribution,
16-
} from '@theia/core/lib/browser';
13+
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
1714
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
1815
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
1916
import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
@@ -77,7 +74,7 @@ export class ArduinoFrontendContribution
7774
}
7875
}
7976

80-
onStart(app: FrontendApplication): void {
77+
onStart(): void {
8178
this.electronWindowPreferences.onPreferenceChanged((event) => {
8279
if (event.newValue !== event.oldValue) {
8380
switch (event.preferenceName) {
@@ -98,8 +95,6 @@ export class ArduinoFrontendContribution
9895
webContents.setZoomLevel(zoomLevel);
9996
})
10097
);
101-
// Removes the _Settings_ (cog) icon from the left sidebar
102-
app.shell.leftPanelHandler.removeBottomMenu('settings-menu');
10398
}
10499

105100
registerToolbarItems(registry: TabBarToolbarRegistry): void {

arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
SketchesService,
2424
SketchesServicePath,
2525
} from '../common/protocol/sketches-service';
26-
import { SketchesServiceClientImpl } from '../common/protocol/sketches-service-client-impl';
26+
import { SketchesServiceClientImpl } from './sketches-service-client-impl';
2727
import { CoreService, CoreServicePath } from '../common/protocol/core-service';
2828
import { BoardsListWidget } from './boards/boards-list-widget';
2929
import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-frontend-contribution';
@@ -344,6 +344,12 @@ import { DebugViewModel } from '@theia/debug/lib/browser/view/debug-view-model';
344344
import { DebugSessionWidget } from '@theia/debug/lib/browser/view/debug-session-widget';
345345
import { DebugConfigurationWidget } from '@theia/debug/lib/browser/view/debug-configuration-widget';
346346
import { ConfigServiceClient } from './config/config-service-client';
347+
import { ValidateSketch } from './contributions/validate-sketch';
348+
import { RenameCloudSketch } from './contributions/rename-cloud-sketch';
349+
import { CreateFeatures } from './create/create-features';
350+
import { Account } from './contributions/account';
351+
import { SidebarBottomMenuWidget } from './theia/core/sidebar-bottom-menu-widget';
352+
import { SidebarBottomMenuWidget as TheiaSidebarBottomMenuWidget } from '@theia/core/lib/browser/shell/sidebar-bottom-menu-widget';
347353

348354
export default new ContainerModule((bind, unbind, isBound, rebind) => {
349355
// Commands and toolbar items
@@ -729,6 +735,9 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
729735
Contribution.configure(bind, UpdateIndexes);
730736
Contribution.configure(bind, InterfaceScale);
731737
Contribution.configure(bind, NewCloudSketch);
738+
Contribution.configure(bind, ValidateSketch);
739+
Contribution.configure(bind, RenameCloudSketch);
740+
Contribution.configure(bind, Account);
732741

733742
bindContributionProvider(bind, StartupTaskProvider);
734743
bind(StartupTaskProvider).toService(BoardsServiceProvider); // to reuse the boards config in another window
@@ -889,6 +898,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
889898
);
890899
bind(CreateApi).toSelf().inSingletonScope();
891900
bind(SketchCache).toSelf().inSingletonScope();
901+
bind(CreateFeatures).toSelf().inSingletonScope();
902+
bind(FrontendApplicationContribution).toService(CreateFeatures);
892903

893904
bind(ShareSketchDialog).toSelf().inSingletonScope();
894905
bind(AuthenticationClientService).toSelf().inSingletonScope();
@@ -1007,4 +1018,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
10071018
},
10081019
}))
10091020
.inSingletonScope();
1021+
1022+
bind(SidebarBottomMenuWidget).toSelf();
1023+
rebind(TheiaSidebarBottomMenuWidget).toService(SidebarBottomMenuWidget);
10101024
});

arduino-ide-extension/src/browser/auth/authentication-client-service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ export class AuthenticationClientService
8383
registerCommands(registry: CommandRegistry): void {
8484
registry.registerCommand(CloudUserCommands.LOGIN, {
8585
execute: () => this.service.login(),
86+
isEnabled: () => !this._session,
87+
isVisible: () => !this._session,
8688
});
8789
registry.registerCommand(CloudUserCommands.LOGOUT, {
8890
execute: () => this.service.logout(),
91+
isEnabled: () => !!this._session,
92+
isVisible: () => !!this._session,
8993
});
9094
}
9195

arduino-ide-extension/src/browser/auth/cloud-user-commands.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { Command } from '@theia/core/lib/common/command';
22

3+
export const LEARN_MORE_URL =
4+
'https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-cloud-sketch-sync';
5+
36
export namespace CloudUserCommands {
47
export const LOGIN = Command.toLocalizedCommand(
58
{
@@ -16,9 +19,4 @@ export namespace CloudUserCommands {
1619
},
1720
'arduino/cloud/signOut'
1821
);
19-
20-
export const OPEN_PROFILE_CONTEXT_MENU: Command = {
21-
id: 'arduino-cloud-sketchbook--open-profile-menu',
22-
label: 'Contextual menu',
23-
};
2422
}

arduino-ide-extension/src/browser/config/config-service-client.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ConfigServiceClient implements FrontendApplicationContribution {
3838
@postConstruct()
3939
protected init(): void {
4040
this.appStateService.reachedState('ready').then(async () => {
41-
const config = await this.fetchConfig();
41+
const config = await this.delegate.getConfiguration();
4242
this.use(config);
4343
});
4444
}
@@ -59,10 +59,6 @@ export class ConfigServiceClient implements FrontendApplicationContribution {
5959
return this.didChangeDataDirUriEmitter.event;
6060
}
6161

62-
async fetchConfig(): Promise<ConfigState> {
63-
return this.delegate.getConfiguration();
64-
}
65-
6662
/**
6763
* CLI config related error messages if any.
6864
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
2+
import { SidebarMenu } from '@theia/core/lib/browser/shell/sidebar-menu-widget';
3+
import { WindowService } from '@theia/core/lib/browser/window/window-service';
4+
import { DisposableCollection } from '@theia/core/lib/common/disposable';
5+
import { MenuPath } from '@theia/core/lib/common/menu';
6+
import { nls } from '@theia/core/lib/common/nls';
7+
import { inject, injectable } from '@theia/core/shared/inversify';
8+
import { CloudUserCommands, LEARN_MORE_URL } from '../auth/cloud-user-commands';
9+
import { CreateFeatures } from '../create/create-features';
10+
import { ArduinoMenus } from '../menu/arduino-menus';
11+
import {
12+
Command,
13+
CommandRegistry,
14+
Contribution,
15+
MenuModelRegistry,
16+
} from './contribution';
17+
18+
export const accountMenu: SidebarMenu = {
19+
id: 'arduino-accounts-menu',
20+
iconClass: 'codicon codicon-account',
21+
title: nls.localize('arduino/account/menuTitle', 'Arduino Cloud'),
22+
menuPath: ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT,
23+
order: 0,
24+
};
25+
26+
@injectable()
27+
export class Account extends Contribution {
28+
@inject(WindowService)
29+
private readonly windowService: WindowService;
30+
@inject(CreateFeatures)
31+
private readonly createFeatures: CreateFeatures;
32+
33+
private readonly toDispose = new DisposableCollection();
34+
private app: FrontendApplication;
35+
36+
override onStart(app: FrontendApplication): void {
37+
this.app = app;
38+
this.updateSidebarCommand();
39+
this.toDispose.push(
40+
this.createFeatures.onDidChangeEnabled((enabled) =>
41+
this.updateSidebarCommand(enabled)
42+
)
43+
);
44+
}
45+
46+
onStop(): void {
47+
this.toDispose.dispose();
48+
}
49+
50+
override registerCommands(registry: CommandRegistry): void {
51+
const openExternal = (url: string) =>
52+
this.windowService.openNewWindow(url, { external: true });
53+
registry.registerCommand(Account.Commands.LEARN_MORE, {
54+
execute: () => openExternal(LEARN_MORE_URL),
55+
isEnabled: () => !Boolean(this.createFeatures.session),
56+
});
57+
registry.registerCommand(Account.Commands.GO_TO_PROFILE, {
58+
execute: () => openExternal('https://id.arduino.cc/'),
59+
isEnabled: () => Boolean(this.createFeatures.session),
60+
});
61+
registry.registerCommand(Account.Commands.GO_TO_CLOUD_EDITOR, {
62+
execute: () => openExternal('https://create.arduino.cc/editor'),
63+
isEnabled: () => Boolean(this.createFeatures.session),
64+
});
65+
registry.registerCommand(Account.Commands.GO_TO_IOT_CLOUD, {
66+
execute: () => openExternal('https://create.arduino.cc/iot/'),
67+
isEnabled: () => Boolean(this.createFeatures.session),
68+
});
69+
}
70+
71+
override registerMenus(registry: MenuModelRegistry): void {
72+
const register = (
73+
menuPath: MenuPath,
74+
...commands: (Command | [command: Command, menuLabel: string])[]
75+
) =>
76+
commands.forEach((command, index) => {
77+
const commandId = Array.isArray(command) ? command[0].id : command.id;
78+
const label = Array.isArray(command) ? command[1] : command.label;
79+
registry.registerMenuAction(menuPath, {
80+
label,
81+
commandId,
82+
order: String(index),
83+
});
84+
});
85+
86+
register(ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__SIGN_IN_GROUP, [
87+
CloudUserCommands.LOGIN,
88+
nls.localize('arduino/cloud/signInToCloud', 'Sign in to Arduino Cloud'),
89+
]);
90+
register(ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__LEARN_MORE_GROUP, [
91+
Account.Commands.LEARN_MORE,
92+
nls.localize('arduino/cloud/learnMore', 'Learn more'),
93+
]);
94+
register(
95+
ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__GO_TO_GROUP,
96+
[
97+
Account.Commands.GO_TO_PROFILE,
98+
nls.localize('arduino/account/goToProfile', 'Go to Profile'),
99+
],
100+
[
101+
Account.Commands.GO_TO_CLOUD_EDITOR,
102+
nls.localize('arduino/account/goToCloudEditor', 'Go to Cloud Editor'),
103+
],
104+
[
105+
Account.Commands.GO_TO_IOT_CLOUD,
106+
nls.localize('arduino/account/goToIoTCloud', 'Go to IoT Cloud'),
107+
]
108+
);
109+
register(
110+
ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__SIGN_OUT_GROUP,
111+
CloudUserCommands.LOGOUT
112+
);
113+
}
114+
115+
private updateSidebarCommand(
116+
visible: boolean = this.preferences['arduino.cloud.enabled']
117+
): void {
118+
if (!this.app) {
119+
return;
120+
}
121+
const handler = this.app.shell.leftPanelHandler;
122+
if (visible) {
123+
handler.addBottomMenu(accountMenu);
124+
} else {
125+
handler.removeBottomMenu(accountMenu.id);
126+
}
127+
}
128+
}
129+
130+
export namespace Account {
131+
export namespace Commands {
132+
export const GO_TO_PROFILE: Command = {
133+
id: 'arduino-go-to-profile',
134+
};
135+
export const GO_TO_CLOUD_EDITOR: Command = {
136+
id: 'arduino-go-to-cloud-editor',
137+
};
138+
export const GO_TO_IOT_CLOUD: Command = {
139+
id: 'arduino-go-to-iot-cloud',
140+
};
141+
export const LEARN_MORE: Command = {
142+
id: 'arduino-learn-more',
143+
};
144+
}
145+
}

arduino-ide-extension/src/browser/contributions/add-file.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from './contribution';
1212
import { FileDialogService } from '@theia/filesystem/lib/browser';
1313
import { nls } from '@theia/core/lib/common';
14-
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
14+
import { CurrentSketch } from '../sketches-service-client-impl';
1515

1616
@injectable()
1717
export class AddFile extends SketchContribution {

arduino-ide-extension/src/browser/contributions/archive-sketch.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
MenuModelRegistry,
1010
} from './contribution';
1111
import { nls } from '@theia/core/lib/common';
12-
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
12+
import { CurrentSketch } from '../sketches-service-client-impl';
1313

1414
@injectable()
1515
export class ArchiveSketch extends SketchContribution {
@@ -56,7 +56,7 @@ export class ArchiveSketch extends SketchContribution {
5656
if (!destinationUri) {
5757
return;
5858
}
59-
await this.sketchService.archive(sketch, destinationUri.toString());
59+
await this.sketchesService.archive(sketch, destinationUri.toString());
6060
this.messageService.info(
6161
nls.localize(
6262
'arduino/sketch/createdArchive',

arduino-ide-extension/src/browser/contributions/close.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
URI,
2121
} from './contribution';
2222
import { Dialog } from '@theia/core/lib/browser/dialogs';
23-
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
23+
import { CurrentSketch } from '../sketches-service-client-impl';
2424
import { SaveAsSketch } from './save-as-sketch';
2525

2626
/**
@@ -185,7 +185,7 @@ export class Close extends SketchContribution {
185185
private async isCurrentSketchTemp(): Promise<false | Sketch> {
186186
const currentSketch = await this.sketchServiceClient.currentSketch();
187187
if (CurrentSketch.isValid(currentSketch)) {
188-
const isTemp = await this.sketchService.isTemp(currentSketch);
188+
const isTemp = await this.sketchesService.isTemp(currentSketch);
189189
if (isTemp) {
190190
return currentSketch;
191191
}

0 commit comments

Comments
 (0)