From 8b6fe7dd4757a049ab9efc293c2aaa23c057d20d Mon Sep 17 00:00:00 2001 From: Dicken Date: Thu, 28 May 2026 09:24:40 +0200 Subject: [PATCH] Dateien nach "frontend/src/tools" hochladen --- frontend/src/tools/dateien.jsx | 50 ++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/frontend/src/tools/dateien.jsx b/frontend/src/tools/dateien.jsx index fb97577..440659c 100644 --- a/frontend/src/tools/dateien.jsx +++ b/frontend/src/tools/dateien.jsx @@ -117,6 +117,47 @@ function ShareModal({ item, type, onClose, toast }) { } // ── Haupt-Komponente ────────────────────────────────────────────────────────── +// ── Passwort-Prompt Modal (ersetzt window.prompt – kein 1Password-Trigger) ──── +function PasswordPromptModal({ filename, onSubmit, onCancel }) { + const [pw, setPw] = useState(''); + const isMobile = window.innerWidth < 768; + return ( +
e.target===e.currentTarget&&onCancel()}> +
+ {isMobile&&
} +
+ 🔒 Passwortgeschützte Datei +
+
+ {filename} +
+ setPw(e.target.value)} + onKeyDown={e=>{ if(e.key==='Enter'&&pw)onSubmit(pw); if(e.key==='Escape')onCancel(); }} + placeholder="Passwort eingeben…" + style={{...S.inp,marginBottom:12,fontSize:14}} + /> +
+ + +
+
+
+ ); +} + export default function Dateien({ toast, mobile }) { const [data, setData] = useState({own:[],shared:[],sharedByMe:[]}); const [folders, setFolders] = useState({own:[],shared:[],sharedByMe:[]}); @@ -126,6 +167,7 @@ export default function Dateien({ toast, mobile }) { const [tab, setTab] = useState('own'); const [search, setSearch] = useState(''); const [shareItem, setShareItem] = useState(null); + const [pwPrompt, setPwPrompt] = useState(null); // {file} const [uploading, setUploading] = useState(false); const [dragOver, setDragOver] = useState(false); const [newFolder, setNewFolder] = useState(false); @@ -170,8 +212,7 @@ export default function Dateien({ toast, mobile }) { if (!res.ok) { const err = await res.json().catch(()=>({error:'Fehler'})); if (err.passwordRequired) { - const entered = window.prompt(`🔑 Datei "${file.originalname}" ist passwortgeschützt.\nBitte Passwort eingeben:`); - if (entered !== null) await download(file, entered); + setPwPrompt(file); return; } if (pw && res.status===403) { toast('Falsches Passwort', 'error'); return; } @@ -236,6 +277,11 @@ export default function Dateien({ toast, mobile }) {
{shareItem && {setShareItem(null);load();}} toast={toast}/>} + {pwPrompt && { setPwPrompt(null); download(pwPrompt, pw); }} + onCancel={()=>setPwPrompt(null)} + />} {/* ── Seitentitel ──────────────────────────────────────────────────── */}