feat: PW-Kopier-Button in Link-Liste, Bezeichnung ohne PW sichtbar, kein Auto-Download

This commit is contained in:
2026-06-13 13:32:12 +02:00
parent e6f5189448
commit d14251da72
2 changed files with 57 additions and 35 deletions

View File

@@ -27,7 +27,7 @@ const IconBtn = ({ onClick, color, title, children, stop }) => (
);
// ── Öffentlicher Link-Share Modal ─────────────────────────────────────────────
function PublicShareModal({ item, itemType, onClose, toast }) {
function PublicShareModal({ item, itemType, onClose, onShareCreated, toast }) {
const [password, setPassword] = useState(() => genPw());
const [expiresH, setExpiresH] = useState(1);
const [label, setLabel] = useState('');
@@ -74,6 +74,7 @@ function PublicShareModal({ item, itemType, onClose, toast }) {
setNewLink(link);
setNewPw(password.trim());
setShares(p => [d.share, ...p]);
onShareCreated?.(d.token, password.trim());
navigator.clipboard?.writeText(link).catch(()=>{});
toast('Link erstellt & kopiert ✓');
setPassword(genPw());
@@ -594,6 +595,7 @@ export default function Dateien({ toast, mobile }) {
const [publicShareItem, setPublicShareItem] = useState(null);
const [publicShares, setPublicShares] = useState([]);
const [showPublicLinks, setShowPublicLinks] = useState(false);
const [sharePws, setSharePws] = useState({}); // {token: plaintext_pw}
const [pwPrompt, setPwPrompt] = useState(null); // {file}
const [uploading, setUploading] = useState(false);
const [dragOver, setDragOver] = useState(false);
@@ -732,7 +734,7 @@ export default function Dateien({ toast, mobile }) {
</div>
)}
{shareItem && <ShareModal item={shareItem.item} type={shareItem.type} onClose={()=>{setShareItem(null);load();}} toast={toast}/>}
{publicShareItem && <PublicShareModal item={publicShareItem.item} itemType={publicShareItem.type} onClose={()=>{setPublicShareItem(null);api('/tools/dateien/public-shares').then(d=>setPublicShares(d.shares||[])).catch(()=>{});}} toast={toast}/>}
{publicShareItem && <PublicShareModal item={publicShareItem.item} itemType={publicShareItem.type} onClose={()=>{setPublicShareItem(null);api('/tools/dateien/public-shares').then(d=>setPublicShares(d.shares||[])).catch(()=>{});}} onShareCreated={(token,pw)=>setSharePws(p=>({...p,[token]:pw}))} toast={toast}/>}
{/* ── Aktive öffentliche Links ──────────────────────────────────────── */}
{publicShares.length > 0 && tab === 'own' && (
@@ -779,6 +781,16 @@ export default function Dateien({ toast, mobile }) {
style={{background:'rgba(74,222,128,0.1)',border:'1px solid rgba(74,222,128,0.3)',borderRadius:5,padding:'4px 8px',color:'#4ade80',fontFamily:'monospace',fontSize:9,cursor:'pointer',flexShrink:0}}>
📋
</button>
{sharePws[s.token] && (
<button onClick={()=>{
navigator.clipboard?.writeText(sharePws[s.token])
.then(()=>toast('Passwort kopiert ✓')).catch(()=>toast(sharePws[s.token]));
}}
style={{background:'rgba(245,158,11,0.1)',border:'1px solid rgba(245,158,11,0.3)',borderRadius:5,padding:'4px 8px',color:'#f59e0b',fontFamily:'monospace',fontSize:9,cursor:'pointer',flexShrink:0}}
title={sharePws[s.token]}>
🔑
</button>
)}
<button onClick={async()=>{
await api(`/tools/dateien/public-shares/${s.id}`,{method:'DELETE'});
setPublicShares(p=>p.filter(x=>x.id!==s.id));