@@ -2,22 +2,34 @@ import { API_ROUTES } from 'data-services/constants'
2
2
import { useCollections } from 'data-services/hooks/collections/useCollections'
3
3
import { PageHeader } from 'design-system/components/page-header/page-header'
4
4
import { PaginationBar } from 'design-system/components/pagination-bar/pagination-bar'
5
+ import { ColumnSettings } from 'design-system/components/table/column-settings/column-settings'
5
6
import { Table } from 'design-system/components/table/table/table'
6
7
import { TableSortSettings } from 'design-system/components/table/types'
7
8
import { NewEntityDialog } from 'pages/project/entities/new-entity-dialog'
8
9
import { useEffect , useState } from 'react'
9
10
import { useParams } from 'react-router-dom'
10
11
import { STRING , translate } from 'utils/language'
12
+ import { useColumnSettings } from 'utils/useColumnSettings'
11
13
import { usePagination } from 'utils/usePagination'
12
14
import { UserPermission } from 'utils/user/types'
13
15
import { columns } from './collection-columns'
14
16
15
17
export const Collections = ( ) => {
16
18
const { projectId } = useParams ( )
17
19
const [ sort , setSort ] = useState < TableSortSettings | undefined > ( {
18
- field : 'created_at ' ,
19
- order : 'desc ' ,
20
+ field : 'id ' ,
21
+ order : 'asc ' ,
20
22
} )
23
+ const { columnSettings, setColumnSettings } = useColumnSettings (
24
+ 'collections' ,
25
+ {
26
+ id : true ,
27
+ name : true ,
28
+ settings : true ,
29
+ 'captures-with-detections' : true ,
30
+ status : true ,
31
+ }
32
+ )
21
33
const { pagination, setPage } = usePagination ( )
22
34
const [ poll , setPoll ] = useState ( false )
23
35
const { collections, userPermissions, total, isLoading, isFetching, error } =
@@ -51,6 +63,11 @@ export const Collections = () => {
51
63
isFetching = { isFetching }
52
64
tooltip = { translate ( STRING . TOOLTIP_COLLECTION ) }
53
65
>
66
+ < ColumnSettings
67
+ columns = { columns ( projectId as string ) }
68
+ columnSettings = { columnSettings }
69
+ onColumnSettingsChange = { setColumnSettings }
70
+ />
54
71
{ canCreate && (
55
72
< NewEntityDialog
56
73
collection = { API_ROUTES . COLLECTIONS }
@@ -59,7 +76,14 @@ export const Collections = () => {
59
76
) }
60
77
</ PageHeader >
61
78
< Table
62
- columns = { columns ( projectId as string ) }
79
+ columns = { columns ( projectId as string ) . filter ( ( column ) => {
80
+ // Always show action column
81
+ if ( column . id === 'actions' ) {
82
+ return true
83
+ }
84
+
85
+ return ! ! columnSettings [ column . id ]
86
+ } ) }
63
87
error = { error }
64
88
isLoading = { isLoading }
65
89
items = { collections }
0 commit comments