Skip to content

Commit c3adde5

Browse files
feat: add shared space support (#2486)
1 parent 2e78e96 commit c3adde5

File tree

6 files changed

+29
-6
lines changed

6 files changed

+29
-6
lines changed

.github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ jobs:
275275
- build-type-determination
276276
- select-targets
277277
env:
278+
# https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
279+
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
278280
# Location of artifacts generated by build.
279281
BUILD_ARTIFACTS_PATH: electron-app/dist/build-artifacts
280282
# to skip passing signing credentials to electron-builder

arduino-ide-extension/src/browser/arduino-preferences.ts

+9
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ const properties: ArduinoPreferenceSchemaProperties = {
228228
),
229229
default: 'https://api2.arduino.cc/create',
230230
},
231+
'arduino.cloud.sharedSpaceID': {
232+
type: 'string',
233+
description: nls.localize(
234+
'arduino/preferences/cloud.sharedSpaceId',
235+
'The ID of the Arduino Cloud shared space to load the sketchbook from. If empty, your private space is selected.'
236+
),
237+
default: '',
238+
},
231239
'arduino.auth.clientID': {
232240
type: 'string',
233241
description: nls.localize(
@@ -329,6 +337,7 @@ export interface ArduinoConfiguration {
329337
'arduino.cloud.push.warn': boolean;
330338
'arduino.cloud.pushpublic.warn': boolean;
331339
'arduino.cloud.sketchSyncEndpoint': string;
340+
'arduino.cloud.sharedSpaceID': string;
332341
'arduino.auth.clientID': string;
333342
'arduino.auth.domain': string;
334343
'arduino.auth.audience': string;

arduino-ide-extension/src/browser/create/create-api.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,19 @@ export class CreateApi {
509509

510510
private async headers(): Promise<Record<string, string>> {
511511
const token = await this.token();
512-
return {
512+
const headers: Record<string, string> = {
513513
'content-type': 'application/json',
514514
accept: 'application/json',
515515
authorization: `Bearer ${token}`,
516516
};
517+
518+
const sharedSpaceID =
519+
this.arduinoPreferences['arduino.cloud.sharedSpaceID'];
520+
if (sharedSpaceID) {
521+
headers['x-organization'] = sharedSpaceID;
522+
}
523+
524+
return headers;
517525
}
518526

519527
private domain(apiVersion = 'v2'): string {

arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-model.ts

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export class SketchbookTreeModel extends FileTreeModel {
127127
if (preferenceName === 'arduino.sketchbook.showAllFiles') {
128128
this.updateRoot();
129129
}
130+
if (preferenceName === 'arduino.cloud.sharedSpaceID') {
131+
this.updateRoot();
132+
}
130133
})
131134
);
132135

arduino-ide-extension/src/test/node/boards-service-impl.slow-test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ describe('boards-service-impl', () => {
113113
expect(result.length).greaterThan(1);
114114
const lastIndex = result.length - 1;
115115
const last = result[lastIndex];
116-
expect(last.id).to.be.equal('arduino:mbed');
116+
expect(last.id).to.be.equal('Microsoft:win10');
117117
expect(last.deprecated).to.be.true;
118-
const windowsIoTCoreIndex = result.findIndex(
119-
(platform) => platform.id === 'Microsoft:win10'
118+
const arduinoMbedCoreIndex = result.findIndex(
119+
(platform) => platform.id === 'arduino:mbed'
120120
);
121-
expect(windowsIoTCoreIndex).to.be.greaterThanOrEqual(0);
122-
expect(windowsIoTCoreIndex).to.be.lessThan(lastIndex);
121+
expect(arduinoMbedCoreIndex).to.be.greaterThanOrEqual(0);
122+
expect(arduinoMbedCoreIndex).to.be.lessThan(lastIndex);
123123
const first = result[0];
124124
expect(typeof first.deprecated).to.be.equal('boolean');
125125
expect(first.deprecated).to.be.false;

i18n/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@
368368
"cloud.pull.warn": "True if users should be warned before pulling a cloud sketch. Defaults to true.",
369369
"cloud.push.warn": "True if users should be warned before pushing a cloud sketch. Defaults to true.",
370370
"cloud.pushpublic.warn": "True if users should be warned before pushing a public sketch to the cloud. Defaults to true.",
371+
"cloud.sharedSpaceId": "The ID of the Arduino Cloud shared space to load the sketchbook from. If empty, your private space is selected.",
371372
"cloud.sketchSyncEndpoint": "The endpoint used to push and pull sketches from a backend. By default it points to Arduino Cloud API.",
372373
"compile": "compile",
373374
"compile.experimental": "True if the IDE should handle multiple compiler errors. False by default",

0 commit comments

Comments
 (0)