diff --git a/arduino-ide-extension/src/browser/arduino-preferences.ts b/arduino-ide-extension/src/browser/arduino-preferences.ts index bc9cdb099..6c54d150d 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 Arduino Cloud shared space ID used to sync sketches from. If empty, user's 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(); + } }) );