Skip to content

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

Issue with move file dialog when called from entry properties (#1949)

Stanimird217b4c4db03
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index 9476ab5de..a0fcfdfd5 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -409,9 +409,9 @@ function EntryProperties(props: Props) {
};
const toggleMoveCopyFilesDialog = () => {
- props.setSelectedEntries([
+ /*props.setSelectedEntries([
{ name: '', isFile: true, tags: [], ...currentEntry.current }
- ]);
+ ]);*/
setMoveCopyFilesDialogOpened(!isMoveCopyFilesDialogOpened);
};
@@ -1394,7 +1394,14 @@ function EntryProperties(props: Props) {
key={getUuid()}
open={isMoveCopyFilesDialogOpened}
onClose={toggleMoveCopyFilesDialog}
- selectedFiles={[currentEntry.current.path]}
+ entries={[
+ {
+ ...currentEntry.current,
+ isFile: currentEntry.current.isFile,
+ name: entryName,
+ tags: []
+ }
+ ]}
/>
)}
{ThumbnailChooserDialog && (
diff --git a/app/components/dialogs/MoveCopyFilesDialog.tsx b/app/components/dialogs/MoveCopyFilesDialog.tsx
index 314d24efa..ed7f634df 100644
--- a/app/components/dialogs/MoveCopyFilesDialog.tsx
+++ b/app/components/dialogs/MoveCopyFilesDialog.tsx
@@ -75,7 +75,8 @@ interface Props {
onUploadProgress?: (progress: Progress, abort: () => void) => void
) => void;
selectedEntries: Array<TS.FileSystemEntry>;
- selectedFiles?: Array<string>;
+ // force to move/copy different entries from selected
+ entries?: Array<TS.FileSystemEntry>;
onUploadProgress: (progress: Progress, abort: () => void) => void;
toggleUploadDialog: (title?) => void;
resetProgress: () => void;
@@ -93,19 +94,25 @@ function MoveCopyFilesDialog(props: Props) {
const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
const { open, onClose } = props;
- let selectedFiles = props.selectedFiles ? props.selectedFiles : [];
- if (props.selectedEntries) {
- selectedFiles = selectedFiles.concat(
- props.selectedEntries
- .filter(fsEntry => fsEntry.isFile)
- .map(fsentry => fsentry.path)
- );
- }
+ let allEntries =
+ props.entries && props.entries.length > 0
+ ? props.entries
+ : props.selectedEntries;
+ /*props.entries && props.entries.length > 0
+ ? [
+ ...props.entries,
+ ...props.selectedEntries.filter(
+ e => !props.entries.some(en => en.path === e.path)
+ )
+ ]
+ : props.selectedEntries;*/
+ //let selectedFiles = props.selectedFiles ? props.selectedFiles : [];
+ const selectedFiles = allEntries
+ ? allEntries.filter(fsEntry => fsEntry.isFile).map(fsentry => fsentry.path)
+ : [];
- const selectedDirs = props.selectedEntries
- ? props.selectedEntries
- .filter(fsEntry => !fsEntry.isFile)
- .map(fsentry => fsentry.path)
+ const selectedDirs = allEntries
+ ? allEntries.filter(fsEntry => !fsEntry.isFile).map(fsentry => fsentry.path)
: [];
useEffect(() => {
@@ -270,9 +277,8 @@ function MoveCopyFilesDialog(props: Props) {
marginBottom: 20
}}
>
- {props.selectedEntries &&
- props.selectedEntries.length > 0 &&
- props.selectedEntries.map(entry => (
+ {allEntries.length > 0 &&
+ allEntries.map(entry => (
<ListItem title={entry.path} key={entry.path}>
<ListItemIcon>
{entry.isFile ? <FileIcon /> : <FolderIcon />}
diff --git a/app/perspectives/list/components/MainContainer.tsx b/app/perspectives/list/components/MainContainer.tsx
index f2e6bf415..9b27d1dd2 100644
--- a/app/perspectives/list/components/MainContainer.tsx
+++ b/app/perspectives/list/components/MainContainer.tsx
@@ -670,11 +670,11 @@ function GridPerspective(props: Props) {
}
};
- const selectedFilePaths = selectedEntries
+ /*const selectedFilePaths = selectedEntries
? selectedEntries
.filter(fsEntry => fsEntry.isFile)
.map(fsentry => fsentry.path)
- : [];
+ : [];*/
const sortedDirectories = sortedDirContent.current.filter(
entry => !entry.isFile
);
@@ -902,7 +902,7 @@ function GridPerspective(props: Props) {
<MoveCopyFilesDialog
open={isMoveCopyFilesDialogOpened}
onClose={() => setIsMoveCopyFilesDialogOpened(false)}
- selectedFiles={selectedFilePaths}
+ // selectedFiles={selectedFilePaths}
/>
)}
{Boolean(fileContextMenuAnchorEl) && (
diff --git a/tests/e2e/folderprops.pw.e2e.js b/tests/e2e/folderprops.pw.e2e.js
index 65e1b7188..181089403 100644
--- a/tests/e2e/folderprops.pw.e2e.js
+++ b/tests/e2e/folderprops.pw.e2e.js
@@ -146,6 +146,8 @@ test.describe('TST02 - Folder properties', () => {
test('TST0207 - Move folder [web,minio,electron]', async () => {
const newFolder = await createNewDirectory('targetFolder');
+ // select folder to move
+ await clickOn(getGridFileSelector('empty_folder'));
await clickOn('[data-tid=moveCopyEntryTID]');
await clickOn('[data-tid=MoveTarget' + newFolder + ']');
await clickOn('[data-tid=confirmMoveFiles]');