From f683dc66dfd5d6bcf64f008cc9004e2efd557c56 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Fri, 17 Jul 2026 20:48:15 +0200 Subject: [PATCH] refactor(ui): move 'apply to all' into the subtitle modal itself Instead of a separate header button + bulk modal, the per-clip subtitle editor now has a second action: 'apply this style to all N clips'. Same bulk loop, but you pick and preview the look on the clip you opened, then one click applies it everywhere (progress shown inline). Header keeps only 'download all' + 'schedule week'. --- dashboard/src/App.jsx | 37 +++------------- dashboard/src/components/ResultCard.jsx | 10 ++++- dashboard/src/components/SubtitleModal.jsx | 49 +++++++++++++++------- 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index 9c2e4c6..5dda430 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -1,9 +1,8 @@ import React, { useState, useEffect } from 'react'; -import { Upload, Sparkles, Youtube, Instagram, Share2, ChevronDown, Check, Activity, LayoutDashboard, Settings, Plus, History, X, Terminal, Shield, LayoutGrid, Image, Globe, RotateCcw, Calendar, AlertTriangle, KeyRound, Bot, Users, Smartphone, ExternalLink, Copy, CheckCircle2, Mail, Loader2, Download, Type } from 'lucide-react'; +import { Upload, Sparkles, Youtube, Instagram, Share2, ChevronDown, Check, Activity, LayoutDashboard, Settings, Plus, History, X, Terminal, Shield, LayoutGrid, Image, Globe, RotateCcw, Calendar, AlertTriangle, KeyRound, Bot, Users, Smartphone, ExternalLink, Copy, CheckCircle2, Mail, Loader2, Download } from 'lucide-react'; import KeyInput from './components/KeyInput'; import MediaInput from './components/MediaInput'; import ResultCard from './components/ResultCard'; -import SubtitleModal from './components/SubtitleModal'; import ProcessingAnimation from './components/ProcessingAnimation'; // import Gallery from './components/Gallery'; import ThumbnailStudio from './components/ThumbnailStudio'; @@ -19,7 +18,6 @@ import AdvancedBanner from './components/AdvancedBanner'; import HistoryTab from './components/HistoryTab'; import ProfileMenu from './components/ProfileMenu'; import Modal from './components/ui/Modal'; -import { getApiUrl } from './config'; import { useAuth } from './contexts/AuthContext'; import { apiFetch, apiJson, QuotaError } from './lib/api'; @@ -183,8 +181,8 @@ function App() { const [jobId, setJobId] = useState(null); const [status, setStatus] = useState('idle'); // idle, processing, complete, error const [results, setResults] = useState(null); - // Bulk subtitles: apply one style to every clip of the job - const [showBulkSubtitles, setShowBulkSubtitles] = useState(false); + // Bulk subtitles: apply one style to every clip of the job (triggered from + // within a clip's subtitle modal via "apply to all"). const [bulkSub, setBulkSub] = useState({ running: false, current: 0, total: 0, errors: 0 }); const [downloadingAll, setDownloadingAll] = useState(false); const [logs, setLogs] = useState([]); @@ -253,7 +251,6 @@ function App() { } } setBulkSub({ running: false, current: total, total, errors }); - setShowBulkSubtitles(false); // Refresh results so each ResultCard picks up its new subtitled video_url. try { const data = await pollJob(jobId); @@ -1212,18 +1209,6 @@ function App() { )} {results?.clips?.length > 0 && status === 'complete' && (
- {results.clips.length > 1 && ( - - )}
@@ -1392,19 +1380,6 @@ function App() { isManaged={isManaged} /> - {/* Bulk subtitles: preview on the first clip, apply the chosen style to all */} - {showBulkSubtitles && results?.clips?.length > 0 && ( - setShowBulkSubtitles(false)} - onGenerate={handleBulkSubtitles} - isProcessing={bulkSub.running} - videoUrl={getApiUrl(results.clips[0].video_url)} - jobId={jobId} - clipIndex={0} - bulkCount={results.clips.length} - /> - )} {showLogin && setShowLogin(false)} />} {showTopUp && ( diff --git a/dashboard/src/components/ResultCard.jsx b/dashboard/src/components/ResultCard.jsx index ac278d7..fe977c8 100644 --- a/dashboard/src/components/ResultCard.jsx +++ b/dashboard/src/components/ResultCard.jsx @@ -23,7 +23,7 @@ function formatDuration(clip) { return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`; } -export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause }) { +export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause, onBulkSubtitle, clipCount = 1, bulkProgress }) { const [showModal, setShowModal] = useState(false); const [showSubtitleModal, setShowSubtitleModal] = useState(false); const videoRef = React.useRef(null); @@ -747,7 +747,13 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK isOpen={showSubtitleModal} onClose={() => setShowSubtitleModal(false)} onGenerate={handleSubtitle} - isProcessing={isSubtitling} + onApplyAll={onBulkSubtitle ? async (options) => { + await onBulkSubtitle(options); + setShowSubtitleModal(false); + } : undefined} + bulkCount={clipCount} + bulkProgress={bulkProgress} + isProcessing={isSubtitling || (bulkProgress?.running ?? false)} videoUrl={originalVideoUrl} jobId={jobId} clipIndex={index} diff --git a/dashboard/src/components/SubtitleModal.jsx b/dashboard/src/components/SubtitleModal.jsx index 65e51cc..e48f82e 100644 --- a/dashboard/src/components/SubtitleModal.jsx +++ b/dashboard/src/components/SubtitleModal.jsx @@ -75,7 +75,7 @@ const swatchClass = (selected) => ? 'ring-2 ring-[color:var(--color-accent)] ring-offset-2 ring-offset-[color:var(--color-paper-2)]' : 'ring-1 ring-[color:var(--color-rule-2)] hover:ring-[color:var(--color-accent)]'}`; -export default function SubtitleModal({ isOpen, onClose, onGenerate, isProcessing, videoUrl, jobId, clipIndex, existingHook, bulkCount = 0 }) { +export default function SubtitleModal({ isOpen, onClose, onGenerate, onApplyAll, isProcessing, videoUrl, jobId, clipIndex, existingHook, bulkCount = 0, bulkProgress }) { const [position, setPosition] = useState('bottom'); const [fontSize] = useState(24); const [fontName, setFontName] = useState('Verdana'); @@ -479,24 +479,45 @@ export default function SubtitleModal({ isOpen, onClose, onGenerate, isProcessin -
- - + }; + const bulkRunning = bulkProgress?.running; + return ( + <> +
+ + +
+ {onApplyAll && bulkCount > 1 && ( + + )} + + ); + })()}