@@ -14,15 +14,15 @@ import { interaction, selection } from "../state";
14
14
* previously saved applications. Can be supplied an array of filters to use
15
15
* to find files to access instead of the currently selected files.
16
16
*/
17
- export default ( filters ?: FileFilter [ ] , onDismiss ?: ( ) => void ) => {
17
+ export default ( folderFilters ?: FileFilter [ ] , onDismiss ?: ( ) => void ) => {
18
18
const dispatch = useDispatch ( ) ;
19
19
const isOnWeb = useSelector ( interaction . selectors . isOnWeb ) ;
20
20
const fileSelection = useSelector ( selection . selectors . getFileSelection ) ;
21
21
const isQueryingAicsFms = useSelector ( selection . selectors . isQueryingAicsFms ) ;
22
22
23
23
const [ fileDetails , setFileDetails ] = React . useState < FileDetail > ( ) ;
24
24
25
- const openWithSubMenuItems = useOpenWithMenuItems ( fileDetails , filters ) ;
25
+ const openWithSubMenuItems = useOpenWithMenuItems ( fileDetails , folderFilters ) ;
26
26
27
27
fileSelection . fetchFocusedItemDetails ( ) . then ( ( fileDetails ) => {
28
28
setFileDetails ( fileDetails ) ;
@@ -33,6 +33,30 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
33
33
evt . preventDefault ( ) ;
34
34
35
35
const contextMenuItems : IContextualMenuItem [ ] = [
36
+ ...( ! folderFilters
37
+ ? [ ]
38
+ : [
39
+ {
40
+ key : "expand" ,
41
+ text : "Expand all" ,
42
+ iconProps : {
43
+ iconName : "ExploreContent" ,
44
+ } ,
45
+ onClick ( ) {
46
+ dispatch ( selection . actions . expandAllFileFolders ( ) ) ;
47
+ } ,
48
+ } ,
49
+ {
50
+ key : "collapse" ,
51
+ text : "Collapse all" ,
52
+ iconProps : {
53
+ iconName : "CollapseContent" ,
54
+ } ,
55
+ onClick ( ) {
56
+ dispatch ( selection . actions . collapseAllFileFolders ( ) ) ;
57
+ } ,
58
+ } ,
59
+ ] ) ,
36
60
// Avoid showing default open option when on web
37
61
...( isOnWeb
38
62
? [ ]
@@ -43,10 +67,10 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
43
67
iconProps : {
44
68
iconName : "OpenInNewWindow" ,
45
69
} ,
46
- disabled : ! filters && fileSelection . count ( ) === 0 ,
70
+ disabled : ! folderFilters && fileSelection . count ( ) === 0 ,
47
71
onClick ( ) {
48
- if ( filters ) {
49
- dispatch ( interaction . actions . openWithDefault ( filters ) ) ;
72
+ if ( folderFilters ) {
73
+ dispatch ( interaction . actions . openWithDefault ( folderFilters ) ) ;
50
74
} else if ( fileDetails ) {
51
75
dispatch (
52
76
interaction . actions . openWithDefault ( undefined , [
@@ -60,7 +84,7 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
60
84
{
61
85
key : "open-with" ,
62
86
text : "Open with" ,
63
- disabled : ! filters && fileSelection . count ( ) === 0 ,
87
+ disabled : ! folderFilters && fileSelection . count ( ) === 0 ,
64
88
iconProps : {
65
89
iconName : "OpenInNewWindow" ,
66
90
} ,
@@ -71,7 +95,7 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
71
95
{
72
96
key : "save-as" ,
73
97
text : "Save metadata as" ,
74
- disabled : ! filters && fileSelection . count ( ) === 0 ,
98
+ disabled : ! folderFilters && fileSelection . count ( ) === 0 ,
75
99
iconProps : {
76
100
iconName : "Saveas" ,
77
101
} ,
@@ -86,13 +110,13 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
86
110
{
87
111
key : "csv" ,
88
112
text : "CSV" ,
89
- disabled : ! filters && fileSelection . count ( ) === 0 ,
113
+ disabled : ! folderFilters && fileSelection . count ( ) === 0 ,
90
114
title : "Download a CSV of the metadata of the selected files" ,
91
115
onClick ( ) {
92
116
dispatch (
93
117
interaction . actions . showManifestDownloadDialog (
94
118
"csv" ,
95
- filters
119
+ folderFilters
96
120
)
97
121
) ;
98
122
} ,
@@ -104,29 +128,29 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
104
128
{
105
129
key : "json" ,
106
130
text : "JSON" ,
107
- disabled : ! filters && fileSelection . count ( ) === 0 ,
131
+ disabled : ! folderFilters && fileSelection . count ( ) === 0 ,
108
132
title :
109
133
"Download a JSON file of the metadata of the selected files" ,
110
134
onClick ( ) {
111
135
dispatch (
112
136
interaction . actions . showManifestDownloadDialog (
113
137
"json" ,
114
- filters
138
+ folderFilters
115
139
)
116
140
) ;
117
141
} ,
118
142
} ,
119
143
{
120
144
key : "parquet" ,
121
145
text : "Parquet" ,
122
- disabled : ! filters && fileSelection . count ( ) === 0 ,
146
+ disabled : ! folderFilters && fileSelection . count ( ) === 0 ,
123
147
title :
124
148
"Download a Parquet file of the metadata of the selected files" ,
125
149
onClick ( ) {
126
150
dispatch (
127
151
interaction . actions . showManifestDownloadDialog (
128
152
"parquet" ,
129
- filters
153
+ folderFilters
130
154
)
131
155
) ;
132
156
} ,
@@ -141,7 +165,7 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
141
165
key : "copy-to-cache" ,
142
166
text : "Copy to vast" ,
143
167
title : "Copy selected files to NAS Cache (VAST)" ,
144
- disabled : ! filters && fileSelection . count ( ) === 0 ,
168
+ disabled : ! folderFilters && fileSelection . count ( ) === 0 ,
145
169
iconProps : { iconName : "MoveToFolder" } ,
146
170
onClick ( ) {
147
171
dispatch ( interaction . actions . showCopyFileManifest ( ) ) ;
@@ -153,7 +177,7 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
153
177
key : "download" ,
154
178
text : "Download" ,
155
179
title : "Download selected files to a specific directory" ,
156
- disabled : ! filters && fileSelection . count ( ) === 0 ,
180
+ disabled : ! folderFilters && fileSelection . count ( ) === 0 ,
157
181
iconProps : {
158
182
iconName : "Download" ,
159
183
} ,
@@ -168,13 +192,13 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
168
192
) ;
169
193
} ,
170
194
[
171
- filters ,
172
195
dispatch ,
173
- onDismiss ,
174
- isOnWeb ,
196
+ fileDetails ,
175
197
fileSelection ,
198
+ folderFilters ,
199
+ isOnWeb ,
176
200
isQueryingAicsFms ,
177
- fileDetails ,
201
+ onDismiss ,
178
202
openWithSubMenuItems ,
179
203
]
180
204
) ;
0 commit comments