Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reload of input component #1406

Merged
merged 1 commit into from
Aug 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -387,94 +387,6 @@ const CopyToSharedFolderModal = ({ close, file, filePath }: IShareFileProps) =>
</div>
), [classes.loadingContainer, isDownloading, isUploading])

const Step1CreateSharedFolder = useCallback(() => (
<>
<div className={clsx(classes.modalFlexItem, classes.titleWrapper)}>
<TextInput
className={classes.shareFolderNameInput}
labelClassName={classes.inputLabel}
label={t`Shared Folder Name`}
value={sharedFolderName}
autoFocus
onChange={onNameChange}
state={nameError ? "error" : "normal"}
/>
{nameError && (
<Typography
component="p"
variant="body1"
className={classes.errorText}
>
{nameError}
</Typography>
)}
</div>
<div className={classes.modalFlexItem}>
<TagsInput
onChange={(values) => onNewUsers(values, "read")}
label={t`Give view-only permission to:`}
labelClassName={classes.inputLabel}
value={sharedFolderReaders}
fetchTags={(inputVal) => handleLookupUser(inputVal, "read")}
placeholder={t`Add by sharing address, username or wallet address`}
styles={{
control: (provided) => ({
...provided,
minHeight: 90,
alignContent: "start"
})
}}/>
</div>
<div className={classes.modalFlexItem}>
<TagsInput
onChange={(values) => onNewUsers(values, "write")}
label={t`Give edit permission to:`}
labelClassName={classes.inputLabel}
value={sharedFolderWriters}
fetchTags={(inputVal) => handleLookupUser(inputVal, "write")}
placeholder={t`Add by sharing address, username or wallet address`}
styles={{
control: (provided) => ({
...provided,
minHeight: 90,
alignContent: "start"
})
}}/>
</div>
{!!usersError && (
<Typography
component="p"
variant="body1"
className={classes.errorText}
>
{usersError}
</Typography>
)}
</>
), [
classes,
handleLookupUser,
nameError,
onNameChange,
onNewUsers,
sharedFolderName,
sharedFolderReaders,
sharedFolderWriters,
usersError
])

const Step1ExistingSharedFolder = useCallback(() => (
<div className={clsx(classes.modalFlexItem, classes.inputWrapper)}>
<SelectInput
label={t`Select an existing shared folder`}
labelClassName={classes.inputLabel}
options={bucketsOptions}
value={destinationBucket?.id}
onChange={(val: string) => setDestinationBucket(buckets.find((bu) => bu.id === val))}
/>
</div>
), [buckets, bucketsOptions, classes.inputLabel, classes.inputWrapper, classes.modalFlexItem, destinationBucket])

return (
<CustomModal
className={classes.modalRoot}
Expand Down Expand Up @@ -507,8 +419,82 @@ const CopyToSharedFolderModal = ({ close, file, filePath }: IShareFileProps) =>
<div className={classes.modalFlexItem}>
{currentStep === "1_SHARED_FOLDER_SELECTION_CREATION" && (
isUsingCurrentBucket
? <Step1ExistingSharedFolder />
: <Step1CreateSharedFolder />
? (
<div className={clsx(classes.modalFlexItem, classes.inputWrapper)}>
<SelectInput
label={t`Select an existing shared folder`}
labelClassName={classes.inputLabel}
options={bucketsOptions}
value={destinationBucket?.id}
onChange={(val: string) => setDestinationBucket(buckets.find((bu) => bu.id === val))}
/>
</div>
)
: (
<>
<div className={clsx(classes.modalFlexItem, classes.titleWrapper)}>
<TextInput
className={classes.shareFolderNameInput}
labelClassName={classes.inputLabel}
label={t`Shared Folder Name`}
value={sharedFolderName}
autoFocus
onChange={onNameChange}
state={nameError ? "error" : "normal"}
/>
{nameError && (
<Typography
component="p"
variant="body1"
className={classes.errorText}
>
{nameError}
</Typography>
)}
</div>
<div className={classes.modalFlexItem}>
<TagsInput
onChange={(values) => onNewUsers(values, "read")}
label={t`Give view-only permission to:`}
labelClassName={classes.inputLabel}
value={sharedFolderReaders}
fetchTags={(inputVal) => handleLookupUser(inputVal, "read")}
placeholder={t`Add by sharing address, username or wallet address`}
styles={{
control: (provided) => ({
...provided,
minHeight: 90,
alignContent: "start"
})
}}/>
</div>
<div className={classes.modalFlexItem}>
<TagsInput
onChange={(values) => onNewUsers(values, "write")}
label={t`Give edit permission to:`}
labelClassName={classes.inputLabel}
value={sharedFolderWriters}
fetchTags={(inputVal) => handleLookupUser(inputVal, "write")}
placeholder={t`Add by sharing address, username or wallet address`}
styles={{
control: (provided) => ({
...provided,
minHeight: 90,
alignContent: "start"
})
}}/>
</div>
{!!usersError && (
<Typography
component="p"
variant="body1"
className={classes.errorText}
>
{usersError}
</Typography>
)}
</>
)
)}
</div>
{currentStep === "1_SHARED_FOLDER_SELECTION_CREATION" && (
Expand Down