Skip to content

Commit

Permalink
feat: preserve all remote drives if no default drives config is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
gpuente committed Sep 4, 2024
1 parent 8b65599 commit b12b176
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/utils/reactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { DocumentDriveServerOptions } from 'document-drive/server';

const DEFAULT_DRIVES_URL =
import.meta.env.PH_CONNECT_DEFAULT_DRIVES_URL || undefined;
const defaultDrivesUrl = DEFAULT_DRIVES_URL?.split(',');
const defaultDrivesUrl = DEFAULT_DRIVES_URL
? DEFAULT_DRIVES_URL.split(',')
: [];

export const getReactorDefaultDrivesConfig = (): Pick<
DocumentDriveServerOptions,
'defaultRemoteDrives' | 'removeOldRemoteDrives'
> => {
const defaultDrives: DocumentDriveServerOptions['defaultRemoteDrives'] =
defaultDrivesUrl?.map(driveUrl => ({
defaultDrivesUrl.map(driveUrl => ({
url: driveUrl,
options: {
sharingType: 'PUBLIC',
Expand Down Expand Up @@ -40,9 +42,12 @@ export const getReactorDefaultDrivesConfig = (): Pick<

return {
defaultRemoteDrives: defaultDrives,
removeOldRemoteDrives: {
strategy: 'preserve-by-url',
urls: defaultDrivesUrl || [],
},
removeOldRemoteDrives:
defaultDrivesUrl.length > 0
? {
strategy: 'preserve-by-url',
urls: defaultDrivesUrl,
}
: { strategy: 'preserve-all' },
};
};
2 changes: 1 addition & 1 deletion src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type ImportMetaEnv = {
SENTRY_ORG: string
SENTRY_PROJECT: string
PH_CONNECT_ROUTER_BASENAME: string
PH_CONNECT_DEFAULT_DRIVES_URL: string
PH_CONNECT_ENABLED_EDITORS: string
PH_CONNECT_DISABLE_ADD_PUBLIC_DRIVES: string
PH_CONNECT_SEARCH_BAR_ENABLED: string
Expand All @@ -40,6 +39,7 @@ type ImportMetaEnv = {
PH_CONNECT_SENTRY_DSN: string
PH_CONNECT_SENTRY_PROJECT: string
PH_CONNECT_SENTRY_ENV: string
PH_CONNECT_DEFAULT_DRIVES_URL?: string
// @user-defined-start
/*
* You can use this section to explicitly extend the type definition of `import.meta.env`
Expand Down

0 comments on commit b12b176

Please sign in to comment.