File uploads external source
This commit is contained in:
@@ -50,7 +50,7 @@ function fmtBytes(n) {
|
||||
return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
export function BatchCatalogPanel() {
|
||||
export function BatchCatalogPanel({ adoptBatch = null }) {
|
||||
const [files, setFiles] = useState([]);
|
||||
const [preview, setPreview] = useState(null);
|
||||
const [previewing, setPreviewing] = useState(false);
|
||||
@@ -63,6 +63,18 @@ export function BatchCatalogPanel() {
|
||||
const pollRef = useRef(null);
|
||||
const batchIdRef = useRef(null);
|
||||
|
||||
// A batch started from the Review Inbox tab. Without this, switching tabs
|
||||
// after pressing "Start selected" would land on an empty panel and the run
|
||||
// would look like it had not happened.
|
||||
useEffect(() => {
|
||||
if (!adoptBatch?.batch_id) return;
|
||||
setBatch(adoptBatch);
|
||||
setFiles([]);
|
||||
setPreview(null);
|
||||
setError('');
|
||||
if (!TERMINAL.has(adoptBatch.status)) batchIdRef.current = adoptBatch.batch_id;
|
||||
}, [adoptBatch]);
|
||||
|
||||
// One interval for the component's lifetime, reading the id from a ref
|
||||
// rather than closing over it. Same reasoning as StoreCatalogPanel: starting
|
||||
// a second batch must not leave an older interval polling the previous one.
|
||||
|
||||
Reference in New Issue
Block a user