Skip to content

Commit

Permalink
feat: add shared space support
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocusinato committed Aug 9, 2024
1 parent 2e78e96 commit 1569975
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions arduino-ide-extension/src/browser/arduino-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion arduino-ide-extension/src/browser/create/create-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,19 @@ export class CreateApi {

private async headers(): Promise<Record<string, string>> {
const token = await this.token();
return {
const headers: Record<string, string> = {
'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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export class SketchbookTreeModel extends FileTreeModel {
if (preferenceName === 'arduino.sketchbook.showAllFiles') {
this.updateRoot();
}
if (preferenceName === 'arduino.cloud.sharedSpaceID') {
this.updateRoot();
}
})
);

Expand Down

0 comments on commit 1569975

Please sign in to comment.