Skip to content

Commit 3f89a68

Browse files
committed
Update npm packages
1 parent a1bbdca commit 3f89a68

19 files changed

+113
-226
lines changed

app/views/layouts/application.html.erb

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<title><%= t('layouts.brand') %></title>
55
<%= csrf_meta_tags %>
66

7+
<%= stylesheet_link_tag 'application', media: 'all' %>
78
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
89
<link rel="stylesheet" href="/katex/katex.css" />
9-
<%= stylesheet_link_tag 'application', media: 'all' %>
1010
<%= yield :styles %>
1111
</head>
1212

@@ -20,9 +20,8 @@
2020
<%= render partial: 'layouts/footer' %>
2121
</div>
2222

23-
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js"></script>
24-
<script src="/katex/katex.js"></script>
2523
<%= javascript_include_tag 'application' %>
24+
<script src="/katex/katex.js"></script>
2625
<%= yield :scripts %>
2726
</body>
2827
</html>

package.json

+20-14
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"scripts": {
1010
"dev-build": "NODE_ENV=development webpack --progress --colors",
1111
"dev-watch": "NODE_ENV=development webpack --progress --colors --watch",
12-
"prod": "NODE_ENV=production webpack",
13-
"heroku-postbuild": "npm run dev-build",
12+
"prod-build": "NODE_ENV=production webpack",
13+
"heroku-postbuild": "npm run prod-build",
1414
"lint": "npm run tslint",
1515
"fix": "npm run tslint-fix",
1616
"tslint": "tslint --project tsconfig.json",
@@ -24,7 +24,10 @@
2424
}
2525
},
2626
"lint-staged": {
27-
"src/**/*.{ts,tsx}": ["tslint --fix", "git add"]
27+
"src/**/*.{ts,tsx}": [
28+
"tslint --fix",
29+
"git add"
30+
]
2831
},
2932
"repository": {
3033
"type": "git",
@@ -38,29 +41,32 @@
3841
"homepage": "https://github.com/ProgrammingDaisukiClub/WPCS2#readme",
3942
"devDependencies": {
4043
"@types/katex": "^0.5.0",
41-
"@types/marked": "0.0.28",
42-
"@types/react": "^15.0.9",
43-
"@types/react-dom": "^0.14.23",
44-
"@types/react-router": "^3.0.3",
44+
"@types/marked": "0.3.0",
45+
"@types/react": "^16.3.14",
46+
"@types/react-dom": "^16.0.5",
47+
"@types/react-router": "^4.0.25",
48+
"@types/react-router-dom": "^4.2.6",
4549
"husky": "^0.14.3",
4650
"lint-staged": "^7.0.5",
4751
"prettier": "^1.12.1",
48-
"ts-loader": "^2.0.0",
52+
"ts-loader": "^4.3.0",
4953
"tslint": "^5.9.1",
5054
"tslint-config-prettier": "^1.12.0",
5155
"tslint-microsoft-contrib": "^5.0.3",
5256
"tslint-plugin-prettier": "^1.3.0",
5357
"tslint-react": "^3.5.1",
5458
"typescript": "^2.1.6",
55-
"webpack": "^2.2.1"
59+
"webpack": "^4.8.3",
60+
"webpack-cli": "^2.1.3"
5661
},
5762
"dependencies": {
58-
"i18n-webpack-plugin": "^0.3.0",
63+
"i18n-webpack-plugin": "^1.0.0",
5964
"marked": "^0.3.6",
60-
"react": "^15.4.2",
61-
"react-dom": "^15.4.2",
62-
"react-render-html": "^0.1.6",
63-
"react-router": "^3.0.2",
65+
"react": "^16.3.2",
66+
"react-dom": "^16.3.2",
67+
"react-render-html": "^0.6.0",
68+
"react-router": "^4.2.0",
69+
"react-router-dom": "^4.2.2",
6470
"whatwg-fetch": "^2.0.2"
6571
}
6672
}

src/contests/ContestApp.tsx

+54-34
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import { Route, Switch } from 'react-router-dom';
23

34
import ContestObject from 'contests/ContestObject';
45
import DataSetObject from 'contests/DataSetObject';
@@ -19,9 +20,11 @@ import SubmitResults from 'contests/SubmitResults';
1920

2021
export interface ContestAppProps extends React.Props<ContestApp> {
2122
children: React.ReactElement<any>;
22-
params: {
23-
contestId: string;
24-
problemId: string;
23+
match: {
24+
params: {
25+
contestId: string;
26+
problemId: string;
27+
};
2528
};
2629
}
2730

@@ -65,7 +68,7 @@ export default class ContestApp extends React.Component<ContestAppProps, Contest
6568
}
6669

6770
public async fetchContest(): Promise<void> {
68-
const responseContest: Response = await fetch(`/api/contests/${this.props.params.contestId}${t('locale')}`, {
71+
const responseContest: Response = await fetch(`/api/contests/${this.props.match.params.contestId}${t('locale')}`, {
6972
credentials: 'same-origin',
7073
});
7174

@@ -119,7 +122,7 @@ export default class ContestApp extends React.Component<ContestAppProps, Contest
119122
let submissions: SubmissionObject[];
120123
if (contest.problems) {
121124
const responseSubmissions: Response = await fetch(
122-
`/api/contests/${this.props.params.contestId}/submissions${t('locale')}`,
125+
`/api/contests/${this.props.match.params.contestId}/submissions${t('locale')}`,
123126
{
124127
credentials: 'same-origin',
125128
}
@@ -162,7 +165,7 @@ export default class ContestApp extends React.Component<ContestAppProps, Contest
162165
const formData: FormData = new FormData();
163166
formData.append(this.csrfParam, this.csrfToken);
164167

165-
const response: Response = await fetch(`/api/contests/${this.props.params.contestId}/entry`, {
168+
const response: Response = await fetch(`/api/contests/${this.props.match.params.contestId}/entry`, {
166169
method: 'post',
167170
credentials: 'same-origin',
168171
body: formData,
@@ -200,7 +203,7 @@ export default class ContestApp extends React.Component<ContestAppProps, Contest
200203

201204
this.changeAnswerForm(problemId, dataSetId, '');
202205

203-
const response: Response = await fetch(`/api/contests/${this.props.params.contestId}/submissions`, {
206+
const response: Response = await fetch(`/api/contests/${this.props.match.params.contestId}/submissions`, {
204207
method: 'post',
205208
credentials: 'same-origin',
206209
body: formData,
@@ -265,7 +268,7 @@ export default class ContestApp extends React.Component<ContestAppProps, Contest
265268
}
266269

267270
public async fetchRanking(): Promise<void> {
268-
const response: Response = await fetch(`/api/contests/${this.props.params.contestId}/ranking${t('locale')}`, {
271+
const response: Response = await fetch(`/api/contests/${this.props.match.params.contestId}/ranking${t('locale')}`, {
269272
credentials: 'same-origin',
270273
});
271274

@@ -337,7 +340,7 @@ export default class ContestApp extends React.Component<ContestAppProps, Contest
337340

338341
public async fetchTime(): Promise<TimerObject> {
339342
let fetchedTime: TimerObject;
340-
const responseTime: Response = await fetch(`/api/contests/${this.props.params.contestId}${t('locale')}`, {
343+
const responseTime: Response = await fetch(`/api/contests/${this.props.match.params.contestId}${t('locale')}`, {
341344
credentials: 'same-origin',
342345
});
343346

@@ -401,38 +404,55 @@ export default class ContestApp extends React.Component<ContestAppProps, Contest
401404
return (
402405
<div className="container">
403406
<Navigation contest={this.state.contest} />
404-
{this.props.children &&
405-
this.props.children.type === ContestHome && (
406-
<ContestHome contest={this.state.contest} join={this.join.bind(this)} />
407-
)}
408-
{this.props.children &&
409-
this.props.children.type === Problem &&
410-
this.state.contest.problems && (
411-
<Problem
412-
contest={this.state.contest}
413-
problem={this.state.contest.problems.find(
414-
(problem: ProblemObject) => problem.id === +this.props.params.problemId
415-
)}
416-
changeAnswerForm={this.changeAnswerForm.bind(this)}
417-
submit={this.submit.bind(this)}
418-
/>
419-
)}
420-
{this.props.children &&
421-
this.props.children.type === Submissions && (
422-
<Submissions contest={this.state.contest} submissions={this.state.submissions} />
423-
)}
424-
{this.props.children &&
425-
this.props.children.type === Ranking &&
426-
this.state.users && <Ranking contest={this.state.contest} users={this.state.users} />}
407+
<Switch>
408+
<Route
409+
exact={true}
410+
path="/contests/:contestId"
411+
render={(): JSX.Element => <ContestHome contest={this.state.contest} join={this.join.bind(this)} />}
412+
/>;
413+
<Route
414+
exact={true}
415+
path="/contests/:contestId/problems/:problemId"
416+
render={(props: any): JSX.Element => {
417+
return !this.state.contest.problems ? null : (
418+
<Problem
419+
contest={this.state.contest}
420+
problem={this.state.contest.problems.find(
421+
(problem: ProblemObject) => problem.id === +props.match.params.problemId
422+
)}
423+
changeAnswerForm={this.changeAnswerForm.bind(this)}
424+
submit={this.submit.bind(this)}
425+
/>
426+
);
427+
}}
428+
/>
429+
<Route
430+
exact={true}
431+
path="/contests/:contestId/ranking"
432+
render={(): JSX.Element => {
433+
return !this.state.users ? null : <Ranking contest={this.state.contest} users={this.state.users} />;
434+
}}
435+
/>
436+
<Route
437+
exact={true}
438+
path="/contests/:contestId/submissions"
439+
render={(): JSX.Element => (
440+
<Submissions contest={this.state.contest} submissions={this.state.submissions} />
441+
)}
442+
/>
443+
<Route
444+
exact={true}
445+
path="/contests/:contestId/editorials/:editorialId"
446+
render={(): JSX.Element => <Editorial editorial={this.state.contest.editorial} />}
447+
/>
448+
</Switch>
427449
{this.state.submissions && (
428450
<SubmitResults
429451
submissions={this.state.submissions}
430452
submitResults={this.state.submitResults}
431453
closeSubmitResults={this.closeSubmitResults.bind(this)}
432454
/>
433455
)}
434-
{this.props.children &&
435-
this.props.children.type === Editorial && <Editorial editorial={this.state.contest.editorial} />}
436456
</div>
437457
);
438458
}

src/contests/Editorial.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export interface EditorialProps {
88
}
99

1010
export default class Editorial extends React.Component<EditorialProps> {
11-
constructor() {
12-
super();
11+
constructor(props: EditorialProps) {
12+
super(props);
1313
this.state = {};
1414
}
1515

src/contests/MarkdownRenderer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface Props {
1212
}
1313

1414
export default class MarkdownRenderer extends React.Component<Props> {
15-
private renderer: MarkedRenderer;
15+
private renderer: marked.Renderer;
1616

1717
constructor(props: Props) {
1818
super(props);

src/contests/Navigation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { Link } from 'react-router';
2+
import { Link } from 'react-router-dom';
33

44
import ContestObject from 'contests/ContestObject';
55
import DataSetObject from 'contests/DataSetObject';

src/contests/Problem.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ export default class Problem extends React.Component<ProblemProps, ProblemState>
2020
private timerId: number;
2121

2222
constructor(props: ProblemProps) {
23-
super();
23+
super(props);
2424

2525
this.state = {
2626
dataSetTabId: props.problem.dataSets[0].id,
2727
};
2828
}
2929

3030
public componentDidMount(): void {
31-
this.timerId = setInterval(() => {
31+
this.timerId = window.setInterval(() => {
3232
this.forceUpdate();
3333
}, 10000);
3434
}

src/contests/Ranking.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ interface RankingState {
1616
}
1717

1818
export default class Ranking extends React.Component<RankingProps, RankingState> {
19-
constructor() {
20-
super();
19+
constructor(props: RankingProps) {
20+
super(props);
2121

2222
this.state = {
2323
currentPage: 1,

src/contests/Submissions.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { Link } from 'react-router';
2+
import { Link } from 'react-router-dom';
33

44
import ContestObject from 'contests/ContestObject';
55
import DataSetObject from 'contests/DataSetObject';
@@ -14,8 +14,8 @@ export interface SubmissionsProps extends React.Props<Submissions> {
1414
}
1515

1616
export default class Submissions extends React.Component<SubmissionsProps> {
17-
constructor() {
18-
super();
17+
constructor(props: SubmissionsProps) {
18+
super(props);
1919
this.state = {};
2020
}
2121

src/contests/SubmitResults.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
// import { Link } from 'react-router';
32

43
import SubmissionObject from 'contests/SubmissionObject';
54

@@ -62,7 +61,7 @@ export default class SubmitResults extends React.Component<SubmitResultsProps> {
6261
<div className="submitResults--inner">
6362
<div className="submitResults--header">{t('judge_results')}</div>
6463
{this.results().map((submission: SubmissionObject) => (
65-
<div className="submitResults--item">
64+
<div key={submission.id} className="submitResults--item">
6665
<span className="submitResults--date">{this.createdAt(submission.createdAt)}</span>
6766
<span className={`submitResults--judgeStatus__${this.judgeStatus(submission.judgeStatus)}`}>
6867
{this.judgeStatus(submission.judgeStatus)}

src/contests/index.tsx

+4-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
import * as React from 'react';
22
import * as ReactDOM from 'react-dom';
3-
import { browserHistory, IndexRoute, Route, Router } from 'react-router';
3+
import { BrowserRouter, Route } from 'react-router-dom';
44
import 'whatwg-fetch';
55

66
import ContestApp from 'contests/ContestApp';
7-
import ContestHome from 'contests/ContestHome';
8-
import Editorial from 'contests/Editorial';
9-
import Problem from 'contests/Problem';
10-
import Ranking from 'contests/Ranking';
11-
import Submissions from 'contests/Submissions';
127

138
ReactDOM.render(
14-
<Router history={browserHistory}>
15-
<Route path="contests/:contestId" component={ContestApp}>
16-
<IndexRoute component={ContestHome} />
17-
<Route path="problems/:problemId" component={Problem} />
18-
<Route path="ranking" component={Ranking} />
19-
<Route path="submissions" component={Submissions} />
20-
<Route path="editorials/:editorialId" component={Editorial} />
21-
</Route>
22-
</Router>,
9+
<BrowserRouter>
10+
<Route path="/contests/:contestId" component={ContestApp} />
11+
</BrowserRouter>,
2312
document.getElementById('contests-app')
2413
);

src/locales/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"contest_home": "Contest Home",
55
"submissions": "Your Submissions",
66
"ranking": "Ranking",
7+
"editorial": "Editorial",
78
"join": "Join Contest",
89
"score": "Score",
910
"submission": "Answer Submission",

0 commit comments

Comments
 (0)