diff --git a/arduino-ide-extension/src/browser/arduino-preferences.ts b/arduino-ide-extension/src/browser/arduino-preferences.ts index bc9cdb099..c7e1698a5 100644 --- a/arduino-ide-extension/src/browser/arduino-preferences.ts +++ b/arduino-ide-extension/src/browser/arduino-preferences.ts @@ -228,6 +228,14 @@ const properties: ArduinoPreferenceSchemaProperties = { ), default: 'https://api2.arduino.cc/create', }, + 'arduino.cloud.sharedSpaceID': { + type: 'string', + description: nls.localize( + 'arduino/preferences/cloud.sharedSpaceId', + 'The ID of the Arduino Cloud shared space to load the sketchbook from. If empty, your private space is selected.' + ), + default: '', + }, 'arduino.auth.clientID': { type: 'string', description: nls.localize( @@ -329,6 +337,7 @@ export interface ArduinoConfiguration { 'arduino.cloud.push.warn': boolean; 'arduino.cloud.pushpublic.warn': boolean; 'arduino.cloud.sketchSyncEndpoint': string; + 'arduino.cloud.sharedSpaceID': string; 'arduino.auth.clientID': string; 'arduino.auth.domain': string; 'arduino.auth.audience': string; diff --git a/arduino-ide-extension/src/browser/create/create-api.ts b/arduino-ide-extension/src/browser/create/create-api.ts index 7f4cfed22..db777b35a 100644 --- a/arduino-ide-extension/src/browser/create/create-api.ts +++ b/arduino-ide-extension/src/browser/create/create-api.ts @@ -509,11 +509,19 @@ export class CreateApi { private async headers(): Promise> { const token = await this.token(); - return { + const headers: Record = { 'content-type': 'application/json', accept: 'application/json', authorization: `Bearer ${token}`, }; + + const sharedSpaceID = + this.arduinoPreferences['arduino.cloud.sharedSpaceID']; + if (sharedSpaceID) { + headers['x-organization'] = sharedSpaceID; + } + + return headers; } private domain(apiVersion = 'v2'): string { diff --git a/arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-model.ts b/arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-model.ts index df1d52964..89a013547 100644 --- a/arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-model.ts +++ b/arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-model.ts @@ -127,6 +127,9 @@ export class SketchbookTreeModel extends FileTreeModel { if (preferenceName === 'arduino.sketchbook.showAllFiles') { this.updateRoot(); } + if (preferenceName === 'arduino.cloud.sharedSpaceID') { + this.updateRoot(); + } }) ); diff --git a/i18n/en.json b/i18n/en.json index c83d280c1..740f89ce5 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -114,6 +114,7 @@ "pushSketchMsg": "This is a Public Sketch. Before pushing, make sure any sensitive information is defined in arduino_secrets.h files. You can make a Sketch private from the Share panel.", "remote": "Remote", "share": "Share...", + "sharedSpaceID": "The ID of the Arduino Cloud shared space to load the sketchbook from. If empty, your private space is selected.", "shareSketch": "Share Sketch", "showHideSketchbook": "Show/Hide Cloud Sketchbook", "signIn": "SIGN IN",