mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
refactor(resources): converge Files onto the shared drag hook and batch bulk authorization (#6748)
* refactor(resources): converge Files onto the shared drag hook and batch bulk authorization Files kept a 280-line copy of the foldered-list drag logic because it also accepts OS file drops. The copies had already drifted, so the external drop becomes an option on the shared hook and the copy goes away. - Add `externalDrop` to `useFolderRowDragDrop`: folder rows highlight and spring open for an OS file drag exactly as for a move, while the body and breadcrumb decline so the page-level upload overlay owns those regions - Collapse the three drop-active booleans into one `ActiveDropTarget` union, so exactly one affordance is armed by construction rather than by hand-clearing - Keep drop-target writes identity-stable so `dragover` does not re-render the list on every event - Give each list its own drag MIME again, restoring the cross-surface isolation `drag-payload.ts` documents - Let a folder spring open more than once per drag, so a drag can walk back out through the breadcrumb and descend again; the guard against re-entering the folder already on screen moves to `useSpringNavigation`, the only layer that can state it - Resolve each bulk item against the workspace context the batch already holds, and memoize the effective-permission lookup for the batch, replacing two invariant queries per item - Fill the drop target at `--surface-active`: `--surface-4` is the button-base token and is lighter than hover in light mode, so the strongest row state read the faintest * fix(resources): dismiss the upload overlay on a folder drop and re-check permission per item The drag hook stops propagation on a drop it handles, so the page-level handler that cleared the upload overlay never ran and the chrome stayed up over the finished upload. Both consuming paths now share one dismissal. Drop the batch permission memo: each item in a bulk move or delete commits independently, so reusing one allow verdict let a revocation part-way through a batch go unseen by the remaining items. The workspace context is still resolved once per batch, which was the larger saving.
This commit is contained in:
@@ -80,9 +80,13 @@ export const chipActiveSurfaceClass = 'bg-[var(--surface-active)]'
|
||||
* own drop affordance is a `--text-subtle` tint. Drawn inside the element's own box so the ring
|
||||
* never overlaps its neighbours. Hand-rolled rows and breadcrumb crumbs import this rather than
|
||||
* restating the literal, so every drop destination reads identically.
|
||||
*
|
||||
* Fills to `--surface-active`, the same weight as a selected row, and leans on the ring to tell
|
||||
* the two apart. Not `--surface-4`: that is the button-base token, and in light mode it is
|
||||
* *lighter* than `--surface-hover`, so the row under the cursor read weaker the moment it became
|
||||
* a drop target — the strongest state painting the faintest fill.
|
||||
*/
|
||||
export const chipDropTargetSurfaceClass =
|
||||
'bg-[var(--surface-4)] outline outline-1 outline-[var(--text-subtle)] outline-offset-[-1px]'
|
||||
export const chipDropTargetSurfaceClass = `${chipActiveSurfaceClass} outline outline-1 outline-[var(--text-subtle)] outline-offset-[-1px]`
|
||||
/**
|
||||
* The disclosure chevron that rotates to expand or collapse a sidebar section or a
|
||||
* tree row: 14px at `--text-icon`, animating on the same 150ms curve the section
|
||||
|
||||
Reference in New Issue
Block a user