Skip to content

Commit

Permalink
feat: enable RW option on cloud storage (#2901)
Browse files Browse the repository at this point in the history
fix #2899
  • Loading branch information
lorenzo-cavazzi committed Dec 4, 2023
1 parent 815f354 commit ff6429d
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 281 deletions.
159 changes: 58 additions & 101 deletions client/src/features/project/components/AddCloudStorageButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
import {
CLOUD_STORAGE_CONFIGURATION_PLACEHOLDER,
CLOUD_STORAGE_SENSITIVE_FIELD_TOKEN,
CLOUD_STORAGE_READWRITE_ENABLED,
} from "../projectCloudStorage.constants";
import {
CloudStorage,
Expand Down Expand Up @@ -205,7 +204,7 @@ function AdvancedAddCloudStorage({
configuration: "",
name: "",
private: true,
readonly: true,
readonly: false,
source_path: "",
},
});
Expand Down Expand Up @@ -321,55 +320,34 @@ function AdvancedAddCloudStorage({
</FormText>
</div>

{!CLOUD_STORAGE_READWRITE_ENABLED ? null : (
<div className="mb-3">
<div className="form-label">Mode</div>
<Controller
control={control}
name="readonly"
render={({ field }) => (
<>
<div className="form-check">
<Input
type="radio"
className="form-check-input"
name="readonlyRadio"
id="addCloudStorageReadOnly"
autoComplete="off"
checked={field.value}
onBlur={field.onBlur}
onChange={() => field.onChange(true)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for="addCloudStorageReadOnly"
>
Read-only
</Label>
</div>
<div className="form-check">
<Input
type="radio"
className="form-check-input"
name="readonlyRadio"
id="addCloudStorageReadWrite"
autoComplete="off"
checked={!field.value}
onBlur={field.onBlur}
onChange={() => field.onChange(false)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for="addCloudStorageReadWrite"
>
Read/Write
</Label>
</div>
</>
)}
/>
</div>
)}
<div className="mb-3">
<Controller
control={control}
name="readonly"
render={({ field }) => (
<Input
aria-describedby="addCloudStorageReadOnlyHelp"
className="form-check-input"
id="addCloudStorageReadOnly"
type="checkbox"
checked={field.value}
innerRef={field.ref}
onBlur={field.onBlur}
onChange={field.onChange}
/>
)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for="addCloudStorageReadOnly"
>
Read-only
</Label>
<FormText id="addCloudStorageReadOnlyHelp" tag="div">
Check this box to mount the storage in read-only mode. Use this
setting to prevent accidental data modifications.
</FormText>
</div>

<div className="mb-3">
<Label className="form-label" for="addCloudStorageSourcePath">
Expand Down Expand Up @@ -496,7 +474,7 @@ function SimpleAddCloudStorage({
name: "",
endpointUrl: "",
private: true,
readonly: true,
readonly: false,
},
});
const onSubmit = useCallback(
Expand Down Expand Up @@ -675,55 +653,34 @@ function SimpleAddCloudStorage({
</FormText>
</div>

{!CLOUD_STORAGE_READWRITE_ENABLED ? null : (
<div>
<div className="form-label">Mode</div>
<Controller
control={control}
name="readonly"
render={({ field }) => (
<>
<div className="form-check">
<Input
type="radio"
className="form-check-input"
name="addCloudStorageReadOnlyRadio"
id="addCloudStorageReadOnly"
autoComplete="off"
checked={field.value}
onBlur={field.onBlur}
onChange={() => field.onChange(true)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for="addCloudStorageReadOnly"
>
Read-only
</Label>
</div>
<div className="form-check">
<Input
type="radio"
className="form-check-input"
name="addCloudStorageReadOnlyRadio"
id="addCloudStorageReadWrite"
autoComplete="off"
checked={!field.value}
onBlur={field.onBlur}
onChange={() => field.onChange(false)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for="addCloudStorageReadWrite"
>
Read/Write
</Label>
</div>
</>
)}
/>
</div>
)}
<div>
<Controller
control={control}
name="readonly"
render={({ field }) => (
<Input
aria-describedby="addCloudStorageReadOnlyHelp"
className="form-check-input"
id="addCloudStorageReadOnly"
type="checkbox"
checked={field.value}
innerRef={field.ref}
onBlur={field.onBlur}
onChange={field.onChange}
/>
)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for="addCloudStorageReadOnly"
>
Read-only
</Label>
<FormText id="addCloudStorageReadOnlyHelp" tag="div">
Check this box to mount the storage in read-only mode. Use this
setting to prevent accidental data modifications.
</FormText>
</div>
</div>
</Form>
</ModalBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import {
import {
CLOUD_STORAGE_CONFIGURATION_PLACEHOLDER,
CLOUD_STORAGE_SENSITIVE_FIELD_TOKEN,
CLOUD_STORAGE_READWRITE_ENABLED,
} from "../projectCloudStorage.constants";
import {
CloudStorage,
Expand Down Expand Up @@ -646,55 +645,35 @@ function EditCloudStorage({
</div>
)}

{!CLOUD_STORAGE_READWRITE_ENABLED ? null : (
<div className="mb-3">
<div className="form-label">Mode</div>
<Controller
control={control}
name="readonly"
render={({ field }) => (
<>
<div className="form-check">
<Input
type="radio"
className="form-check-input"
name={`updateCloudStorageReadOnlyRadio-${name}`}
id={`updateCloudStorageReadOnly-${name}`}
autoComplete="off"
checked={field.value}
onBlur={field.onBlur}
onChange={() => field.onChange(true)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for={`updateCloudStorageReadOnly-${name}`}
>
Read-only
</Label>
</div>
<div className="form-check">
<Input
type="radio"
className="form-check-input"
name={`updateCloudStorageReadOnlyRadio-${name}`}
id={`updateCloudStorageReadWrite-${name}`}
autoComplete="off"
checked={!field.value}
onBlur={field.onBlur}
onChange={() => field.onChange(false)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for={`updateCloudStorageReadWrite-${name}`}
>
Read/Write
</Label>
</div>
</>
)}
/>
</div>
)}
<div className="mb-3">
<Controller
control={control}
name="readonly"
render={({ field }) => (
<Input
aria-describedby="updateCloudStorageReadOnlyHelp"
className="form-check-input"
id={`updateCloudStorageReadOnly-${name}`}
type="checkbox"
checked={field.value}
innerRef={field.ref}
onBlur={field.onBlur}
onChange={field.onChange}
/>
)}
/>
<Label
className={cx("form-check-label", "ms-2")}
for={`updateCloudStorageReadOnly-${name}`}
>
Read-only
</Label>
<FormText id="updateCloudStorageReadOnlyHelp" tag="div">
Check this box to mount the storage in read-only mode. Use this
setting to prevent accidental data modifications.
</FormText>
</div>

<div className="mb-3">
<Label
className="form-label"
Expand Down Expand Up @@ -855,9 +834,13 @@ function CloudStorageDetails({
)}
<div className="mt-2">
<div className="text-rk-text-light">
<small>Mode</small>
<small>Access mode</small>
</div>
<div>
{readonly
? "Force Read-only"
: "Allow Read-Write (requires adequate privileges on the storage)"}
</div>
<div>{readonly ? "Read-only" : "Read/Write"}</div>
</div>
<div className="mt-2">
<div className="text-rk-text-light">
Expand Down
2 changes: 0 additions & 2 deletions client/src/features/project/projectCloudStorage.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export const CLOUD_STORAGE_SENSITIVE_FIELD_TOKEN = "<sensitive>";

export const CLOUD_STORAGE_CONFIGURATION_PLACEHOLDER =
"[example]\ntype = s3\nprovider = AWS\nregion = us-east-1";

export const CLOUD_STORAGE_READWRITE_ENABLED = false;
Loading

0 comments on commit ff6429d

Please sign in to comment.