Skip to content

Commit e52ca30

Browse files
authored
Merge pull request #8 from gerhean/mission-edit-assess-edit
Mission edit assess edit
2 parents 67b9b14 + 0c12834 commit e52ca30

File tree

15 files changed

+1012
-23
lines changed

15 files changed

+1012
-23
lines changed

src/components/Application.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as React from 'react'
44
import { Redirect, Route, RouteComponentProps, Switch } from 'react-router'
55

66
import Academy from '../containers/academy'
7+
import IncubatorContainer from '../containers/incubator'
78
import Login from '../containers/LoginContainer'
89
import Playground from '../containers/PlaygroundContainer'
910
import { Role, sourceChapters } from '../reducers/states'
@@ -30,6 +31,12 @@ export interface IDispatchProps {
3031
handlePlaygroundExternalSelect: (external: ExternalLibraryName) => void
3132
}
3233

34+
const assessmentRenderFactory = (cat: string) => (
35+
routerProps: RouteComponentProps<any>
36+
) => <IncubatorContainer assessmentCategory={cat} />
37+
38+
const assessmentRegExp = ':assessmentId(-?\\d+)?/:questionId(\\d+)?'
39+
3340
class Application extends React.Component<IApplicationProps, {}> {
3441
public componentDidMount() {
3542
parsePlayground(this.props)
@@ -47,6 +54,10 @@ class Application extends React.Component<IApplicationProps, {}> {
4754
<div className="Application__main">
4855
<Switch>
4956
<Route path="/academy" component={toAcademy(this.props)} />
57+
<Route
58+
path={`/incubator/${assessmentRegExp}`}
59+
render={assessmentRenderFactory("Missions")}
60+
/>
5061
<Route path="/playground" component={Playground} />
5162
<Route path="/login" render={toLogin(this.props)} />
5263
<Route exact={true} path="/" render={this.redirectToAcademy} />

src/components/NavigationBar.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ const NavigationBar: React.SFC<INavigationBarProps> = props => (
5555
</NavbarGroup>
5656

5757
<NavbarGroup align={Alignment.RIGHT}>
58+
<NavLink
59+
activeClassName="pt-active"
60+
className="NavigationBar__link pt-button pt-minimal"
61+
to="/incubator"
62+
>
63+
<Icon icon={IconNames.CODE} />
64+
<div className="navbar-button-text hidden-xs">Incubator</div>
65+
</NavLink>
66+
5867
<NavLink
5968
activeClassName="pt-active"
6069
className="NavigationBar__link pt-button pt-minimal"

src/components/Playground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Playground extends React.Component<IPlaygroundProps, PlaygroundState> {
101101
editorProps: {
102102
editorValue: this.props.editorValue,
103103
handleEditorEval: this.props.handleEditorEval,
104-
handleEditorValueChange: this.props.handleEditorValueChange
104+
handleEditorValueChange: this.props.handleEditorValueChange,
105105
},
106106
editorWidth: this.props.editorWidth,
107107
handleEditorWidthChange: this.props.handleEditorWidthChange,

src/components/academy/grading/GradingWorkspace.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
107107
? {
108108
editorValue: editorValue!,
109109
handleEditorEval: this.props.handleEditorEval,
110-
handleEditorValueChange: this.props.handleEditorValueChange
110+
handleEditorValueChange: this.props.handleEditorValueChange,
111111
}
112112
: undefined,
113113
editorWidth: this.props.editorWidth,
114114
handleEditorWidthChange: this.props.handleEditorWidthChange,
115115
handleSideContentHeightChange: this.props.handleSideContentHeightChange,
116116
mcqProps: {
117117
mcq: question as IMCQQuestion,
118-
handleMCQSubmit: (i: number) => {}
118+
handleMCQSubmit: (i: number) => {},
119119
},
120120
sideContentHeight: this.props.sideContentHeight,
121121
sideContentProps: this.sideContentProps(this.props, questionId),

src/components/assessment/EditingOverviewCard.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Markdown from '../commons/Markdown'
2424
const DEFAULT_QUESTION_ID: number = 0
2525

2626
type Props = {
27+
listingPath?: string,
2728
overview: IAssessmentOverview,
2829
updateEditingOverview: (overview: IAssessmentOverview) => void
2930
}
@@ -33,12 +34,6 @@ interface IState {
3334
fieldValue: any
3435
}
3536

36-
const textareaStyle = {
37-
"height": "100%",
38-
"width": "100%",
39-
"overflow": "hidden" as "hidden",
40-
"resize": "none" as "none"
41-
}
4237

4338
export class EditingOverviewCard extends React.Component<Props, IState> {
4439
public constructor(props: Props) {
@@ -88,7 +83,7 @@ export class EditingOverviewCard extends React.Component<Props, IState> {
8883
private makeEditingOverviewTextarea = (field: keyof IAssessmentOverview) =>
8984
<Textarea
9085
autoFocus={true}
91-
style={textareaStyle}
86+
className={'editing-textarea'}
9287
onChange={this.handleEditOverview()}
9388
onBlur={this.saveEditOverview(field)}
9489
value={this.state.fieldValue}
@@ -155,7 +150,7 @@ export class EditingOverviewCard extends React.Component<Props, IState> {
155150
: `${getPrettyDate(overview.closeAt)}`}
156151
</div>
157152
</Text>
158-
{makeOverviewCardButton(overview)}
153+
{makeOverviewCardButton(overview, this.props.listingPath)}
159154
</div>
160155
</div>
161156
</Card>
@@ -197,14 +192,13 @@ export class EditingOverviewCard extends React.Component<Props, IState> {
197192

198193
}
199194

200-
const makeOverviewCardButton = (overview: IAssessmentOverview) => {
195+
const makeOverviewCardButton = (overview: IAssessmentOverview, listingPath: string | undefined) => {
201196
const icon: IconName = IconNames.EDIT;
202197
const label: string = "Edit mission";
198+
listingPath = listingPath || ('/academy/' + assessmentCategoryLink(overview.category));
203199
return (
204200
<NavLink
205-
to={`/academy/${assessmentCategoryLink(
206-
overview.category
207-
)}/${overview.id.toString()}/${DEFAULT_QUESTION_ID}`}
201+
to={listingPath + `/${overview.id.toString()}/${DEFAULT_QUESTION_ID}`}
208202
>
209203
{controlButton(label, icon)}
210204
</NavLink>

0 commit comments

Comments
 (0)