11import { useInfiniteQuery , useMutation , useQueryClient } from '@tanstack/react-query' ;
22import type { ColumnDef } from '@tanstack/react-table' ;
3- import { MoreHorizontal , RefreshCcw , Trash2 } from '@teable/icons' ;
3+ import { Database , RefreshCcw , Trash2 } from '@teable/icons' ;
44import type { ITrashItemVo , ITrashVo } from '@teable/openapi' ;
55import {
66 getTrash ,
@@ -13,13 +13,7 @@ import { InfiniteTable } from '@teable/sdk/components';
1313import { ReactQueryKeys } from '@teable/sdk/config' ;
1414import { useIsHydrated } from '@teable/sdk/hooks' ;
1515import { ConfirmDialog } from '@teable/ui-lib/base' ;
16- import {
17- Button ,
18- DropdownMenu ,
19- DropdownMenuContent ,
20- DropdownMenuItem ,
21- DropdownMenuTrigger ,
22- } from '@teable/ui-lib/shadcn' ;
16+ import { Button } from '@teable/ui-lib/shadcn' ;
2317import { toast } from '@teable/ui-lib/shadcn/ui/sonner' ;
2418import dayjs from 'dayjs' ;
2519import { useParams } from 'next/navigation' ;
@@ -58,7 +52,7 @@ export const SpaceInnerTrashPage = () => {
5852 } ;
5953
6054 const { data, isFetching, isLoading, fetchNextPage } = useInfiniteQuery ( {
61- queryKey : ReactQueryKeys . getSpaceTrash ( resourceType ) ,
55+ queryKey : ReactQueryKeys . getSpaceTrash ( resourceType , spaceId ) ,
6256 queryFn,
6357 refetchOnMount : 'always' ,
6458 refetchOnWindowFocus : false ,
@@ -69,15 +63,15 @@ export const SpaceInnerTrashPage = () => {
6963 mutationFn : ( props : { trashId : string } ) => restoreTrash ( props . trashId ) ,
7064 onSuccess : ( ) => {
7165 queryClient . invalidateQueries ( ReactQueryKeys . spaceList ( ) ) ;
72- queryClient . invalidateQueries ( ReactQueryKeys . getSpaceTrash ( resourceType ) ) ;
66+ queryClient . invalidateQueries ( ReactQueryKeys . getSpaceTrash ( resourceType , spaceId ) ) ;
7367 toast . success ( t ( 'actions.restoreSucceed' ) ) ;
7468 } ,
7569 } ) ;
7670
7771 const { mutateAsync : mutatePermanentDeleteBase } = useMutation ( {
7872 mutationFn : ( props : { baseId : string } ) => permanentDeleteBase ( props . baseId ) ,
7973 onSuccess : ( ) => {
80- queryClient . invalidateQueries ( ReactQueryKeys . getSpaceTrash ( resourceType ) ) ;
74+ queryClient . invalidateQueries ( ReactQueryKeys . getSpaceTrash ( resourceType , spaceId ) ) ;
8175 toast . success ( t ( 'actions.deleteSucceed' ) ) ;
8276 } ,
8377 } ) ;
@@ -99,36 +93,13 @@ export const SpaceInnerTrashPage = () => {
9993 const resourceInfo = resourceMap [ resourceId ] ;
10094
10195 if ( ! resourceInfo ) return null ;
102-
10396 const { name } = resourceInfo ;
104-
105- if ( 'spaceId' in resourceInfo ) {
106- const spaceId = resourceInfo . spaceId ;
107- const spaceInfo = resourceMap [ spaceId ] ;
108-
109- return (
110- < div className = "flex items-center space-x-2 pr-2 text-sm" >
111- < span > { name } </ span >
112- < Button
113- className = "text-xs"
114- variant = "outline"
115- size = "xs"
116- onClick = { ( ) => {
117- router . push ( {
118- pathname : '/space/[spaceId]' ,
119- query : { spaceId } ,
120- } ) ;
121- } }
122- >
123- < span className = "max-w-40 truncate text-xs" >
124- { t ( 'trash.fromSpace' , { name : spaceInfo . name } ) }
125- </ span >
126- </ Button >
127- </ div >
128- ) ;
129- }
130-
131- return < div className = "text-wrap pr-2 text-sm" > { name } </ div > ;
97+ return (
98+ < div className = "flex min-w-0 items-center gap-2 pl-2" >
99+ < Database className = "size-6 rounded-md border p-1" />
100+ < span className = "truncate text-sm " > { name } </ span >
101+ </ div >
102+ ) ;
132103 } ,
133104 } ,
134105 {
@@ -172,32 +143,32 @@ export const SpaceInnerTrashPage = () => {
172143 if ( ! resourceInfo ) return null ;
173144
174145 return (
175- < DropdownMenu >
176- < DropdownMenuTrigger asChild >
177- < Button aria-haspopup = "true" size = "icon" variant = "ghost" className = "size-8" >
178- < MoreHorizontal className = "size-4" />
179- </ Button >
180- </ DropdownMenuTrigger >
181- < DropdownMenuContent align = "end" >
182- < DropdownMenuItem className = "gap-x-2" onClick = { ( ) => mutateRestore ( { trashId } ) } >
183- < RefreshCcw className = "size-4" />
184- { t ( 'actions.restore' ) }
185- </ DropdownMenuItem >
186- < DropdownMenuItem
187- className = "gap-x-2 text-destructive focus:text-destructive "
188- onClick = { ( ) => {
189- setConfirmVisible ( true ) ;
190- setDeletingResource ( {
191- resourceId ,
192- name : resourceInfo . name ,
193- } ) ;
194- } }
195- >
196- < Trash2 className = "size-4" />
197- { t ( 'actions.permanentDelete' ) }
198- </ DropdownMenuItem >
199- </ DropdownMenuContent >
200- </ DropdownMenu >
146+ < div className = "flex items-center gap-1" >
147+ < Button
148+ size = "xs"
149+ variant = "ghost"
150+ className = "p-1"
151+ title = { t ( 'actions.restore' ) }
152+ onClick = { ( ) => mutateRestore ( { trashId } ) }
153+ >
154+ < RefreshCcw className = "size-4" />
155+ </ Button >
156+ < Button
157+ size = "xs"
158+ variant = "ghost "
159+ className = "p-1"
160+ title = { t ( 'actions.permanentDelete' ) }
161+ onClick = { ( ) => {
162+ setConfirmVisible ( true ) ;
163+ setDeletingResource ( {
164+ resourceId ,
165+ name : resourceInfo . name ,
166+ } ) ;
167+ } }
168+ >
169+ < Trash2 className = "size-4" / >
170+ </ Button >
171+ </ div >
201172 ) ;
202173 } ,
203174 } ,
0 commit comments