From 4b5c3679f9098b06fcd25557ed05020d9d04752c Mon Sep 17 00:00:00 2001 From: ajcoder13 Date: Wed, 16 Jul 2025 12:00:29 +0530 Subject: [PATCH 1/3] Added popup on verification/deletion of files --- .../file-display/components/ConfirmDialog.jsx | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 client/src/screens/browse/components/file-display/components/ConfirmDialog.jsx diff --git a/client/src/screens/browse/components/file-display/components/ConfirmDialog.jsx b/client/src/screens/browse/components/file-display/components/ConfirmDialog.jsx new file mode 100644 index 00000000..a2a0b337 --- /dev/null +++ b/client/src/screens/browse/components/file-display/components/ConfirmDialog.jsx @@ -0,0 +1,68 @@ +import React from "react"; + +const styles = { + overlay: { + position: "fixed", + top: 0, + left: 0, + right: 0, + bottom: 0, + backgroundColor: "rgba(0, 0, 0, 0.4)", + display: "flex", + alignItems: "center", + justifyContent: "center", + zIndex: 1000, + }, + dialog: { + backgroundColor: "#fff", + padding: "20px 25px", + borderRadius: "8px", + maxWidth: "400px", + width: "90%", + boxShadow: "0 4px 20px rgba(0, 0, 0, 0.2)", + textAlign: "center", + fontFamily: "sans-serif", + }, + buttonGroup: { + marginTop: "20px", + display: "flex", + justifyContent: "center", + gap: "12px", + }, + confirmBtn: { + backgroundColor: "#22c55e", + color: "#fff", + border: "none", + padding: "10px 18px", + borderRadius: "5px", + cursor: "pointer", + fontWeight: "bold", + }, + cancelBtn: { + backgroundColor: "#ef4444", + color: "#fff", + border: "none", + padding: "10px 18px", + borderRadius: "5px", + cursor: "pointer", + fontWeight: "bold", + }, +}; + +const ConfirmDialog = ({ isOpen, message, onConfirm, onCancel }) => { + if (!isOpen) return null; + + return ( +
+
+

{message}

+
+ + +
+
+
+ ); +}; + +export default ConfirmDialog; From 635aa13564bd1173394c9bee546463f78c2b06df Mon Sep 17 00:00:00 2001 From: ajcoder13 Date: Wed, 16 Jul 2025 14:10:39 +0530 Subject: [PATCH 2/3] Save local changes before merging master --- server/modules/auth/auth.controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/modules/auth/auth.controller.js b/server/modules/auth/auth.controller.js index 58562666..a6075b99 100644 --- a/server/modules/auth/auth.controller.js +++ b/server/modules/auth/auth.controller.js @@ -279,8 +279,8 @@ export const redirectHandler = async (req, res, next) => { httpOnly: true, }); - // return res.redirect(appConfig.clientURL); - return res.redirect(`${appConfig.clientURL}/login/success?token=${token}`); //to redirect with token + return res.redirect(appConfig.clientURL); + // return res.redirect(`${appConfig.clientURL}/login/success?token=${token}`); //to redirect with token }; export const mobileRedirectHandler = async (req, res, next) => { From 77fd6d78a36788b8c00b609bdc68b2fcf68a2e77 Mon Sep 17 00:00:00 2001 From: ajcoder13 Date: Wed, 16 Jul 2025 15:53:15 +0530 Subject: [PATCH 3/3] Add confirmation dialog for file verify/delete with UI improvements --- .../components/file-display/assets/cross.svg | 1 + .../components/file-display/assets/tick.svg | 1 + .../file-display/components/ConfirmDialog.jsx | 118 ++++++++++++++++++ .../browse/components/file-display/index.jsx | 40 ++++-- client/yarn.lock | 10 ++ server/yarn.lock | 5 + 6 files changed, 167 insertions(+), 8 deletions(-) create mode 100644 client/src/screens/browse/components/file-display/assets/cross.svg create mode 100644 client/src/screens/browse/components/file-display/assets/tick.svg create mode 100644 client/src/screens/browse/components/file-display/components/ConfirmDialog.jsx diff --git a/client/src/screens/browse/components/file-display/assets/cross.svg b/client/src/screens/browse/components/file-display/assets/cross.svg new file mode 100644 index 00000000..3f98f5d4 --- /dev/null +++ b/client/src/screens/browse/components/file-display/assets/cross.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/src/screens/browse/components/file-display/assets/tick.svg b/client/src/screens/browse/components/file-display/assets/tick.svg new file mode 100644 index 00000000..294d863c --- /dev/null +++ b/client/src/screens/browse/components/file-display/assets/tick.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/src/screens/browse/components/file-display/components/ConfirmDialog.jsx b/client/src/screens/browse/components/file-display/components/ConfirmDialog.jsx new file mode 100644 index 00000000..02ddfd47 --- /dev/null +++ b/client/src/screens/browse/components/file-display/components/ConfirmDialog.jsx @@ -0,0 +1,118 @@ +import React from "react"; +import tick from "../assets/tick.svg"; +import cross from "../assets/cross.svg"; + +const styles = { + overlay: { + position: "fixed", + top: 0, + left: 0, + right: 0, + bottom: 0, + backgroundColor: "rgba(0, 0, 0, 0.4)", + display: "flex", + alignItems: "center", + justifyContent: "center", + zIndex: 1000, + }, + dialog: { + backgroundColor: "#fff", + padding: "25px 30px", + borderRadius: "8px", + maxWidth: "400px", + width: "90%", + boxShadow: "0 4px 20px rgba(0, 0, 0, 0.2)", + textAlign: "center", + fontFamily: "sans-serif", + }, + + iconImage: { + width: "80px", + height: "80px", + margin:"1em", + }, + heading: { + fontSize:"2em", + }, + message: { + fontSize: "1em", + color: "#374151", + margin: "1em", + }, + buttonGroup: { + display: "flex", + justifyContent: "center", + gap: "1em", + }, + confirmBtn: { + display: "flex", + alignItems: "center", + backgroundColor: "#22c55e", + color: "#fff", + border: "none", + padding: "10px 18px", + borderRadius: "5px", + cursor: "pointer", + fontWeight: "bold", + fontSize:"1em", + }, + deleteBtn: { + display: "flex", + alignItems: "center", + backgroundColor: "#ef4444", + color: "#fff", + border: "none", + padding: "10px 18px", + borderRadius: "5px", + cursor: "pointer", + fontWeight: "bold", + fontSize:"1em", + }, + cancelBtn: { + backgroundColor: "#9ca3af", + color: "#fff", + border: "none", + padding: "10px 18px", + borderRadius: "5px", + cursor: "pointer", + fontWeight: "bold", + fontSize:"1em", + }, +}; + +const ConfirmDialog = ({ isOpen, type, onConfirm, onCancel }) => { + if (!isOpen) return null; + + const isDelete = type === "delete"; + + const message = isDelete + ? "Do you want to permanently delete this file? This action cannot be undone." + : "Do you want to verify this file? Once verified, it will be visible to all users."; + + return ( +
+
+ {isDelete +

Are you sure?

+

{message}

+
+ + +
+
+
+ ); +}; + +export default ConfirmDialog; diff --git a/client/src/screens/browse/components/file-display/index.jsx b/client/src/screens/browse/components/file-display/index.jsx index 2dce8a7c..63e0934a 100644 --- a/client/src/screens/browse/components/file-display/index.jsx +++ b/client/src/screens/browse/components/file-display/index.jsx @@ -1,4 +1,5 @@ import "./styles.scss"; +import React, { useState } from "react"; import { formatFileName, formatFileSize, formatFileType } from "../../../../utils/formatFile"; import { AddToFavourites } from "../../../../api/User"; import { toast } from "react-toastify"; @@ -12,11 +13,16 @@ import capitalise from "../../../../utils/capitalise.js"; import Share from "../../../share"; import { verifyFile, unverifyFile } from "../../../../api/File"; import { RemoveFileFromFolder, UpdateFileVerificationStatus } from "../../../../actions/filebrowser_actions.js"; +import ConfirmDialog from "./components/ConfirmDialog.jsx"; const FileDisplay = ({ file, path, code }) => { const user = useSelector((state) => state.user?.user); const fileSize = formatFileSize(file.size); const fileType = formatFileType(file.name); + const [showDialog, setShowDialog] = useState(false); + const [dialogType, setDialogType] = useState("verify"); + const [onConfirmAction, setOnConfirmAction] = useState(() => () => {}); + let name = file.name; let _dispName = formatFileName(name); let contributor = file.name; @@ -92,9 +98,11 @@ if (!file.isVerified && !currentUser?.isBR) { dispatch(UpdateFavourites(resp?.data?.favourites)); } }; -const handleVerify = async () => { - const confirmAction = window.confirm("Are you sure you want to verify this file?"); - if (!confirmAction) return; +const handleVerify = () => { +// const confirmAction = window.confirm("Are you sure you want to verify this file?"); +// if (!confirmAction) return; + setDialogType("verify"); + setOnConfirmAction(()=> async()=>{ try { console.log("Verifying file:", file._id); @@ -107,13 +115,18 @@ const handleVerify = async () => { } catch (err) { console.error("Error verifying:", err); toast.error("Failed to verify file."); + } finally{ + setShowDialog(false); } +}); + setShowDialog(true); }; -const handleUnverify = async () => { - const confirmAction = window.confirm("Are you sure you want to permanently delete this file?"); - if (!confirmAction) return; - +const handleUnverify = () => { +// const confirmAction = window.confirm("Are you sure you want to permanently delete this file?"); +// if (!confirmAction) return; + setDialogType("delete"); + setOnConfirmAction(()=>async()=>{ try { console.log("Deleting file:", file._id); await unverifyFile(file._id, file.fileId, currFolderId); @@ -124,7 +137,11 @@ const handleUnverify = async () => { } catch (err) { console.error("Error deleting:", err); toast.error("Failed to delete file."); - } + } finally { + setShowDialog(false); + } +}); + setShowDialog(true); }; @@ -188,6 +205,13 @@ const handleUnverify = async () => { + setShowDialog(false)} + /> + ); }; diff --git a/client/yarn.lock b/client/yarn.lock index 66057e70..b06eafa0 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -487,6 +487,11 @@ electron-to-chromium@^1.4.251: resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz" integrity sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA== +esbuild-darwin-arm64@0.15.16: + version "0.15.16" + resolved "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.16.tgz" + integrity sha512-fMXaUr5ou0M4WnewBKsspMtX++C1yIa3nJ5R2LSbLCfJT3uFdcRoU/NZjoM4kOMKyOD9Sa/2vlgN8G07K3SJnw== + esbuild@^0.15.9: version "0.15.16" resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.15.16.tgz" @@ -551,6 +556,11 @@ form-data@^4.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + function-bind@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" diff --git a/server/yarn.lock b/server/yarn.lock index 12f358fc..46c8594e 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -1541,6 +1541,11 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + function-bind@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"