Feature: add auto open share modal config for global. (#474)

* feat(admin): add auto open share modal config for global.

* feat(upload): Apply the flag that disables the automatic open create share modal.

* fix: remove migration and add new config variable to seed script

* chore(translations): improve auto open share modal description

* refactor: run formatter

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
Ivan Li
2024-06-10 17:32:52 +08:00
committed by GitHub
parent 1c7832ad1f
commit 4fd29037a0
10 changed files with 1652 additions and 18 deletions

View File

@@ -40,6 +40,7 @@ const Upload = ({
const chunkSize = useRef(parseInt(config.get("share.chunkSize")));
maxShareSize ??= parseInt(config.get("share.maxSize"));
const autoOpenCreateUploadModal = config.get("share.autoOpenShareModal");
const uploadFiles = async (share: CreateShare, files: FileUpload[]) => {
setisUploading(true);
@@ -121,7 +122,6 @@ const Upload = ({
};
const showCreateUploadModalCallback = (files: FileUpload[]) => {
setFiles(files);
showCreateUploadModal(
modals,
{
@@ -139,6 +139,15 @@ const Upload = ({
);
};
const handleDropzoneFilesChanged = (files: FileUpload[]) => {
if (autoOpenCreateUploadModal) {
setFiles(files);
showCreateUploadModalCallback(files);
} else {
setFiles((oldArr) => [...oldArr, ...files]);
}
};
useEffect(() => {
// Check if there are any files that failed to upload
const fileErrorCount = files.filter(
@@ -191,8 +200,13 @@ const Upload = ({
</Button>
</Group>
<Dropzone
title={
!autoOpenCreateUploadModal && files.length > 0
? t("share.edit.append-upload")
: undefined
}
maxShareSize={maxShareSize}
showCreateUploadModalCallback={showCreateUploadModalCallback}
onFilesChanged={handleDropzoneFilesChanged}
isUploading={isUploading}
/>
{files.length > 0 && (