Skip to content

Commit db9d4f0

Browse files
committed
use prop-types and setState
1 parent 50fd49a commit db9d4f0

17 files changed

Lines changed: 130 additions & 78 deletions

File tree

app/components/App/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FieldDBObject } from 'fielddb/api/FieldDBObject'
33
import Helmet from 'react-helmet'
44
import Q from 'q'
55
import React, { Component } from 'react'
6+
import PropTypes from 'prop-types'
67

78
FieldDBObject.todo = function () {}
89
FieldDBObject.warn = function () {}
@@ -55,7 +56,7 @@ class App extends Component {
5556
}
5657

5758
App.propTypes = {
58-
children: React.PropTypes.object.isRequired
59+
children: PropTypes.object.isRequired
5960
}
6061

6162
function mapStateToProps () {

app/components/App/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CorpusMaskContainer from '../CorpusMask'
77
import UserMaskContainer from '../UserMask'
88
import SearchContainer from '../Search'
99

10-
export default function (history) {
10+
export default function Routes(history) {
1111
return (
1212
<Router history={history}>
1313
<Route path='/' component={App}>

app/components/Corpora/Corpora.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { Link } from 'react-router'
34
import { List } from 'immutable'
45

@@ -38,8 +39,8 @@ class Corpora extends Component {
3839
}
3940

4041
Corpora.propTypes = {
41-
corpora: React.PropTypes.instanceOf(List).isRequired,
42-
className: React.PropTypes.string.isRequired
42+
corpora: PropTypes.instanceOf(List).isRequired,
43+
className: PropTypes.string.isRequired
4344
}
4445

4546
export default Corpora

app/components/Corpora/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { connect } from 'react-redux'
22
import React, { Component } from 'react'
3+
import PropTypes from 'prop-types'
34
import Helmet from 'react-helmet'
45

56
import Corpora from './Corpora.jsx'
@@ -34,8 +35,8 @@ class CorpusMaskContainer extends Component {
3435
}
3536

3637
CorpusMaskContainer.propTypes = {
37-
loadCorpora: React.PropTypes.func.isRequired,
38-
corpora: React.PropTypes.object.isRequired
38+
loadCorpora: PropTypes.func.isRequired,
39+
corpora: PropTypes.object.isRequired
3940
}
4041

4142
function mapStateToProps (state) {

app/components/CorpusMask/index.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { connect } from 'react-redux'
33
import Helmet from 'react-helmet'
44
import Immutable from 'immutable'
55
import React, { Component } from 'react'
6+
import PropTypes from 'prop-types'
67
import { CorpusMask } from 'fielddb/api/corpus/CorpusMask'
78
import { DatumFields } from 'fielddb/api/datum/DatumFields'
89
import marked from 'marked'
@@ -220,6 +221,7 @@ class CorpusMaskContainer extends Component {
220221
<dt>Rights</dt>
221222
<dd>Resource creators, researchers and the speech communities who provide the primary data have different priorities over who has access to language resources.</dd>
222223
<dt>Solution</dt>
224+
{/* eslint-disable-next-line react/jsx-no-target-blank */}
223225
<dd>Terms of use should be well documented, and enforced if necessary with encryption or licensing. It is important however to limit the duration of <a target='_blank' href='http://emeld.org/school/classroom/ethics/access.html'>access restrictions</a>: A resource whose access is permanently restricted to one user is of no long-term value since it cannot be used once that user is gone.</dd>
224226
</dl>
225227
</li>
@@ -242,11 +244,11 @@ function mapStateToProps (state) {
242244
}
243245

244246
CorpusMaskContainer.propTypes = {
245-
children: React.PropTypes.object,
246-
corpusMask: React.PropTypes.object.isRequired,
247-
searchResults: React.PropTypes.object.isRequired,
248-
params: React.PropTypes.object.isRequired,
249-
loadCorpusMaskDetail: React.PropTypes.func.isRequired
247+
children: PropTypes.object,
248+
corpusMask: PropTypes.object.isRequired,
249+
searchResults: PropTypes.object.isRequired,
250+
params: PropTypes.object.isRequired,
251+
loadCorpusMaskDetail: PropTypes.func.isRequired
250252
}
251253

252254
export { CorpusMaskContainer }

app/components/DataList/index.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import marked from 'marked'
22
import React, { Component } from 'react'
3+
import PropTypes from 'prop-types'
34
import SearchResult from '../Search/SearchResult.jsx'
45

56
marked.setOptions({
@@ -74,9 +75,9 @@ class DataList extends Component {
7475
}
7576

7677
DataList.propTypes = {
77-
className: React.PropTypes.string.isRequired,
78-
corpus: React.PropTypes.object.isRequired,
79-
datalist: React.PropTypes.object.isRequired
78+
className: PropTypes.string.isRequired,
79+
corpus: PropTypes.object.isRequired,
80+
datalist: PropTypes.object.isRequired
8081
}
8182

8283
export default DataList

app/components/Datum/IGT.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23

34
function isEmpty (value) {
45
return value
@@ -22,8 +23,8 @@ class IGT extends Component {
2223
}
2324

2425
IGT.propTypes = {
25-
fields: React.PropTypes.object.isRequired,
26-
igt: React.PropTypes.object.isRequired
26+
fields: PropTypes.object.isRequired,
27+
igt: PropTypes.object.isRequired
2728
}
2829

2930
export default IGT

app/components/Datum/ParallelText.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23

34
function isEmpty (value) {
45
return value
@@ -20,7 +21,7 @@ class ParallelText extends Component {
2021
}
2122

2223
ParallelText.propTypes = {
23-
parallelText: React.PropTypes.object.isRequired
24+
parallelText: PropTypes.object.isRequired
2425
}
2526

2627
export default ParallelText

app/components/Media/index.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23

34
const audioExtensions = [
45
'.3gp',
@@ -72,21 +73,23 @@ class Media extends Component {
7273
)
7374
} else if ((media.type && media.type.includes('image')) || imageExtensions.indexOf(extension) > -1) {
7475
return (
76+
// eslint-disable-next-line react/jsx-no-target-blank
7577
<a target='_blank' href={url}>
7678
<img title={media.description} src={url} />
7779
</a>
7880
)
7981
} else {
8082
return (
83+
// eslint-disable-next-line react/jsx-no-target-blank
8184
<a target='_blank' title={'Open ' + media.filename + ' in a new tab'} href={url}>{media.filename}</a>
8285
)
8386
}
8487
}
8588
}
8689

8790
Media.propTypes = {
88-
corpus: React.PropTypes.object.isRequired,
89-
media: React.PropTypes.object.isRequired
91+
corpus: PropTypes.object.isRequired,
92+
media: PropTypes.object.isRequired
9093
}
9194

9295
export default Media

app/components/Search/Search.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ describe('Component::SearchContainer', function () {
3131
let element = doc.find('div')
3232

3333
expect(element).to.exist
34-
expect(element.length).to.equal(3)
34+
expect(element.length).to.equal(1)
35+
36+
let inputs = doc.find('input')
37+
38+
expect(inputs).to.exist
39+
expect(inputs.length).to.equal(1)
3540
})
3641
})

0 commit comments

Comments
 (0)