Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Create new confirm dialog for S3 listObjects (#1966)

Stanimir8f8487f7a88d
diff --git a/.gitignore b/.gitignore
index 897f0633e..522895c26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -103,6 +103,7 @@ tests/*
!tests/setup-functions.js
!tests/test-data-refresh.js
!tests/create-1000files-nothumbs.sh
+!tests/create-1000files.js
builds/*
web/sw-con
@@ -122,4 +123,4 @@ playwright-report/*
deploy.sh
-docker/*.zip
\ No newline at end of file
+docker/*.zip
diff --git a/app/components/dialogs/CreateEditLocationDialog.tsx b/app/components/dialogs/CreateEditLocationDialog.tsx
index e206d4bbc..69a2d49e3 100644
--- a/app/components/dialogs/CreateEditLocationDialog.tsx
+++ b/app/components/dialogs/CreateEditLocationDialog.tsx
@@ -78,6 +78,7 @@ import useMediaQuery from '@mui/material/useMediaQuery';
import { loadLocationDataPromise } from '-/services/utils-io';
import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import { ExpandIcon } from '-/components/CommonIcons';
+import MaxLoopsSelect from '-/components/dialogs/MaxLoopsSelect';
const PREFIX = 'CreateEditLocationDialog';
@@ -795,40 +796,10 @@ function CreateEditLocationDialog(props: Props) {
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
- <Select
- data-tid="maxLoopsTID"
- name="maxLoops"
- onChange={changeMaxLoops}
- value={maxLoops}
- >
- <MenuItem value="1">
- <span>1000</span>
- </MenuItem>
- <MenuItem value="2">
- <span>2000</span>
- </MenuItem>
- <MenuItem value="5">
- <span>5000</span>
- </MenuItem>
- <MenuItem value="10">
- <span>10000</span>
- </MenuItem>
- <MenuItem value="20">
- <span>20000</span>
- </MenuItem>
- <MenuItem value="50">
- <span>50000</span>
- </MenuItem>
- <MenuItem value="100">
- <span>100000</span>
- </MenuItem>
- <MenuItem value="150">
- <span>150000</span>
- </MenuItem>
- <MenuItem value="200">
- <span>200000</span>
- </MenuItem>
- </Select>
+ <MaxLoopsSelect
+ maxLoops={maxLoops}
+ changeMaxLoops={changeMaxLoops}
+ />
}
label={
<Typography>
diff --git a/app/components/dialogs/IsTruncatedConfirmDialog.tsx b/app/components/dialogs/IsTruncatedConfirmDialog.tsx
new file mode 100644
index 000000000..94fa1b7d3
--- /dev/null
+++ b/app/components/dialogs/IsTruncatedConfirmDialog.tsx
@@ -0,0 +1,135 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import React, { useState } from 'react';
+import Button from '@mui/material/Button';
+import DialogActions from '@mui/material/DialogActions';
+import DialogContent from '@mui/material/DialogContent';
+import DialogTitle from '@mui/material/DialogTitle';
+import DialogContentText from '@mui/material/DialogContentText';
+import DraggablePaper from '-/components/DraggablePaper';
+import Dialog from '@mui/material/Dialog';
+import { locationType } from '@tagspaces/tagspaces-common/misc';
+import i18n from '-/services/i18n';
+import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
+import MaxLoopsSelect from '-/components/dialogs/MaxLoopsSelect';
+import AppConfig from '-/AppConfig';
+import { TS } from '-/tagspaces.namespace';
+import { useDispatch, useSelector } from 'react-redux';
+import {
+ actions as LocationActions,
+ getCurrentLocation
+} from '-/reducers/locations';
+import {
+ actions as AppActions,
+ AppDispatch,
+ getDirectoryPath
+} from '-/reducers/app';
+import Typography from '@mui/material/Typography';
+import InfoIcon from '-/components/InfoIcon';
+import FormControlLabel from '@mui/material/FormControlLabel';
+import PlatformIO from '-/services/platform-facade';
+
+interface Props {
+ open: boolean;
+ onClose: () => void;
+}
+
+function IsTruncatedConfirmDialog(props: Props) {
+ const { open, onClose } = props;
+ const dispatch: AppDispatch = useDispatch();
+ const location: TS.Location = useSelector(getCurrentLocation);
+ const currentDirectoryPath = useSelector(getDirectoryPath);
+
+ let defaultMaxLoops = AppConfig.maxLoops;
+ if (location && location.maxLoops && location.maxLoops > 0) {
+ const maxLoopsAsString = location.maxLoops + '';
+ defaultMaxLoops = parseInt(maxLoopsAsString, 10);
+ }
+ //const [maxLoops, setMaxLoops] = useState<number>(defaultMaxLoops);
+
+ function changeMaxLoops(event: React.ChangeEvent<HTMLInputElement>) {
+ const loops = event.target.value;
+ if (loops) {
+ dispatch(
+ LocationActions.editLocation(
+ {
+ ...location,
+ maxLoops: parseInt(loops, 10)
+ },
+ false
+ )
+ );
+ onClose();
+ if (location.type === locationType.TYPE_CLOUD) {
+ PlatformIO.enableObjectStoreSupport(location)
+ .then(() =>
+ dispatch(
+ AppActions.loadDirectoryContent(currentDirectoryPath, true, true)
+ )
+ )
+ .catch(error => {
+ console.log('enableObjectStoreSupport', error);
+ });
+ }
+ }
+ }
+
+ return (
+ <Dialog
+ aria-labelledby="draggable-dialog-title"
+ PaperComponent={DraggablePaper}
+ open={open}
+ onClose={onClose}
+ keepMounted
+ scroll="paper"
+ >
+ <DialogTitle style={{ cursor: 'move' }} id="draggable-dialog-title">
+ {i18n.t('core:warningDirectoryIsTruncated')}
+ <DialogCloseButton testId="closeIsTruncatedTID" onClose={onClose} />
+ </DialogTitle>
+ <DialogContent>
+ <DialogContentText component="span">
+ <FormControlLabel
+ labelPlacement="start"
+ style={{ justifyContent: 'space-between' }}
+ control={
+ <MaxLoopsSelect
+ maxLoops={defaultMaxLoops}
+ changeMaxLoops={changeMaxLoops}
+ />
+ }
+ label={
+ <Typography>
+ {i18n.t('core:maxLoops')}
+ <InfoIcon tooltip={i18n.t('core:maxLoopsHelp')} />
+ </Typography>
+ }
+ />
+ </DialogContentText>
+ </DialogContent>
+ <DialogActions>
+ <Button onClick={() => onClose()} color="primary">
+ {i18n.t('core:continue')}
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+}
+
+export default IsTruncatedConfirmDialog;
diff --git a/app/components/dialogs/MaxLoopsSelect.tsx b/app/components/dialogs/MaxLoopsSelect.tsx
new file mode 100644
index 000000000..3e5226567
--- /dev/null
+++ b/app/components/dialogs/MaxLoopsSelect.tsx
@@ -0,0 +1,49 @@
+import React from 'react';
+import { MenuItem, Select } from '@mui/material';
+
+interface Props {
+ maxLoops: number;
+ changeMaxLoops: (event: React.ChangeEvent<HTMLInputElement>) => void;
+}
+
+function MaxLoopsSelect(props: Props) {
+ const { maxLoops, changeMaxLoops } = props;
+ return (
+ <Select
+ data-tid="maxLoopsTID"
+ name="maxLoops"
+ onChange={changeMaxLoops}
+ value={maxLoops}
+ >
+ <MenuItem value="1">
+ <span>1000</span>
+ </MenuItem>
+ <MenuItem value="2">
+ <span>2000</span>
+ </MenuItem>
+ <MenuItem value="5">
+ <span>5000</span>
+ </MenuItem>
+ <MenuItem value="10">
+ <span>10000</span>
+ </MenuItem>
+ <MenuItem value="20">
+ <span>20000</span>
+ </MenuItem>
+ <MenuItem value="50">
+ <span>50000</span>
+ </MenuItem>
+ <MenuItem value="100">
+ <span>100000</span>
+ </MenuItem>
+ <MenuItem value="150">
+ <span>150000</span>
+ </MenuItem>
+ <MenuItem value="200">
+ <span>200000</span>
+ </MenuItem>
+ </Select>
+ );
+}
+
+export default MaxLoopsSelect;
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsx
index 6f576b907..d245fae93 100644
--- a/app/containers/MainPage.tsx
+++ b/app/containers/MainPage.tsx
@@ -72,7 +72,8 @@ import {
getSelectedEntries,
currentUser,
isLocationDialogOpened,
- isProTeaserVisible
+ isProTeaserVisible,
+ isTruncatedConfirmDialogOpened
} from '../reducers/app';
import TargetFileBox from '../components/TargetFileBox';
import i18n from '../services/i18n';
@@ -92,6 +93,7 @@ import MoveOrCopyFilesDialog from '-/components/dialogs/MoveOrCopyFilesDialog';
import PlatformIO from '-/services/platform-facade';
import { Pro } from '-/pro';
import NewFileDialog from '-/components/dialogs/NewFileDialog';
+import IsTruncatedConfirmDialog from '-/components/dialogs/IsTruncatedConfirmDialog';
import { styled, useTheme } from '@mui/material/styles';
const drawerWidth = 320;
@@ -153,6 +155,7 @@ interface Props {
isThirdPartyLibsDialogOpened: boolean;
isOnboardingDialogOpened: boolean;
isUploadProgressDialogOpened: string | undefined;
+ isTruncatedConfirmDialogOpened: boolean;
isProgressDialogOpened: boolean;
isProTeaserVisible: boolean;
toggleUploadDialog: () => void;
@@ -194,6 +197,7 @@ interface Props {
leftSplitSize: number;
mainSplitSize: any;
toggleShowUnixHiddenEntries: () => void;
+ toggleTruncatedConfirmDialog: () => void;
setMainVerticalSplitSize: (splitSize: string) => void;
isLocationManagerPanelOpened: boolean;
isOpenLinkDialogOpened: boolean;
@@ -769,7 +773,13 @@ function MainPage(props: Props) {
title={props.isUploadProgressDialogOpened}
/>
)}
- {props.isProgressDialogOpened && (
+ {props.isTruncatedConfirmDialogOpened && (
+ <IsTruncatedConfirmDialog
+ open={true}
+ onClose={props.toggleTruncatedConfirmDialog}
+ />
+ )}
+ {props.isProgressDialogOpened && (
<ProgressDialog
open={props.isProgressDialogOpened}
onClose={toggleProgressDialog}
@@ -938,6 +948,7 @@ function mapStateToProps(state) {
isLicenseDialogOpened: isLicenseDialogOpened(state),
isThirdPartyLibsDialogOpened: isThirdPartyLibsDialogOpened(state),
isUploadProgressDialogOpened: isUploadDialogOpened(state),
+ isTruncatedConfirmDialogOpened: isTruncatedConfirmDialogOpened(state),
isOpenLinkDialogOpened: isOpenLinkDialogOpened(state),
isProTeaserVisible: isProTeaserVisible(state),
isProgressDialogOpened: isProgressOpened(state),
@@ -971,6 +982,7 @@ function mapDispatchToProps(dispatch) {
toggleProgressDialog: AppActions.toggleProgressDialog,
resetProgress: AppActions.resetProgress,
toggleEditTagDialog: AppActions.toggleEditTagDialog,
+ toggleTruncatedConfirmDialog: AppActions.toggleTruncatedConfirmDialog,
onUploadProgress: AppActions.onUploadProgress,
saveFile: AppActions.saveFile,
openLink: AppActions.openLink,
@@ -1048,6 +1060,8 @@ const areEqual = (prevProp, nextProp) =>
nextProp.isSearchPanelOpened === prevProp.isSearchPanelOpened &&
nextProp.isSettingsDialogOpened === prevProp.isSettingsDialogOpened &&
nextProp.isTagLibraryPanelOpened === prevProp.isTagLibraryPanelOpened &&
+ nextProp.isTruncatedConfirmDialogOpened ===
+ prevProp.isTruncatedConfirmDialogOpened &&
nextProp.isThirdPartyLibsDialogOpened ===
prevProp.isThirdPartyLibsDialogOpened &&
nextProp.isUploadProgressDialogOpened ===
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 7657f3efa..5d917e3e3 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -148,6 +148,7 @@ export const types = {
'APP/TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG',
TOGGLE_IMPORT_KANBAN_DIALOG: 'APP/TOGGLE_IMPORT_KANBAN_DIALOG',
TOGGLE_UPLOAD_DIALOG: 'APP/TOGGLE_UPLOAD_DIALOG',
+ TOGGLE_TRUNCATED_DIALOG: 'APP/TOGGLE_TRUNCATED_DIALOG',
SET_CURRENT_DIRECTORY_DIRS: 'APP/SET_CURRENT_DIRECTORY_DIRS',
CLEAR_UPLOAD_DIALOG: 'APP/CLEAR_UPLOAD_DIALOG',
TOGGLE_PROGRESS_DIALOG: 'APP/TOGGLE_PROGRESS_DIALOG',
@@ -547,6 +548,12 @@ export default (state: any = initialState, action: any) => {
//}
// return state;
}
+ case types.TOGGLE_TRUNCATED_DIALOG: {
+ return {
+ ...state,
+ isTruncatedConfirmDialogOpened: !state.isTruncatedConfirmDialogOpened
+ };
+ }
case types.SET_CURRENT_DIRECTORY_DIRS: {
return {
...state,
@@ -1283,6 +1290,9 @@ export const actions = {
type: types.TOGGLE_UPLOAD_DIALOG,
title
}),
+ toggleTruncatedConfirmDialog: () => ({
+ type: types.TOGGLE_TRUNCATED_DIALOG
+ }),
setCurrentDirectoryDirs: dirs => ({
type: types.SET_CURRENT_DIRECTORY_DIRS,
dirs
@@ -1446,13 +1456,15 @@ export const actions = {
)
.then(results => {
if (resultsLimit.IsTruncated) {
- dispatch(
+ // TO DO OPEN ISTRUNCATED dialog
+ dispatch(actions.toggleTruncatedConfirmDialog());
+ /*dispatch(
actions.showNotification(
i18n.t('warningDirectoryIsTruncated') + ': ' + directoryPath,
'error',
false
)
- );
+ );*/
}
updateHistory(currentLocation, directoryPath);
if (results !== undefined) {
@@ -3090,6 +3102,8 @@ export const isImportKanBanDialogOpened = (state: any) =>
state.app.importKanBanDialogOpened;
export const isUploadDialogOpened = (state: any) =>
state.app.uploadDialogOpened;
+export const isTruncatedConfirmDialogOpened = (state: any) =>
+ state.app.isTruncatedConfirmDialogOpened;
export const isOpenLinkDialogOpened = (state: any) =>
state.app.openLinkDialogOpened;
export const isProTeaserVisible = (state: any) => state.app.proTeaserIndex > -1;
diff --git a/tests/create-1000files.js b/tests/create-1000files.js
new file mode 100644
index 000000000..3a896f1d1
--- /dev/null
+++ b/tests/create-1000files.js
@@ -0,0 +1,14 @@
+const fs = require('fs');
+const path = require('path');
+
+const testdir = './testdata-tmp/file-structure/supported-filestypes';
+
+for (let i = 1; i <= 2000; i++) {
+ const fileName = `file${i}.txt`;
+ const fileContent = `This is file number ${i}`;
+ const filePath = path.join(testdir, fileName);
+ fs.writeFile(filePath, fileContent, err => {
+ if (err) throw err;
+ console.log(`File ${fileName} has been created.`);
+ });
+}