Skip to content

Commit 1a1b827

Browse files
feat: add shared space support
1 parent 2e78e96 commit 1a1b827

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 9 additions & 1 deletion
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

Lines changed: 3 additions & 0 deletions
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

i18n/en.json

Lines changed: 1 addition & 0 deletions
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)