From 8db7ff962d89c6e40076ddacb1fde8148650611c Mon Sep 17 00:00:00 2001 From: Joao Miguel Date: Thu, 24 Jul 2025 11:39:40 +0100 Subject: [PATCH 1/2] feat(eng-10240): site selection enabled --- README.md | 2 ++ src/filePicker.ts | 4 ++++ src/types.ts | 1 + src/utils/url.ts | 2 ++ 4 files changed, 9 insertions(+) diff --git a/README.md b/README.md index ad63b44..13b756c 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ const options = { fields = ['name', 'path', 'driveId'], showBranding = false, folderSelectionEnabled = true, + siteSelectionEnabled = true, onFilesPicked = (files) => { console.log('Selected files:', files); }, @@ -84,6 +85,7 @@ const filePicker = new FilePicker(options); | **fields** | string[] | No | Which fields from the raw picked file will be mapped on the files picked callback. | | **showBranding** | boolean | No | Show StackOne footer on the file picker, it is defaulted to true. | | **folderSelectionEnabled** | boolean | No | Enable the selection of folders on the unified and native pickers. | +| **siteSelectionEnabled** | boolean | No | Enable the selection of sites on the unified and native pickers. | | **onFilesPicked** | function | No | Called when files are selected. | | **onOpen()** | function | No | Called when the file picker is opened. | | **onClose()** | function | No | Called every time the file picker is closed regardless of whether a file has been picked or not. | diff --git a/src/filePicker.ts b/src/filePicker.ts index 27dcdfe..ebfb4fc 100644 --- a/src/filePicker.ts +++ b/src/filePicker.ts @@ -12,6 +12,7 @@ export class FilePicker { #showBranding = true; #fields?: string[]; #folderSelectionEnabled = false; + #siteSelectionEnabled = false; #onFilesPicked: (data: File[]) => void; #onClose: () => void; #onOpen: () => void; @@ -27,6 +28,7 @@ export class FilePicker { fields, showBranding, folderSelectionEnabled, + siteSelectionEnabled, onFilesPicked, onClose, onOpen, @@ -40,6 +42,7 @@ export class FilePicker { this.#apiUrl = apiUrl ?? 'https://api.stackone.com'; this.#showBranding = showBranding ?? true; this.#folderSelectionEnabled = folderSelectionEnabled ?? false; + this.#siteSelectionEnabled = siteSelectionEnabled ?? false; this.#onFilesPicked = onFilesPicked ?? (() => {}); this.#onClose = onClose ?? (() => {}); this.#onOpen = onOpen ?? (() => {}); @@ -79,6 +82,7 @@ export class FilePicker { this.#apiUrl, this.#showBranding, this.#folderSelectionEnabled, + this.#siteSelectionEnabled, ); this.#iframe.src = url; } diff --git a/src/types.ts b/src/types.ts index 9811902..4e29c21 100644 --- a/src/types.ts +++ b/src/types.ts @@ -13,6 +13,7 @@ export interface FilePickerOptions { fields?: string[]; showBranding?: boolean; folderSelectionEnabled?: boolean; + siteSelectionEnabled?: boolean; onFilesPicked?: (data: File[]) => void; onError?: (error: Error) => void; onClose?: () => void; diff --git a/src/utils/url.ts b/src/utils/url.ts index e9328c2..6c24fd1 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -6,12 +6,14 @@ export const createUrl = ( apiUrl?: string, showBranding?: boolean, folderSelectionEnabled?: boolean, + siteSelectionEnabled?: boolean, ) => { const url = new URL(baseUrl); url.searchParams.set('token', sessionToken); url.searchParams.set('origin', btoa(origin)); url.searchParams.set('showBranding', showBranding ? 'true' : 'false'); url.searchParams.set('folderSelectionEnabled', folderSelectionEnabled ? 'true' : 'false'); + url.searchParams.set('siteSelectionEnabled', siteSelectionEnabled ? 'true' : 'false'); if (fields) { url.searchParams.set('fields', btoa(JSON.stringify(fields))); From 0d37d9d6c227db3dc97eb50fe26993c9141bf892 Mon Sep 17 00:00:00 2001 From: Joao Miguel Date: Thu, 24 Jul 2025 11:42:36 +0100 Subject: [PATCH 2/2] fix: change site to drive --- README.md | 4 ++-- src/filePicker.ts | 8 ++++---- src/types.ts | 2 +- src/utils/url.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 13b756c..a7bee8a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ const options = { fields = ['name', 'path', 'driveId'], showBranding = false, folderSelectionEnabled = true, - siteSelectionEnabled = true, + driveSelectionEnabled = true, onFilesPicked = (files) => { console.log('Selected files:', files); }, @@ -85,7 +85,7 @@ const filePicker = new FilePicker(options); | **fields** | string[] | No | Which fields from the raw picked file will be mapped on the files picked callback. | | **showBranding** | boolean | No | Show StackOne footer on the file picker, it is defaulted to true. | | **folderSelectionEnabled** | boolean | No | Enable the selection of folders on the unified and native pickers. | -| **siteSelectionEnabled** | boolean | No | Enable the selection of sites on the unified and native pickers. | +| **driveSelectionEnabled** | boolean | No | Enable the selection of drives on the unified and native pickers. | | **onFilesPicked** | function | No | Called when files are selected. | | **onOpen()** | function | No | Called when the file picker is opened. | | **onClose()** | function | No | Called every time the file picker is closed regardless of whether a file has been picked or not. | diff --git a/src/filePicker.ts b/src/filePicker.ts index ebfb4fc..3004bf0 100644 --- a/src/filePicker.ts +++ b/src/filePicker.ts @@ -12,7 +12,7 @@ export class FilePicker { #showBranding = true; #fields?: string[]; #folderSelectionEnabled = false; - #siteSelectionEnabled = false; + #driveSelectionEnabled = false; #onFilesPicked: (data: File[]) => void; #onClose: () => void; #onOpen: () => void; @@ -28,7 +28,7 @@ export class FilePicker { fields, showBranding, folderSelectionEnabled, - siteSelectionEnabled, + driveSelectionEnabled, onFilesPicked, onClose, onOpen, @@ -42,7 +42,7 @@ export class FilePicker { this.#apiUrl = apiUrl ?? 'https://api.stackone.com'; this.#showBranding = showBranding ?? true; this.#folderSelectionEnabled = folderSelectionEnabled ?? false; - this.#siteSelectionEnabled = siteSelectionEnabled ?? false; + this.#driveSelectionEnabled = driveSelectionEnabled ?? false; this.#onFilesPicked = onFilesPicked ?? (() => {}); this.#onClose = onClose ?? (() => {}); this.#onOpen = onOpen ?? (() => {}); @@ -82,7 +82,7 @@ export class FilePicker { this.#apiUrl, this.#showBranding, this.#folderSelectionEnabled, - this.#siteSelectionEnabled, + this.#driveSelectionEnabled, ); this.#iframe.src = url; } diff --git a/src/types.ts b/src/types.ts index 4e29c21..64285a9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -13,7 +13,7 @@ export interface FilePickerOptions { fields?: string[]; showBranding?: boolean; folderSelectionEnabled?: boolean; - siteSelectionEnabled?: boolean; + driveSelectionEnabled?: boolean; onFilesPicked?: (data: File[]) => void; onError?: (error: Error) => void; onClose?: () => void; diff --git a/src/utils/url.ts b/src/utils/url.ts index 6c24fd1..9b3d8bb 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -6,14 +6,14 @@ export const createUrl = ( apiUrl?: string, showBranding?: boolean, folderSelectionEnabled?: boolean, - siteSelectionEnabled?: boolean, + driveSelectionEnabled?: boolean, ) => { const url = new URL(baseUrl); url.searchParams.set('token', sessionToken); url.searchParams.set('origin', btoa(origin)); url.searchParams.set('showBranding', showBranding ? 'true' : 'false'); url.searchParams.set('folderSelectionEnabled', folderSelectionEnabled ? 'true' : 'false'); - url.searchParams.set('siteSelectionEnabled', siteSelectionEnabled ? 'true' : 'false'); + url.searchParams.set('driveSelectionEnabled', driveSelectionEnabled ? 'true' : 'false'); if (fields) { url.searchParams.set('fields', btoa(JSON.stringify(fields)));