Skip to content

Commit 5116b0e

Browse files
committed
feat!: add a convenient way to add an openBIS data connector
1 parent a4b8d72 commit 5116b0e

File tree

4 files changed

+61
-39
lines changed

4 files changed

+61
-39
lines changed

client/src/features/dataConnectorsV2/components/DataConnectorModal/DataConnectorModalBody.tsx

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Controller, useForm } from "react-hook-form";
2323
import { ButtonGroup, FormText, Input, Label } from "reactstrap";
2424

2525
import { Loader } from "../../../../components/Loader";
26-
import { WarnAlert } from "../../../../components/Alert";
26+
import { InfoAlert, WarnAlert } from "../../../../components/Alert";
2727
import useAppDispatch from "../../../../utils/customHooks/useAppDispatch.hook";
2828
import useAppSelector from "../../../../utils/customHooks/useAppSelector.hook";
2929
import { slugFromTitle } from "../../../../utils/helpers/HelperFunctions";
@@ -117,24 +117,16 @@ function AddOrEditDataConnector({
117117
: null;
118118
if (CloudStorageContentByStep)
119119
return (
120-
<>
121-
<div className={cx("d-flex", "justify-content-end")}>
122-
<AddStorageAdvancedToggle
123-
state={cloudStorageState}
124-
setState={setState}
125-
/>
126-
</div>
127-
<CloudStorageContentByStep
128-
schema={schemata}
129-
state={cloudStorageState}
130-
storage={flatDataConnector}
131-
setState={setState}
132-
setStorage={setFlatDataConnector}
133-
storageSecrets={storageSecrets}
134-
validationSucceeded={validationResult?.isSuccess ?? false}
135-
isV2={true}
136-
/>
137-
</>
120+
<CloudStorageContentByStep
121+
schema={schemata}
122+
state={cloudStorageState}
123+
storage={flatDataConnector}
124+
setState={setState}
125+
setStorage={setFlatDataConnector}
126+
storageSecrets={storageSecrets}
127+
validationSucceeded={validationResult?.isSuccess ?? false}
128+
isV2={true}
129+
/>
138130
);
139131
const DataConnectorContentByStep =
140132
cloudStorageState.step >= 0 &&
@@ -507,21 +499,35 @@ export function DataConnectorMount() {
507499
}}
508500
value=""
509501
checked={flatDataConnector.readOnly ?? false}
502+
disabled={
503+
(flatDataConnector.convenientMode &&
504+
flatDataConnector.readOnly) ??
505+
false
506+
}
510507
/>
511508
)}
512509
rules={{ required: true }}
513510
/>
514-
{!flatDataConnector.readOnly && (
511+
{(flatDataConnector.convenientMode && flatDataConnector.readOnly && (
515512
<div className="mt-1">
516-
<WarnAlert dismissible={false}>
513+
<InfoAlert dismissible={false}>
517514
<p className="mb-0">
518-
You are mounting this storage in read-write mode. If you have
519-
read-only access, please check the box to prevent errors with
520-
some storage types.
515+
This cloud storage only supports read-only access.
521516
</p>
522-
</WarnAlert>
517+
</InfoAlert>
523518
</div>
524-
)}
519+
)) ||
520+
(!flatDataConnector.readOnly && (
521+
<div className="mt-1">
522+
<WarnAlert dismissible={false}>
523+
<p className="mb-0">
524+
You are mounting this storage in read-write mode. If you have
525+
read-only access, please check the box to prevent errors with
526+
some storage types.
527+
</p>
528+
</WarnAlert>
529+
</div>
530+
))}
525531
<div className={cx("form-text", "text-muted")}>
526532
Check this box to mount the storage in read-only mode. You should
527533
always check this if you do not have credentials to write. You can use

client/src/features/dataConnectorsV2/components/DataConnectorModal/DataConnectorModalFooter.tsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,19 @@ export default function DataConnectorModalFooter({
287287

288288
// Visual elements
289289
const disableContinueButton =
290-
cloudStorageState.step === 1 &&
291-
(!flatDataConnector.schema ||
292-
(schemaRequiresProvider && !flatDataConnector.provider));
290+
(cloudStorageState.step === 1 &&
291+
(!flatDataConnector.schema ||
292+
(schemaRequiresProvider && !flatDataConnector.provider))) ||
293+
(cloudStorageState.step === 2 &&
294+
flatDataConnector.convenientMode &&
295+
!(
296+
flatDataConnector.sourcePath &&
297+
flatDataConnector.options &&
298+
Object.values(flatDataConnector.options).every((v) => v)
299+
)) ||
300+
false;
301+
302+
console.log("disableContinueButton", disableContinueButton);
293303

294304
const isAddResultLoading = createResult.isLoading;
295305
const isModifyResultLoading = updateResult.isLoading;
@@ -350,15 +360,17 @@ export default function DataConnectorModalFooter({
350360
<DataConnectorModalBackButton success={success} toggle={toggle} />
351361
)}
352362
{!success && (
353-
<DataConnectorModalContinueButton
354-
addButtonDisableReason={addButtonDisableReason}
355-
addOrEditStorage={addOrEditStorage}
356-
disableAddButton={disableAddButton}
357-
disableContinueButton={disableContinueButton}
358-
hasStoredCredentialsInConfig={hasStoredCredentialsInConfig}
359-
isResultLoading={isResultLoading}
360-
dataConnectorId={dataConnectorId}
361-
/>
363+
<>
364+
<DataConnectorModalContinueButton
365+
addButtonDisableReason={addButtonDisableReason}
366+
addOrEditStorage={addOrEditStorage}
367+
disableAddButton={disableAddButton}
368+
disableContinueButton={disableContinueButton}
369+
hasStoredCredentialsInConfig={hasStoredCredentialsInConfig}
370+
isResultLoading={isResultLoading}
371+
dataConnectorId={dataConnectorId}
372+
/>
373+
</>
362374
)}
363375
</>
364376
);

client/src/features/dataConnectorsV2/components/DataConnectorModal/dataConnectorModalButtons.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export function DataConnectorModalContinueButton({
168168
continueId="add-data-connector-continue"
169169
step={cloudStorageState.step}
170170
testId="test-data-connector"
171+
disableContinueButton={disableContinueButton}
171172
/>
172173
{disableContinueButton && (
173174
<UncontrolledTooltip
@@ -248,11 +249,13 @@ interface TestConnectionAndContinueButtonsProps
248249
continueId: string;
249250
step: number;
250251
testId: string;
252+
disableContinueButton: boolean;
251253
}
252254
function TestConnectionAndContinueButtons({
253255
continueId,
254256
step,
255257
testId,
258+
disableContinueButton,
256259
}: TestConnectionAndContinueButtonsProps) {
257260
const dispatch = useAppDispatch();
258261
const { flatDataConnector, isActionOngoing, validationResultIsCurrent } =
@@ -341,7 +344,7 @@ function TestConnectionAndContinueButtons({
341344
color={testConnectionColor}
342345
id={buttonTestId}
343346
data-cy={buttonTestId}
344-
disabled={validationResult.isLoading}
347+
disabled={disableContinueButton || validationResult.isLoading}
345348
onClick={() => validateConnection()}
346349
>
347350
{testConnectionContent}

client/src/features/dataConnectorsV2/components/dataConnector.utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export type DataConnectorFlat = {
4949
readOnly?: boolean;
5050
schema?: string;
5151
sourcePath?: string;
52+
convenientMode?: boolean;
5253
};
5354

5455
type DataConnectorOptions = Record<

0 commit comments

Comments
 (0)