Skip to content

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

Moving folder with DnD to another folder should open a preconfigured … (#2329)

Stanimir384540eba8b7
diff --git a/package-lock.json b/package-lock.json
index 5be69b0e4..29e76cd33 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -21,10 +21,10 @@
"@mui/lab": "7.0.0-beta.13",
"@mui/material": "^7.1.1",
"@mui/x-date-pickers": "^8.5.2",
- "@tagspaces/tagspaces-common": "4.5.84",
- "@tagspaces/tagspaces-common-aws3": "4.5.84",
- "@tagspaces/tagspaces-common-cordova": "4.5.84",
- "@tagspaces/tagspaces-indexer": "4.5.84",
+ "@tagspaces/tagspaces-common": "4.5.86",
+ "@tagspaces/tagspaces-common-aws3": "4.5.86",
+ "@tagspaces/tagspaces-common-cordova": "4.5.86",
+ "@tagspaces/tagspaces-indexer": "4.5.86",
"aws-amplify": "^4.3.8",
"clone": "^2.1.2",
"coordinate-parser": "^1.0.7",
@@ -19045,9 +19045,9 @@
}
},
"node_modules/@tagspaces/tagspaces-common": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.84.tgz",
- "integrity": "sha512-LaArC01ofI7+M5afXp9F/9VlO/Y2ULo2774PTo+AC0a1tfJ1X9FO/sKfZsWIJw8ciq/kFNKkrxswjB6bzpxYzQ==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.86.tgz",
+ "integrity": "sha512-K5cC/iqWhaJ7Rw4VqPVmblQRn0kp4/jFpLpuexRZnrJ4QMl1v01oflKBUGCRaP3hkrQT2AjdiKG9Eky23AsWuQ==",
"license": "MIT",
"dependencies": {
"dompurify": "^3.2.3",
@@ -19059,25 +19059,25 @@
}
},
"node_modules/@tagspaces/tagspaces-common-aws3": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-aws3/-/tagspaces-common-aws3-4.5.84.tgz",
- "integrity": "sha512-2gmdIv5faMWNf8pIvnicyB0Bufri0jcVS34VFOIbU6rzd9WVT20//YQVEW4q4pAOC6F/fries6SJQhQrrU9hlQ==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-aws3/-/tagspaces-common-aws3-4.5.86.tgz",
+ "integrity": "sha512-Wx1e+YWTwHfnMIGcrN20RCE0XRQo3e9kKcxYBGCOG4/BH8+MLFuojJSFbXC2oZoJt2mWs6JkC1XJ5zUE5f43ww==",
"license": "MIT",
"dependencies": {
"@aws-sdk/client-s3": "^3.665.0",
"@aws-sdk/lib-storage": "^3.665.0",
"@aws-sdk/s3-request-presigner": "^3.665.0",
- "@tagspaces/tagspaces-common": "^4.5.84",
+ "@tagspaces/tagspaces-common": "^4.5.86",
"crypto-js": "^4.2.0"
}
},
"node_modules/@tagspaces/tagspaces-common-cordova": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-cordova/-/tagspaces-common-cordova-4.5.84.tgz",
- "integrity": "sha512-Hjph3np2v4Tj6jAzL1UAuoSZNmD8yjRfAjqvQmYR/LAGfmLoJnwQSFQkmfkr0EPvbJU7nHjLRPXDKMmudT2q5Q==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-cordova/-/tagspaces-common-cordova-4.5.86.tgz",
+ "integrity": "sha512-/W90KAAS6SYb0AuiiVm22cSFUV3ilBD3YKsidj1OO1FR00p0rwbNfR1sHpmsha8ji/N9kwdwHLouFq+HN4hedQ==",
"license": "MIT",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.84"
+ "@tagspaces/tagspaces-common": "^4.5.86"
}
},
"node_modules/@tagspaces/tagspaces-common/node_modules/cssstyle": {
@@ -19284,12 +19284,12 @@
}
},
"node_modules/@tagspaces/tagspaces-indexer": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.5.84.tgz",
- "integrity": "sha512-jRs8Tsx5yv4FvXJPr8zc90KRth6LxTxaiRLRvuK4gKVpX7JcgDW1ObKe5zY2kHp3a1PdjGG7wk/30kbl1EWRfw==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.5.86.tgz",
+ "integrity": "sha512-zOvdcmW2BPyIp/7IxNTMOdATLoyg1HMoImFMLz4RFz8GZyU8CevDY0rq2trIM56tgMfg/QE2tZkU4ECaaMjY0A==",
"license": "MIT",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.84"
+ "@tagspaces/tagspaces-common": "^4.5.86"
}
},
"node_modules/@tagspacespro/tagspacespro": {
diff --git a/package.json b/package.json
index 814f00a30..7d0406a9e 100644
--- a/package.json
+++ b/package.json
@@ -172,10 +172,10 @@
"@mui/lab": "7.0.0-beta.13",
"@mui/material": "^7.1.1",
"@mui/x-date-pickers": "^8.5.2",
- "@tagspaces/tagspaces-common": "4.5.84",
- "@tagspaces/tagspaces-common-aws3": "4.5.84",
- "@tagspaces/tagspaces-common-cordova": "4.5.84",
- "@tagspaces/tagspaces-indexer": "4.5.84",
+ "@tagspaces/tagspaces-common": "4.5.86",
+ "@tagspaces/tagspaces-common-aws3": "4.5.86",
+ "@tagspaces/tagspaces-common-cordova": "4.5.86",
+ "@tagspaces/tagspaces-indexer": "4.5.86",
"aws-amplify": "^4.3.8",
"clone": "^2.1.2",
"coordinate-parser": "^1.0.7",
diff --git a/release/app/package-lock.json b/release/app/package-lock.json
index 9fe677fbb..2e6f9294d 100644
--- a/release/app/package-lock.json
+++ b/release/app/package-lock.json
@@ -11,9 +11,9 @@
"license": "AGPL-3.0",
"dependencies": {
"@elife/pm2": "3.6.1",
- "@tagspaces/extensions": "1.0.191",
- "@tagspaces/tagspaces-common-node": "4.5.84",
- "@tagspaces/tagspaces-ws": "4.5.84",
+ "@tagspaces/extensions": "1.0.192",
+ "@tagspaces/tagspaces-common-node": "4.5.86",
+ "@tagspaces/tagspaces-ws": "4.5.86",
"sharp": "0.32.6",
"ws": "8.18.1"
},
@@ -147,9 +147,9 @@
}
},
"node_modules/@tagspaces/extensions": {
- "version": "1.0.191",
- "resolved": "https://registry.npmjs.org/@tagspaces/extensions/-/extensions-1.0.191.tgz",
- "integrity": "sha512-uIGKhG6MmTXrkU2dkkLRMP2ippnLZz3bLUB/JFUDgSOxVh9lwYHw74yCbHUr981sTmQZuDw+AoJjM4eKSVqv8g==",
+ "version": "1.0.192",
+ "resolved": "https://registry.npmjs.org/@tagspaces/extensions/-/extensions-1.0.192.tgz",
+ "integrity": "sha512-BFWl+0l97+pBpgokIw4BEjTJh+4KP7BkK+ROzeVDwighrbG6HOqLsDmhmscEyKs25uSm6CC6pOaZphNusvZEzg==",
"dependencies": {
"shelljs": "^0.8.5",
"shx": "^0.3.4"
@@ -160,9 +160,9 @@
}
},
"node_modules/@tagspaces/tagspaces-common": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.84.tgz",
- "integrity": "sha512-LaArC01ofI7+M5afXp9F/9VlO/Y2ULo2774PTo+AC0a1tfJ1X9FO/sKfZsWIJw8ciq/kFNKkrxswjB6bzpxYzQ==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.86.tgz",
+ "integrity": "sha512-K5cC/iqWhaJ7Rw4VqPVmblQRn0kp4/jFpLpuexRZnrJ4QMl1v01oflKBUGCRaP3hkrQT2AjdiKG9Eky23AsWuQ==",
"dependencies": {
"dompurify": "^3.2.3",
"dotenv": "^16.0.2",
@@ -173,22 +173,22 @@
}
},
"node_modules/@tagspaces/tagspaces-common-node": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.5.84.tgz",
- "integrity": "sha512-codH4oV5UVxMYPxKHVANrhzCl6ZGh88NV7e004i5JJLHqfpqufBHXdiGUU2dmH0pFI4BMlu6/soDYTXgWm+3fA==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.5.86.tgz",
+ "integrity": "sha512-ymzguGOfZb593tFh5Bo76BOkut4QUqVy2hTOJFaYD7YPWncXvN0JoK6VJQxE0+2Ws48DjTP8XILSQX7bU/ZMrQ==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.84",
+ "@tagspaces/tagspaces-common": "^4.5.86",
"adm-zip": "0.5.10",
"fs-extra": "^10.0.0",
"klaw": "^4.1.0"
}
},
"node_modules/@tagspaces/tagspaces-indexer": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.5.84.tgz",
- "integrity": "sha512-jRs8Tsx5yv4FvXJPr8zc90KRth6LxTxaiRLRvuK4gKVpX7JcgDW1ObKe5zY2kHp3a1PdjGG7wk/30kbl1EWRfw==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.5.86.tgz",
+ "integrity": "sha512-zOvdcmW2BPyIp/7IxNTMOdATLoyg1HMoImFMLz4RFz8GZyU8CevDY0rq2trIM56tgMfg/QE2tZkU4ECaaMjY0A==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.84"
+ "@tagspaces/tagspaces-common": "^4.5.86"
}
},
"node_modules/@tagspaces/tagspaces-pdf-extraction": {
@@ -209,25 +209,25 @@
}
},
"node_modules/@tagspaces/tagspaces-workers": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.5.84.tgz",
- "integrity": "sha512-+gVhrEkh7EZqJvZ9wJQLoAC/yxBqKTx/qZHJ7ztNi1X/Pfa0B1hHyIEAATqmQzcGQr3xp71ciEIFWC+HBM3D3g==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.5.86.tgz",
+ "integrity": "sha512-ToDKL980IYBoZ3NDOU5pAwOXiXA+JoGUPrMHsjn/08g94K3QgJESDdhX39zEIeiKyuI8OX+V4hmPV5T57fyyyw==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.84",
- "@tagspaces/tagspaces-common-node": "^4.5.84",
+ "@tagspaces/tagspaces-common": "^4.5.86",
+ "@tagspaces/tagspaces-common-node": "^4.5.86",
"@tagspaces/tagspaces-pdf-extraction": "^4.5.53",
"@tagspaces/tagspaces-thumbgen-image": "^4.5.60",
"fswin": "^3.24.829"
}
},
"node_modules/@tagspaces/tagspaces-ws": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.5.84.tgz",
- "integrity": "sha512-2R+Jqj2kDzdX0INqvPcsmPgMYOgE6vOyFXYqopvmkKbtzYKCIrzWzMNxgSovWgKio92d8y8BMIn7DmBCszNA3A==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.5.86.tgz",
+ "integrity": "sha512-ZoCzmCc2RWef/tYgXvWKur5NJ5oiJ1lgjgBy3QnDTJzMsML27cDpVbv3zEpQBQlt0BNz0yp9UFnRCG720z16Ng==",
"dependencies": {
- "@tagspaces/tagspaces-indexer": "^4.5.84",
+ "@tagspaces/tagspaces-indexer": "^4.5.86",
"@tagspaces/tagspaces-pdf-extraction": "^4.5.53",
- "@tagspaces/tagspaces-workers": "^4.5.84",
+ "@tagspaces/tagspaces-workers": "^4.5.86",
"find-free-ports": "^3.1.1",
"jsonwebtoken": "^8.5.1",
"ws": "^8.15.1"
@@ -596,9 +596,9 @@
}
},
"node_modules/dotenv": {
- "version": "16.5.0",
- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
- "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
+ "version": "16.6.0",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.0.tgz",
+ "integrity": "sha512-Omf1L8paOy2VJhILjyhrhqwLIdstqm1BvcDPKg4NGAlkwEu9ODyrFbvk8UymUOMCT+HXo31jg1lArIrVAAhuGA==",
"engines": {
"node": ">=12"
},
@@ -1881,18 +1881,18 @@
}
},
"@tagspaces/extensions": {
- "version": "1.0.191",
- "resolved": "https://registry.npmjs.org/@tagspaces/extensions/-/extensions-1.0.191.tgz",
- "integrity": "sha512-uIGKhG6MmTXrkU2dkkLRMP2ippnLZz3bLUB/JFUDgSOxVh9lwYHw74yCbHUr981sTmQZuDw+AoJjM4eKSVqv8g==",
+ "version": "1.0.192",
+ "resolved": "https://registry.npmjs.org/@tagspaces/extensions/-/extensions-1.0.192.tgz",
+ "integrity": "sha512-BFWl+0l97+pBpgokIw4BEjTJh+4KP7BkK+ROzeVDwighrbG6HOqLsDmhmscEyKs25uSm6CC6pOaZphNusvZEzg==",
"requires": {
"shelljs": "^0.8.5",
"shx": "^0.3.4"
}
},
"@tagspaces/tagspaces-common": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.84.tgz",
- "integrity": "sha512-LaArC01ofI7+M5afXp9F/9VlO/Y2ULo2774PTo+AC0a1tfJ1X9FO/sKfZsWIJw8ciq/kFNKkrxswjB6bzpxYzQ==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.86.tgz",
+ "integrity": "sha512-K5cC/iqWhaJ7Rw4VqPVmblQRn0kp4/jFpLpuexRZnrJ4QMl1v01oflKBUGCRaP3hkrQT2AjdiKG9Eky23AsWuQ==",
"requires": {
"dompurify": "^3.2.3",
"dotenv": "^16.0.2",
@@ -1903,22 +1903,22 @@
}
},
"@tagspaces/tagspaces-common-node": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.5.84.tgz",
- "integrity": "sha512-codH4oV5UVxMYPxKHVANrhzCl6ZGh88NV7e004i5JJLHqfpqufBHXdiGUU2dmH0pFI4BMlu6/soDYTXgWm+3fA==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.5.86.tgz",
+ "integrity": "sha512-ymzguGOfZb593tFh5Bo76BOkut4QUqVy2hTOJFaYD7YPWncXvN0JoK6VJQxE0+2Ws48DjTP8XILSQX7bU/ZMrQ==",
"requires": {
- "@tagspaces/tagspaces-common": "^4.5.84",
+ "@tagspaces/tagspaces-common": "^4.5.86",
"adm-zip": "0.5.10",
"fs-extra": "^10.0.0",
"klaw": "^4.1.0"
}
},
"@tagspaces/tagspaces-indexer": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.5.84.tgz",
- "integrity": "sha512-jRs8Tsx5yv4FvXJPr8zc90KRth6LxTxaiRLRvuK4gKVpX7JcgDW1ObKe5zY2kHp3a1PdjGG7wk/30kbl1EWRfw==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.5.86.tgz",
+ "integrity": "sha512-zOvdcmW2BPyIp/7IxNTMOdATLoyg1HMoImFMLz4RFz8GZyU8CevDY0rq2trIM56tgMfg/QE2tZkU4ECaaMjY0A==",
"requires": {
- "@tagspaces/tagspaces-common": "^4.5.84"
+ "@tagspaces/tagspaces-common": "^4.5.86"
}
},
"@tagspaces/tagspaces-pdf-extraction": {
@@ -1939,25 +1939,25 @@
}
},
"@tagspaces/tagspaces-workers": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.5.84.tgz",
- "integrity": "sha512-+gVhrEkh7EZqJvZ9wJQLoAC/yxBqKTx/qZHJ7ztNi1X/Pfa0B1hHyIEAATqmQzcGQr3xp71ciEIFWC+HBM3D3g==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.5.86.tgz",
+ "integrity": "sha512-ToDKL980IYBoZ3NDOU5pAwOXiXA+JoGUPrMHsjn/08g94K3QgJESDdhX39zEIeiKyuI8OX+V4hmPV5T57fyyyw==",
"requires": {
- "@tagspaces/tagspaces-common": "^4.5.84",
- "@tagspaces/tagspaces-common-node": "^4.5.84",
+ "@tagspaces/tagspaces-common": "^4.5.86",
+ "@tagspaces/tagspaces-common-node": "^4.5.86",
"@tagspaces/tagspaces-pdf-extraction": "^4.5.53",
"@tagspaces/tagspaces-thumbgen-image": "^4.5.60",
"fswin": "^3.24.829"
}
},
"@tagspaces/tagspaces-ws": {
- "version": "4.5.84",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.5.84.tgz",
- "integrity": "sha512-2R+Jqj2kDzdX0INqvPcsmPgMYOgE6vOyFXYqopvmkKbtzYKCIrzWzMNxgSovWgKio92d8y8BMIn7DmBCszNA3A==",
+ "version": "4.5.86",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.5.86.tgz",
+ "integrity": "sha512-ZoCzmCc2RWef/tYgXvWKur5NJ5oiJ1lgjgBy3QnDTJzMsML27cDpVbv3zEpQBQlt0BNz0yp9UFnRCG720z16Ng==",
"requires": {
- "@tagspaces/tagspaces-indexer": "^4.5.84",
+ "@tagspaces/tagspaces-indexer": "^4.5.86",
"@tagspaces/tagspaces-pdf-extraction": "^4.5.53",
- "@tagspaces/tagspaces-workers": "^4.5.84",
+ "@tagspaces/tagspaces-workers": "^4.5.86",
"find-free-ports": "^3.1.1",
"jsonwebtoken": "^8.5.1",
"ws": "^8.15.1"
@@ -2217,9 +2217,9 @@
}
},
"dotenv": {
- "version": "16.5.0",
- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
- "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg=="
+ "version": "16.6.0",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.0.tgz",
+ "integrity": "sha512-Omf1L8paOy2VJhILjyhrhqwLIdstqm1BvcDPKg4NGAlkwEu9ODyrFbvk8UymUOMCT+HXo31jg1lArIrVAAhuGA=="
},
"dunder-proto": {
"version": "1.0.1",
diff --git a/release/app/package.json b/release/app/package.json
index c161c46fa..26476ac81 100644
--- a/release/app/package.json
+++ b/release/app/package.json
@@ -19,8 +19,8 @@
"dependencies": {
"@elife/pm2": "3.6.1",
"@tagspaces/extensions": "1.0.192",
- "@tagspaces/tagspaces-common-node": "4.5.84",
- "@tagspaces/tagspaces-ws": "4.5.84",
+ "@tagspaces/tagspaces-common-node": "4.5.86",
+ "@tagspaces/tagspaces-ws": "4.5.86",
"sharp": "0.32.6",
"ws": "8.18.1"
},
diff --git a/src/renderer/components/DirectoryListView.tsx b/src/renderer/components/DirectoryListView.tsx
index 33789bf27..c0a25e059 100644
--- a/src/renderer/components/DirectoryListView.tsx
+++ b/src/renderer/components/DirectoryListView.tsx
@@ -27,12 +27,14 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
interface Props {
setTargetDir: (dirPath: string) => void;
- currentDirectoryPath?: string;
+ targetPath?: string;
+ targetLocationID?: string;
}
const DirectoryListView: React.FC<Props> = ({
- currentDirectoryPath,
+ targetPath,
setTargetDir,
+ targetLocationID,
}) => {
const { t } = useTranslation();
const { currentLocation, findLocation, locations } =
@@ -41,25 +43,21 @@ const DirectoryListView: React.FC<Props> = ({
const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();
const showUnixHiddenEntries: boolean = useSelector(getShowUnixHiddenEntries);
const chosenLocationId = useRef<string>(
- currentLocation ? currentLocation.uuid : undefined,
+ targetLocationID ? targetLocationID : currentLocation?.uuid,
);
- const chosenDirectory = useRef<string>(currentDirectoryPath);
+ const chosenDirectory = useRef<string>(targetPath);
const [directoryContent, setDirectoryContent] = useState<
TS.FileSystemEntry[]
>(currentDirectoryEntries.filter((entry) => !entry.isFile));
- /*useEffect(() => {
- const chosenLocation = findLocation(chosenLocationId.current);
- if (chosenLocation) {
- const path =
- currentLocation &&
- chosenLocation.uuid === currentLocation.uuid &&
- currentDirectoryPath
- ? currentDirectoryPath
- : chosenLocation.path;
- listDirectory(path);
+ useEffect(() => {
+ if (targetLocationID && targetLocationID !== currentLocation?.uuid) {
+ const chosenLocation = findLocation(chosenLocationId.current);
+ if (chosenLocation) {
+ listDirectory(targetPath);
+ }
}
- }, [chosenLocationId.current]);*/
+ }, []);
const handleLocationChange = (event: React.ChangeEvent<HTMLInputElement>) => {
chosenLocationId.current = event.target.value;
@@ -107,7 +105,7 @@ const DirectoryListView: React.FC<Props> = ({
function listDirectory(directoryPath) {
chosenDirectory.current = directoryPath;
- currentLocation
+ findLocation(chosenLocationId.current)
.listDirectoryPromise(
directoryPath,
[], // mode,
diff --git a/src/renderer/components/DirectoryTreeView.tsx b/src/renderer/components/DirectoryTreeView.tsx
index 718997925..4163af6e7 100644
--- a/src/renderer/components/DirectoryTreeView.tsx
+++ b/src/renderer/components/DirectoryTreeView.tsx
@@ -25,7 +25,6 @@ import TargetTableMoveFileBox from '-/components/TargetTableMoveFileBox';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { getShowUnixHiddenEntries } from '-/reducers/settings';
-import { CommonLocation } from '-/utils/CommonLocation';
import { alpha, useTheme } from '@mui/material/styles';
import { locationType } from '@tagspaces/tagspaces-common/misc';
import Table from 'rc-table';
@@ -42,17 +41,17 @@ import { TS } from '-/tagspaces.namespace';
import { resolveRelativePath } from '-/services/utils-io';
interface Props {
- location: CommonLocation;
+ location: SubFolder;
handleFileMoveDrop: (item, monitor) => void;
}
export interface DirectoryTreeViewRef {
- changeLocation: (location: CommonLocation) => void;
+ changeLocation: (location: SubFolder) => void;
closeLocation: () => void;
}
// Re‐declare SubFolder with explicit types
-interface SubFolder extends TS.FileSystemEntry {
+export interface SubFolder extends TS.FileSystemEntry {
/* accessKeyId?: string;
bucketName?: string;
region?: string;
@@ -61,9 +60,8 @@ interface SubFolder extends TS.FileSystemEntry {
uuid: string;
name: string;
- type: string;
- path: string;*/
-
+ path: string;
+ type: string; */
children?: SubFolder[];
}
@@ -86,7 +84,7 @@ const DirectoryTreeView = forwardRef(
// When currentLocationId changes refresh `data`
useEffect(() => {
- if (data && currentLocationId === location.uuid) {
+ if (data && currentLocationId === location.locationID) {
setData(undefined);
}
}, [currentLocationId]);
@@ -95,13 +93,11 @@ const DirectoryTreeView = forwardRef(
useEffect(() => {
if (
data === undefined &&
- currentLocationId === location.uuid &&
+ currentLocationId === location.locationID &&
currentDirectoryEntries?.length > 0
) {
- const location = findLocation(currentLocationId);
- //resolveRelativePath(location.path).then((path) => {
if (
- currentDirectoryEntries[0].locationID === location.uuid &&
+ currentDirectoryEntries[0].locationID === location.locationID &&
currentDirectoryPath === location.path
) {
attachNewChildren(
@@ -111,12 +107,12 @@ const DirectoryTreeView = forwardRef(
name: location.name,
path: currentDirectoryPath,
size: 0,
- locationID: location.uuid,
+ locationID: location.locationID,
children: [],
},
processDirs(
currentDirectoryEntries,
- location,
+ location.locationID,
showUnixHiddenEntries,
),
);
@@ -126,9 +122,9 @@ const DirectoryTreeView = forwardRef(
}, [data, currentLocationId, currentDirectoryEntries]);
useImperativeHandle(ref, () => ({
- changeLocation(newLocation: CommonLocation) {
+ changeLocation(newLocation: SubFolder) {
if (currentLocationId === undefined) {
- changeLocation(newLocation, true);
+ changeLocation(findLocation(newLocation.locationID), true);
}
if (isExpanded) {
// Collapse (and clear) if already expanded
@@ -141,7 +137,7 @@ const DirectoryTreeView = forwardRef(
name: newLocation.name,
path: newLocation.path,
size: 0,
- locationID: newLocation.uuid,
+ locationID: newLocation.locationID,
children: [],
});
}
@@ -157,13 +153,17 @@ const DirectoryTreeView = forwardRef(
const { FILE } = NativeTypes;
const renderBodyRow = (propsRow: any) => {
- if (AppConfig.isElectron || location.type !== locationType.TYPE_CLOUD) {
+ const subFolderLocation = findLocation(location.locationID);
+ if (
+ AppConfig.isElectron ||
+ subFolderLocation.type !== locationType.TYPE_CLOUD
+ ) {
// DnD to S3 location is not permitted in web browser without <input> element
return (
<TargetFileBox
accepts={[FILE]}
directoryPath={location.path}
- locationId={location.uuid}
+ locationId={subFolderLocation.uuid}
>
<CustomDragLayer />
<TargetTableMoveFileBox
@@ -281,7 +281,7 @@ const DirectoryTreeView = forwardRef(
// console.debug('listDirectoryPromise resolved:' + dirEntries.length);
const directoryContent = processDirs(
dirEntries,
- loc,
+ loc.uuid,
showUnixHiddenEntries,
);
resolve(directoryContent);
@@ -298,13 +298,13 @@ const DirectoryTreeView = forwardRef(
* keeping only "files" (not directories), skipping any hidden or meta-folder entries.
*
* @param entries The array of FileSystemEntry; if undefined, returns [].
- * @param loc A CommonLocation object whose fields will be copied into each SubFolder.
+ * @param locationID A locationID whose fields will be copied into each SubFolder.
* @param showHiddenEntries If false, skip any files whose name starts with a dot.
* @returns An array of SubFolder objects (children always initialized to []).
*/
function processDirs(
entries: TS.FileSystemEntry[] | undefined,
- loc: CommonLocation,
+ locationID: string,
showHiddenEntries: boolean,
): SubFolder[] {
// Early exit if entries is missing or empty
@@ -355,7 +355,7 @@ const DirectoryTreeView = forwardRef(
// 3) Map each remaining FileSystemEntry to SubFolder
.map((entry) => ({
...entry,
- locationID: loc.uuid,
+ locationID: locationID,
children: [] as SubFolder[],
}))
);
@@ -429,7 +429,7 @@ const DirectoryTreeView = forwardRef(
if (isExpanded && data !== undefined) {
return (
<Table
- key={location.uuid}
+ key={location.locationID}
style={{
borderRadius: AppConfig.defaultCSSRadius,
backgroundColor: alpha(theme.palette.grey.A400, 0.2),
@@ -443,7 +443,7 @@ const DirectoryTreeView = forwardRef(
showHeader={false}
// className="table"
rowKey="path"
- data={data[location.uuid]}
+ data={data[location.locationID]}
columns={columns}
indentSize={20}
expandable={{ onExpand }}
diff --git a/src/renderer/components/FileUploadContainer.tsx b/src/renderer/components/FileUploadContainer.tsx
index 9f39a06db..ce73a6e43 100644
--- a/src/renderer/components/FileUploadContainer.tsx
+++ b/src/renderer/components/FileUploadContainer.tsx
@@ -17,7 +17,6 @@
*/
import AppConfig from '-/AppConfig';
-import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
@@ -39,6 +38,7 @@ interface Props {
export interface FileUploadContainerRef {
onFileUpload: (directoryPath: string) => void;
+ onMetaUpload: () => void;
}
const FileUploadContainer = forwardRef(
@@ -46,16 +46,22 @@ const FileUploadContainer = forwardRef(
const dispatch: AppDispatch = useDispatch();
const { id } = props;
const { findLocalLocation } = useCurrentLocationContext();
- const { openFileUploadDialog } = useFileUploadDialogContext();
- const { uploadFilesAPI } = useIOActionsContext();
+ //const { openFileUploadDialog } = useFileUploadDialogContext();
+ const { uploadFilesAPI, uploadMeta } = useIOActionsContext();
const { setReflectMetaActions } = useEditedEntryMetaContext();
const directoryPath = useRef<string>(undefined);
+ const metaUpload = useRef<() => void>(undefined);
const onUploadProgress = (progress, abort, fileName) => {
dispatch(AppActions.onUploadProgress(progress, abort, fileName));
};
useImperativeHandle(ref, () => ({
+ onMetaUpload() {
+ if (metaUpload.current) {
+ metaUpload.current();
+ }
+ },
onFileUpload(dirPath: string) {
directoryPath.current = dirPath;
/* if (AppConfig.isCordovaAndroid) {
@@ -100,7 +106,7 @@ const FileUploadContainer = forwardRef(
// console.log("Selected File: "+JSON.stringify(selection.currentTarget.files[0]));
// const file = selection.currentTarget.files[0];
dispatch(AppActions.resetProgress());
- openFileUploadDialog();
+ // openFileUploadDialog();
const localLocation = findLocalLocation();
const sourceLocationId = localLocation ? localLocation.uuid : undefined;
@@ -117,7 +123,7 @@ const FileUploadContainer = forwardRef(
files,
directoryPath.current,
onUploadProgress,
- true,
+ false,
true,
undefined,
sourceLocationId,
@@ -133,6 +139,15 @@ const FileUploadContainer = forwardRef(
.catch((error) => {
console.log('uploadFiles', error);
});
+ metaUpload.current = () =>
+ uploadMeta(
+ files.map((f) => f.path),
+ directoryPath.current,
+ onUploadProgress,
+ false,
+ undefined,
+ sourceLocationId,
+ );
}
const inputId = id || `id-${Math.random().toString(36).substr(2, 9)}`;
diff --git a/src/renderer/components/LocationManager.tsx b/src/renderer/components/LocationManager.tsx
index 4b4221b7d..229928e0d 100644
--- a/src/renderer/components/LocationManager.tsx
+++ b/src/renderer/components/LocationManager.tsx
@@ -27,6 +27,9 @@ import { Box, List } from '@mui/material';
import { useRef, useState } from 'react';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
import { useTranslation } from 'react-i18next';
+import { TS } from '-/tagspaces.namespace';
+import { useSelector } from 'react-redux';
+import { getLocations } from '-/reducers/locations';
/*const CreateEditLocationDialog = React.lazy(
() =>
@@ -51,7 +54,6 @@ interface Props {
function LocationManager(props: Props) {
const { t } = useTranslation();
const {
- locations,
findLocation,
moveLocation,
deleteLocation,
@@ -61,7 +63,7 @@ function LocationManager(props: Props) {
} = useCurrentLocationContext();
const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();
- //const locations: Array<CommonLocation> = useSelector(getLocations);
+ const locations: TS.Location[] = useSelector(getLocations);
// const loading: boolean = useSelector(isLoading);
//const language: string = useSelector(getCurrentLanguage);
const fileInputRef = useRef<HTMLInputElement>(null);
@@ -196,7 +198,15 @@ function LocationManager(props: Props) {
>
<LocationView
key={location.uuid}
- location={location}
+ location={{
+ isFile: false,
+ lmdt: 0,
+ name: location.name,
+ path: location.path,
+ size: 0,
+ locationID: location.uuid,
+ children: [],
+ }}
setDeleteLocationDialogOpened={
setDeleteLocationDialogOpened
}
diff --git a/src/renderer/components/LocationView.tsx b/src/renderer/components/LocationView.tsx
index 3bb847304..44ace4f46 100644
--- a/src/renderer/components/LocationView.tsx
+++ b/src/renderer/components/LocationView.tsx
@@ -26,12 +26,12 @@ import {
import CustomDragLayer from '-/components/CustomDragLayer';
import DirectoryTreeView, {
DirectoryTreeViewRef,
+ SubFolder,
} from '-/components/DirectoryTreeView';
import TargetFileBox from '-/components/TargetFileBox';
import Tooltip from '-/components/Tooltip';
import TsIconButton from '-/components/TsIconButton';
import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';
-import { useMoveOrCopyFilesDialogContext } from '-/components/dialogs/hooks/useMoveOrCopyFilesDialogContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
@@ -39,7 +39,6 @@ import { useNotificationContext } from '-/hooks/useNotificationContext';
import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';
import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
import { TS } from '-/tagspaces.namespace';
-import { CommonLocation } from '-/utils/CommonLocation';
import { Box, ListItemText } from '@mui/material';
import ListItem from '@mui/material/ListItem';
import ListItemIcon from '@mui/material/ListItemIcon';
@@ -53,9 +52,11 @@ import { useDispatch } from 'react-redux';
import { actions as AppActions, AppDispatch } from '../reducers/app';
import DragItemTypes from './DragItemTypes';
import TargetMoveFileBox from './TargetMoveFileBox';
+import { useMenuContext } from '-/components/dialogs/hooks/useMenuContext';
+import { CommonLocation } from '-/utils/CommonLocation';
interface Props {
- location: CommonLocation;
+ location: SubFolder;
hideDrawer?: () => void;
setDeleteLocationDialogOpened: (open: boolean) => void;
}
@@ -66,12 +67,13 @@ function LocationView(props: Props) {
const { uploadFiles } = useIOActionsContext();
const { openFileUploadDialog } = useFileUploadDialogContext();
const {
+ findLocation,
openLocation,
currentLocation,
setSelectedLocation,
setLocationDirectoryContextMenuAnchorEl,
} = useCurrentLocationContext();
- const { openMoveOrCopyFilesDialog } = useMoveOrCopyFilesDialogContext();
+ const { openMoveCopyFilesDialog } = useMenuContext();
const { setActions } = usePerspectiveActionsContext();
const { setSelectedEntries, selectedEntries } = useSelectedEntriesContext();
const { currentLocationPath, openDirectory } = useDirectoryContentContext();
@@ -81,7 +83,8 @@ function LocationView(props: Props) {
const dispatch: AppDispatch = useDispatch();
const { location, hideDrawer } = props;
- const isCloudLocation = location?.type === locationType.TYPE_CLOUD;
+ const subFolderLocation = findLocation(location.locationID);
+ const isCloudLocation = subFolderLocation?.type === locationType.TYPE_CLOUD;
const handleLocationIconClick = (
event: React.MouseEvent<HTMLSpanElement, MouseEvent>,
@@ -94,21 +97,24 @@ function LocationView(props: Props) {
};
const handleLocationClick = () => {
- if (currentLocation && location.uuid === currentLocation.uuid) {
+ if (currentLocation && location.locationID === currentLocation.uuid) {
// the same location click
openDirectory(currentLocationPath).then(() => {
const action: TS.PerspectiveActions = { action: 'reload' };
setActions(action);
});
} else {
- openLocation(location);
+ openLocation(subFolderLocation);
if (hideDrawer) {
hideDrawer();
}
}
};
- const handleLocationContextMenuClick = (event: any, chosenLocation) => {
+ const handleLocationContextMenuClick = (
+ event: any,
+ chosenLocation: CommonLocation,
+ ) => {
event.preventDefault();
event.stopPropagation();
setSelectedLocation(chosenLocation);
@@ -142,8 +148,9 @@ function LocationView(props: Props) {
showNotification(t('core:dndDisabledReadOnlyMode'), 'error', true);
return;
}
- const targetLocation = item.targetLocation;
- let targetPath = targetLocation ? targetLocation.path : undefined;
+ const itemLocation = item.targetLocation;
+ const targetLocation = findLocation(itemLocation?.locationID);
+ let targetPath = itemLocation ? itemLocation.path : undefined;
if (targetPath === undefined) {
targetPath = item.targetPath;
}
@@ -168,7 +175,8 @@ function LocationView(props: Props) {
} else if (targetLocation.type === locationType.TYPE_LOCAL) {
const entries =
selectedEntries.length > 0 ? selectedEntries : [entry];
- openMoveOrCopyFilesDialog(entries, targetPath, targetLocation.uuid);
+ openMoveCopyFilesDialog(entries, targetPath, targetLocation.uuid);
+ //openMoveOrCopyFilesDialog(entries, targetPath, targetLocation.uuid);
//moveFiles(arrPath, targetPath, targetLocation.uuid);
} else {
showNotification(t('Moving file not possible'), 'error', true);
@@ -180,11 +188,13 @@ function LocationView(props: Props) {
};
let locationNameTitle = location?.path;
- if (isCloudLocation && location?.bucketName) {
- if (location.endpointURL) {
- locationNameTitle = location.endpointURL + ' - ' + location.bucketName;
- } else if (location.region) {
- locationNameTitle = location.region + ' - ' + location.bucketName;
+ if (isCloudLocation && subFolderLocation?.bucketName) {
+ if (subFolderLocation.endpointURL) {
+ locationNameTitle =
+ subFolderLocation.endpointURL + ' - ' + subFolderLocation.bucketName;
+ } else if (subFolderLocation.region) {
+ locationNameTitle =
+ subFolderLocation.region + ' - ' + subFolderLocation.bucketName;
}
}
@@ -239,7 +249,7 @@ function LocationView(props: Props) {
}}
onClick={handleLocationClick}
onContextMenu={(event) =>
- handleLocationContextMenuClick(event, location)
+ handleLocationContextMenuClick(event, subFolderLocation)
}
>
<ListItemIcon
@@ -281,7 +291,7 @@ function LocationView(props: Props) {
</TargetMoveFileBox>
)}
</ListItemText>
- {location?.isDefault && (
+ {subFolderLocation?.isDefault && (
<Tooltip title={t('core:thisIsStartupLocation')}>
<DefaultLocationIcon data-tid="startupIndication" />
</Tooltip>
@@ -291,9 +301,11 @@ function LocationView(props: Props) {
aria-haspopup="true"
edge="end"
data-tid={'locationMoreButton_' + location.name}
- onClick={(event) => handleLocationContextMenuClick(event, location)}
+ onClick={(event) =>
+ handleLocationContextMenuClick(event, subFolderLocation)
+ }
onContextMenu={(event) =>
- handleLocationContextMenuClick(event, location)
+ handleLocationContextMenuClick(event, subFolderLocation)
}
>
<MoreMenuIcon />
diff --git a/src/renderer/components/TargetMoveFileBox.tsx b/src/renderer/components/TargetMoveFileBox.tsx
index 685996646..511301bd0 100644
--- a/src/renderer/components/TargetMoveFileBox.tsx
+++ b/src/renderer/components/TargetMoveFileBox.tsx
@@ -17,15 +17,16 @@
*/
import AppConfig from '-/AppConfig';
-import { CommonLocation } from '-/utils/CommonLocation';
import { useDrop } from 'react-dnd';
+import { TS } from '-/tagspaces.namespace';
+import { SubFolder } from '-/components/DirectoryTreeView';
interface Props {
accepts: string[];
onDrop: (item: any, monitor: any) => void;
children: any;
targetPath?: string;
- targetLocation?: CommonLocation;
+ targetLocation?: SubFolder;
}
const TargetMoveFileBox = (props: Props) => {
diff --git a/src/renderer/components/dialogs/FileUploadDialog.tsx b/src/renderer/components/dialogs/FileUploadDialog.tsx
index c26b76312..35ba864ab 100644
--- a/src/renderer/components/dialogs/FileUploadDialog.tsx
+++ b/src/renderer/components/dialogs/FileUploadDialog.tsx
@@ -43,6 +43,7 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import AppConfig from '-/AppConfig';
import { uploadAbort } from '-/services/utils-io';
+import { useFileUploadContext } from '-/hooks/useFileUploadContext';
interface Props {
open: boolean;
@@ -59,6 +60,7 @@ function FileUploadDialog(props: Props) {
const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
const { currentDirectoryPath } = useDirectoryContentContext();
const { findLocation } = useCurrentLocationContext();
+ const { uploadMeta } = useFileUploadContext();
const progress = useSelector(getProgress);
const targetPath = React.useRef<string>(getTargetPath()); // todo ContextProvider
@@ -157,6 +159,7 @@ function FileUploadDialog(props: Props) {
}
return '/';
}
+ const completed = progress?.filter((item) => item.progress === 100);
return (
<Dialog
@@ -172,9 +175,14 @@ function FileUploadDialog(props: Props) {
slotProps={{ backdrop: { style: { backgroundColor: 'transparent' } } }}
>
<TsDialogTitle
- dialogTitle={t(
- 'core:' + (title && title.length > 0 ? title : 'importDialogTitle'),
- )}
+ dialogTitle={
+ t(
+ 'core:' + (title && title.length > 0 ? title : 'importDialogTitle'),
+ ) +
+ (progress
+ ? ' (' + completed.length + '/' + progress.length + ')'
+ : '')
+ }
closeButtonTestId="closeFileUploadTID"
onClose={onClose}
/>
@@ -239,14 +247,16 @@ function FileUploadDialog(props: Props) {
)}
</Grid>
<Grid size={{ xs: 2 }}>
- {abort && typeof abort === 'function' && (
- <TsButton
- tooltip={t('core:abort')}
- onClick={() => abort()}
- >
- <CloseIcon />
- </TsButton>
- )}
+ {abort &&
+ typeof abort === 'function' &&
+ percentage !== 100 && (
+ <TsButton
+ tooltip={t('core:abort')}
+ onClick={() => abort()}
+ >
+ <CloseIcon />
+ </TsButton>
+ )}
</Grid>
<Grid size={{ xs: 12 }}>
{percentage > -1 && (
@@ -258,16 +268,29 @@ function FileUploadDialog(props: Props) {
})}
</DialogContent>
<TsDialogActions>
- {!haveProgress && (
- <TsButton
- data-tid="uploadCloseAndClearTID"
- onClick={() => {
- onClose();
- dispatch(AppActions.resetProgress());
- }}
- >
- {t('core:closeAndClear')}
- </TsButton>
+ {progress && progress.length > 0 && !haveProgress && (
+ <>
+ {AppConfig.isElectron && (
+ <TsButton
+ data-tid="uploadMetaTID"
+ onClick={() => {
+ uploadMeta();
+ }}
+ >
+ {t('core:uploadMeta')}
+ </TsButton>
+ )}
+
+ <TsButton
+ data-tid="uploadCloseAndClearTID"
+ onClick={() => {
+ onClose();
+ dispatch(AppActions.resetProgress());
+ }}
+ >
+ {t('core:closeAndClear')}
+ </TsButton>
+ </>
)}
<TsButton data-tid="uploadMinimizeDialogTID" onClick={onClose}>
{t('core:minimize')}
diff --git a/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx b/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx
index f03ca1851..b69559ef6 100644
--- a/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx
+++ b/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx
@@ -33,11 +33,14 @@ interface Props {
onClose: (clearSelection?: boolean) => void;
// force to move/copy different entries from selected
entries: TS.FileSystemEntry[];
+ targetDir?: string;
+ targetLocationId?: string;
}
function MoveCopyFilesDialog(props: Props) {
const { t } = useTranslation();
const dispatch: AppDispatch = useDispatch();
+ const { open, entries, onClose, targetDir, targetLocationId } = props;
const { findLocation } = useCurrentLocationContext();
const { currentDirectoryPath } = useDirectoryContentContext();
const { handleEntryExist, openEntryExistDialog } =
@@ -46,14 +49,14 @@ function MoveCopyFilesDialog(props: Props) {
const { openFileUploadDialog } = useFileUploadDialogContext();
const [targetPath, setTargetPath] = useState(
- currentDirectoryPath ? currentDirectoryPath : '',
+ targetDir ? targetDir : currentDirectoryPath,
);
const dirProp = useRef({});
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
- const { open, entries, onClose } = props;
const currentLocation = findLocation();
+ const targetLocation = findLocation(targetLocationId);
const selectedFiles = entries
? entries.filter((fsEntry) => fsEntry.isFile).map((fsentry) => fsentry.path)
@@ -106,7 +109,7 @@ function MoveCopyFilesDialog(props: Props) {
copyFiles(
selectedFiles,
targetPath,
- currentLocation.uuid,
+ targetLocation.uuid,
onUploadProgress,
);
setTargetPath('');
@@ -115,7 +118,7 @@ function MoveCopyFilesDialog(props: Props) {
copyDirs(
getEntriesCount(selectedDirs),
targetPath,
- currentLocation.uuid,
+ targetLocation.uuid,
onUploadProgress,
);
}
@@ -131,7 +134,7 @@ function MoveCopyFilesDialog(props: Props) {
moveFiles(
selectedFiles,
targetPath,
- currentLocation.uuid,
+ targetLocation.uuid,
onUploadProgress,
true,
true,
@@ -144,7 +147,7 @@ function MoveCopyFilesDialog(props: Props) {
moveDirs(
getEntriesCount(selectedDirs),
targetPath,
- currentLocation.uuid,
+ targetLocation.uuid,
onUploadProgress,
);
}
@@ -220,7 +223,8 @@ function MoveCopyFilesDialog(props: Props) {
</List>
<DirectoryListView
setTargetDir={setTargetPath}
- currentDirectoryPath={currentDirectoryPath}
+ targetPath={targetPath}
+ targetLocationID={targetLocation?.uuid}
/>
<Box style={{ marginTop: 10 }}>
{targetPath ? (
diff --git a/src/renderer/components/dialogs/hooks/FileUploadDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/FileUploadDialogContextProvider.tsx
index bfa89b235..d1c284a38 100644
--- a/src/renderer/components/dialogs/hooks/FileUploadDialogContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/FileUploadDialogContextProvider.tsx
@@ -16,8 +16,17 @@
*
*/
-import React, { createContext, useMemo, useReducer, useRef } from 'react';
+import React, {
+ createContext,
+ useEffect,
+ useMemo,
+ useReducer,
+ useRef,
+} from 'react';
import FileUploadDialog from '-/components/dialogs/FileUploadDialog';
+import { useSelector } from 'react-redux';
+import { getProgress } from '-/reducers/app';
+import useFirstRender from '-/utils/useFirstRender';
type FileUploadDialogContextData = {
openFileUploadDialog: (targetPath?: string, dialogTitle?: string) => void;
@@ -40,9 +49,22 @@ export const FileUploadDialogContextProvider = ({
const open = useRef<boolean>(false);
const targetPath = useRef<string>(undefined);
const dialogTitle = useRef<string>('importDialogTitle');
+ const progress = useSelector(getProgress);
+ const firstRender = useFirstRender();
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
+ useEffect(() => {
+ if (
+ !firstRender &&
+ !open.current &&
+ Array.isArray(progress) &&
+ progress.length > 0
+ ) {
+ openDialog();
+ }
+ }, [progress]);
+
function openDialog(tPath?: string, dTitle?: string) {
open.current = true;
targetPath.current = tPath;
diff --git a/src/renderer/components/dialogs/hooks/MenuContextProvider.tsx b/src/renderer/components/dialogs/hooks/MenuContextProvider.tsx
index aab18db9c..cc6893b3c 100644
--- a/src/renderer/components/dialogs/hooks/MenuContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/MenuContextProvider.tsx
@@ -52,7 +52,11 @@ type MenuContextData = {
closeDirectoryMenu: () => void;
openRenameEntryDialog: () => void;
closeRenameEntryDialog: () => void;
- openMoveCopyFilesDialog: (entries?: TS.FileSystemEntry[]) => void;
+ openMoveCopyFilesDialog: (
+ entries?: TS.FileSystemEntry[],
+ targetDirectory?: string,
+ targetLocationId?: string,
+ ) => void;
closeMoveCopyFilesDialog: () => void;
openAddRemoveTagsDialog: (entries?: TS.FileSystemEntry[]) => void;
closeAddRemoveTagsDialog: () => void;
@@ -113,6 +117,8 @@ export const MenuContextProvider = ({ children }: MenuContextProviderProps) => {
const [fileContextMenuAnchorEl, setFileContextMenuAnchorEl] =
useState<null | HTMLElement>(null);
const currentEntries = useRef<TS.FileSystemEntry[]>(undefined);
+ const targetDirectory = useRef<string>(undefined);
+ const targetLocationId = useRef<string>(undefined);
const openRenameEntry = useRef<boolean>(false);
const openMoveCopyFiles = useRef<boolean>(false);
const openAddRemoveTags = useRef<boolean>(false);
@@ -209,9 +215,15 @@ export const MenuContextProvider = ({ children }: MenuContextProviderProps) => {
forceUpdate();
};
- const openMoveCopyFilesDialog = (entries?: TS.FileSystemEntry[]) => {
+ const openMoveCopyFilesDialog = (
+ entries?: TS.FileSystemEntry[],
+ tDirectory?: string,
+ tLocationId?: string,
+ ) => {
openMoveCopyFiles.current = true;
currentEntries.current = entries;
+ targetDirectory.current = tDirectory;
+ targetLocationId.current = tLocationId;
forceUpdate();
};
@@ -311,6 +323,8 @@ export const MenuContextProvider = ({ children }: MenuContextProviderProps) => {
entries={
currentEntries.current ? currentEntries.current : selectedEntries
}
+ targetDir={targetDirectory.current}
+ targetLocationId={targetLocationId.current}
/>
<AddRemoveTagsDialogAsync
open={openAddRemoveTags.current}
diff --git a/src/renderer/containers/DialogsRoot.tsx b/src/renderer/containers/DialogsRoot.tsx
index bca48cb31..568d59857 100644
--- a/src/renderer/containers/DialogsRoot.tsx
+++ b/src/renderer/containers/DialogsRoot.tsx
@@ -34,7 +34,6 @@ import { ProTeaserDialogContextProvider } from '-/components/dialogs/hooks/ProTe
import { SettingsDialogContextProvider } from '-/components/dialogs/hooks/SettingsDialogContextProvider';
import { DeleteMultipleEntriesDialogContextProvider } from '-/components/dialogs/hooks/DeleteMultipleEntriesDialogContextProvider';
import { ResolveConflictContextProvider } from '-/components/dialogs/hooks/ResolveConflictContextProvider';
-import { FileUploadContextProvider } from '-/hooks/FileUploadContextProvider';
import { DownloadUrlContextProvider } from '-/components/dialogs/hooks/DownloadUrlDialogContextProvider';
import { AiGenerationDialogContextProvider } from '-/components/dialogs/hooks/AiGenerationDialogContextProvider';
import { MenuContextProvider } from '-/components/dialogs/hooks/MenuContextProvider';
@@ -47,45 +46,43 @@ function DialogsRoot({ children }: DialogsRootProps) {
return (
<EntryExistDialogContextProvider>
<DeleteMultipleEntriesDialogContextProvider>
- <FileUploadContextProvider>
- <CreateEditLocationDialogContextProvider>
- <MoveOrCopyFilesDialogContextProvider>
- <CreateDirectoryDialogContextProvider>
- <ProgressDialogContextProvider>
- <NewFileDialogContextProvider>
- <NewAudioDialogContextProvider>
- <LicenseDialogContextProvider>
- <ThirdPartyLibsDialogContextProvider>
- <AboutDialogContextProvider>
- <OnboardingDialogContextProvider>
- <KeyboardDialogContextProvider>
- <LinkDialogContextProvider>
- <ProTeaserDialogContextProvider>
- <AiGenerationDialogContextProvider>
- <SettingsDialogContextProvider>
- <ResolveConflictContextProvider>
- <DownloadUrlContextProvider>
- <MenuContextProvider>
- {children}
- </MenuContextProvider>
- </DownloadUrlContextProvider>
- </ResolveConflictContextProvider>
- </SettingsDialogContextProvider>
- </AiGenerationDialogContextProvider>
- </ProTeaserDialogContextProvider>
- </LinkDialogContextProvider>
- </KeyboardDialogContextProvider>
- </OnboardingDialogContextProvider>
- </AboutDialogContextProvider>
- </ThirdPartyLibsDialogContextProvider>
- </LicenseDialogContextProvider>
- </NewAudioDialogContextProvider>
- </NewFileDialogContextProvider>
- </ProgressDialogContextProvider>
- </CreateDirectoryDialogContextProvider>
- </MoveOrCopyFilesDialogContextProvider>
- </CreateEditLocationDialogContextProvider>
- </FileUploadContextProvider>
+ <CreateEditLocationDialogContextProvider>
+ <MoveOrCopyFilesDialogContextProvider>
+ <CreateDirectoryDialogContextProvider>
+ <ProgressDialogContextProvider>
+ <NewFileDialogContextProvider>
+ <NewAudioDialogContextProvider>
+ <LicenseDialogContextProvider>
+ <ThirdPartyLibsDialogContextProvider>
+ <AboutDialogContextProvider>
+ <OnboardingDialogContextProvider>
+ <KeyboardDialogContextProvider>
+ <LinkDialogContextProvider>
+ <ProTeaserDialogContextProvider>
+ <AiGenerationDialogContextProvider>
+ <SettingsDialogContextProvider>
+ <ResolveConflictContextProvider>
+ <DownloadUrlContextProvider>
+ <MenuContextProvider>
+ {children}
+ </MenuContextProvider>
+ </DownloadUrlContextProvider>
+ </ResolveConflictContextProvider>
+ </SettingsDialogContextProvider>
+ </AiGenerationDialogContextProvider>
+ </ProTeaserDialogContextProvider>
+ </LinkDialogContextProvider>
+ </KeyboardDialogContextProvider>
+ </OnboardingDialogContextProvider>
+ </AboutDialogContextProvider>
+ </ThirdPartyLibsDialogContextProvider>
+ </LicenseDialogContextProvider>
+ </NewAudioDialogContextProvider>
+ </NewFileDialogContextProvider>
+ </ProgressDialogContextProvider>
+ </CreateDirectoryDialogContextProvider>
+ </MoveOrCopyFilesDialogContextProvider>
+ </CreateEditLocationDialogContextProvider>
</DeleteMultipleEntriesDialogContextProvider>
</EntryExistDialogContextProvider>
);
diff --git a/src/renderer/containers/Root.tsx b/src/renderer/containers/Root.tsx
index 735602528..cea57f595 100644
--- a/src/renderer/containers/Root.tsx
+++ b/src/renderer/containers/Root.tsx
@@ -55,6 +55,7 @@ import { FileUploadDialogContextProvider } from '-/components/dialogs/hooks/File
import { EntryPropsTabsContextProvider } from '-/hooks/EntryPropsTabsContextProvider';
import { SearchQueryContextProvider } from '-/hooks/SearchQueryContextProvider';
import { HistoryContextProvider } from '-/hooks/HistoryContextProvider';
+import { FileUploadContextProvider } from '-/hooks/FileUploadContextProvider';
type RootType = {
store: Store<{}>;
@@ -99,29 +100,31 @@ export default function Root({ store, persistor }: RootType) {
<SavedSearchesContextProvider>
<SearchQueryContextProvider>
<BrowserHistoryContextProvider>
- <FileUploadDialogContextProvider>
- <ChatContextProvider>
- <HistoryContextProvider>
- {Pro ? (
- <Pro.contextProviders.BookmarksContextProvider>
- <Pro.contextProviders.KanBanImportDialogContextProvider>
- <Pro.contextProviders.ThumbDialogContextProvider>
- <Pro.contextProviders.BgndDialogContextProvider>
- <DialogsRoot>
- <MainPage />
- </DialogsRoot>
- </Pro.contextProviders.BgndDialogContextProvider>
- </Pro.contextProviders.ThumbDialogContextProvider>
- </Pro.contextProviders.KanBanImportDialogContextProvider>
- </Pro.contextProviders.BookmarksContextProvider>
- ) : (
- <DialogsRoot>
- <MainPage />
- </DialogsRoot>
- )}
- </HistoryContextProvider>
- </ChatContextProvider>
- </FileUploadDialogContextProvider>
+ <FileUploadContextProvider>
+ <FileUploadDialogContextProvider>
+ <ChatContextProvider>
+ <HistoryContextProvider>
+ {Pro ? (
+ <Pro.contextProviders.BookmarksContextProvider>
+ <Pro.contextProviders.KanBanImportDialogContextProvider>
+ <Pro.contextProviders.ThumbDialogContextProvider>
+ <Pro.contextProviders.BgndDialogContextProvider>
+ <DialogsRoot>
+ <MainPage />
+ </DialogsRoot>
+ </Pro.contextProviders.BgndDialogContextProvider>
+ </Pro.contextProviders.ThumbDialogContextProvider>
+ </Pro.contextProviders.KanBanImportDialogContextProvider>
+ </Pro.contextProviders.BookmarksContextProvider>
+ ) : (
+ <DialogsRoot>
+ <MainPage />
+ </DialogsRoot>
+ )}
+ </HistoryContextProvider>
+ </ChatContextProvider>
+ </FileUploadDialogContextProvider>
+ </FileUploadContextProvider>
</BrowserHistoryContextProvider>
</SearchQueryContextProvider>
</SavedSearchesContextProvider>
diff --git a/src/renderer/hooks/FileUploadContextProvider.tsx b/src/renderer/hooks/FileUploadContextProvider.tsx
index 87e255c5f..73fb99be2 100644
--- a/src/renderer/hooks/FileUploadContextProvider.tsx
+++ b/src/renderer/hooks/FileUploadContextProvider.tsx
@@ -23,10 +23,12 @@ import FileUploadContainer, {
type FileUploadContextData = {
openFileUpload: (dPath: string) => void;
+ uploadMeta: () => void;
};
export const FileUploadContext = createContext<FileUploadContextData>({
openFileUpload: undefined,
+ uploadMeta: undefined,
});
export type FileUploadContextProviderProps = {
@@ -39,12 +41,17 @@ export const FileUploadContextProvider = ({
const fileUploadContainerRef = useRef<FileUploadContainerRef>(null);
function openFileUpload(dPath: string) {
- fileUploadContainerRef.current.onFileUpload(dPath);
+ fileUploadContainerRef.current?.onFileUpload(dPath);
+ }
+
+ function uploadMeta() {
+ fileUploadContainerRef.current?.onMetaUpload();
}
const context = useMemo(() => {
return {
openFileUpload: openFileUpload,
+ uploadMeta: uploadMeta,
};
}, []);
diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsx
index 2ada06c44..5027a62cd 100644
--- a/src/renderer/hooks/IOActionsContextProvider.tsx
+++ b/src/renderer/hooks/IOActionsContextProvider.tsx
@@ -40,6 +40,7 @@ import {
cleanFrontDirSeparator,
generateFileName,
getMetaContentFileLocation,
+ getFileLocationFromMetaFile,
} from '@tagspaces/tagspaces-common/paths';
import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
@@ -125,6 +126,14 @@ type IOActionsContextData = {
targetLocationId?: string,
sourceLocationId?: string,
) => Promise<TS.FileSystemEntry[]>;
+ uploadMeta: (
+ files: Array<any>,
+ targetPath: string,
+ onUploadProgress?: (progress, abort, fileName?) => void,
+ open?: boolean,
+ targetLocationId?: string,
+ sourceLocationId?: string,
+ ) => Promise<TS.FileSystemEntry[]>;
uploadFiles: (
paths: Array<string>,
targetPath: string,
@@ -239,6 +248,7 @@ export const IOActionsContext = createContext<IOActionsContextData>({
downloadUrl: undefined,
downloadFsEntry: undefined,
uploadFilesAPI: undefined,
+ uploadMeta: undefined,
uploadFiles: undefined,
renameDirectory: undefined,
renameFile: undefined,
@@ -1152,11 +1162,12 @@ export const IOActionsContextProvider = ({
onUploadProgress?: (progress, response) => void,
reflect: boolean = true,
locationID: string = undefined,
- ) {
+ override = false,
+ ): Promise<TS.FileSystemEntry> {
return findLocation(locationID)
.getPropertiesPromise(filePath)
.then((entryProps) => {
- if (entryProps) {
+ if (entryProps && !override) {
showNotification(
'File with the same name already exist, importing skipped!',
'warning',
@@ -1203,7 +1214,92 @@ export const IOActionsContextProvider = ({
})
.catch((err) => {
console.log('Error getting properties', err);
+ return undefined;
+ });
+ }
+
+ interface job {
+ src: string;
+ dst: string;
+ type: 'meta' | 'thumb' | 'file';
+ originalPathForThumb?: string;
+ }
+ /**
+ * Uploads the “.meta” and thumbnail files.
+ * Returns a Promise that resolves when *all* meta/thumb uploads settle.
+ */
+ function uploadMeta(
+ paths: string[],
+ targetPath: string,
+ onUploadProgress?: (progress, response) => void,
+ open = true,
+ targetLocationId: string = undefined,
+ sourceLocationId: string = undefined,
+ ): Promise<TS.FileSystemEntry[]> {
+ const metaJobs: job[] = [];
+
+ for (let i = 0; i < paths.length; i++) {
+ const src = paths[i];
+ let dst = joinPaths(
+ currentLocation?.getDirSeparator(),
+ targetPath,
+ extractFileName(src, AppConfig.dirSeparator),
+ );
+ // meta file
+ metaJobs.push({
+ src: getMetaFileLocationForFile(src, AppConfig.dirSeparator),
+ dst: getMetaFileLocationForFile(
+ dst,
+ currentLocation!.getDirSeparator(),
+ ),
+ type: 'meta',
});
+
+ // thumb file
+ metaJobs.push({
+ src: getThumbFileLocationForFile(src, AppConfig.dirSeparator, false),
+ dst: getThumbFileLocationForFile(
+ dst,
+ currentLocation!.getDirSeparator(),
+ false,
+ ),
+ type: 'thumb',
+ originalPathForThumb: src,
+ });
+ }
+ return processUploadJobs(
+ metaJobs,
+ onUploadProgress,
+ open,
+ targetLocationId,
+ sourceLocationId,
+ true,
+ ).then((entries) => {
+ if (entries && entries.length > 0) {
+ const filePaths = entries.map((entry) => {
+ return getFileLocationFromMetaFile(entry.path);
+ });
+ const unique = [...new Set(filePaths)];
+ const reflectActionsPromises: Promise<TS.EditAction>[] = unique.map(
+ (path) => {
+ return getAllPropertiesPromise(path, targetLocationId).then(
+ (entry) => {
+ return {
+ action: 'update',
+ entry: entry,
+ open: false,
+ oldEntryPath: entry.path,
+ };
+ },
+ );
+ },
+ );
+ Promise.all(reflectActionsPromises).then((reflectActions) => {
+ setReflectActions(...reflectActions);
+ });
+ }
+ return entries;
+ });
}
/**
@@ -1225,114 +1321,151 @@ export const IOActionsContextProvider = ({
targetLocationId: string = undefined,
sourceLocationId: string = undefined,
): Promise<TS.FileSystemEntry[]> {
- return new Promise((resolve, reject) => {
- const uploadJobs = [];
- paths.map((path) => {
- let target = joinPaths(
- currentLocation?.getDirSeparator(),
- targetPath,
- extractFileName(path, AppConfig.dirSeparator),
- ); // with "/" dir separator cannot extractFileName on Win
- // fix for Win
- /*if (
- currentLocation.haveObjectStoreSupport() &&
- (target.startsWith('\\') || target.startsWith('/'))
- ) {
- target = target.substr(1);
- }*/
- uploadJobs.push([path, target, 'file']);
- if (uploadMeta) {
- // copy meta
- uploadJobs.push([
- getMetaFileLocationForFile(path, AppConfig.dirSeparator),
- getMetaFileLocationForFile(
- target,
- currentLocation?.getDirSeparator(),
- ),
- 'meta',
- ]);
- uploadJobs.push([
- getThumbFileLocationForFile(path, AppConfig.dirSeparator),
- getThumbFileLocationForFile(
- target,
- currentLocation?.getDirSeparator(),
- ),
- 'thumb',
- path,
- ]);
- }
- return true;
+ if (onUploadProgress) {
+ paths.forEach((path) => {
+ const key =
+ targetPath + '/' + extractFileName(path, AppConfig.dirSeparator);
+ onUploadProgress({ key: key, loaded: 0, total: 0 }, undefined);
});
- const jobsPromises = uploadJobs.map((job) => {
- // console.log("Selected File: "+JSON.stringify(selection.currentTarget.files[0]));
- // const file = selection.currentTarget.files[0];
- const filePath = job[1];
- const fileType = job[2];
-
- // TODO try to replace this with <input type="file"
- if (AppConfig.isElectron) {
- return findLocation(sourceLocationId)
- .getFileContentPromise(job[0], 'arraybuffer')
- .then((fileContent) =>
- uploadFile(
- filePath,
- fileType,
- fileContent,
- onUploadProgress,
- false,
- targetLocationId,
- ),
- )
- .catch((err) => {
- if (
- err &&
- err.message &&
- err.message.indexOf(
- 'Error: EISDIR: illegal operation on a directory, read',
- ) > -1
- ) {
- const errorMessage = t('core:uploadDirsNotSupported');
- showNotification(errorMessage, 'warning', true);
- dispatch(AppActions.setProgress(filePath, -1, errorMessage));
- }
- // console.log('Error getting file:' + job[0] + ' ' + err);
- if (fileType === 'thumb' && job[3]) {
- return generateThumbnailPromise(
- job[3],
- 0,
- currentLocation.loadTextFilePromise,
- currentLocation.getFileContentPromise,
- currentLocation.getThumbPath,
- currentLocation?.getDirSeparator(),
- ).then((dataURL) => {
- if (dataURL && dataURL.length > 6) {
- const baseString = dataURL.split(',').pop();
- const fileContent = base64ToBlob(baseString);
- return uploadFile(
- filePath,
- fileType,
- fileContent,
- onUploadProgress,
- false,
- targetLocationId,
- );
- }
- return undefined;
- });
- }
- });
- }
-
- return undefined;
+ }
+ const uploadJobs: job[] = [];
+ paths.map((path) => {
+ let target = joinPaths(
+ currentLocation?.getDirSeparator(),
+ targetPath,
+ extractFileName(path, AppConfig.dirSeparator),
+ );
+ uploadJobs.push({
+ src: path,
+ dst: target,
+ type: 'file',
});
+ if (uploadMeta) {
+ // copy meta
+ uploadJobs.push({
+ src: getMetaFileLocationForFile(path, AppConfig.dirSeparator),
+ dst: getMetaFileLocationForFile(
+ target,
+ currentLocation?.getDirSeparator(),
+ ),
+ type: 'meta',
+ });
+
+ // thumb file
+ uploadJobs.push({
+ src: getThumbFileLocationForFile(path, AppConfig.dirSeparator),
+ dst: getThumbFileLocationForFile(
+ target,
+ currentLocation?.getDirSeparator(),
+ false,
+ ),
+ type: 'thumb',
+ originalPathForThumb: path,
+ });
+ }
+ return true;
+ });
+ return processUploadJobs(
+ uploadJobs,
+ onUploadProgress,
+ open,
+ targetLocationId,
+ sourceLocationId,
+ ).then((entries) => {
+ const reflectActions: TS.EditAction[] = entries.map((entry) => ({
+ action: 'add',
+ entry: entry,
+ open: open,
+ source: 'upload',
+ }));
+ setReflectActions(...reflectActions);
+ return entries;
+ });
+ }
+
+ function processUploadJobs(
+ uploadJobs: job[],
+ onUploadProgress?: (progress, response) => void,
+ open = true,
+ targetLocationId: string = undefined,
+ sourceLocationId: string = undefined,
+ override = false,
+ ): Promise<TS.FileSystemEntry[]> {
+ return new Promise((resolve, reject) => {
+ const jobsPromises: Promise<TS.FileSystemEntry>[] = uploadJobs.map(
+ (job) => {
+ // console.log("Selected File: "+JSON.stringify(selection.currentTarget.files[0]));
+ // const file = selection.currentTarget.files[0];
+ const filePath = job.dst;
+ const fileType = job.type;
+ const originalPathForThumb = job.originalPathForThumb;
+
+ // TODO try to replace this with <input type="file"
+ if (AppConfig.isElectron) {
+ return findLocation(sourceLocationId)
+ .getFileContentPromise(job.src, 'arraybuffer')
+ .then((fileContent) =>
+ uploadFile(
+ filePath,
+ fileType,
+ fileContent,
+ onUploadProgress,
+ false,
+ targetLocationId,
+ override,
+ ),
+ )
+ .catch((err) => {
+ if (
+ err &&
+ err.message &&
+ err.message.indexOf(
+ 'Error: EISDIR: illegal operation on a directory, read',
+ ) > -1
+ ) {
+ const errorMessage = t('core:uploadDirsNotSupported');
+ showNotification(errorMessage, 'warning', true);
+ dispatch(AppActions.setProgress(filePath, -1, errorMessage));
+ }
+ if (fileType === 'thumb' && originalPathForThumb) {
+ return generateThumbnailPromise(
+ originalPathForThumb,
+ 0,
+ currentLocation.loadTextFilePromise,
+ currentLocation.getFileContentPromise,
+ currentLocation.getThumbPath,
+ currentLocation.getDirSeparator(),
+ ).then((dataURL) => {
+ if (dataURL && dataURL.length > 6) {
+ const baseString = dataURL.split(',').pop();
+ const fileContent = base64ToBlob(baseString);
+ return uploadFile(
+ filePath,
+ fileType,
+ fileContent,
+ onUploadProgress,
+ false,
+ targetLocationId,
+ override,
+ );
+ }
+ return undefined;
+ });
+ }
+ });
+ }
+
+ return undefined;
+ },
+ );
Promise.allSettled(jobsPromises)
.then((filesProm) => {
- const arrFiles: Array<TS.FileSystemEntry> = [];
- const arrMeta: Array<TS.FileSystemEntry> = [];
+ const arrFiles: TS.FileSystemEntry[] = [];
+ const arrMeta: TS.FileSystemEntry[] = [];
filesProm.map((result) => {
if (result.status !== 'rejected') {
- const file = result.value;
+ const file: TS.FileSystemEntry = result.value;
if (file) {
if (file.meta) {
arrMeta.push(file);
@@ -1355,7 +1488,7 @@ export const IOActionsContextProvider = ({
);
// Enhance entries
- const entriesEnhanced = arrFiles.map(
+ const entriesEnhanced: Promise<TS.FileSystemEntry>[] = arrFiles.map(
async (file: TS.FileSystemEntry) => {
const metaFilePath = getMetaFileLocationForFile(
file.path,
@@ -1391,28 +1524,19 @@ export const IOActionsContextProvider = ({
}
}
if (file.meta) {
- return enhanceEntry(
+ const enhancedEntry: TS.FileSystemEntry = enhanceEntry(
file,
AppConfig.tagDelimiter,
currentLocation?.getDirSeparator(),
);
+ return enhancedEntry;
}
return file;
},
);
Promise.all(entriesEnhanced).then((entries) => {
- const reflectActions: TS.EditAction[] = entries.map((entry) => ({
- action: 'add',
- entry: entry,
- open: open,
- source: 'upload',
- }));
- setReflectActions(...reflectActions);
resolve(entries);
});
- } else {
- // eslint-disable-next-line prefer-promise-reject-errors
- reject('Upload failed');
}
return true;
})
@@ -2372,6 +2496,7 @@ export const IOActionsContextProvider = ({
downloadFsEntry,
uploadFilesAPI,
uploadFiles,
+ uploadMeta,
renameDirectory,
renameFile,
openFileNatively,
diff --git a/src/renderer/perspectives/common/CellView.tsx b/src/renderer/perspectives/common/CellView.tsx
index 83b915bf7..e8ab3fe9c 100644
--- a/src/renderer/perspectives/common/CellView.tsx
+++ b/src/renderer/perspectives/common/CellView.tsx
@@ -73,7 +73,8 @@ function CellView(props: Props) {
usePerspectiveSettingsContext();
const theme = useTheme();
- const { openFileMenu, openDirectoryMenu } = useMenuContext();
+ const { openFileMenu, openDirectoryMenu, openMoveCopyFilesDialog } =
+ useMenuContext();
const { openEntryInternal, openedEntry } = useOpenedEntryContext();
const { openDirectory } = useDirectoryContentContext();
const { moveFiles, openFileNatively } = useIOActionsContext();
@@ -245,34 +246,26 @@ function CellView(props: Props) {
}
if (item) {
const { entry } = item;
- let arrPath;
+ let arrEntries;
if (
selectedEntries &&
selectedEntries.length > 0 &&
selectedEntries.some((e) => e.path === entry.path)
) {
const arrSelected = selectedEntries
- .map((entry) => entry.path)
+ //.map((entry) => entry.path)
// remove target folder selection
- .filter((epath) => epath !== item.targetPath);
+ .filter((e) => e.path !== item.targetPath);
if (arrSelected.length > 0) {
- arrPath = arrSelected;
+ arrEntries = arrSelected;
} else {
- arrPath = [entry.path];
+ arrEntries = [entry];
}
} else if (entry) {
- arrPath = [entry.path];
+ arrEntries = [entry];
}
- console.log('Dropped files: ' + JSON.stringify(arrPath));
- handleEntryExist(selectedEntries, item.targetPath).then((exist) => {
- if (exist) {
- openEntryExistDialog(exist, () => {
- moveFiles(arrPath, item.targetPath, currentLocationId);
- });
- } else {
- moveFiles(arrPath, item.targetPath, currentLocationId);
- }
- });
+ //console.log('Dropped files: ' + JSON.stringify(arrEntries));
+ openMoveCopyFilesDialog(arrEntries, item.targetPath, currentLocationId);
}
};
diff --git a/src/renderer/reducers/app.ts b/src/renderer/reducers/app.ts
index f25998362..d34e2a5ca 100644
--- a/src/renderer/reducers/app.ts
+++ b/src/renderer/reducers/app.ts
@@ -126,7 +126,7 @@ export default (state: any = initialState, action: any) => {
},
];
state.progress.map((fileProgress) => {
- if (fileProgress.path !== action.path) {
+ if (fileProgress && fileProgress.path !== action.path) {
arrProgress.push(fileProgress);
}
return true;
@@ -134,7 +134,11 @@ export default (state: any = initialState, action: any) => {
return { ...state, progress: arrProgress };
}
case types.PROGRESS_FINISH: {
- return { ...state, progress: action.progresses, state: 'finished' };
+ const arrProgress = action.progresses.map((p) => ({
+ ...p,
+ state: 'finished',
+ }));
+ return { ...state, progress: arrProgress };
}
case types.RESET_PROGRESS: {
return { ...state, progress: [] };