@@ -8,6 +8,11 @@ import { useFileBrowserContext } from './FileBrowserContext';
8
8
import { sendFetchRequest , makeMapKey , HTTPError } from '@/utils' ;
9
9
import { createSuccess , handleError , toHttpError } from '@/utils/errorHandling' ;
10
10
import type { Result } from '@/shared.types' ;
11
+ import {
12
+ LAYOUT_NAME ,
13
+ WITH_PROPERTIES_AND_SIDEBAR ,
14
+ ONLY_PROPERTIES
15
+ } from '@/constants/layoutConstants' ;
11
16
12
17
export type FolderFavorite = {
13
18
type : 'folder' ;
@@ -53,6 +58,7 @@ type PreferencesContextType = {
53
58
recentlyViewedFolders : FolderPreference [ ] ;
54
59
layout : string ;
55
60
handleUpdateLayout : ( layout : string ) => Promise < void > ;
61
+ setLayoutWithPropertiesOpen : ( ) => Promise < Result < void > > ;
56
62
loadingRecentlyViewedFolders : boolean ;
57
63
isLayoutLoadedFromDB : boolean ;
58
64
handleContextMenuFavorite : ( ) => Promise < Result < boolean > > ;
@@ -223,6 +229,34 @@ export const PreferencesProvider = ({
223
229
setLayout ( layout ) ;
224
230
} ;
225
231
232
+ const setLayoutWithPropertiesOpen = async ( ) : Promise < Result < void > > => {
233
+ try {
234
+ // Keep sidebar in new layout if it is currently present
235
+ const hasSidebar = layout . includes ( 'sidebar' ) ;
236
+
237
+ const layoutKey = hasSidebar
238
+ ? WITH_PROPERTIES_AND_SIDEBAR
239
+ : ONLY_PROPERTIES ;
240
+
241
+ const layoutSizes = hasSidebar ? [ 24 , 50 , 26 ] : [ 75 , 25 ] ;
242
+
243
+ const newLayout = {
244
+ [ LAYOUT_NAME ] : {
245
+ [ layoutKey ] : {
246
+ expandToSizes : { } ,
247
+ layout : layoutSizes
248
+ }
249
+ }
250
+ } ;
251
+ const newLayoutString = JSON . stringify ( newLayout ) ;
252
+ await savePreferencesToBackend ( 'layout' , newLayoutString ) ;
253
+ setLayout ( newLayoutString ) ;
254
+ return createSuccess ( undefined ) ;
255
+ } catch ( error ) {
256
+ return handleError ( error ) ;
257
+ }
258
+ } ;
259
+
226
260
const handlePathPreferenceSubmit = React . useCallback (
227
261
async (
228
262
localPathPreference : [ 'linux_path' ] | [ 'windows_path' ] | [ 'mac_path' ]
@@ -750,6 +784,7 @@ export const PreferencesProvider = ({
750
784
recentlyViewedFolders,
751
785
layout,
752
786
handleUpdateLayout,
787
+ setLayoutWithPropertiesOpen,
753
788
loadingRecentlyViewedFolders,
754
789
isLayoutLoadedFromDB,
755
790
handleContextMenuFavorite
0 commit comments