Skip to content

Commit 41d9348

Browse files
merge
1 parent f45e429 commit 41d9348

File tree

9 files changed

+40
-10
lines changed

9 files changed

+40
-10
lines changed

src/commons/application/ApplicationTypes.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ export const createDefaultWorkspace = (workspaceLocation: WorkspaceLocation): Wo
393393
: undefined,
394394
value: ['playground', 'sourcecast'].includes(workspaceLocation) ? defaultEditorValue : '',
395395
highlightedLines: [],
396-
breakpoints: []
396+
breakpoints: [],
397+
githubSaveInfo: { repoName:'', filePath:''}
397398
}
398399
],
399400
programPrependValue: '',
@@ -461,7 +462,8 @@ export const defaultWorkspaceManager: WorkspaceManagerState = {
461462
filePath: getDefaultFilePath('playground'),
462463
value: defaultEditorValue,
463464
highlightedLines: [],
464-
breakpoints: []
465+
breakpoints: [],
466+
githubSaveInfo: {repoName:'', filePath:''}
465467
}
466468
]
467469
},
@@ -515,7 +517,8 @@ export const defaultWorkspaceManager: WorkspaceManagerState = {
515517
filePath: getDefaultFilePath('sicp'),
516518
value: defaultEditorValue,
517519
highlightedLines: [],
518-
breakpoints: []
520+
breakpoints: [],
521+
githubSaveInfo: {repoName:'', filePath:''}
519522
}
520523
]
521524
},

src/commons/editingWorkspace/EditingWorkspace.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ const EditingWorkspace: React.FC<EditingWorkspaceProps> = props => {
321321
{
322322
value: editorValue,
323323
highlightedLines: [],
324-
breakpoints: []
324+
breakpoints: [],
325+
githubSaveInfo: {repoName: '', filePath: ''}
325326
}
326327
],
327328
programPrependValue,

src/commons/fileSystemView/FileSystemViewFileNode.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { WorkspaceLocation } from '../workspace/WorkspaceTypes';
1515
import FileSystemViewContextMenu from './FileSystemViewContextMenu';
1616
import FileSystemViewFileName from './FileSystemViewFileName';
1717
import FileSystemViewIndentationPadding from './FileSystemViewIndentationPadding';
18+
import { OverallState } from '../application/ApplicationTypes';
19+
import { actions } from '../utils/ActionsHelper';
1820

1921
type Props = {
2022
workspaceLocation: WorkspaceLocation;
@@ -60,10 +62,12 @@ const FileSystemViewFileNode: React.FC<Props> = ({
6062

6163
const [isEditing, setIsEditing] = React.useState(false);
6264
const dispatch = useDispatch();
65+
const store = useStore<OverallState>();
6366

6467
const fullPath = path.join(basePath, fileName);
6568

6669
const handleOpenFile = () => {
70+
fileSystem.readFile(fullPath, 'utf-8', async (err, fileContents) => {
6771
fileSystem.readFile(fullPath, 'utf-8', async (err, fileContents) => {
6872
if (err) {
6973
console.error(err);
@@ -72,6 +76,19 @@ const FileSystemViewFileNode: React.FC<Props> = ({
7276
throw new Error('File contents are undefined.');
7377
}
7478
dispatch(addEditorTab(workspaceLocation, fullPath, fileContents));
79+
const idx = store.getState().workspaces['playground'].activeEditorTabIndex || 0;
80+
const repoName = store.getState().playground.repoName || '';
81+
const editorFilePath = store.getState().workspaces['playground'].editorTabs[idx].filePath || '';
82+
console.log(repoName);
83+
console.log(editorFilePath);
84+
store.dispatch(actions.updateEditorGithubSaveInfo(
85+
'playground',
86+
idx,
87+
repoName,
88+
editorFilePath,
89+
new Date()
90+
));
91+
console.log(store.getState().workspaces['playground'].editorTabs);
7592
});
7693
};
7794

src/commons/workspace/WorkspaceActions.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ import {
7474
UPDATE_WORKSPACE,
7575
WorkspaceLocation,
7676
WorkspaceLocationsWithTools,
77-
WorkspaceState
77+
WorkspaceState,
78+
UPDATE_EDITOR_GITHUB_SAVE_INFO
7879
} from './WorkspaceTypes';
7980

8081
export const setTokenCount = createAction(

src/commons/workspace/WorkspaceReducer.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ import {
8989
UPDATE_LAST_DEBUGGER_RESULT,
9090
UPDATE_LAST_NON_DET_RESULT,
9191
WorkspaceLocation,
92-
WorkspaceManagerState
92+
WorkspaceManagerState,
93+
UPDATE_EDITOR_GITHUB_SAVE_INFO
9394
} from './WorkspaceTypes';
9495

9596
const getWorkspaceLocation = (action: any): WorkspaceLocation => {
@@ -637,7 +638,8 @@ const newWorkspaceReducer = createReducer(defaultWorkspaceManager, builder => {
637638
filePath,
638639
value: editorValue,
639640
highlightedLines: [],
640-
breakpoints: []
641+
breakpoints: [],
642+
githubSaveInfo: {repoName: '', filePath: ''}
641643
};
642644
editorTabs.push(newEditorTab);
643645
// Set the newly added editor tab as the active tab.

src/commons/workspace/WorkspaceTypes.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { ExternalLibraryName } from '../application/types/ExternalTypes';
77
import { AutogradingResult, Testcase } from '../assessment/AssessmentTypes';
88
import { HighlightedLines, Position } from '../editor/EditorTypes';
99

10+
import { GitHubSaveInfo } from 'src/features/github/GitHubTypes';
11+
1012
export const ADD_HTML_CONSOLE_ERROR = 'ADD_HTML_CONSOLE_ERROR';
1113
export const BEGIN_CLEAR_CONTEXT = 'BEGIN_CLEAR_CONTEXT';
1214
export const BROWSE_REPL_HISTORY_DOWN = 'BROWSE_REPL_HISTORY_DOWN';
@@ -119,6 +121,7 @@ export type EditorTabState = {
119121
readonly highlightedLines: HighlightedLines[];
120122
readonly breakpoints: string[];
121123
readonly newCursorPosition?: Position;
124+
githubSaveInfo: GitHubSaveInfo;
122125
};
123126

124127
export type WorkspaceState = {
@@ -174,4 +177,4 @@ export type SubmissionsTableFilters = {
174177
export type TeamFormationsTableFilters = {
175178
columnFilters: { id: string; value: unknown }[];
176179
globalFilter: string | null;
177-
};
180+
};

src/features/playground/PlaygroundActions.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
PLAYGROUND_UPDATE_PERSISTENCE_FOLDER,
1414
PLAYGROUND_UPDATE_REPO_NAME,
1515
SHORTEN_URL,
16-
UPDATE_SHORT_URL
16+
UPDATE_SHORT_URL,
17+
PLAYGROUND_UPDATE_REPO_NAME
1718
} from './PlaygroundTypes';
1819

1920
export const generateLzString = createAction(GENERATE_LZ_STRING, () => ({ payload: {} }));

src/features/playground/PlaygroundReducer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
PLAYGROUND_UPDATE_PERSISTENCE_FILE,
1212
PLAYGROUND_UPDATE_PERSISTENCE_FOLDER,
1313
PLAYGROUND_UPDATE_REPO_NAME,
14+
PLAYGROUND_UPDATE_REPO_NAME,
1415
PlaygroundState,
1516
UPDATE_SHORT_URL
1617
} from './PlaygroundTypes';

src/pages/academy/grading/subcomponents/GradingWorkspace.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ const GradingWorkspace: React.FC<Props> = props => {
273273
{
274274
value: editorValue,
275275
highlightedLines: [],
276-
breakpoints: []
276+
breakpoints: [],
277+
githubSaveInfo: {repoName: '', filePath: ''}
277278
}
278279
],
279280
programPrependValue,

0 commit comments

Comments
 (0)