diff --git a/client/src/features/dataConnectorsV2/components/DataConnectorModal.tsx b/client/src/features/dataConnectorsV2/components/DataConnectorModal.tsx index 4738ec206..6eb43bc50 100644 --- a/client/src/features/dataConnectorsV2/components/DataConnectorModal.tsx +++ b/client/src/features/dataConnectorsV2/components/DataConnectorModal.tsx @@ -59,7 +59,6 @@ import { import { AddCloudStorageContinueButton, AddCloudStorageBackButton, - AddCloudStorageBodyContent, AddCloudStorageConnectionTestResult, AddCloudStorageHeaderContent, } from "../../project/components/cloudStorage/cloudStorageModalComponents"; @@ -72,6 +71,8 @@ import { import styles from "../../project/components/cloudStorage/CloudStorage.module.scss"; +import DataConnectorModalBody from "./DataConnectorModalBody"; + interface DataConnectorModalProps { currentStorage?: | CloudStorage @@ -490,7 +491,7 @@ export default function DataConnectorModal({ - ) => void; + setState: (newState: Partial) => void; + state: AddCloudStorageState; + storage: CloudStorageDetails; + storageSecrets: CloudStorageSecretGet[]; +} + +interface AddOrEditCloudStoragePropsV2 extends AddOrEditCloudStorageProps { + validationSucceeded: boolean; +} + +export default function DataConnectorModalBody({ + addResultStorageName, + credentialSaveStatus, + redraw, + schema, + schemaError, + schemaIsFetching, + setStateSafe, + setStorageDetailsSafe, + state, + storageDetails, + storageId, + storageSecrets, + success, + validationSucceeded, +}: AddCloudStorageBodyContentProps) { + if (redraw) return ; + if (success) { + return ( + + ); + } + if (schemaIsFetching || !schema) return ; + if (schemaError) return ; + return ( + <> + {!storageId && ( +

+ Add published datasets from data repositories for use in your project. + Or, connect to cloud storage to read and write custom data. +

+ )} + + + ); +} + +function AddOrEditCloudStorageV2({ + schema, + setStorage, + setState, + state, + storage, + storageSecrets, + validationSucceeded, +}: AddOrEditCloudStoragePropsV2) { + const ContentByStep = + state.step >= 0 && state.step <= CLOUD_STORAGE_TOTAL_STEPS + ? mapStepToElement[state.step] + : null; + + if (ContentByStep) + return ( + <> +
+ +
+ + + ); + return

Error - not implemented yet

; +} + +// *** Add storage: helpers *** // +interface AddStorageStepProps { + schema: CloudStorageSchema[]; + setStorage: (newDetails: Partial) => void; + setState: (newState: Partial) => void; + state: AddCloudStorageState; + storage: CloudStorageDetails; + storageSecrets: CloudStorageSecretGet[]; + isV2?: boolean; + validationSucceeded: boolean; +} + +const mapStepToElement: { + [key: number]: React.ComponentType; +} = { + 0: AddStorageAdvanced, + 1: AddStorageType, + 2: AddStorageOptions, + 3: AddStorageMount, +}; diff --git a/client/src/features/project/components/cloudStorage/AddOrEditCloudStorage.tsx b/client/src/features/project/components/cloudStorage/AddOrEditCloudStorage.tsx index d58f3436f..f70e5071f 100644 --- a/client/src/features/project/components/cloudStorage/AddOrEditCloudStorage.tsx +++ b/client/src/features/project/components/cloudStorage/AddOrEditCloudStorage.tsx @@ -113,44 +113,6 @@ export default function AddOrEditCloudStorage({ return

Error - not implemented yet

; } -interface AddOrEditCloudStoragePropsV2 extends AddOrEditCloudStorageProps { - validationSucceeded: boolean; -} - -export function AddOrEditCloudStorageV2({ - schema, - setStorage, - setState, - state, - storage, - storageSecrets, - validationSucceeded, -}: AddOrEditCloudStoragePropsV2) { - const ContentByStep = - state.step >= 0 && state.step <= CLOUD_STORAGE_TOTAL_STEPS - ? mapStepToElement[state.step] - : null; - - if (ContentByStep) - return ( - <> -
- -
- - - ); - return

Error - not implemented yet

; -} interface AddStorageAdvancedToggleProps { setState: (newState: Partial) => void; state: AddCloudStorageState; diff --git a/client/src/features/project/components/cloudStorage/cloudStorageModalComponents.tsx b/client/src/features/project/components/cloudStorage/cloudStorageModalComponents.tsx index 6e76b1fe3..2e580a141 100644 --- a/client/src/features/project/components/cloudStorage/cloudStorageModalComponents.tsx +++ b/client/src/features/project/components/cloudStorage/cloudStorageModalComponents.tsx @@ -33,9 +33,7 @@ import { Button, UncontrolledTooltip } from "reactstrap"; import { SuccessAlert } from "../../../../components/Alert"; import { Loader } from "../../../../components/Loader"; import { RtkOrNotebooksError } from "../../../../components/errors/RtkErrorAlert"; -import AddOrEditCloudStorage, { - AddOrEditCloudStorageV2, -} from "./AddOrEditCloudStorage"; +import AddOrEditCloudStorage from "./AddOrEditCloudStorage"; import { useTestCloudStorageConnectionMutation } from "./projectCloudStorage.api"; import { CLOUD_STORAGE_TOTAL_STEPS } from "./projectCloudStorage.constants"; import { @@ -95,7 +93,7 @@ export function AddCloudStorageBackButton({ ); } -interface AddCloudStorageBodyContentProps +export interface AddCloudStorageBodyContentProps extends AddCloudStorageHeaderContentProps { addResultStorageName: string | undefined; credentialSaveStatus: CredentialSaveStatus; @@ -116,7 +114,6 @@ interface AddCloudStorageBodyContentProps export function AddCloudStorageBodyContent({ addResultStorageName, credentialSaveStatus, - isV2, redraw, schema, schemaError, @@ -126,9 +123,7 @@ export function AddCloudStorageBodyContent({ state, storageDetails, storageId, - storageSecrets, success, - validationSucceeded, }: AddCloudStorageBodyContentProps) { if (redraw) return ; if (success) { @@ -140,36 +135,15 @@ export function AddCloudStorageBodyContent({ } if (schemaIsFetching || !schema) return ; if (schemaError) return ; - if (!isV2) { - return ( - - ); - } return ( - <> - {!storageId && ( -

- Add published datasets from data repositories for use in your project. - Or, connect to cloud storage to read and write custom data. -

- )} - - + ); } @@ -347,7 +321,7 @@ type AddCloudStorageSuccessAlertProps = Pick< "addResultStorageName" | "credentialSaveStatus" | "storageId" >; -function AddCloudStorageSuccessAlert({ +export function AddCloudStorageSuccessAlert({ addResultStorageName, credentialSaveStatus, storageId,