Skip to content

Commit

Permalink
Revert "streamlining ui behaviouor for github wip"
Browse files Browse the repository at this point in the history
This reverts commit 292b1ef.
  • Loading branch information
linedoestrolling committed Apr 15, 2024
1 parent d7804dc commit 31dd5ec
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/commons/sagas/GitHubPersistenceSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ import FileExplorerDialog, { FileExplorerDialogProps } from '../gitHubOverlay/Fi
import RepositoryDialog, { RepositoryDialogProps } from '../gitHubOverlay/RepositoryDialog';
import { actions } from '../utils/ActionsHelper';
import Constants from '../utils/Constants';
import { promisifyDialog } from '../utils/DialogHelper';
import { promisifyDialog, showSimpleErrorDialog } from '../utils/DialogHelper';
import { dismiss, showMessage, showSuccessMessage, showWarningMessage } from '../utils/notifications/NotificationsHelper';
import { EditorTabState } from '../workspace/WorkspaceTypes';
import { Intent } from '@blueprintjs/core';
import { filePathRegex } from '../utils/PersistenceHelper';

export function* GitHubPersistenceSaga(): SagaIterator {
yield takeLatest(LOGIN_GITHUB, githubLoginSaga);
Expand Down Expand Up @@ -288,6 +289,39 @@ function* githubSaveAll(): any {
>;

if (store.getState().fileSystem.persistenceFileArray.length === 0) {
// check if there is only one top level folder
const fileSystem: FSModule | null = yield select(
(state: OverallState) => state.fileSystem.inBrowserFileSystem
);

// If the file system is not initialised, do nothing.
if (fileSystem === null) {
yield call(console.log, 'no filesystem!'); // TODO change to throw new Error
return;
}
const currFiles: Record<string, string> = yield call(
retrieveFilesInWorkspaceAsRecord,
'playground',
fileSystem
);
const testPaths: Set<string> = new Set();
Object.keys(currFiles).forEach(e => {
const regexResult = filePathRegex.exec(e)!;
testPaths.add(regexResult![1].slice('/playground/'.length, -1).split('/')[0]); //TODO hardcoded playground
});
if (testPaths.size !== 1) {
yield call(showSimpleErrorDialog, {
title: 'Unable to Save All',
contents: (
"There must be exactly one top level folder present in order to use Save All."
),
label: 'OK'
});
return;
}

//only one top level folder, proceeding to selection

type ListForAuthenticatedUserData = GetResponseDataTypeFromEndpointMethod<
typeof octokit.repos.listForAuthenticatedUser
>;
Expand Down
5 changes: 5 additions & 0 deletions src/features/github/GitHubUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import {
addGithubSaveInfo,

Check failure on line 8 in src/features/github/GitHubUtils.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Duplicate identifier 'addGithubSaveInfo'.
updateRefreshFileViewKey

Check failure on line 9 in src/features/github/GitHubUtils.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Duplicate identifier 'updateRefreshFileViewKey'.
} from 'src/commons/fileSystem/FileSystemActions';
import {
addGithubSaveInfo,

Check failure on line 12 in src/features/github/GitHubUtils.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Duplicate identifier 'addGithubSaveInfo'.
updateRefreshFileViewKey

Check failure on line 13 in src/features/github/GitHubUtils.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Duplicate identifier 'updateRefreshFileViewKey'.
} from 'src/commons/fileSystem/FileSystemActions';
import { filePathRegex } from 'src/commons/utils/PersistenceHelper';
import { WORKSPACE_BASE_PATHS } from 'src/pages/fileSystem/createInBrowserFileSystem';

Expand Down Expand Up @@ -276,6 +280,7 @@ export async function openFileInEditor(
}
const newFilePath = regexResult[2] + regexResult[3];
console.log(newFilePath);
console.log(newFilePath);

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

0 comments on commit 31dd5ec

Please sign in to comment.