refactor: full codebase audit — extract modules, fix type safety, clean dead code
- Extract API helpers from UploadZone into lib/upload-api.ts (FormData builder, checkFolderDiffs, uploadDrive, uploadGit)
- Extract upload orchestration into hooks/useUploadOrchestrator.ts (UploadZone: 489 → 162 lines)
- Extract file diff classification into lib/diff-files.ts (from git route)
- Extract shared SVG icons into components/ui/icons.tsx (7 icons, 0 duplication)
- Extract shared modal wrapper into components/ui/Modal.tsx + ModalActions
- Extract DriveStatusLine sub-component from FolderCard
- Fix checkFolderDiffs silently swallowing auth/network errors (now throws)
- Fix type safety: remove as never casts, add isHttpError type guard, use discriminated union for validateFolder
- Fix nextcloud: cache getConfig, add max bound to findNextVersion, optimize mkdirRecursive (skip PROPFIND)
- Fix drive route: remove req.clone(), extend parseMultiUpload to return extra fields
- Fix commit message: model shown as unchanged with ↔️ on updates (not falsely marked as modified)
- Clean dead code: unused folderExists import, FileStatus/DriveStatus exports, ParsedFile.textureName, getConfig basePath
- Add security headers in next.config.ts (HSTS, X-Content-Type-Options, X-Frame-Options, etc.)
- Update README with new project structure
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import type { FileDiff } from '@/lib/types'
|
||||
import Modal, { ModalActions } from '@/components/ui/Modal'
|
||||
import { WarningIcon } from '@/components/ui/icons'
|
||||
|
||||
interface OverwriteConfirmModalProps {
|
||||
destination: string
|
||||
@@ -16,83 +18,59 @@ export default function OverwriteConfirmModal({
|
||||
onConfirm,
|
||||
}: OverwriteConfirmModalProps) {
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="overwrite-title"
|
||||
>
|
||||
<div className="bg-black-900 border border-white/20 rounded-2xl p-6 max-w-md w-full mx-4 space-y-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-full bg-yellow-900/30 flex items-center justify-center shrink-0">
|
||||
<svg className="w-5 h-5 text-yellow-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h3 id="overwrite-title" className="text-sm font-semibold text-gray-100">
|
||||
Dossier deja existant
|
||||
</h3>
|
||||
<p className="text-xs text-gray-400 mt-0.5">
|
||||
<span className="font-mono text-yellow-400">{destination}/{folderName}</span> existe deja.
|
||||
Les anciens fichiers seront archives sur le Drive, puis les nouveaux seront envoyes sur le Drive et Git.
|
||||
</p>
|
||||
</div>
|
||||
<Modal ariaLabelledBy="overwrite-title">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-full bg-yellow-900/30 flex items-center justify-center shrink-0">
|
||||
<WarningIcon className="w-5 h-5 text-yellow-400" />
|
||||
</div>
|
||||
|
||||
{diffs.length > 0 && (
|
||||
<div className="bg-black-800 border border-white/10 rounded-xl p-3 max-h-40 overflow-y-auto">
|
||||
<p className="text-xs text-gray-500 mb-2">Modifications detectees :</p>
|
||||
<ul className="space-y-1">
|
||||
{diffs.map((d) => (
|
||||
<li key={d.name} className="flex items-center gap-2 text-xs font-mono">
|
||||
{d.status === 'changed' && (
|
||||
<>
|
||||
<span className="text-yellow-400">🔄</span>
|
||||
<span className="text-gray-300">{d.name}</span>
|
||||
</>
|
||||
)}
|
||||
{d.status === 'new' && (
|
||||
<>
|
||||
<span className="text-green-400">✅</span>
|
||||
<span className="text-gray-300">{d.name}</span>
|
||||
</>
|
||||
)}
|
||||
{d.status === 'deleted' && (
|
||||
<>
|
||||
<span className="text-red-400">❌</span>
|
||||
<span className="text-gray-500 line-through">{d.name}</span>
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-3">
|
||||
<button
|
||||
onClick={onCancel}
|
||||
className="flex-1 bg-black-700 text-gray-300 font-medium text-sm
|
||||
py-2.5 px-4 rounded-xl border border-white/10 transition-colors duration-150
|
||||
hover:bg-black-600"
|
||||
>
|
||||
Annuler
|
||||
</button>
|
||||
<button
|
||||
onClick={onConfirm}
|
||||
className="flex-1 bg-yellow-600 text-[#000000] font-medium text-sm
|
||||
py-2.5 px-4 rounded-xl transition-colors duration-150
|
||||
hover:bg-yellow-500"
|
||||
>
|
||||
Remplacer
|
||||
</button>
|
||||
<div>
|
||||
<h3 id="overwrite-title" className="text-sm font-semibold text-gray-100">
|
||||
Dossier deja existant
|
||||
</h3>
|
||||
<p className="text-xs text-gray-400 mt-0.5">
|
||||
<span className="font-mono text-yellow-400">{destination}/{folderName}</span> existe deja.
|
||||
Les anciens fichiers seront archives sur le Drive, puis les nouveaux seront envoyes sur le Drive et Git.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{diffs.length > 0 && (
|
||||
<div className="bg-black-800 border border-white/10 rounded-xl p-3 max-h-40 overflow-y-auto">
|
||||
<p className="text-xs text-gray-500 mb-2">Modifications detectees :</p>
|
||||
<ul className="space-y-1">
|
||||
{diffs.map((d) => (
|
||||
<li key={d.name} className="flex items-center gap-2 text-xs font-mono">
|
||||
{d.status === 'changed' && (
|
||||
<>
|
||||
<span className="text-yellow-400">🔄</span>
|
||||
<span className="text-gray-300">{d.name}</span>
|
||||
</>
|
||||
)}
|
||||
{d.status === 'new' && (
|
||||
<>
|
||||
<span className="text-green-400">✅</span>
|
||||
<span className="text-gray-300">{d.name}</span>
|
||||
</>
|
||||
)}
|
||||
{d.status === 'deleted' && (
|
||||
<>
|
||||
<span className="text-red-400">❌</span>
|
||||
<span className="text-gray-500 line-through">{d.name}</span>
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<ModalActions
|
||||
cancelLabel="Annuler"
|
||||
confirmLabel="Remplacer"
|
||||
onCancel={onCancel}
|
||||
onConfirm={onConfirm}
|
||||
confirmClassName="bg-yellow-600 text-[#000000] hover:bg-yellow-500"
|
||||
/>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user