Skip to content

Commit 31dd5ec

Browse files
Revert "streamlining ui behaviouor for github wip"
This reverts commit 292b1ef.
1 parent d7804dc commit 31dd5ec

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/commons/sagas/GitHubPersistenceSaga.ts

+35-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ import FileExplorerDialog, { FileExplorerDialogProps } from '../gitHubOverlay/Fi
3030
import RepositoryDialog, { RepositoryDialogProps } from '../gitHubOverlay/RepositoryDialog';
3131
import { actions } from '../utils/ActionsHelper';
3232
import Constants from '../utils/Constants';
33-
import { promisifyDialog } from '../utils/DialogHelper';
33+
import { promisifyDialog, showSimpleErrorDialog } from '../utils/DialogHelper';
3434
import { dismiss, showMessage, showSuccessMessage, showWarningMessage } from '../utils/notifications/NotificationsHelper';
3535
import { EditorTabState } from '../workspace/WorkspaceTypes';
3636
import { Intent } from '@blueprintjs/core';
37+
import { filePathRegex } from '../utils/PersistenceHelper';
3738

3839
export function* GitHubPersistenceSaga(): SagaIterator {
3940
yield takeLatest(LOGIN_GITHUB, githubLoginSaga);
@@ -288,6 +289,39 @@ function* githubSaveAll(): any {
288289
>;
289290

290291
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+
291325
type ListForAuthenticatedUserData = GetResponseDataTypeFromEndpointMethod<
292326
typeof octokit.repos.listForAuthenticatedUser
293327
>;

src/features/github/GitHubUtils.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import {
88
addGithubSaveInfo,
99
updateRefreshFileViewKey
1010
} from 'src/commons/fileSystem/FileSystemActions';
11+
import {
12+
addGithubSaveInfo,
13+
updateRefreshFileViewKey
14+
} from 'src/commons/fileSystem/FileSystemActions';
1115
import { filePathRegex } from 'src/commons/utils/PersistenceHelper';
1216
import { WORKSPACE_BASE_PATHS } from 'src/pages/fileSystem/createInBrowserFileSystem';
1317

@@ -276,6 +280,7 @@ export async function openFileInEditor(
276280
}
277281
const newFilePath = regexResult[2] + regexResult[3];
278282
console.log(newFilePath);
283+
console.log(newFilePath);
279284

280285
const newEditorValue = Buffer.from(content, 'base64').toString();
281286
const activeEditorTabIndex = store.getState().workspaces.playground.activeEditorTabIndex;

0 commit comments

Comments
 (0)