feat: icon-only toolbar, versioning fixes, history modal, PanelRight repositioning
- Toolbar: remove text labels from all icon buttons (AI, Save, Preview, Convert) all buttons now icon-only with title tooltip for accessibility - Toolbar: reposition PanelRight (info panel toggle) to far right after three-dot menu - Versioning: decouple getNoteHistory/restoreNoteVersion from global userAISettings.noteHistory now checks note.historyEnabled directly — unblocks manual per-note history - Versioning: add 'Sauvegarder cette version' button in Versions tab of info panel calls commitNoteHistory with visual feedback (spinner → success state) - note-document-info-panel: import commitNoteHistory, add isSavingVersion state - notes.ts: fix double guard that silently blocked all history operations
This commit is contained in:
@@ -11,7 +11,7 @@ import { useLanguage } from '@/lib/i18n'
|
||||
import { useNotebooks } from '@/context/notebooks-context'
|
||||
import { LabelBadge } from './label-badge'
|
||||
import { NoteHistoryModal } from './note-history-modal'
|
||||
import { enableNoteHistory } from '@/app/actions/notes'
|
||||
import { enableNoteHistory, commitNoteHistory } from '@/app/actions/notes'
|
||||
|
||||
type Tab = 'info' | 'versions'
|
||||
|
||||
@@ -47,6 +47,8 @@ export function NoteDocumentInfoPanel({ note, content, onClose, onNoteRestored }
|
||||
const [activeTab, setActiveTab] = useState<Tab>('info')
|
||||
const [showHistory, setShowHistory] = useState(false)
|
||||
const [historyEnabled, setHistoryEnabled] = useState(note.historyEnabled ?? false)
|
||||
const [isSavingVersion, setIsSavingVersion] = useState(false)
|
||||
const [versionSaved, setVersionSaved] = useState(false)
|
||||
const locale = getLocale(language)
|
||||
|
||||
const notebook = useMemo(
|
||||
@@ -62,7 +64,7 @@ export function NoteDocumentInfoPanel({ note, content, onClose, onNoteRestored }
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex w-80 shrink-0 flex-col border-l border-border/40 bg-background overflow-hidden">
|
||||
<div className="flex w-full h-full flex-col bg-background overflow-hidden">
|
||||
|
||||
{/* Header tabs */}
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-border/40">
|
||||
@@ -199,8 +201,42 @@ export function NoteDocumentInfoPanel({ note, content, onClose, onNoteRestored }
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<p className="text-[10px] uppercase tracking-widest text-muted-foreground mb-3">Versions sauvegardées</p>
|
||||
<div className="space-y-3">
|
||||
<p className="text-[10px] uppercase tracking-widest text-muted-foreground">Versions sauvegardées</p>
|
||||
|
||||
{/* Save version button */}
|
||||
<button
|
||||
disabled={isSavingVersion}
|
||||
className={cn(
|
||||
'w-full flex items-center justify-center gap-2 p-3 rounded-xl border transition-colors text-sm font-medium',
|
||||
versionSaved
|
||||
? 'border-emerald-500/40 bg-emerald-50 dark:bg-emerald-950/30 text-emerald-700 dark:text-emerald-400'
|
||||
: 'border-foreground/20 bg-foreground text-background hover:opacity-80',
|
||||
isSavingVersion && 'opacity-50 cursor-not-allowed'
|
||||
)}
|
||||
onClick={async () => {
|
||||
setIsSavingVersion(true)
|
||||
try {
|
||||
await commitNoteHistory(note.id)
|
||||
setVersionSaved(true)
|
||||
setTimeout(() => setVersionSaved(false), 3000)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
setIsSavingVersion(false)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isSavingVersion ? (
|
||||
<><span className="h-3.5 w-3.5 rounded-full border-2 border-current border-t-transparent animate-spin" />Sauvegarde…</>
|
||||
) : versionSaved ? (
|
||||
<><span className="text-base">✓</span> Version sauvegardée !</>
|
||||
) : (
|
||||
<><span className="text-base">⎘</span> Sauvegarder cette version</>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* View history */}
|
||||
<button
|
||||
className="w-full flex items-center justify-between p-3 rounded-xl border border-border hover:bg-muted transition-colors text-left"
|
||||
onClick={() => setShowHistory(true)}
|
||||
|
||||
Reference in New Issue
Block a user