@@ -30,10 +30,11 @@ import FileExplorerDialog, { FileExplorerDialogProps } from '../gitHubOverlay/Fi
30
30
import RepositoryDialog , { RepositoryDialogProps } from '../gitHubOverlay/RepositoryDialog' ;
31
31
import { actions } from '../utils/ActionsHelper' ;
32
32
import Constants from '../utils/Constants' ;
33
- import { promisifyDialog } from '../utils/DialogHelper' ;
33
+ import { promisifyDialog , showSimpleErrorDialog } from '../utils/DialogHelper' ;
34
34
import { dismiss , showMessage , showSuccessMessage , showWarningMessage } from '../utils/notifications/NotificationsHelper' ;
35
35
import { EditorTabState } from '../workspace/WorkspaceTypes' ;
36
36
import { Intent } from '@blueprintjs/core' ;
37
+ import { filePathRegex } from '../utils/PersistenceHelper' ;
37
38
38
39
export function * GitHubPersistenceSaga ( ) : SagaIterator {
39
40
yield takeLatest ( LOGIN_GITHUB , githubLoginSaga ) ;
@@ -288,6 +289,39 @@ function* githubSaveAll(): any {
288
289
> ;
289
290
290
291
if ( store . getState ( ) . fileSystem . persistenceFileArray . length === 0 ) {
292
+ // check if there is only one top level folder
293
+ const fileSystem : FSModule | null = yield select (
294
+ ( state : OverallState ) => state . fileSystem . inBrowserFileSystem
295
+ ) ;
296
+
297
+ // If the file system is not initialised, do nothing.
298
+ if ( fileSystem === null ) {
299
+ yield call ( console . log , 'no filesystem!' ) ; // TODO change to throw new Error
300
+ return ;
301
+ }
302
+ const currFiles : Record < string , string > = yield call (
303
+ retrieveFilesInWorkspaceAsRecord ,
304
+ 'playground' ,
305
+ fileSystem
306
+ ) ;
307
+ const testPaths : Set < string > = new Set ( ) ;
308
+ Object . keys ( currFiles ) . forEach ( e => {
309
+ const regexResult = filePathRegex . exec ( e ) ! ;
310
+ testPaths . add ( regexResult ! [ 1 ] . slice ( '/playground/' . length , - 1 ) . split ( '/' ) [ 0 ] ) ; //TODO hardcoded playground
311
+ } ) ;
312
+ if ( testPaths . size !== 1 ) {
313
+ yield call ( showSimpleErrorDialog , {
314
+ title : 'Unable to Save All' ,
315
+ contents : (
316
+ "There must be exactly one top level folder present in order to use Save All."
317
+ ) ,
318
+ label : 'OK'
319
+ } ) ;
320
+ return ;
321
+ }
322
+
323
+ //only one top level folder, proceeding to selection
324
+
291
325
type ListForAuthenticatedUserData = GetResponseDataTypeFromEndpointMethod <
292
326
typeof octokit . repos . listForAuthenticatedUser
293
327
> ;
0 commit comments