feat: diff viewer backups — point 6 (backups, diff, restore)
CI / lint (push) Failing after 4s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / security (push) Successful in 8s

- Backend: 3 nouveaux endpoints
  - GET /api/file/{vault}/backups — liste les backups horodatés
  - GET /api/file/{vault}/diff — diff unifié entre versions
  - POST /api/file/{vault}/restore — restaure une version (backup auto avant)
- Frontend: module backups.js — UI modale avec:
  - Sélecteur gauche (backup) / droite (version actuelle ou autre backup)
  - Diff coloré: vert pour ajouts, rouge pour suppressions
  - Bouton Restaurer avec confirmation
- Menu contextuel: clic droit fichier → 'Backups / Versions'
- CSS: styles complets pour la modale, toolbar, table de diff
- ROADMAP: point 6 marqué comme complété
This commit is contained in:
2026-06-03 22:22:50 -04:00
parent c07de4fd65
commit d1ba15c3aa
5 changed files with 967 additions and 9 deletions
+279
View File
@@ -6868,3 +6868,282 @@ body.popup-mode .content-area {
background: rgba(239,68,68,0.1);
}
}
/* ==========================================================================
Backup / Diff Viewer Modal
========================================================================== */
.backup-viewer-panel {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: min(90vw, 960px);
height: min(85vh, 700px);
background: var(--bg-primary, #1e1e2e);
border: 1px solid var(--border);
border-radius: 12px;
box-shadow: 0 25px 60px rgba(0,0,0,0.5);
display: flex;
flex-direction: column;
overflow: hidden;
z-index: 1001;
}
.backup-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 18px;
border-bottom: 1px solid var(--border);
background: var(--bg-secondary);
flex-shrink: 0;
}
.backup-header-left {
display: flex;
align-items: baseline;
gap: 10px;
min-width: 0;
}
.backup-header h3 {
margin: 0;
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
}
.backup-file-path {
font-size: 0.78rem;
color: var(--text-muted);
font-family: var(--font-mono, 'SF Mono', 'Fira Code', monospace);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.backup-header-right {
display: flex;
align-items: center;
gap: 12px;
flex-shrink: 0;
}
.backup-count {
font-size: 0.75rem;
color: var(--text-muted);
background: var(--bg-tertiary);
padding: 3px 8px;
border-radius: 4px;
}
.backup-close-btn {
width: 32px;
height: 32px;
border: none;
border-radius: 6px;
background: transparent;
color: var(--text-muted);
font-size: 1.4rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
line-height: 1;
transition: color 0.15s, background 0.15s;
}
.backup-close-btn:hover {
color: var(--text-primary);
background: var(--bg-tertiary);
}
.backup-toolbar {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 18px;
border-bottom: 1px solid var(--border);
background: var(--bg-primary);
flex-shrink: 0;
}
.backup-selector-group {
display: flex;
align-items: center;
gap: 6px;
}
.backup-selector-group label {
font-size: 0.78rem;
color: var(--text-muted);
white-space: nowrap;
}
.backup-select {
padding: 6px 10px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--bg-secondary);
color: var(--text-primary);
font-size: 0.8rem;
font-family: var(--font-mono);
max-width: 240px;
cursor: pointer;
}
.backup-select:focus {
outline: none;
border-color: var(--accent);
}
.backup-vs-label {
font-size: 0.75rem;
color: var(--text-muted);
font-weight: 600;
user-select: none;
}
.backup-restore-btn {
margin-left: auto;
padding: 6px 14px;
border: 1px solid var(--accent);
border-radius: 6px;
background: color-mix(in srgb, var(--accent) 10%, transparent);
color: var(--accent);
font-size: 0.8rem;
font-weight: 500;
cursor: pointer;
display: flex;
align-items: center;
gap: 5px;
transition: background 0.15s, opacity 0.15s;
white-space: nowrap;
}
.backup-restore-btn:hover {
background: color-mix(in srgb, var(--accent) 20%, transparent);
}
.backup-restore-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.backup-restore-btn .icon-sm {
width: 14px;
height: 14px;
}
.backup-diff-container {
flex: 1;
overflow-y: auto;
background: var(--bg-primary);
}
.backup-diff-loading,
.backup-diff-error,
.backup-diff-empty {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
color: var(--text-muted);
font-size: 0.85rem;
}
.backup-diff-error {
color: var(--danger, #ef4444);
}
.backup-diff-output {
padding: 0;
}
.backup-diff-table {
width: 100%;
border-collapse: collapse;
font-family: var(--font-mono, 'SF Mono', 'Fira Code', 'Cascadia Code', monospace);
font-size: 0.8rem;
line-height: 1.55;
table-layout: fixed;
}
.backup-diff-table td {
padding: 0;
}
.backup-diff-table td.diff-prefix {
width: 22px;
text-align: center;
user-select: none;
font-weight: 600;
padding: 1px 0;
vertical-align: top;
}
.backup-diff-table td.diff-content {
padding: 1px 8px;
vertical-align: top;
}
.backup-diff-table td.diff-content pre {
margin: 0;
white-space: pre-wrap;
word-break: break-all;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
.backup-diff-table tr.diff-add td {
background: rgba(34, 197, 94, 0.12);
}
.backup-diff-table tr.diff-add td.diff-prefix {
color: #22c55e;
}
.backup-diff-table tr.diff-del td {
background: rgba(239, 68, 68, 0.12);
}
.backup-diff-table tr.diff-del td.diff-prefix {
color: #ef4444;
}
.backup-diff-table tr.diff-hunk td {
background: color-mix(in srgb, var(--accent) 8%, transparent);
color: var(--accent);
font-weight: 600;
}
.backup-diff-table tr.diff-header-line td {
background: var(--bg-secondary);
color: var(--text-muted);
font-weight: 600;
}
.backup-diff-table tr.diff-context td {
color: var(--text-secondary);
}
.backup-body {
flex: 1;
display: flex;
flex-direction: column;
overflow: auto;
}
.backup-footer {
padding: 6px 18px;
border-top: 1px solid var(--border);
background: var(--bg-secondary);
flex-shrink: 0;
}
.backup-footer-hint {
font-size: 0.7rem;
color: var(--text-muted);
}