File tree Expand file tree Collapse file tree 2 files changed +19
-16
lines changed
src/packages/frontend/project/explorer Expand file tree Collapse file tree 2 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -165,19 +165,17 @@ export function ActionBar({
165
165
}
166
166
}
167
167
168
- function render_action_button ( name : FileAction ) : React . JSX . Element {
169
- const disabled =
170
- isDisabledSnapshots ( name ) &&
171
- ( current_path != null
172
- ? current_path . startsWith ( SNAPSHOTS )
173
- : undefined ) ;
168
+ function render_action_button ( name : FileAction ) {
169
+ if ( isSnapshotPath ( current_path ) && isDisabledSnapshots ( name ) ) {
170
+ return null ;
171
+ }
174
172
const obj = file_actions [ name ] ;
175
173
const handle_click = ( _e : React . MouseEvent ) => {
176
174
actions . set_file_action ( name ) ;
177
175
} ;
178
176
179
177
return (
180
- < Button onClick = { handle_click } disabled = { disabled } key = { name } >
178
+ < Button onClick = { handle_click } key = { name } >
181
179
< Icon name = { obj . icon } /> { " " }
182
180
< VisibleMDLG > { `${ intl . formatMessage ( obj . name ) } ...` } </ VisibleMDLG >
183
181
</ Button >
@@ -297,13 +295,18 @@ export const ACTION_BUTTONS_MULTI = [
297
295
"copy" ,
298
296
] as const ;
299
297
298
+ const DISABLED_SNAPSHOT_ACTIONS = new Set ( [
299
+ "move" ,
300
+ "compress" ,
301
+ "rename" ,
302
+ "share" ,
303
+ "duplicate" ,
304
+ ] ) ;
305
+
300
306
export function isDisabledSnapshots ( name : string ) {
301
- return [
302
- "move" ,
303
- "compress" ,
304
- "rename" ,
305
- "delete" ,
306
- "share" ,
307
- "duplicate" ,
308
- ] . includes ( name ) ;
307
+ return DISABLED_SNAPSHOT_ACTIONS . has ( name ) ;
308
+ }
309
+
310
+ export function isSnapshotPath ( path ?: string ) {
311
+ return path == SNAPSHOTS || path ?. startsWith ( SNAPSHOTS + "/" ) ;
309
312
}
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ export function ActionBox({
171
171
actions . open_directory ( SNAPSHOTS ) ;
172
172
} }
173
173
>
174
- ~/.snapshots
174
+ { SNAPSHOTS }
175
175
</ a > { " " }
176
176
directory.
177
177
</ div >
You can’t perform that action at this time.
0 commit comments