@@ -2,6 +2,8 @@ import { SupportedLocale } from '@studio/common/lib/locale';
22import { useI18n } from '@wordpress/react-i18n' ;
33import { useCallback , useEffect , useRef , useState } from 'react' ;
44import Button from 'src/components/button' ;
5+ import { FormPathInputComponent } from 'src/components/form-path-input' ;
6+ import { useFeatureFlags } from 'src/hooks/use-feature-flags' ;
57import { isWindowsStore } from 'src/lib/app-globals' ;
68import { getIpcApi } from 'src/lib/get-ipc-api' ;
79import { ColorSchemePicker } from 'src/modules/user-settings/components/color-scheme-picker' ;
@@ -26,7 +28,7 @@ import {
2628 useGetStudioCliIsInstalledQuery ,
2729 useSaveStudioCliIsInstalledMutation ,
2830} from 'src/stores/installed-apps-api' ;
29- import { DefaultDirectoryPicker } from './default-directory-picker ' ;
31+ import { SettingsFormField } from './settings-form-field ' ;
3032
3133export const PreferencesTab = ( { onClose } : { onClose : ( ) => void } ) => {
3234 const { __ } = useI18n ( ) ;
@@ -51,7 +53,6 @@ export const PreferencesTab = ( { onClose }: { onClose: () => void } ) => {
5153 const [ storedDefaultSiteDirectory , setStoredDefaultSiteDirectory ] = useState < string > ( ) ;
5254 const [ defaultSiteDirectory , setDefaultSiteDirectory ] = useState < string > ( ) ;
5355 const [ isLoadingDefaultSiteDirectory , setIsLoadingDefaultSiteDirectory ] = useState ( true ) ;
54- const [ isSelectingDefaultDirectory , setIsSelectingDefaultDirectory ] = useState ( false ) ;
5556
5657 const wasSavedRef = useRef ( false ) ;
5758 const dirtyColorSchemeRef = useRef ( dirtyColorScheme ) ;
@@ -143,17 +144,12 @@ export const PreferencesTab = ( { onClose }: { onClose: () => void } ) => {
143144 } , [ ] ) ;
144145
145146 const handleChangeDefaultDirectory = async ( ) => {
146- setIsSelectingDefaultDirectory ( true ) ;
147- try {
148- const response = await getIpcApi ( ) . showOpenFolderDialog (
149- __ ( 'Select default site directory' ) ,
150- defaultSiteDirectory ?? ''
151- ) ;
152- if ( response ?. path ) {
153- setDefaultSiteDirectory ( response . path ) ;
154- }
155- } finally {
156- setIsSelectingDefaultDirectory ( false ) ;
147+ const response = await getIpcApi ( ) . showOpenFolderDialog (
148+ __ ( 'Select default site directory' ) ,
149+ defaultSiteDirectory ?? ''
150+ ) ;
151+ if ( response ?. path ) {
152+ setDefaultSiteDirectory ( response . path ) ;
157153 }
158154 } ;
159155
@@ -172,12 +168,13 @@ export const PreferencesTab = ( { onClose }: { onClose: () => void } ) => {
172168 { ! isWindowsStore ( ) && (
173169 < StudioCliToggle value = { isCliInstalledSelection } onChange = { setDirtyIsCliInstalled } />
174170 ) }
175- < DefaultDirectoryPicker
176- directory = { defaultSiteDirectory }
177- isLoading = { isLoadingDefaultSiteDirectory }
178- isSelecting = { isSelectingDefaultDirectory }
179- onPick = { handleChangeDefaultDirectory }
180- />
171+ < SettingsFormField label = { __ ( 'Default site directory' ) } >
172+ < FormPathInputComponent
173+ value = { isLoadingDefaultSiteDirectory ? __ ( 'Loading...' ) : defaultSiteDirectory ?? '' }
174+ onClick = { handleChangeDefaultDirectory }
175+ doesPathContainWordPress = { false }
176+ />
177+ </ SettingsFormField >
181178 < div className = "mt-auto pt-2 flex justify-end gap-3" >
182179 < Button
183180 variant = "tertiary"
0 commit comments