From e58299df0ba10002dc0209ba76dd9b2799ee9914 Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Thu, 16 Jan 2025 15:11:15 +0530 Subject: [PATCH] feat: transition to frappe ui list feat: allow bulk actions fix: improve download --- drive/api/files.py | 9 +- frontend/package-lock.json | 384 +++++++++--- frontend/package.json | 2 +- frontend/src/components/EntityToolbar.vue | 5 +- frontend/src/components/ListView.vue | 550 ++++++------------ frontend/src/components/Navbar.vue | 7 +- frontend/src/components/PageGeneric.vue | 291 +++------ .../components/ShareDialog/ShareDialog.vue | 2 +- frontend/src/components/Toast.vue | 2 +- frontend/src/pages/File.vue | 2 +- frontend/src/resources/files.js | 20 + frontend/src/router.js | 1 + frontend/src/stores/listView.js | 10 - .../utils/{folderDownload.js => download.js} | 15 +- frontend/src/utils/toasts.js | 2 +- 15 files changed, 608 insertions(+), 694 deletions(-) create mode 100644 frontend/src/resources/files.js delete mode 100644 frontend/src/stores/listView.js rename frontend/src/utils/{folderDownload.js => download.js} (88%) diff --git a/drive/api/files.py b/drive/api/files.py index 5aa2e177..c10572ee 100644 --- a/drive/api/files.py +++ b/drive/api/files.py @@ -1226,7 +1226,7 @@ def list_recents(order_by="last_interaction", limit=100, offset=0): @frappe.whitelist() -def remove_recents(entity_names=None, clear_all=False): +def remove_recents(entity_names=[], clear_all=False): """ Clear recent DriveEntities for specified user @@ -1236,12 +1236,11 @@ def remove_recents(entity_names=None, clear_all=False): """ if clear_all: - frappe.db.delete("Drive Entity Log", {"user": frappe.session.user}) - return - if isinstance(entity_names, str): - entity_names = json.loads(entity_names) + return frappe.db.delete("Drive Entity Log", {"user": frappe.session.user}) + if not isinstance(entity_names, list): frappe.throw(f"Expected list but got {type(entity_names)}", ValueError) + print("HO", entity_names) for entity in entity_names: existing_doc = frappe.db.exists( { diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 2ebf36d3..ee3d5739 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -41,7 +41,7 @@ "docx-preview": "^0.1.15", "dropzone": "^6.0.0-beta.2", "feather-icons": "^4.29.0", - "frappe-ui": "^0.1.62", + "frappe-ui": "^0.1.104", "fuzzysort": "^2.0.4", "idb-keyval": "^6.2.1", "js-base64": "^3.7.5", @@ -3602,49 +3602,53 @@ } }, "node_modules/@vue/compiler-core": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.38.tgz", - "integrity": "sha512-8IQOTCWnLFqfHzOGm9+P8OPSEDukgg3Huc92qSG49if/xI2SAwLHQO2qaPQbjCWPBcQoO1WYfXfTACUrWV3c5A==", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", + "integrity": "sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==", + "license": "MIT", "dependencies": { - "@babel/parser": "^7.24.7", - "@vue/shared": "3.4.38", + "@babel/parser": "^7.25.3", + "@vue/shared": "3.5.13", "entities": "^4.5.0", "estree-walker": "^2.0.2", "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-dom": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.38.tgz", - "integrity": "sha512-Osc/c7ABsHXTsETLgykcOwIxFktHfGSUDkb05V61rocEfsFDcjDLH/IHJSNJP+/Sv9KeN2Lx1V6McZzlSb9EhQ==", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.13.tgz", + "integrity": "sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==", + "license": "MIT", "dependencies": { - "@vue/compiler-core": "3.4.38", - "@vue/shared": "3.4.38" + "@vue/compiler-core": "3.5.13", + "@vue/shared": "3.5.13" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.38.tgz", - "integrity": "sha512-s5QfZ+9PzPh3T5H4hsQDJtI8x7zdJaew/dCGgqZ2630XdzaZ3AD8xGZfBqpT8oaD/p2eedd+pL8tD5vvt5ZYJQ==", - "dependencies": { - "@babel/parser": "^7.24.7", - "@vue/compiler-core": "3.4.38", - "@vue/compiler-dom": "3.4.38", - "@vue/compiler-ssr": "3.4.38", - "@vue/shared": "3.4.38", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.13.tgz", + "integrity": "sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.25.3", + "@vue/compiler-core": "3.5.13", + "@vue/compiler-dom": "3.5.13", + "@vue/compiler-ssr": "3.5.13", + "@vue/shared": "3.5.13", "estree-walker": "^2.0.2", - "magic-string": "^0.30.10", - "postcss": "^8.4.40", + "magic-string": "^0.30.11", + "postcss": "^8.4.48", "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-ssr": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.38.tgz", - "integrity": "sha512-YXznKFQ8dxYpAz9zLuVvfcXhc31FSPFDcqr0kyujbOwNhlmaNvL2QfIy+RZeJgSn5Fk54CWoEUeW+NVBAogGaw==", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.13.tgz", + "integrity": "sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==", + "license": "MIT", "dependencies": { - "@vue/compiler-dom": "3.4.38", - "@vue/shared": "3.4.38" + "@vue/compiler-dom": "3.5.13", + "@vue/shared": "3.5.13" } }, "node_modules/@vue/devtools-api": { @@ -3653,49 +3657,54 @@ "integrity": "sha512-0MiMsFma/HqA6g3KLKn+AGpL1kgKhFWszC9U29NfpWK5LE7bjeXxySWJrOJ77hBz+TBrBQ7o4QJqbPbqbs8rJw==" }, "node_modules/@vue/reactivity": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.38.tgz", - "integrity": "sha512-4vl4wMMVniLsSYYeldAKzbk72+D3hUnkw9z8lDeJacTxAkXeDAP1uE9xr2+aKIN0ipOL8EG2GPouVTH6yF7Gnw==", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.13.tgz", + "integrity": "sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==", + "license": "MIT", "dependencies": { - "@vue/shared": "3.4.38" + "@vue/shared": "3.5.13" } }, "node_modules/@vue/runtime-core": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.38.tgz", - "integrity": "sha512-21z3wA99EABtuf+O3IhdxP0iHgkBs1vuoCAsCKLVJPEjpVqvblwBnTj42vzHRlWDCyxu9ptDm7sI2ZMcWrQqlA==", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.13.tgz", + "integrity": "sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==", + "license": "MIT", "dependencies": { - "@vue/reactivity": "3.4.38", - "@vue/shared": "3.4.38" + "@vue/reactivity": "3.5.13", + "@vue/shared": "3.5.13" } }, "node_modules/@vue/runtime-dom": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.38.tgz", - "integrity": "sha512-afZzmUreU7vKwKsV17H1NDThEEmdYI+GCAK/KY1U957Ig2NATPVjCROv61R19fjZNzMmiU03n79OMnXyJVN0UA==", - "dependencies": { - "@vue/reactivity": "3.4.38", - "@vue/runtime-core": "3.4.38", - "@vue/shared": "3.4.38", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.13.tgz", + "integrity": "sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.13", + "@vue/runtime-core": "3.5.13", + "@vue/shared": "3.5.13", "csstype": "^3.1.3" } }, "node_modules/@vue/server-renderer": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.38.tgz", - "integrity": "sha512-NggOTr82FbPEkkUvBm4fTGcwUY8UuTsnWC/L2YZBmvaQ4C4Jl/Ao4HHTB+l7WnFCt5M/dN3l0XLuyjzswGYVCA==", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.13.tgz", + "integrity": "sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==", + "license": "MIT", "dependencies": { - "@vue/compiler-ssr": "3.4.38", - "@vue/shared": "3.4.38" + "@vue/compiler-ssr": "3.5.13", + "@vue/shared": "3.5.13" }, "peerDependencies": { - "vue": "3.4.38" + "vue": "3.5.13" } }, "node_modules/@vue/shared": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.38.tgz", - "integrity": "sha512-q0xCiLkuWWQLzVrecPb0RMsNWyxICOjPrcrwxTUEHb1fsnvni4dcuyG7RT/Ie7VPTvnjzIaWzRMUBsrqNj/hhw==" + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.13.tgz", + "integrity": "sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==", + "license": "MIT" }, "node_modules/@vueuse/core": { "version": "10.11.1", @@ -4079,6 +4088,55 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "license": "MIT", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/bl/node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/bl/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/bluebird": { "version": "3.4.7", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", @@ -4250,7 +4308,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4326,11 +4383,32 @@ "node": ">=4" } }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cli-width": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==" }, + "node_modules/clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "license": "MIT", + "engines": { + "node": ">=0.8" + } + }, "node_modules/codepage": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", @@ -4468,7 +4546,8 @@ "node_modules/csstype": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", - "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "license": "MIT" }, "node_modules/custom-error-instance": { "version": "2.1.1", @@ -4492,6 +4571,12 @@ "date-fns": "^3.0.0" } }, + "node_modules/dayjs": { + "version": "1.11.13", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", + "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==", + "license": "MIT" + }, "node_modules/debug": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", @@ -4526,6 +4611,18 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "license": "MIT", + "dependencies": { + "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/defu": { "version": "6.1.4", "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", @@ -4924,7 +5021,8 @@ "node_modules/estree-walker": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" }, "node_modules/esutils": { "version": "2.0.3", @@ -5178,9 +5276,10 @@ "integrity": "sha512-qyzDZ7JXWf/yZT2rQDpQwFBbIaZS2o+zb0s740vqreXQ6bFQPd8tAy4D1gGN0CUeIcnNHjuvb0EaLnqHhGV/PA==" }, "node_modules/frappe-ui": { - "version": "0.1.67", - "resolved": "https://registry.npmjs.org/frappe-ui/-/frappe-ui-0.1.67.tgz", - "integrity": "sha512-9/TSES7eP/AUi042b+znXyVwMRgeSY4RSAXb0hwEl/3PqUFNHVLPjZJFqWJBzjObNraCpUuxQLJKLLUtLnmNYA==", + "version": "0.1.104", + "resolved": "https://registry.npmjs.org/frappe-ui/-/frappe-ui-0.1.104.tgz", + "integrity": "sha512-rLgYwGKPChJHYBH6AIgsdN3ZPpT+N1K2UthRvKrPva0xLX9YAQS7xpiw5xVxwZXnpc1//EiXqOQcB7bb575wAg==", + "license": "MIT", "dependencies": { "@headlessui/vue": "^1.7.14", "@popperjs/core": "^2.11.2", @@ -5204,16 +5303,19 @@ "@tiptap/suggestion": "^2.0.3", "@tiptap/vue-3": "^2.0.3", "@vueuse/core": "^10.4.1", + "dayjs": "^1.11.13", "feather-icons": "^4.28.0", "idb-keyval": "^6.2.0", + "ora": "5.4.1", "prettier": "^3.3.2", "radix-vue": "^1.5.3", "showdown": "^2.1.0", "socket.io-client": "^4.5.1", - "tippy.js": "^6.3.7" + "tippy.js": "^6.3.7", + "typescript": "^5.0.2" }, "peerDependencies": { - "vue": "^3.2.45", + "vue": ">=3.5.0", "vue-router": "^4.1.6" } }, @@ -5475,7 +5577,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, "engines": { "node": ">=8" } @@ -5831,6 +5932,15 @@ "node": ">=0.10.0" } }, + "node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/is-network-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-network-error/-/is-network-error-1.1.0.tgz", @@ -5883,6 +5993,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-what": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz", @@ -6209,6 +6331,22 @@ "lodash._baseuniq": "~4.6.0" } }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -6252,9 +6390,10 @@ } }, "node_modules/magic-string": { - "version": "0.30.11", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.11.tgz", - "integrity": "sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==", + "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0" } @@ -6394,7 +6533,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true, "engines": { "node": ">=6" } @@ -6688,7 +6826,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, "dependencies": { "mimic-fn": "^2.1.0" }, @@ -6833,6 +6970,54 @@ "node": ">= 0.8.0" } }, + "node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "license": "MIT", + "dependencies": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora/node_modules/cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "license": "MIT", + "dependencies": { + "restore-cursor": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ora/node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "license": "MIT", + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/orderedmap": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz", @@ -7052,9 +7237,9 @@ } }, "node_modules/postcss": { - "version": "8.4.41", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.41.tgz", - "integrity": "sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ==", + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.1.tgz", + "integrity": "sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ==", "funding": [ { "type": "opencollective", @@ -7069,10 +7254,11 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { - "nanoid": "^3.3.7", - "picocolors": "^1.0.1", - "source-map-js": "^1.2.0" + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" }, "engines": { "node": "^10 || ^12 || >=14" @@ -7199,15 +7385,16 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, "node_modules/postcss/node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -8143,9 +8330,10 @@ } }, "node_modules/source-map-js": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", - "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } @@ -8327,7 +8515,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -8539,6 +8726,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", @@ -8745,15 +8945,16 @@ } }, "node_modules/vue": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.38.tgz", - "integrity": "sha512-f0ZgN+mZ5KFgVv9wz0f4OgVKukoXtS3nwET4c2vLBGQR50aI8G0cqbFtLlX9Yiyg3LFGBitruPHt2PxwTduJEw==", + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.13.tgz", + "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==", + "license": "MIT", "dependencies": { - "@vue/compiler-dom": "3.4.38", - "@vue/compiler-sfc": "3.4.38", - "@vue/runtime-dom": "3.4.38", - "@vue/server-renderer": "3.4.38", - "@vue/shared": "3.4.38" + "@vue/compiler-dom": "3.5.13", + "@vue/compiler-sfc": "3.5.13", + "@vue/runtime-dom": "3.5.13", + "@vue/server-renderer": "3.5.13", + "@vue/shared": "3.5.13" }, "peerDependencies": { "typescript": "*" @@ -8834,6 +9035,15 @@ "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==" }, + "node_modules/wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "license": "MIT", + "dependencies": { + "defaults": "^1.0.3" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index c15ede35..5444092a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -46,7 +46,7 @@ "docx-preview": "^0.1.15", "dropzone": "^6.0.0-beta.2", "feather-icons": "^4.29.0", - "frappe-ui": "^0.1.62", + "frappe-ui": "^0.1.104", "fuzzysort": "^2.0.4", "idb-keyval": "^6.2.1", "js-base64": "^3.7.5", diff --git a/frontend/src/components/EntityToolbar.vue b/frontend/src/components/EntityToolbar.vue index aa42cf44..c4290a99 100644 --- a/frontend/src/components/EntityToolbar.vue +++ b/frontend/src/components/EntityToolbar.vue @@ -69,10 +69,7 @@ import { useStore } from "vuex" import { Checkbox, Button } from "frappe-ui" import { computed } from "vue" -import { - folderDownload, - selectedEntitiesDownload, -} from "@/utils/folderDownload" +import { folderDownload, selectedEntitiesDownload } from "@/utils/download" defineOptions({ inheritAttrs: false, diff --git a/frontend/src/components/ListView.vue b/frontend/src/components/ListView.vue index 4f071c2e..c1b91a73 100644 --- a/frontend/src/components/ListView.vue +++ b/frontend/src/components/ListView.vue @@ -1,237 +1,127 @@ + + + + + diff --git a/frontend/src/components/Navbar.vue b/frontend/src/components/Navbar.vue index 06fc0d67..9495fd78 100644 --- a/frontend/src/components/Navbar.vue +++ b/frontend/src/components/Navbar.vue @@ -158,10 +158,7 @@ import RenameDialog from "@/components/RenameDialog.vue" import Breadcrumbs from "@/components/Breadcrumbs.vue" import { formatDate } from "@/utils/format" import { getLink } from "@/utils/getLink" -import { - folderDownload, - selectedEntitiesDownload, -} from "@/utils/folderDownload" +import { folderDownload, selectedEntitiesDownload } from "@/utils/download" import Printer from "./EspressoIcons/Printer.vue" import Share from "./EspressoIcons/Share.vue" import Star from "./EspressoIcons/Star.vue" @@ -435,7 +432,7 @@ export default { ) }, }, - ].filter((item) => item.isEnabled()) + ].filter((a) => !a.isEnabled || a.isEnabled()) }, fullName() { return this.$store.state.user.fullName diff --git a/frontend/src/components/PageGeneric.vue b/frontend/src/components/PageGeneric.vue index 4a631682..c4d751fd 100644 --- a/frontend/src/components/PageGeneric.vue +++ b/frontend/src/components/PageGeneric.vue @@ -41,7 +41,7 @@ :folder-contents="groupedByFolder" :selected-entities="selectedEntities" :override-can-load-more="overrideCanLoadMore" - @entity-selected="(selected) => (selectedEntities = selected)" + :action-items="actionItems" @show-entity-context="(data) => toggleEntityContext(data)" @open-entity="(entity) => openEntity(entity)" @fetch-folder-contents="() => $resources.folderContents.fetch()" @@ -200,10 +200,9 @@ import EmptyEntityContextMenu from "@/components/EmptyEntityContextMenu.vue" import { formatSize, formatDate } from "@/utils/format" import { getLink } from "@/utils/getLink" import { useTimeAgo } from "@vueuse/core" -import { - folderDownload, - selectedEntitiesDownload, -} from "@/utils/folderDownload" +import { toggleFav, clearRecent } from "@/resources/files" + +import { selectedEntitiesDownload } from "@/utils/download" import { RotateCcw } from "lucide-vue-next" import NewFolder from "./EspressoIcons/NewFolder.vue" import FileUpload from "./EspressoIcons/File-upload.vue" @@ -440,7 +439,7 @@ export default { }, isEnabled: () => this.$store.state.pasteData.entities.length, },*/ - ].filter((item) => item.isEnabled()) + ].filter((a) => !a.isEnabled || a.isEnabled()) }, actionItems() { if (this.$route.name === "Trash") { @@ -448,147 +447,61 @@ export default { { label: "Restore", icon: RotateCcw, - onClick: () => { - this.showRestoreDialog = true - }, - isEnabled: () => { - return this.selectedEntities.length > 0 - }, + onClick: () => (this.showRestoreDialog = true), }, { label: "Delete forever", icon: Trash, - danger: true, onClick: () => { this.showDeleteDialog = true }, - isEnabled: () => { - if (this.$route.name === "Trash") { - return this.selectedEntities.length > 0 - } - }, + isEnabled: () => this.$route.name === "Trash", }, - ].filter((item) => item.isEnabled()) + ].filter((a) => !a.isEnabled || a.isEnabled()) } else { return [ { label: "Preview", icon: Preview, - onClick: () => { - console.log(this.selectedEntities[0].is_group) - this.openEntity(this.selectedEntities[0]) - }, - isEnabled: () => { - if (this.selectedEntities.length === 1) { - return true - } - }, - }, - { - label: "Download", - icon: Download, - onClick: () => { - window.location.href = `/api/method/drive.api.files.get_file_content?entity_name=${this.selectedEntities[0].name}&trigger_download=1` - }, - isEnabled: () => { - if (this.selectedEntities.length === 1) { - if ( - this.selectedEntities.length === 1 && - !this.selectedEntities[0].is_group && - !this.selectedEntities[0].document - ) { - return ( - this.selectedEntities[0].allow_download || - this.selectedEntities[0].owner === "You" - ) - } - } - }, + onClick: ([entity]) => this.openEntity(entity), important: true, }, - /* Folder Download */ { label: "Download", icon: Download, - onClick: () => { - if (this.selectedEntities.length > 1) { - let selected_entities = this.selectedEntities - selectedEntitiesDownload(selected_entities) - } else if (this.selectedEntities[0].is_group === 1) { - folderDownload(this.selectedEntities[0]) - } - }, - isEnabled: () => { - if ( - this.selectedEntities.length === 1 && - !this.selectedEntities[0].is_group - ) { - return false - } - if (this.selectedEntities.length) { - const allEntitiesSatisfyCondition = this.selectedEntities.every( - (entity) => { - return entity.allow_download || entity.owner === "You" - } - ) - return allEntitiesSatisfyCondition - } - }, + onClick: selectedEntitiesDownload, + isEnabled: (e) => + e.allow_download || e.owner === "You" || e.owner.label === "You", + multi: true, important: true, }, - { label: "Share", icon: Share, - onClick: () => { - this.showShareDialog = true - }, - isEnabled: () => { - return ( - this.selectedEntities.length === 1 && - (this.selectedEntities[0].owner === "You" || - this.selectedEntities[0].share) - ) - }, + onClick: () => (this.showShareDialog = true), + isEnabled: (e) => + e.owner === "You" || e.owner.label === "You" || e.share, important: true, }, { label: "Get Link", icon: Link, - onClick: () => { - getLink(this.selectedEntities[0]) - }, - isEnabled: () => { - return this.selectedEntities.length === 1 - }, + onClick: ([entity]) => getLink(entity), important: true, }, { label: "Rename", icon: Rename, - onClick: () => { - this.showRenameDialog = true - }, - isEnabled: () => { - return ( - this.selectedEntities.length === 1 && - (this.selectedEntities[0].write || - this.selectedEntities[0].owner === "You") - ) - }, + onClick: () => (this.showRenameDialog = true), + isEnabled: (e) => + e.write || e.owner === "You" || e.owner.label === "You", }, { label: "Move", icon: Move, - onClick: () => { - this.showMoveDialog = true - }, - isEnabled: () => { - const allOwned = this.selectedEntities.every((entity) => { - return entity.owner === "You" - }) - return this.selectedEntities.length > 0 && allOwned - }, + onClick: () => (this.showMoveDialog = true), + isEnabled: (e) => e.owner === "You" || e.owner.label === "You", + multi: true, }, /* { label: "Duplicate", @@ -610,28 +523,15 @@ export default { { label: "Show Info", icon: Info, - onClick: () => { - this.$store.commit("setShowInfo", true) - }, - isEnabled: () => { - return ( - !this.$store.state.showInfo && - this.selectedEntities.length === 1 - ) - }, + onClick: () => this.$store.commit("setShowInfo", true), + isEnabled: () => !this.$store.state.showInfo, important: true, }, { label: "Hide Info", icon: Info, - onClick: () => { - this.$store.commit("setShowInfo", false) - }, - isEnabled: () => { - return ( - this.$store.state.showInfo && this.selectedEntities.length === 1 - ) - }, + onClick: () => this.$store.commit("setShowInfo", false), + isEnabled: () => this.$store.state.showInfo, important: true, }, /*{ @@ -651,74 +551,61 @@ export default { { label: "Favourite", icon: "star", - onClick: () => { - this.$resources.toggleFavourite.submit() - }, - isEnabled: () => { - return ( - this.selectedEntities.length > 0 && - this.selectedEntities.every((x) => !x.is_favourite) - ) - }, + onClick: (entities) => + toggleFav.submit({ + entities, + }), + isEnabled: (e, multi) => !e.is_favourite || multi, important: true, + multi: true, }, { label: "Unfavourite", icon: "star", - onClick: () => { - this.$resources.toggleFavourite.submit() - }, - isEnabled: () => { - return ( - this.selectedEntities.length > 0 && - this.selectedEntities.every((x) => x.is_favourite) - ) - }, + onClick: (entities) => + toggleFav.submit({ + entities: entities.map((e) => ({ + name: e.name, + is_favourite: false, + })), + }), + isEnabled: (e) => e.is_favourite, important: true, + multi: true, }, - { - label: "Color", - isEnabled: () => { - return ( - this.selectedEntities.length === 1 && - this.selectedEntities[0].is_group && - (this.selectedEntities[0].write === 1 || - this.selectedEntities[0].owner === "You") - ) - }, - }, + // { + // label: "Color", + // isEnabled: (e) => e.is_group && (e.write || e.owner === "You" || e.owner.label === "You"), + // }, { label: "Remove from Recents", - icon: Trash, - danger: true, - onClick: () => { - this.$resources.clearRecent.submit() - }, - isEnabled: () => { - if (this.$route.name === "Recents") { - return this.selectedEntities.length > 0 - } - }, + icon: "clock", + onClick: (entities) => + clearRecent.submit( + { + entities, + }, + { + onSuccess: () => + entities.length > 1 + ? toast(`Cleared ${entities.length} files from Recents`) + : null, + } + ), + isEnabled: () => this.$route.name === "Recents", + important: true, + multi: true, }, { label: "Unshare", danger: true, icon: "trash-2", - onClick: () => { - this.showUnshareDialog = true - }, - isEnabled: () => { - if (this.selectedEntities.length) { - return ( - this.selectedEntities.every( - (x) => - x.owner != "You" && - x.user_doctype === "User" && - x.everyone !== 1 - ) && !this.isSharedFolder - ) - } - }, + onClick: () => (this.showUnshareDialog = true), + isEnabled: (e) => + e.owner != "You" && + e.user_doctype === "User" && + e.everyone !== 1 && + !this.isSharedFolder, }, { label: "Move to Trash", @@ -727,15 +614,11 @@ export default { onClick: () => { this.showRemoveDialog = true }, - isEnabled: () => { - const allOwned = this.selectedEntities.every((entity) => { - return entity.owner === "You" - }) - return this.selectedEntities.length > 0 && allOwned - }, + isEnabled: (e) => e.owner === "You" || e.owner.label === "You", important: true, + multi: true, }, - ].filter((item) => item.isEnabled()) + ] } }, foldersBefore() { @@ -938,7 +821,6 @@ export default { 0, endPage * this.pageLength - this.pageLength ) - let totalPages = endtityOgOffset - 0 this.$resources.folderContents .fetch({ entity_name: this.entityName, @@ -965,7 +847,6 @@ export default { return } if (entity.is_group) { - this.selectedEntities = [] this.$router.push({ name: "Folder", params: { entityName: entity.name }, @@ -1129,6 +1010,7 @@ export default { return { method: "GET", url: this.url, + cache: "folder-contents", auto: false, params: { entity_name: this.entityName || "", @@ -1144,6 +1026,7 @@ export default { }, transform(data) { this.$resources.folderContents.error = null + console.log(data) data.forEach((entity) => { entity.size_in_bytes = entity.file_size if (entity.is_group) { @@ -1213,34 +1096,6 @@ export default { }, } }, - clearRecent() { - return { - method: "POST", - auto: false, - url: "drive.api.files.remove_recents", - params: { - entity_names: JSON.stringify( - this.selectedEntities?.map((entity) => entity.name) - ), - }, - onSuccess() { - toast({ - title: `Cleared ${this.selectedEntities.length} ${ - this.selectedEntities.length > 1 ? " items" : " item" - } from Recents`, - position: "bottom-right", - timeout: 2, - }) - this.handleListMutation(this.selectedEntities[0].name) - this.selectedEntities = [] - }, - onError(error) { - if (error.messages) { - console.log(error.messages) - } - }, - } - }, createDocument() { return { method: "POST", diff --git a/frontend/src/components/ShareDialog/ShareDialog.vue b/frontend/src/components/ShareDialog/ShareDialog.vue index 167a8605..cfa2257d 100644 --- a/frontend/src/components/ShareDialog/ShareDialog.vue +++ b/frontend/src/components/ShareDialog/ShareDialog.vue @@ -318,6 +318,7 @@ import { FeatherIcon, Switch, LoadingIndicator, + DatePicker, } from "frappe-ui" import AccessButton from "@/components/ShareDialog/AccessButton.vue" import { getLink } from "@/utils/getLink" @@ -327,7 +328,6 @@ import Link from "@/components/EspressoIcons/Link.vue" import Diamond from "@/components/EspressoIcons/Diamond.vue" import Check from "@/components/EspressoIcons/Check.vue" import { capture } from "@/telemetry" -import DatePicker from "frappe-ui/src/components/DatePicker.vue" import { formatDate } from "@/utils/format" import { useDateFormat } from "@vueuse/core" diff --git a/frontend/src/components/Toast.vue b/frontend/src/components/Toast.vue index 572358f4..df212ec6 100644 --- a/frontend/src/components/Toast.vue +++ b/frontend/src/components/Toast.vue @@ -90,7 +90,7 @@ export default { }, timeout: { type: Number, - default: 2, + default: 10, }, }, emits: ["close"], diff --git a/frontend/src/pages/File.vue b/frontend/src/pages/File.vue index 789c1e10..79b3ffe7 100644 --- a/frontend/src/pages/File.vue +++ b/frontend/src/pages/File.vue @@ -194,7 +194,7 @@ let file = createResource({ function scrollEntity(negative = false) { currentEntity.value = negative ? prevEntity.value : nextEntity.value - fetchFile(currentEntity.value.name) + if (currentEntity.value) fetchFile(currentEntity.value.name) } onMounted(() => { diff --git a/frontend/src/resources/files.js b/frontend/src/resources/files.js new file mode 100644 index 00000000..c1c5505d --- /dev/null +++ b/frontend/src/resources/files.js @@ -0,0 +1,20 @@ +import { createResource } from "frappe-ui" + +export const toggleFav = createResource({ + url: "drive.api.files.set_favourite", + makeParams({ entities }) { + return { + entities, + } + }, +}) + +export const clearRecent = createResource({ + url: "drive.api.files.remove_recents", + makeParams({ entities }) { + console.log(entities.map((e) => e.name)) + return { + entity_names: entities.map((e) => e.name), + } + }, +}) diff --git a/frontend/src/router.js b/frontend/src/router.js index dcc12b50..bd1055e4 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -45,6 +45,7 @@ const routes = [ { path: "/notifications", name: "Notifications", + // Load a skeleton template directly component: () => import("@/pages/Notifications.vue"), beforeEnter: [setRootBreadCrumb, clearStore], }, diff --git a/frontend/src/stores/listView.js b/frontend/src/stores/listView.js deleted file mode 100644 index d9aac015..00000000 --- a/frontend/src/stores/listView.js +++ /dev/null @@ -1,10 +0,0 @@ -import { createResource } from "frappe-ui" - -export const toggleFav = createResource({ - url: "drive.api.files.set_favourite", - makeParams({ entities }) { - return { - entities, - } - }, -}) diff --git a/frontend/src/utils/folderDownload.js b/frontend/src/utils/download.js similarity index 88% rename from frontend/src/utils/folderDownload.js rename to frontend/src/utils/download.js index b30dbd95..9346e019 100644 --- a/frontend/src/utils/folderDownload.js +++ b/frontend/src/utils/download.js @@ -1,6 +1,13 @@ import JSZip from "jszip" +import { toast } from "./toasts" export function selectedEntitiesDownload(selected_entities) { + if (selected_entities.length === 1) { + return selected_entities[0].is_group + ? folderDownload(selected_entities[0]) + : (window.location.href = `/api/method/drive.api.files.get_file_content?entity_name=${selected_entities[0].name}&trigger_download=1`) + } + const t = toast("Preparing download...") const generateRandomString = () => [...Array(5)].map(() => Math.random().toString(36)[2]).join("") const randomString = generateRandomString() @@ -32,18 +39,18 @@ export function selectedEntitiesDownload(selected_entities) { .then(() => { return zip.generateAsync({ type: "blob", streamFiles: true }) }) - .then(function (content) { + .then(async function (content) { var downloadLink = document.createElement("a") downloadLink.href = URL.createObjectURL(content) downloadLink.download = folderName + ".zip" document.body.appendChild(downloadLink) + downloadLink.click() document.body.removeChild(downloadLink) + document.getElementById(t).remove() }) - .catch((error) => { - console.error(error) - }) + .catch(console.error) } export function folderDownload(root_entity) { diff --git a/frontend/src/utils/toasts.js b/frontend/src/utils/toasts.js index 4d4d601e..5a239601 100644 --- a/frontend/src/utils/toasts.js +++ b/frontend/src/utils/toasts.js @@ -74,7 +74,7 @@ function getToastsGroup(position) { .map((toast) => { return h( "div", - { key: toast.key, class: "pointer-events-auto flex" }, + { id: toast.key, class: "pointer-events-auto flex" }, h(Toast, { ...toast, onClose: () => {