Skip to content

Commit 96d717e

Browse files
in the process of unifying github behaviour with gdrive behaviour
1 parent dee536b commit 96d717e

File tree

7 files changed

+140
-137
lines changed

7 files changed

+140
-137
lines changed

src/commons/controlBar/github/ControlBarGitHubButtons.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import React from 'react';
55
import { useResponsive } from 'src/commons/utils/Hooks';
66
import { PersistenceFile } from 'src/features/persistence/PersistenceTypes';
77

8-
import { GitHubSaveInfo } from '../../../features/github/GitHubTypes';
98
import ControlButton from '../../ControlButton';
109

1110
type Props = {
1211
isFolderModeEnabled: boolean;
1312
workspaceLocation: string;
1413
currPersistenceFile?: PersistenceFile;
1514
loggedInAs?: Octokit;
16-
githubSaveInfo: GitHubSaveInfo;
17-
isDirty: boolean;
15+
isDirty?: boolean;
1816
isGDriveSynced: boolean;
1917
onClickOpen?: () => void;
2018
onClickSave?: () => void;
@@ -33,7 +31,7 @@ type Props = {
3331
export const ControlBarGitHubButtons: React.FC<Props> = props => {
3432
const { isMobileBreakpoint } = useResponsive();
3533

36-
const filePath = props.githubSaveInfo.filePath || '';
34+
const filePath = props.currPersistenceFile ? props.currPersistenceFile.path : '';
3735

3836
const isNotPlayground = props.workspaceLocation !== "playground";
3937

src/commons/fileSystemView/FileSystemViewDirectoryNode.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { PersistenceFile } from 'src/features/persistence/PersistenceTypes';
1414
import classes from 'src/styles/FileSystemView.module.scss';
1515

16-
import { isGDriveSyncing, isGithubSyncing, rmdirRecursively } from '../fileSystem/FileSystemUtils';
16+
import { rmdirRecursively } from '../fileSystem/FileSystemUtils';
1717
import { showSimpleConfirmDialog, showSimpleErrorDialog } from '../utils/DialogHelper';
1818
import { removeEditorTabsForDirectory } from '../workspace/WorkspaceActions';
1919
import { WorkspaceLocation } from '../workspace/WorkspaceTypes';
@@ -90,12 +90,8 @@ const FileSystemViewDirectoryNode: React.FC<Props> = ({
9090
if (!shouldProceed) {
9191
return;
9292
}
93-
if (isGDriveSyncing()) {
94-
dispatch(persistenceDeleteFolder(fullPath));
95-
}
96-
if (isGithubSyncing()) {
97-
dispatch(githubDeleteFolder(fullPath));
98-
}
93+
dispatch(persistenceDeleteFolder(fullPath));
94+
dispatch(githubDeleteFolder(fullPath));
9995
dispatch(removeEditorTabsForDirectory(workspaceLocation, fullPath));
10096
rmdirRecursively(fileSystem, fullPath).then(refreshParentDirectory);
10197
});
@@ -128,12 +124,8 @@ const FileSystemViewDirectoryNode: React.FC<Props> = ({
128124
if (err) {
129125
console.error(err);
130126
}
131-
if (isGDriveSyncing()) {
132-
dispatch(persistenceCreateFile(newFilePath));
133-
}
134-
if (isGithubSyncing()) {
135-
dispatch(githubCreateFile(newFilePath));
136-
}
127+
dispatch(persistenceCreateFile(newFilePath));
128+
dispatch(githubCreateFile(newFilePath));
137129
forceRefreshFileSystemViewList();
138130
});
139131
});

src/commons/fileSystemView/FileSystemViewFileName.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
renameEditorTabsForDirectory
1616
} from '../workspace/WorkspaceActions';
1717
import { WorkspaceLocation } from '../workspace/WorkspaceTypes';
18-
import { isGDriveSyncing, isGithubSyncing } from '../fileSystem/FileSystemUtils';
1918

2019
type Props = {
2120
workspaceLocation: WorkspaceLocation;
@@ -75,20 +74,12 @@ const FileSystemViewFileName: React.FC<Props> = ({
7574
}
7675

7776
if (isDirectory) {
78-
if (isGDriveSyncing()) {
79-
dispatch(persistenceRenameFolder({ oldFolderPath: oldPath, newFolderPath: newPath }));
80-
}
81-
if (isGithubSyncing()) {
82-
dispatch(githubRenameFolder(oldPath, newPath));
83-
}
77+
dispatch(persistenceRenameFolder({ oldFolderPath: oldPath, newFolderPath: newPath }));
78+
dispatch(githubRenameFolder(oldPath, newPath));
8479
dispatch(renameEditorTabsForDirectory(workspaceLocation, oldPath, newPath));
8580
} else {
86-
if (isGDriveSyncing()) {
87-
dispatch(persistenceRenameFile({ oldFilePath: oldPath, newFilePath: newPath }));
88-
}
89-
if (isGithubSyncing()) {
90-
dispatch(githubRenameFile(oldPath, newPath));
91-
}
81+
dispatch(persistenceRenameFile({ oldFilePath: oldPath, newFilePath: newPath }));
82+
dispatch(githubRenameFile(oldPath, newPath));
9283
dispatch(renameEditorTabForFile(workspaceLocation, oldPath, newPath));
9384
}
9485
refreshDirectory();

src/commons/fileSystemView/FileSystemViewFileNode.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { WorkspaceLocation } from '../workspace/WorkspaceTypes';
1515
import FileSystemViewContextMenu from './FileSystemViewContextMenu';
1616
import FileSystemViewFileName from './FileSystemViewFileName';
1717
import FileSystemViewIndentationPadding from './FileSystemViewIndentationPadding';
18-
import { isGDriveSyncing, isGithubSyncing } from '../fileSystem/FileSystemUtils';
1918

2019
type Props = {
2120
workspaceLocation: WorkspaceLocation;
@@ -108,12 +107,8 @@ const FileSystemViewFileNode: React.FC<Props> = ({
108107
if (err) {
109108
console.error(err);
110109
}
111-
if (isGDriveSyncing()) {
112-
dispatch(persistenceDeleteFile(fullPath));
113-
}
114-
if (isGithubSyncing()) {
115-
dispatch(githubDeleteFile(fullPath));
116-
}
110+
dispatch(persistenceDeleteFile(fullPath));
111+
dispatch(githubDeleteFile(fullPath));
117112
dispatch(removeEditorTabForFile(workspaceLocation, fullPath));
118113
refreshDirectory();
119114
});

src/commons/sagas/GitHubPersistenceSaga.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { OverallState } from '../application/ApplicationTypes';
2424
import { LOGIN_GITHUB, LOGOUT_GITHUB } from '../application/types/SessionTypes';
2525
import {
2626
getPersistenceFile,
27+
isGithubSyncing,
2728
retrieveFilesInWorkspaceAsRecord
2829
} from '../fileSystem/FileSystemUtils';
2930
import FileExplorerDialog, { FileExplorerDialogProps } from '../gitHubOverlay/FileExplorerDialog';
@@ -400,6 +401,9 @@ function* githubSaveAll(): any {
400401

401402
function* githubCreateFile({ payload }: ReturnType<typeof actions.githubCreateFile>): any {
402403
let toastKey: string | undefined;
404+
if (!isGithubSyncing()) {
405+
return;
406+
}
403407
try {
404408
store.dispatch(actions.disableFileSystemContextMenus());
405409
toastKey = yield call(showMessage, {
@@ -478,6 +482,9 @@ function* githubCreateFile({ payload }: ReturnType<typeof actions.githubCreateFi
478482

479483
function* githubDeleteFile({ payload }: ReturnType<typeof actions.githubDeleteFile>): any {
480484
let toastKey: string | undefined;
485+
if (!isGithubSyncing()) {
486+
return;
487+
}
481488
try {
482489
store.dispatch(actions.disableFileSystemContextMenus());
483490
toastKey = yield call(showMessage, {
@@ -541,6 +548,9 @@ function* githubDeleteFile({ payload }: ReturnType<typeof actions.githubDeleteFi
541548

542549
function* githubDeleteFolder({ payload }: ReturnType<typeof actions.githubDeleteFolder>): any {
543550
let toastKey: string | undefined;
551+
if (!isGithubSyncing()) {
552+
return;
553+
}
544554
try {
545555
store.dispatch(actions.disableFileSystemContextMenus());
546556
toastKey = yield call(showMessage, {
@@ -604,6 +614,9 @@ function* githubDeleteFolder({ payload }: ReturnType<typeof actions.githubDelete
604614

605615
function* githubRenameFile({ payload }: ReturnType<typeof actions.githubRenameFile>): any {
606616
let toastKey: string | undefined;
617+
if (!isGithubSyncing()) {
618+
return;
619+
}
607620
try {
608621
store.dispatch(actions.disableFileSystemContextMenus());
609622
toastKey = yield call(showMessage, {
@@ -669,6 +682,9 @@ function* githubRenameFile({ payload }: ReturnType<typeof actions.githubRenameFi
669682

670683
function* githubRenameFolder({ payload }: ReturnType<typeof actions.githubRenameFile>): any {
671684
let toastKey: string | undefined;
685+
if (!isGithubSyncing()) {
686+
return;
687+
}
672688
try {
673689
store.dispatch(actions.disableFileSystemContextMenus());
674690
toastKey = yield call(showMessage, {

0 commit comments

Comments
 (0)