1
- import { ComponentProps , type ComponentType , type Context } from 'react' ;
2
- import { useRecoilValue } from 'recoil' ;
1
+ import type { ComponentProps , ComponentType , Context } from 'react' ;
3
2
4
3
import { useDropdownButton } from '@/ui/dropdown/hooks/useDropdownButton' ;
5
4
import { TopBar } from '@/ui/top-bar/TopBar' ;
6
- import { useContextScopeId } from '@/ui/utilities/recoil-scope/hooks/useContextScopeId' ;
7
- import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue' ;
8
5
9
- import { currentViewIdScopedState } from '../states/currentViewIdScopedState' ;
10
- import { canPersistFiltersScopedFamilySelector } from '../states/selectors/canPersistFiltersScopedFamilySelector' ;
11
- import { canPersistSortsScopedFamilySelector } from '../states/selectors/canPersistSortsScopedFamilySelector' ;
12
6
import { FiltersHotkeyScope } from '../types/FiltersHotkeyScope' ;
13
7
import { ViewsHotkeyScope } from '../types/ViewsHotkeyScope' ;
14
8
15
9
import { FilterDropdownButton } from './FilterDropdownButton' ;
16
10
import {
17
11
SortDropdownButton ,
18
- SortDropdownButtonProps ,
12
+ type SortDropdownButtonProps ,
19
13
} from './SortDropdownButton' ;
20
14
import {
21
15
UpdateViewButtonGroup ,
22
- UpdateViewButtonGroupProps ,
16
+ type UpdateViewButtonGroupProps ,
23
17
} from './UpdateViewButtonGroup' ;
24
- import ViewBarDetails from './ViewBarDetails' ;
18
+ import ViewBarDetails , { type ViewBarDetailsProps } from './ViewBarDetails' ;
25
19
import {
26
20
ViewsDropdownButton ,
27
- ViewsDropdownButtonProps ,
21
+ type ViewsDropdownButtonProps ,
28
22
} from './ViewsDropdownButton' ;
29
23
30
24
export type ViewBarProps < SortField > = ComponentProps < 'div' > & {
31
- canPersistViewFields ?: boolean ;
32
25
OptionsDropdownButton : ComponentType ;
33
26
optionsDropdownKey : string ;
34
27
scopeContext : Context < string | null > ;
@@ -37,12 +30,14 @@ export type ViewBarProps<SortField> = ComponentProps<'div'> & {
37
30
'defaultViewName' | 'onViewsChange' | 'onViewSelect'
38
31
> &
39
32
Pick < SortDropdownButtonProps < SortField > , 'availableSorts' > &
33
+ Pick < ViewBarDetailsProps , 'canPersistViewFields' | 'onReset' > &
40
34
Pick < UpdateViewButtonGroupProps , 'onViewSubmit' > ;
41
35
42
36
export const ViewBar = < SortField , > ( {
43
37
availableSorts,
44
38
canPersistViewFields,
45
39
defaultViewName,
40
+ onReset,
46
41
onViewsChange,
47
42
onViewSelect,
48
43
onViewSubmit,
@@ -51,19 +46,6 @@ export const ViewBar = <SortField,>({
51
46
scopeContext,
52
47
...props
53
48
} : ViewBarProps < SortField > ) => {
54
- const recoilScopeId = useContextScopeId ( scopeContext ) ;
55
-
56
- const currentViewId = useRecoilScopedValue (
57
- currentViewIdScopedState ,
58
- scopeContext ,
59
- ) ;
60
- const canPersistFilters = useRecoilValue (
61
- canPersistFiltersScopedFamilySelector ( [ recoilScopeId , currentViewId ] ) ,
62
- ) ;
63
- const canPersistSorts = useRecoilValue (
64
- canPersistSortsScopedFamilySelector ( [ recoilScopeId , currentViewId ] ) ,
65
- ) ;
66
-
67
49
const { openDropdownButton : openOptionsDropdownButton } = useDropdownButton ( {
68
50
key : optionsDropdownKey ,
69
51
} ) ;
@@ -100,13 +82,13 @@ export const ViewBar = <SortField,>({
100
82
}
101
83
bottomComponent = {
102
84
< ViewBarDetails
103
- canPersistView = {
104
- canPersistViewFields || canPersistFilters || canPersistSorts
105
- }
85
+ canPersistViewFields = { canPersistViewFields }
106
86
context = { scopeContext }
107
87
hasFilterButton
88
+ onReset = { onReset }
108
89
rightComponent = {
109
90
< UpdateViewButtonGroup
91
+ canPersistViewFields = { canPersistViewFields }
110
92
onViewEditModeChange = { openOptionsDropdownButton }
111
93
onViewSubmit = { onViewSubmit }
112
94
hotkeyScope = { ViewsHotkeyScope . CreateDropdown }
0 commit comments