Upload folder using huggingface_hub
Browse files
client/src/components/Refinity.tsx
CHANGED
|
@@ -55,6 +55,13 @@ const Refinity: React.FC = () => {
|
|
| 55 |
return 'Anonymous';
|
| 56 |
}
|
| 57 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
// File upload (.docx placeholder)
|
| 60 |
const [uploading, setUploading] = React.useState(false);
|
|
@@ -102,6 +109,20 @@ const Refinity: React.FC = () => {
|
|
| 102 |
})();
|
| 103 |
}, [task?.id]);
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
const [flowIndex, setFlowIndex] = React.useState<number>(0);
|
| 106 |
const focusedIndex = React.useMemo(() => {
|
| 107 |
const idx = taskVersions.findIndex(v => v.id === currentVersionId);
|
|
@@ -443,7 +464,7 @@ const Refinity: React.FC = () => {
|
|
| 443 |
selectManual(v.id);
|
| 444 |
}}
|
| 445 |
className="inline-flex items-center justify-center gap-2 text-white text-sm font-medium rounded-2xl ring-1 ring-inset ring-white/50 active:translate-y-0.5 transition-all duration-200"
|
| 446 |
-
style={{ position: 'relative', zIndex: 3100, pointerEvents: 'auto', padding: '0.5rem 0.75rem', backgroundColor: '#4f46e5',
|
| 447 |
>
|
| 448 |
Revise
|
| 449 |
</button>
|
|
@@ -451,10 +472,20 @@ const Refinity: React.FC = () => {
|
|
| 451 |
type="button"
|
| 452 |
onClick={(e) => { e.preventDefault(); e.stopPropagation(); setCompareUIOpen(true); if (!compareA) setCompareA(v.id); }}
|
| 453 |
className="inline-flex items-center justify-center gap-2 text-black text-sm font-medium rounded-2xl ring-1 ring-inset ring-white/50 active:translate-y-0.5 transition-all duration-200"
|
| 454 |
-
style={{ position: 'relative', zIndex: 3100, pointerEvents: 'auto', padding: '0.5rem 0.75rem', background: 'rgba(255,255,255,0.3)',
|
| 455 |
>
|
| 456 |
Compare
|
| 457 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
</div>
|
| 459 |
)}
|
| 460 |
</div>
|
|
|
|
| 55 |
return 'Anonymous';
|
| 56 |
}
|
| 57 |
});
|
| 58 |
+
const [isAdmin] = React.useState<boolean>(() => {
|
| 59 |
+
try {
|
| 60 |
+
const u = localStorage.getItem('user');
|
| 61 |
+
const role = u ? (JSON.parse(u)?.role || '') : '';
|
| 62 |
+
return String(role).toLowerCase() === 'admin';
|
| 63 |
+
} catch { return false; }
|
| 64 |
+
});
|
| 65 |
|
| 66 |
// File upload (.docx placeholder)
|
| 67 |
const [uploading, setUploading] = React.useState(false);
|
|
|
|
| 109 |
})();
|
| 110 |
}, [task?.id]);
|
| 111 |
|
| 112 |
+
const deleteVersion = React.useCallback(async (versionId: string) => {
|
| 113 |
+
try {
|
| 114 |
+
const ok = window.confirm('Delete this version? This cannot be undone.');
|
| 115 |
+
if (!ok) return;
|
| 116 |
+
const base = ((api.defaults as any)?.baseURL as string || '').replace(/\/$/, '');
|
| 117 |
+
const resp = await fetch(`${base}/api/refinity/versions/${encodeURIComponent(versionId)}`, {
|
| 118 |
+
method: 'DELETE',
|
| 119 |
+
headers: { 'x-user-role': 'admin' }
|
| 120 |
+
});
|
| 121 |
+
if (!resp.ok) throw new Error('Delete failed');
|
| 122 |
+
setVersions(prev => prev.filter(v => v.id !== versionId));
|
| 123 |
+
} catch {}
|
| 124 |
+
}, []);
|
| 125 |
+
|
| 126 |
const [flowIndex, setFlowIndex] = React.useState<number>(0);
|
| 127 |
const focusedIndex = React.useMemo(() => {
|
| 128 |
const idx = taskVersions.findIndex(v => v.id === currentVersionId);
|
|
|
|
| 464 |
selectManual(v.id);
|
| 465 |
}}
|
| 466 |
className="inline-flex items-center justify-center gap-2 text-white text-sm font-medium rounded-2xl ring-1 ring-inset ring-white/50 active:translate-y-0.5 transition-all duration-200"
|
| 467 |
+
style={{ position: 'relative', zIndex: 3100, pointerEvents: 'auto', padding: '0.5rem 0.75rem', backgroundColor: '#4f46e5', borderRadius: '1rem', border: '1px solid rgba(255,255,255,0.5)' }}
|
| 468 |
>
|
| 469 |
Revise
|
| 470 |
</button>
|
|
|
|
| 472 |
type="button"
|
| 473 |
onClick={(e) => { e.preventDefault(); e.stopPropagation(); setCompareUIOpen(true); if (!compareA) setCompareA(v.id); }}
|
| 474 |
className="inline-flex items-center justify-center gap-2 text-black text-sm font-medium rounded-2xl ring-1 ring-inset ring-white/50 active:translate-y-0.5 transition-all duration-200"
|
| 475 |
+
style={{ position: 'relative', zIndex: 3100, pointerEvents: 'auto', padding: '0.5rem 0.75rem', background: 'rgba(255,255,255,0.3)', borderRadius: '1rem', border: '1px solid rgba(255,255,255,0.5)' }}
|
| 476 |
>
|
| 477 |
Compare
|
| 478 |
</button>
|
| 479 |
+
{isAdmin && (
|
| 480 |
+
<button
|
| 481 |
+
type="button"
|
| 482 |
+
onClick={(e)=>{ e.preventDefault(); e.stopPropagation(); deleteVersion(v.id); }}
|
| 483 |
+
className="inline-flex items-center justify-center gap-2 text-white text-sm font-medium rounded-2xl ring-1 ring-inset ring-white/50 active:translate-y-0.5 transition-all duration-200"
|
| 484 |
+
style={{ position: 'relative', zIndex: 3100, pointerEvents: 'auto', padding: '0.5rem 0.75rem', backgroundColor: '#dc2626', borderRadius: '1rem', border: '1px solid rgba(255,255,255,0.5)' }}
|
| 485 |
+
>
|
| 486 |
+
Delete
|
| 487 |
+
</button>
|
| 488 |
+
)}
|
| 489 |
</div>
|
| 490 |
)}
|
| 491 |
</div>
|