-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cloud-storage): cloud storage supports new directory (#1716)
* feat(flat-components): add navigation component to the cloudStorage * feat(flat-components): add new directory component to the cloudStorage * refactor(flat-components): replace icons * refactor(cloud-storage): the upload flow add directory name * refactor(cloud-storage): add new button and add relate function of new directory * chore(flat-components): add annotation * refactor(flat-components): support rename directory * refactor(cloud-storage): add relate function of new directory to cloud storage store * refactor(flat-pages): refresh component when directory path change * refactor(i18n): add i18n and error code * refactor(flat-components): add the render conditional of the navigation component * refactor(flat-components): add i18n to cloudStorageNavigation components * refactor(cloud-storage): sort files of the cloud storage store * chore(i18n): add i18n * chore(cloud-storage): remove console log * chore(i18n): add i18n of the new directory and rename directory error tips * refactor(flat-components): remove unimportant comments and beautify the path value
- Loading branch information
Showing
39 changed files
with
764 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...components/src/components/CloudStorage/CloudStorageFileTitle/CloudStorageNewDirectory.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import checkSVG from "./icons/check.svg"; | ||
import crossSVG from "./icons/cross.svg"; | ||
|
||
import { Button, Input, InputRef, message } from "antd"; | ||
import React, { useEffect, useRef, useState } from "react"; | ||
import { DirectoryInfo } from "../../../containers/CloudStorageContainer"; | ||
import { checkInvalidDirectoryName } from "./utils"; | ||
import { useTranslate } from "@netless/flat-i18n"; | ||
|
||
export interface CloudStorageNewDirectoryProps { | ||
parentDirectoryPath: string; | ||
onNewDirectory?: (directoryInfo: DirectoryInfo) => void; | ||
} | ||
|
||
export const CloudStorageNewDirectory = /* @__PURE__ */ React.memo<CloudStorageNewDirectoryProps>( | ||
function CloudStorageNewDirectory({ parentDirectoryPath, onNewDirectory }) { | ||
// Antd docs uses any | ||
const t = useTranslate(); | ||
const inputRef = useRef<any>(); | ||
const [name, setText] = useState(t("new-directory")); | ||
|
||
const onCancel = | ||
onNewDirectory && (() => onNewDirectory({ directoryName: "", parentDirectoryPath })); | ||
const onConfirm = | ||
onNewDirectory && | ||
(() => { | ||
checkInvalidDirectoryName(name) | ||
? message.error(t("invalid-directory-name-tips")) | ||
: onNewDirectory({ directoryName: name, parentDirectoryPath }); | ||
}); | ||
|
||
useEffect(() => { | ||
const input: InputRef = inputRef.current; | ||
if (input) { | ||
input.focus(); | ||
input.select(); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Input | ||
ref={inputRef} | ||
className="cloud-storage-file-title-rename-input" | ||
size="small" | ||
value={name} | ||
onChange={e => setText(e.currentTarget.value)} | ||
onPressEnter={onConfirm} | ||
/> | ||
<Button | ||
className="cloud-storage-file-title-rename-btn" | ||
shape="circle" | ||
size="small" | ||
type="text" | ||
onClick={onConfirm} | ||
> | ||
<img alt="confirm" height={22} src={checkSVG} width={22} /> | ||
</Button> | ||
<Button | ||
className="cloud-storage-file-title-rename-btn" | ||
shape="circle" | ||
size="small" | ||
type="text" | ||
onClick={onCancel} | ||
> | ||
<img alt="cancel" height={22} src={crossSVG} width={22} /> | ||
</Button> | ||
</> | ||
); | ||
}, | ||
); |
2 changes: 1 addition & 1 deletion
2
...at-components/src/components/CloudStorage/CloudStorageFileTitle/icons/audio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
...-components/src/components/CloudStorage/CloudStorageFileTitle/icons/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
...omponents/src/components/CloudStorage/CloudStorageFileTitle/icons/directory.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
...flat-components/src/components/CloudStorage/CloudStorageFileTitle/icons/img.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
...flat-components/src/components/CloudStorage/CloudStorageFileTitle/icons/pdf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.