Skip to content

Segregate Playground and Assessment Workspaces #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
34a178c
Remove updateEditorValue in workspace/DispatchProp
remo5000 Jun 25, 2018
4ed142c
Rename workspaceSaga to playgroundSaga
remo5000 Jun 25, 2018
f6400d8
Move actionTypes around
remo5000 Jun 25, 2018
4f71473
Move playground actions into workspace/actions
remo5000 Jun 25, 2018
389a3a1
Disconnect all workspace components
remo5000 Jun 25, 2018
92bd2d6
Refactor components that call Workspace
remo5000 Jun 25, 2018
e7c06dc
Fill in missing props in Playground and Assessment
remo5000 Jun 25, 2018
ca9b246
Pass in SideContentProps instead of tabs
remo5000 Jun 25, 2018
83fa368
Add location to saga calls
remo5000 Jun 25, 2018
dd9a3a4
Fix more errors
remo5000 Jun 25, 2018
60a1a44
Modify default values for ControlBar
remo5000 Jun 25, 2018
e83eacf
Add WorkspaceManager state
remo5000 Jun 26, 2018
0f5780e
Add location for reducer cases
remo5000 Jun 26, 2018
d07a85c
Fix PlaygroundContainer's IState reference
remo5000 Jun 26, 2018
49df071
Add location to sagas
remo5000 Jun 26, 2018
b7a6e94
Fix reducer naming error
remo5000 Jun 26, 2018
b6d1b5a
Rename workspace file to workspaces
remo5000 Jun 26, 2018
b55e7f5
Add MapDispatchToProps call and DispatchProps
remo5000 Jun 26, 2018
797da3a
Add dispatch and state references to container
remo5000 Jun 26, 2018
374fbcf
Use dispatch props in Playground component
remo5000 Jun 26, 2018
6e9a1c1
Fix sideContentHeight not being stored in state
remo5000 Jun 26, 2018
f1193f4
Remove buggy currying function
remo5000 Jun 26, 2018
02af528
Fix property bug with evaluation
remo5000 Jun 26, 2018
59ca74d
Add state and dispatch for Assessment
remo5000 Jun 26, 2018
05e029b
Sepatate Contexts for playground and assessment
remo5000 Jun 26, 2018
c51d87a
Format and Update test snapshots
remo5000 Jun 26, 2018
27bf990
Use more elegant enums
remo5000 Jun 27, 2018
e75f9d4
Sort properties
remo5000 Jun 27, 2018
947916c
Update test because of sorting
remo5000 Jun 27, 2018
105cb91
Use editorValue in Assessment
remo5000 Jun 27, 2018
764e4ed
Make editorValue possibly undefined
remo5000 Jun 27, 2018
5e40725
Add .env to gitignore
remo5000 Jun 27, 2018
c283e36
Add aciton to reset assessment workspace
remo5000 Jun 27, 2018
e2d9a93
Add state slice for tracking assessment/question
remo5000 Jun 27, 2018
6e9a470
Format Assessment component
remo5000 Jun 27, 2018
fcd3c41
Add comopnent props to get the current Assessment
remo5000 Jun 27, 2018
8f750fc
Add update method for current assessment
remo5000 Jun 27, 2018
ac86239
Clean up logic for updating
remo5000 Jun 27, 2018
160a64f
Fix logical errors preventing store changes
remo5000 Jun 27, 2018
b64557f
Format and update tests
remo5000 Jun 27, 2018
5924403
Fix member ordering
ning-y Jun 27, 2018
7adfc18
Fix sideContentHeight not auto-adjusting
remo5000 Jun 27, 2018
52da48d
Rename saga
remo5000 Jun 27, 2018
eea266d
Rename actions/workspace -> actions/workspaces
remo5000 Jun 27, 2018
ad927aa
Fix playground default text bug
remo5000 Jun 27, 2018
4030286
Format some files
remo5000 Jun 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# production
/build
src/styles/*.css
/.env

# deployment
terraform*
Expand Down
20 changes: 12 additions & 8 deletions src/actions/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,31 @@ export interface IAction extends ReduxAction {
export const SAVE_CANVAS = 'SAVE_CANVAS'

/** Playground */
export const CHANGE_QUERY_STRING = 'CHANGE_QUERY_STRING'
export const GENERATE_LZ_STRING = 'GENERATE_LZ_STRING'

/** Interpreter */
export const HANDLE_CONSOLE_LOG = 'HANDLE_CONSOLE_LOG'
export const EVAL_INTERPRETER_SUCCESS = 'EVAL_INTERPRETER_SUCCESS'
export const EVAL_INTERPRETER_ERROR = 'EVAL_INTERPRETER_ERROR'
export const INTERRUPT_EXECUTION = 'INTERRUPT_EXECUTION'

/** Workspace */
export const CHANGE_ACTIVE_TAB = 'CHANGE_ACTIVE_TAB'
export const CHANGE_CHAPTER = 'CHANGE_CHAPTER'
export const CHANGE_EDITOR_WIDTH = 'CHANGE_EDITOR_WIDTH'
export const CHANGE_QUERY_STRING = 'CHANGE_QUERY_STRING'
export const CHANGE_SIDE_CONTENT_HEIGHT = 'CHANGE_SIDE_CONTENT_HEIGHT'
export const CHAPTER_SELECT = 'CHAPTER_SELECT'
export const CLEAR_REPL_INPUT = 'CLEAR_REPL_INPUT'
export const CLEAR_REPL_OUTPUT = 'CLEAR_REPL_OUTPUT'
export const CLEAR_CONTEXT = 'CLEAR_CONTEXT'
export const EVAL_EDITOR = 'EVAL_EDITOR'
export const EVAL_REPL = 'EVAL_REPL'
export const GENERATE_LZ_STRING = 'GENERATE_LZ_STRING'
export const UPDATE_EDITOR_VALUE = 'UPDATE_EDITOR_VALUE'
export const UPDATE_REPL_VALUE = 'UPDATE_REPL_VALUE'
export const SEND_REPL_INPUT_TO_OUTPUT = 'SEND_REPL_INPUT_TO_OUTPUT'

/** Interpreter */
export const HANDLE_CONSOLE_LOG = 'HANDLE_CONSOLE_LOG'
export const EVAL_INTERPRETER_SUCCESS = 'EVAL_INTERPRETER_SUCCESS'
export const EVAL_INTERPRETER_ERROR = 'EVAL_INTERPRETER_ERROR'
export const INTERRUPT_EXECUTION = 'INTERRUPT_EXECUTION'
export const RESET_ASSESSMENT_WORKSPACE = 'RESET_ASSESSMENT_WORKSPACE'
export const UPDATE_CURRENT_ASSESSMENT_ID = 'UPDATE_CURRENT_ASSESSMENT_ID'

/** Session */
export const CHANGE_TOKEN = 'CHANGE_TOKEN'
Expand Down
1 change: 1 addition & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './game'
export * from './interpreter'
export * from './playground'
export * from './session'
export * from './workspaces'
26 changes: 18 additions & 8 deletions src/actions/interpreter.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
import { SourceError, Value } from '../slang/types'
import * as actionTypes from './actionTypes'
import { WorkspaceLocation } from './workspaces'

export const handleConsoleLog = (log: string) => ({
// TODO fix this immediately after location
// is implemented completely
export const handleConsoleLog = (
logString: string,
workspaceLocation: WorkspaceLocation = 'assessment'
) => ({
type: actionTypes.HANDLE_CONSOLE_LOG,
payload: log
payload: { logString, workspaceLocation }
})

export const evalInterpreterSuccess = (value: Value) => ({
export const evalInterpreterSuccess = (value: Value, workspaceLocation: WorkspaceLocation) => ({
type: actionTypes.EVAL_INTERPRETER_SUCCESS,
payload: { type: 'result', value }
payload: { type: 'result', value, workspaceLocation }
})

export const evalInterpreterError = (errors: SourceError[]) => ({
export const evalInterpreterError = (
errors: SourceError[],
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.EVAL_INTERPRETER_ERROR,
payload: { type: 'errors', errors }
payload: { type: 'errors', errors, workspaceLocation }
})

export const handleInterruptExecution = () => ({
type: actionTypes.INTERRUPT_EXECUTION
export const handleInterruptExecution = (workspaceLocation: WorkspaceLocation) => ({
type: actionTypes.INTERRUPT_EXECUTION,
payload: { workspaceLocation }
})
69 changes: 0 additions & 69 deletions src/actions/playground.ts
Original file line number Diff line number Diff line change
@@ -1,74 +1,5 @@
import { ActionCreator } from 'redux'
import * as actionTypes from './actionTypes'

export const changeActiveTab: ActionCreator<actionTypes.IAction> = (activeTab: number) => ({
type: actionTypes.CHANGE_ACTIVE_TAB,
payload: activeTab
})

export const changeChapter: ActionCreator<actionTypes.IAction> = (newChapter: number) => ({
type: actionTypes.CHANGE_CHAPTER,
payload: newChapter
})

export const changeEditorWidth: ActionCreator<actionTypes.IAction> = (widthChange: string) => ({
type: actionTypes.CHANGE_EDITOR_WIDTH,
payload: widthChange
})

export const changeQueryString: ActionCreator<actionTypes.IAction> = (queryString: string) => ({
type: actionTypes.CHANGE_QUERY_STRING,
payload: queryString
})

export const changeSideContentHeight: ActionCreator<actionTypes.IAction> = (height: number) => ({
type: actionTypes.CHANGE_SIDE_CONTENT_HEIGHT,
payload: height
})

export const chapterSelect: ActionCreator<actionTypes.IAction> = (chapter, changeEvent) => ({
type: actionTypes.CHAPTER_SELECT,
payload: chapter.chapter
})

export const clearContext = () => ({
type: actionTypes.CLEAR_CONTEXT
})

export const clearReplInput = () => ({
type: actionTypes.CLEAR_REPL_INPUT
})

export const clearReplOutput = () => ({
type: actionTypes.CLEAR_REPL_OUTPUT
})

export const evalEditor = () => ({
type: actionTypes.EVAL_EDITOR
})

export const evalRepl = () => ({
type: actionTypes.EVAL_REPL
})

export const generateLzString = () => ({
type: actionTypes.GENERATE_LZ_STRING
})

export const updateEditorValue: ActionCreator<actionTypes.IAction> = (newEditorValue: string) => ({
type: actionTypes.UPDATE_EDITOR_VALUE,
payload: newEditorValue
})

export const updateReplValue: ActionCreator<actionTypes.IAction> = (newReplValue: string) => ({
type: actionTypes.UPDATE_REPL_VALUE,
payload: newReplValue
})

export const sendReplInputToOutput: ActionCreator<actionTypes.IAction> = (newOutput: string) => ({
type: actionTypes.SEND_REPL_INPUT_TO_OUTPUT,
payload: {
type: 'code',
value: newOutput
}
})
135 changes: 135 additions & 0 deletions src/actions/workspaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { ActionCreator } from 'redux'
import * as actionTypes from './actionTypes'

/**
* Used to differenciate between the sources of actions, as
* two workspaces can work at the same time. To generalise this
* or add more instances of `Workspace`s, one can add a string,
* and call the actions with the respective string (taken
* from the below enum).
*
* Note that the names must correspond with the name of the
* object in IWorkspaceManagerState.
*/
export enum WorkspaceLocations {
assessment,
playground
}
export type WorkspaceLocation = keyof typeof WorkspaceLocations

export const changeActiveTab: ActionCreator<actionTypes.IAction> = (
activeTab: number,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.CHANGE_ACTIVE_TAB,
payload: { activeTab, workspaceLocation }
})

export const changeChapter: ActionCreator<actionTypes.IAction> = (
newChapter: number,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.CHANGE_CHAPTER,
payload: { newChapter, workspaceLocation }
})

export const changeEditorWidth: ActionCreator<actionTypes.IAction> = (
widthChange: string,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.CHANGE_EDITOR_WIDTH,
payload: { widthChange, workspaceLocation }
})

export const changeQueryString: ActionCreator<actionTypes.IAction> = (
queryString: string,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.CHANGE_QUERY_STRING,
payload: { queryString, workspaceLocation }
})

export const changeSideContentHeight: ActionCreator<actionTypes.IAction> = (
height: number,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.CHANGE_SIDE_CONTENT_HEIGHT,
payload: { height, workspaceLocation }
})

export const chapterSelect: ActionCreator<actionTypes.IAction> = (
chapter,
changeEvent,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.CHAPTER_SELECT,
payload: {
chapter: chapter.chapter,
workspaceLocation
}
})

export const clearContext = (workspaceLocation: WorkspaceLocation) => ({
type: actionTypes.CLEAR_CONTEXT,
payload: { workspaceLocation }
})

export const clearReplInput = (workspaceLocation: WorkspaceLocation) => ({
type: actionTypes.CLEAR_REPL_INPUT,
payload: { workspaceLocation }
})

export const clearReplOutput = (workspaceLocation: WorkspaceLocation) => ({
type: actionTypes.CLEAR_REPL_OUTPUT,
payload: { workspaceLocation }
})

export const evalEditor = (workspaceLocation: WorkspaceLocation) => ({
type: actionTypes.EVAL_EDITOR,
payload: { workspaceLocation }
})

export const evalRepl = (workspaceLocation: WorkspaceLocation) => ({
type: actionTypes.EVAL_REPL,
payload: { workspaceLocation }
})

export const updateEditorValue: ActionCreator<actionTypes.IAction> = (
newEditorValue: string,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.UPDATE_EDITOR_VALUE,
payload: { newEditorValue, workspaceLocation }
})

export const updateReplValue: ActionCreator<actionTypes.IAction> = (
newReplValue: string,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.UPDATE_REPL_VALUE,
payload: { newReplValue, workspaceLocation }
})

export const sendReplInputToOutput: ActionCreator<actionTypes.IAction> = (
newOutput: string,
workspaceLocation: WorkspaceLocation
) => ({
type: actionTypes.SEND_REPL_INPUT_TO_OUTPUT,
payload: {
type: 'code',
workspaceLocation,
value: newOutput
}
})

export const resetAssessmentWorkspace = () => ({
type: actionTypes.RESET_ASSESSMENT_WORKSPACE
})

export const updateCurrentAssessmentId = (assessmentId: number, questionId: number) => ({
type: actionTypes.UPDATE_CURRENT_ASSESSMENT_ID,
payload: {
assessmentId,
questionId
}
})
Loading