feat(canvas): native field preservation, label materialization, batch workspace delete (#12)
* feat(canvas): native field preservation, label materialization, batch workspace delete - fillNativeFields() + repairContainerBinding() in db layer ensure every element stored in SQLite is a complete, round-trippable Excalidraw element with correct containerId ↔ boundElements bidirectional binding - materializeLabel() in server.ts: shapes with label.text/text produce a native bound text element at write time (create, update, batch) so text follows its container when moved — matches VSCode Excalidraw extension behavior - Batch workspace UI: Select/Unselect All, per-row checkboxes, Delete N workspaces button with confirmation - POST /api/tenants/batch-delete: delete up to 50 tenants in one request - 42 new backend tests; 519 total passing - Bump version 1.0.6 → 1.1.0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(tests): update e2e assertions for label materialization phase2-regressions: label is now a native bound text element (id: pos-stable-1-label) — check bound text element text instead of container.label?.text which is no longer stored. sync-flows FTS: search now matches the bound text element (fts-el-label) rather than the container — accept either id as valid match. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
d14d767c75
commit
9846e0ba0f
@@ -402,6 +402,9 @@
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.menu-search-wrap {
|
||||
padding: 8px 10px 4px;
|
||||
@@ -573,6 +576,110 @@
|
||||
}
|
||||
.project-delete-no:hover { background: #dee2e6; }
|
||||
|
||||
/* Batch selection mode */
|
||||
.batch-mode-toggle {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 3px 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
background: #f8f9fa;
|
||||
color: #555;
|
||||
cursor: pointer;
|
||||
text-transform: none;
|
||||
letter-spacing: 0;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
}
|
||||
.batch-mode-toggle:hover { background: #e9ecef; border-color: #ccc; }
|
||||
.batch-mode-active { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
|
||||
.batch-mode-active:hover { background: #c8e6c9; }
|
||||
.batch-actions-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
background: #fafafa;
|
||||
}
|
||||
.batch-action-btn {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
color: #555;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.batch-action-btn:hover { background: #e9ecef; }
|
||||
.batch-count {
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
margin-left: auto;
|
||||
}
|
||||
.batch-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
gap: 10px;
|
||||
}
|
||||
.batch-item-disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
.batch-checkbox {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex-shrink: 0;
|
||||
accent-color: #e03131;
|
||||
cursor: pointer;
|
||||
}
|
||||
.batch-item-disabled .batch-checkbox { cursor: default; }
|
||||
.batch-item-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
.batch-active-label {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: #4caf50;
|
||||
text-transform: uppercase;
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.batch-delete-bar {
|
||||
padding: 8px 12px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
background: #fff5f5;
|
||||
}
|
||||
.batch-delete-btn {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
background: #e03131;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.batch-delete-btn:hover { background: #c92a2a; }
|
||||
.batch-delete-confirm {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.batch-delete-msg {
|
||||
flex: 1;
|
||||
font-size: 13px;
|
||||
color: #c92a2a;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Clear canvas confirmation dialog */
|
||||
.confirm-dialog {
|
||||
position: absolute;
|
||||
|
||||
+98
-2
@@ -134,6 +134,9 @@ function App(): JSX.Element {
|
||||
const newProjectInputRef = useRef<HTMLInputElement | null>(null)
|
||||
const [confirmDeleteProjectId, setConfirmDeleteProjectId] = useState<string | null>(null)
|
||||
const [confirmDeleteTenantId, setConfirmDeleteTenantId] = useState<string | null>(null)
|
||||
const [batchSelectMode, setBatchSelectMode] = useState<boolean>(false)
|
||||
const [selectedTenantIds, setSelectedTenantIds] = useState<Set<string>>(new Set())
|
||||
const [confirmBatchDelete, setConfirmBatchDelete] = useState<boolean>(false)
|
||||
|
||||
// Keep refs in sync so closures (WebSocket handlers) always see latest values
|
||||
useEffect(() => {
|
||||
@@ -1325,6 +1328,38 @@ function App(): JSX.Element {
|
||||
}
|
||||
}
|
||||
|
||||
const batchDeleteTenants = async () => {
|
||||
const ids = Array.from(selectedTenantIds)
|
||||
try {
|
||||
const res = await fetch('/api/tenants/batch-delete', {
|
||||
method: 'POST',
|
||||
headers: tenantHeaders({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({ ids })
|
||||
})
|
||||
const data = await res.json()
|
||||
const deleted = data.deletedCount ?? 0
|
||||
const deletedIds = new Set((data.results ?? []).filter((r: { deleted: boolean }) => r.deleted).map((r: { id: string }) => r.id))
|
||||
setTenantList(prev => prev.filter(t => !deletedIds.has(t.id)))
|
||||
setSelectedTenantIds(new Set())
|
||||
setConfirmBatchDelete(false)
|
||||
setBatchSelectMode(false)
|
||||
showToast(`${deleted} workspace${deleted !== 1 ? 's' : ''} deleted`)
|
||||
} catch (err) {
|
||||
console.error('Batch delete failed:', err)
|
||||
showToast('Batch delete failed', 4000)
|
||||
setConfirmBatchDelete(false)
|
||||
}
|
||||
}
|
||||
|
||||
const toggleTenantSelection = (id: string) => {
|
||||
setSelectedTenantIds(prev => {
|
||||
const next = new Set(prev)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
return next
|
||||
})
|
||||
}
|
||||
|
||||
const syncToBackend = async (): Promise<void> => {
|
||||
if (!excalidrawAPI || isSyncingRef.current) return
|
||||
|
||||
@@ -1569,10 +1604,37 @@ function App(): JSX.Element {
|
||||
const filtered = q
|
||||
? tenantList.filter(t => t.name.toLowerCase().includes(q) || t.workspace_path.toLowerCase().includes(q))
|
||||
: tenantList
|
||||
const selectableFiltered = filtered.filter(t => t.id !== activeTenant?.id)
|
||||
return (
|
||||
<div className="menu-overlay" onClick={() => setMenuOpen(false)}>
|
||||
<div className="menu-overlay" onClick={() => { setMenuOpen(false); setBatchSelectMode(false); setSelectedTenantIds(new Set()); setConfirmBatchDelete(false) }}>
|
||||
<div className="menu-panel" onClick={e => e.stopPropagation()}>
|
||||
<div className="menu-header">Workspaces</div>
|
||||
<div className="menu-header">
|
||||
<span>Workspaces</span>
|
||||
<button
|
||||
className={`batch-mode-toggle ${batchSelectMode ? 'batch-mode-active' : ''}`}
|
||||
title={batchSelectMode ? 'Exit selection mode' : 'Select workspaces to delete'}
|
||||
onClick={() => {
|
||||
setBatchSelectMode(prev => !prev)
|
||||
setSelectedTenantIds(new Set())
|
||||
setConfirmBatchDelete(false)
|
||||
}}
|
||||
>
|
||||
{batchSelectMode ? 'Done' : 'Select'}
|
||||
</button>
|
||||
</div>
|
||||
{batchSelectMode && selectableFiltered.length > 0 && (
|
||||
<div className="batch-actions-bar">
|
||||
<button
|
||||
className="batch-action-btn"
|
||||
onClick={() => setSelectedTenantIds(new Set(selectableFiltered.map(t => t.id)))}
|
||||
>Select All</button>
|
||||
<button
|
||||
className="batch-action-btn"
|
||||
onClick={() => setSelectedTenantIds(new Set())}
|
||||
>Unselect All</button>
|
||||
<span className="batch-count">{selectedTenantIds.size} selected</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="menu-search-wrap">
|
||||
<input
|
||||
ref={searchInputRef}
|
||||
@@ -1592,6 +1654,25 @@ function App(): JSX.Element {
|
||||
<button className="project-delete-yes" onClick={() => deleteTenantUI(t.id)}>Delete</button>
|
||||
<button className="project-delete-no" onClick={() => setConfirmDeleteTenantId(null)}>Cancel</button>
|
||||
</div>
|
||||
) : batchSelectMode ? (
|
||||
<label className={`menu-item batch-item ${activeTenant?.id === t.id ? 'menu-item-active batch-item-disabled' : ''}`}>
|
||||
<input
|
||||
type="checkbox"
|
||||
className="batch-checkbox"
|
||||
disabled={activeTenant?.id === t.id}
|
||||
checked={selectedTenantIds.has(t.id)}
|
||||
onChange={() => toggleTenantSelection(t.id)}
|
||||
/>
|
||||
<span className="batch-item-content">
|
||||
<span className="menu-item-name">{t.name}</span>
|
||||
<span className="menu-item-path" title={t.workspace_path}>
|
||||
{t.workspace_path.length > 40
|
||||
? '...' + t.workspace_path.slice(-37)
|
||||
: t.workspace_path}
|
||||
</span>
|
||||
</span>
|
||||
{activeTenant?.id === t.id && <span className="batch-active-label">active</span>}
|
||||
</label>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
@@ -1619,6 +1700,21 @@ function App(): JSX.Element {
|
||||
))}
|
||||
{filtered.length === 0 && <div className="menu-empty">No matching workspaces</div>}
|
||||
</div>
|
||||
{batchSelectMode && selectedTenantIds.size > 0 && (
|
||||
<div className="batch-delete-bar">
|
||||
{confirmBatchDelete ? (
|
||||
<div className="batch-delete-confirm">
|
||||
<span className="batch-delete-msg">Delete {selectedTenantIds.size} workspace{selectedTenantIds.size !== 1 ? 's' : ''}?</span>
|
||||
<button className="project-delete-yes" onClick={batchDeleteTenants}>Delete</button>
|
||||
<button className="project-delete-no" onClick={() => setConfirmBatchDelete(false)}>Cancel</button>
|
||||
</div>
|
||||
) : (
|
||||
<button className="batch-delete-btn" onClick={() => setConfirmBatchDelete(true)}>
|
||||
Delete {selectedTenantIds.size} workspace{selectedTenantIds.size !== 1 ? 's' : ''}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user