Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions apps/sim/app/api/workspaces/[id]/recently-deleted/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { listRecentlyDeletedContract } from '@/lib/api/contracts/recently-deleted'
import { cursorRoute, cursorScopeKey } from '@/lib/api/cursor-binding'
import {
defineInternalJsonRoute,
internalOrchestrationErrorPolicy,
internalRateLimits,
internalSessionAuth,
} from '@/lib/api/server/routes'
import {
listRecentlyDeleted,
recentlyDeletedOperations,
} from '@/lib/workspaces/application/list-recently-deleted'
import { readSortedCursor, writeSortedCursor } from '@/app/api/v2/lib/response'

export const dynamic = 'force-dynamic'

function cursorScope(id: string, type: string, search: string | undefined) {
return cursorScopeKey(cursorRoute(listRecentlyDeletedContract, { id }), { type, search })
}

/** GET /api/workspaces/[id]/recently-deleted — One page of the workspace's Recently Deleted view. */
export const GET = defineInternalJsonRoute({
contract: listRecentlyDeletedContract,
auth: internalSessionAuth,
operation: recentlyDeletedOperations.list,
rateLimit: internalRateLimits.none({
reason: 'Replaces the per-type archived lists, which carry no rate limit',
}),
errorPolicy: internalOrchestrationErrorPolicy,
mapInput: ({ params, query }) => ({
workspaceId: params.id,
filter: query.type,
search: query.search,
sortBy: query.sortBy,
sortOrder: query.sortOrder,
limit: query.limit,
cursorKeys: readSortedCursor(
query.cursor,
query.sortBy,
query.sortOrder,
cursorScope(params.id, query.type, query.search)
),
}),
useCase: listRecentlyDeleted,
present: ({ items, nextCursorKeys }, { input }) => ({
items,
nextCursor: writeSortedCursor(
nextCursorKeys,
input.sortBy,
input.sortOrder,
cursorScope(input.workspaceId, input.filter, input.search)
),
}),
})
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import type { BreadcrumbDropConfig } from '@/app/workspace/[workspaceId]/compone
import { ResourceHeader } from '@/app/workspace/[workspaceId]/components/resource/components/resource-header'
import { ResourceOptions } from '@/app/workspace/[workspaceId]/components/resource/components/resource-options'
import { SearchHighlight } from '@/app/workspace/[workspaceId]/components/search-highlight/search-highlight'
import { useLoadMoreSentinel } from '@/hooks/use-load-more-sentinel'

export interface ResourceColumn {
id: string
Expand Down Expand Up @@ -287,7 +288,7 @@ const ResourceTable = memo(function ResourceTable({
emptyState,
}: ResourceTableProps) {
const scrollRef = useRef<HTMLDivElement>(null)
const loadMoreRef = useRef<HTMLDivElement>(null)
const loadMoreRef = useLoadMoreSentinel({ onLoadMore, enabled: Boolean(hasMore) })

const showEmptyState = rows.length === 0 && Boolean(emptyState)

Expand Down Expand Up @@ -321,20 +322,6 @@ const ResourceTable = memo(function ResourceTable({
}
}, [contextMenuRowId])

useEffect(() => {
if (!onLoadMore || !hasMore) return
const el = loadMoreRef.current
if (!el) return
const observer = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting) onLoadMore()
},
{ rootMargin: '200px' }
)
observer.observe(el)
return () => observer.disconnect()
}, [onLoadMore, hasMore])

const hasCheckbox = selectable != null
const bodyDrop = rowDragDrop?.body

Expand Down

This file was deleted.

Loading
Loading