refactor: simplify upload rules and remove destination flow

This commit is contained in:
Tom Boullay
2026-04-24 16:23:02 +02:00
parent 61a0146545
commit 944959fc22
20 changed files with 2033 additions and 217 deletions
+21 -17
View File
@@ -5,7 +5,6 @@ import { useSecret } from '@/hooks/useSecret'
import { useFolderEntries } from '@/hooks/useFolderEntries'
import { useUploadOrchestrator } from '@/hooks/useUploadOrchestrator'
import SecretInput from './upload/SecretInput'
import DestinationPicker from './upload/DestinationPicker'
import FolderDropzone from './upload/FolderDropzone'
import FolderCard from './upload/FolderCard'
import ActionButtons from './upload/ActionButtons'
@@ -38,8 +37,6 @@ export default function UploadZone() {
isUploading,
globalError,
setGlobalError,
destination,
setDestination,
overwriteConfirm,
setOverwriteConfirm,
noChangesFolder,
@@ -84,18 +81,28 @@ export default function UploadZone() {
onToggleVisible={toggleSecretVisible}
/>
<DestinationPicker
destination={destination}
disabled={isUploading}
onChange={setDestination}
/>
{entries.length === 0 && (
<FolderDropzone
isUploading={isUploading}
onFolderSelected={handleFolderSelected}
onError={setGlobalError}
/>
<div className="space-y-2">
<p className="text-xs text-gray-400 leading-relaxed text-center">
Deposez un dossier complet contenant votre modele 3D nomme
{' '}<span className="font-mono text-gray-200">model.glb</span>
{' '}ainsi que toutes les textures necessaires.
{' '}Les textures peuvent etre en
{' '}<span className="font-mono text-gray-200">.png</span>,
{' '}<span className="font-mono text-gray-200">.jpg</span>
{' '}ou <span className="font-mono text-gray-200">.webp</span>.
{' '}Utilisez un nom simple si la texture s&apos;applique au modele entier, et un nom detaille si elle correspond a une partie precise du modele,
{' '}par exemple <span className="font-mono text-gray-200">color_fenetre.jpg</span>,
{' '}<span className="font-mono text-gray-200">roughness_tuyaux.png</span>,
{' '}<span className="font-mono text-gray-200">normal_dashboard.webp</span>
{' '}ou <span className="font-mono text-gray-200">opacity_verre.png</span>.
</p>
<FolderDropzone
isUploading={isUploading}
onFolderSelected={handleFolderSelected}
onError={setGlobalError}
/>
</div>
)}
{globalError && (
@@ -119,7 +126,6 @@ export default function UploadZone() {
<ActionButtons
isUploading={isUploading}
isSecretEmpty={isSecretEmpty}
noDestination={!destination}
hasPendingOrErrors={hasPendingOrErrors}
allDone={allDone}
hasErrors={hasErrors}
@@ -130,7 +136,6 @@ export default function UploadZone() {
{overwriteConfirm && (
<OverwriteConfirmModal
destination={destination!}
folderName={overwriteConfirm.folderName}
diffs={overwriteConfirm.diffs}
onCancel={() => setOverwriteConfirm(null)}
@@ -140,7 +145,6 @@ export default function UploadZone() {
{noChangesFolder && (
<NoChangesModal
destination={destination!}
folderName={noChangesFolder}
onCancel={() => {
setNoChangesFolder(null)
+1 -3
View File
@@ -1,7 +1,6 @@
interface ActionButtonsProps {
isUploading: boolean
isSecretEmpty: boolean
noDestination: boolean
hasPendingOrErrors: boolean
allDone: boolean
hasErrors: boolean
@@ -13,7 +12,6 @@ interface ActionButtonsProps {
export default function ActionButtons({
isUploading,
isSecretEmpty,
noDestination,
hasPendingOrErrors,
allDone,
hasErrors,
@@ -21,7 +19,7 @@ export default function ActionButtons({
onCancel,
onReset,
}: ActionButtonsProps) {
const cantUpload = isSecretEmpty || noDestination
const cantUpload = isSecretEmpty
return (
<div className="flex gap-3">
-38
View File
@@ -1,38 +0,0 @@
import { DESTINATIONS } from '@/lib/constants'
import type { Destination } from '@/lib/constants'
interface DestinationPickerProps {
destination: Destination | null
disabled: boolean
onChange: (value: Destination) => void
}
export default function DestinationPicker({
destination,
disabled,
onChange,
}: DestinationPickerProps) {
return (
<div className="space-y-1.5">
<label className="block text-sm font-medium text-gray-300">Destination</label>
<div className="grid grid-cols-3 gap-2">
{DESTINATIONS.map((dest) => (
<button
key={dest.value}
type="button"
onClick={() => onChange(dest.value)}
disabled={disabled}
className={`px-3 py-2 rounded-xl text-sm font-medium transition-all duration-150 border
disabled:opacity-50 disabled:cursor-not-allowed
${destination === dest.value
? 'bg-white text-[#000000] border-white'
: 'bg-black-800 text-gray-400 border-white/20 hover:border-white/40 hover:text-gray-200'
}`}
>
{dest.label}
</button>
))}
</div>
</div>
)
}
-4
View File
@@ -170,10 +170,6 @@ export default function FolderDropzone({
Deposez votre dossier ici
<span className="text-gray-500 font-normal"> ou cliquez pour parcourir</span>
</p>
<p className="text-xs text-gray-500 mt-1">
Contenu attendu : model.glb/gltf + textures (roughness, normal, metalness, color, displace)
<br />Les originaux sont archives sur le Drive, les comprimes sont envoyes sur Git.
</p>
</div>
</>
)
+1 -3
View File
@@ -2,14 +2,12 @@ import Modal, { ModalActions } from '@/components/ui/Modal'
import { CheckIcon } from '@/components/ui/icons'
interface NoChangesModalProps {
destination: string
folderName: string
onCancel: () => void
onModify: () => void
}
export default function NoChangesModal({
destination,
folderName,
onCancel,
onModify,
@@ -25,7 +23,7 @@ export default function NoChangesModal({
Aucun changement detecte
</h3>
<p className="text-xs text-gray-400 mt-0.5">
Le dossier <span className="font-mono text-gray-300">{destination}/{folderName}</span> est identique au contenu distant. Rien a envoyer.
Le dossier <span className="font-mono text-gray-300">public/models/{folderName}</span> est identique au contenu distant. Rien a envoyer.
</p>
</div>
</div>
+1 -3
View File
@@ -3,7 +3,6 @@ import Modal, { ModalActions } from '@/components/ui/Modal'
import { WarningIcon } from '@/components/ui/icons'
interface OverwriteConfirmModalProps {
destination: string
folderName: string
diffs: FileDiff[]
onCancel: () => void
@@ -11,7 +10,6 @@ interface OverwriteConfirmModalProps {
}
export default function OverwriteConfirmModal({
destination,
folderName,
diffs,
onCancel,
@@ -28,7 +26,7 @@ export default function OverwriteConfirmModal({
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.
<span className="font-mono text-yellow-400">public/models/{folderName}</span> existe deja.
Les anciens fichiers seront archives sur le Drive, puis les nouveaux seront envoyes sur le Drive et Git.
</p>
</div>