Skip to content

Commit 1569975

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

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

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 Arduino Cloud shared space ID used to sync sketches from. If empty, user's 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

0 commit comments

Comments
 (0)