Skip to content

Commit f6c44af

Browse files
committed
cleanup: effect, emcn tokens, mutation error handling
- Replace selection-pruning useEffect with inline state adjustment during render - Fix drag overlay using invalid --accent HSL token → --brand-secondary; z-50 → z-[var(--z-dropdown)] - Move static inline styles on context menu trigger div to className - Add missing onError toast to useUpdateWorkspaceFileFolder, useRestoreWorkspaceFileFolder, useRestoreWorkspaceFile
1 parent 344bbe3 commit f6c44af

6 files changed

Lines changed: 34 additions & 41 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-row-context-menu/file-row-context-menu.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,8 @@ export const FileRowContextMenu = memo(function FileRowContextMenu({
5252
<DropdownMenu open={isOpen} onOpenChange={(open) => !open && onClose()} modal={false}>
5353
<DropdownMenuTrigger asChild>
5454
<div
55-
style={{
56-
position: 'fixed',
57-
left: `${position.x}px`,
58-
top: `${position.y}px`,
59-
width: '1px',
60-
height: '1px',
61-
pointerEvents: 'none',
62-
}}
55+
className='pointer-events-none fixed h-px w-px'
56+
style={{ left: `${position.x}px`, top: `${position.y}px` }}
6357
tabIndex={-1}
6458
aria-hidden
6559
/>

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ const STATIC_MARKDOWN_COMPONENTS = {
631631
</div>
632632
),
633633
thead: ({ children }: { children?: React.ReactNode }) => (
634-
<thead className='bg-[var(--surface-2)]'>{children}</thead>
634+
<thead className='bg-[var(--surface-3)]'>{children}</thead>
635635
),
636636
tbody: ({ children }: { children?: React.ReactNode }) => <tbody>{children}</tbody>,
637637
tr: ({ children }: { children?: React.ReactNode }) => (

apps/sim/app/workspace/[workspaceId]/files/files.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,14 +486,16 @@ export function Files() {
486486

487487
const visibleRowIds = useMemo(() => rows.map((row) => row.id), [rows])
488488

489-
useEffect(() => {
489+
const prevVisibleRowIdsRef = useRef(visibleRowIds)
490+
if (prevVisibleRowIdsRef.current !== visibleRowIds) {
491+
prevVisibleRowIdsRef.current = visibleRowIds
490492
lastSelectedIndexRef.current = -1
491493
const visible = new Set(visibleRowIds)
492494
setSelectedRowIds((prev) => {
493495
const next = new Set(Array.from(prev).filter((id) => visible.has(id)))
494496
return next.size === prev.size ? prev : next
495497
})
496-
}, [visibleRowIds])
498+
}
497499

498500
const isAllSelected =
499501
visibleRowIds.length > 0 && visibleRowIds.every((id) => selectedRowIds.has(id))
@@ -1870,10 +1872,12 @@ export function Files() {
18701872
isLoading={bulkArchiveItems.isPending || moveItems.isPending}
18711873
/>
18721874
{isDraggingOver ? (
1873-
<div className='pointer-events-none absolute inset-0 z-50 flex flex-col items-center justify-center gap-2 border border-[var(--accent)] border-dashed bg-[var(--surface-4)] transition-colors'>
1874-
<Upload className='size-5 text-[var(--accent)]' />
1875+
<div className='pointer-events-none absolute inset-0 z-[var(--z-dropdown)] flex flex-col items-center justify-center gap-2 border border-[var(--brand-secondary)] border-dashed bg-[var(--surface-4)] transition-colors'>
1876+
<Upload className='size-5 text-[var(--brand-secondary)]' />
18751877
<div className='flex flex-col gap-0.5 text-center'>
1876-
<p className='font-medium text-[14px] text-[var(--accent)]'>Drop to upload</p>
1878+
<p className='font-medium text-[14px] text-[var(--brand-secondary)]'>
1879+
Drop to upload
1880+
</p>
18771881
<p className='text-[11px] text-[var(--text-tertiary)]'>
18781882
Release files here to add them to this workspace
18791883
</p>

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,28 +1118,19 @@ export const Sidebar = memo(function Sidebar() {
11181118
[workspaces, handleLeaveWorkspace]
11191119
)
11201120

1121-
const tasksCollapsedIcon = useMemo(
1122-
() => <Blimp className='size-[16px] flex-shrink-0 text-[var(--text-icon)]' />,
1123-
[]
1124-
)
1121+
const tasksCollapsedIcon = <Blimp className='size-[16px] flex-shrink-0 text-[var(--text-icon)]' />
11251122

1126-
const workflowsCollapsedIcon = useMemo(
1127-
() => (
1128-
<div
1129-
className='size-[16px] flex-shrink-0 rounded-sm border-[2.5px]'
1130-
style={WORKFLOW_ICON_STYLE}
1131-
/>
1132-
),
1133-
[]
1123+
const workflowsCollapsedIcon = (
1124+
<div
1125+
className='size-[16px] flex-shrink-0 rounded-sm border-[2.5px]'
1126+
style={WORKFLOW_ICON_STYLE}
1127+
/>
11341128
)
11351129

1136-
const workflowsPrimaryAction = useMemo(
1137-
() => ({
1138-
label: 'New workflow',
1139-
onSelect: handleCreateWorkflow,
1140-
}),
1141-
[handleCreateWorkflow]
1142-
)
1130+
const workflowsPrimaryAction = {
1131+
label: 'New workflow',
1132+
onSelect: handleCreateWorkflow,
1133+
}
11431134

11441135
const handleExpandSidebar = (e: React.MouseEvent) => {
11451136
e.preventDefault()
@@ -1160,13 +1151,10 @@ export const Sidebar = memo(function Sidebar() {
11601151
}
11611152
}, [workspaceId, navigateToPage])
11621153

1163-
const tasksPrimaryAction = useMemo(
1164-
() => ({
1165-
label: 'New task',
1166-
onSelect: handleNewTask,
1167-
}),
1168-
[handleNewTask]
1169-
)
1154+
const tasksPrimaryAction = {
1155+
label: 'New task',
1156+
onSelect: handleNewTask,
1157+
}
11701158

11711159
const handleSeeMoreTasks = () => setVisibleTaskCount((prev) => prev + 5)
11721160

apps/sim/hooks/queries/workspace-file-folders.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ export function useUpdateWorkspaceFileFolder() {
109109
}
110110
return { previous }
111111
},
112-
onError: (_err, variables, context) => {
112+
onError: (err, variables, context) => {
113113
if (context?.previous) {
114114
queryClient.setQueryData(
115115
workspaceFileFolderKeys.list(variables.workspaceId, 'active'),
116116
context.previous
117117
)
118118
}
119+
toast.error(toError(err).message)
119120
},
120121
onSettled: (_data, _error, variables) => {
121122
invalidateWorkspaceFileBrowsers(queryClient, variables.workspaceId)
@@ -192,6 +193,9 @@ export function useRestoreWorkspaceFileFolder() {
192193
onSuccess: () => {
193194
toast.success('Folder restored')
194195
},
196+
onError: (err) => {
197+
toast.error(toError(err).message)
198+
},
195199
onSettled: (_data, _error, variables) => {
196200
invalidateWorkspaceFileBrowsers(queryClient, variables.workspaceId)
197201
},

apps/sim/hooks/queries/workspace-files.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ export function useRestoreWorkspaceFile() {
513513
onSuccess: () => {
514514
toast.success('File restored')
515515
},
516+
onError: (err) => {
517+
toast.error(toError(err).message)
518+
},
516519
onSettled: (_data, _error, variables) => {
517520
queryClient.invalidateQueries({
518521
queryKey: workspaceFilesKeys.workspaceLists(variables.workspaceId),

0 commit comments

Comments
 (0)