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:
@@ -72,7 +72,7 @@ export default function AppShellDemo() {
|
||||
};
|
||||
|
||||
const updateConfigVariable = (configVariable: UpdateConfig) => {
|
||||
if (configVariable.key === 'general.appUrl') {
|
||||
if (configVariable.key === "general.appUrl") {
|
||||
configVariable.value = sanitizeUrl(configVariable.value);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ export default function AppShellDemo() {
|
||||
};
|
||||
|
||||
const sanitizeUrl = (url: string): string => {
|
||||
return url.endsWith('/') ? url.slice(0, -1) : url;
|
||||
return url.endsWith("/") ? url.slice(0, -1) : url;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -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 && (
|
||||
|
||||
Reference in New Issue
Block a user