Skip to content

Commit 61a9fa0

Browse files
authored
Merge branch 'master' into feature/validation_tooltips
2 parents 58dcce4 + 75d482f commit 61a9fa0

File tree

16 files changed

+249
-37
lines changed

16 files changed

+249
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
.idea
33
.deps_check
44
.DS_Store
5+
.nyc_output
56
npm-debug.log*
67
.eslintcache
78
package-lock.json

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ We love contributions from our community of users! This document explains our gu
44

55
#### Environment setup
66

7-
0. Install Node.js (4 or newer) and npm (3 or newer).
7+
0. Install Node.js (6 or newer) and npm (3 or newer).
88
1. Make a fork of Swagger-UI on GitHub, then clone your fork to your machine.
99
2. Run `npm install` in your Swagger-UI directory.
1010
3. Run `npm run dev`. `localhost:3200` should open automatically.

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"test-in-node": "npm run lint-errors && npm run just-test-in-node",
3434
"just-test": "karma start --config karma.conf.js",
3535
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components test/bugs test/swagger-ui-dist-package test/xss",
36+
"just-check-coverage": "nyc npm run just-test-in-node",
3637
"test-e2e": "sleep 3 && nightwatch test/e2e/scenarios/ --config test/e2e/nightwatch.json",
3738
"e2e-initial-render": "nightwatch test/e2e/scenarios/ --config test/e2e/nightwatch.json --group initial-render",
3839
"mock-api": "json-server --watch test/e2e/db.json --port 3204",
@@ -60,13 +61,13 @@
6061
"react-addons-perf": "^15.4.0",
6162
"react-addons-shallow-compare": "0.14.8",
6263
"react-addons-test-utils": "^15.6.2",
63-
"react-collapse": "2.3.1",
64+
"react-collapse": "^4.0.3",
6465
"react-dom": "^15.6.2",
6566
"react-height": "^2.0.0",
6667
"react-hot-loader": "1.3.1",
6768
"react-immutable-proptypes": "2.1.0",
6869
"react-markdown": "^2.5.0",
69-
"react-motion": "0.4.4",
70+
"react-motion": "^0.5.2",
7071
"react-object-inspector": "0.2.1",
7172
"react-redux": "^4.x.x",
7273
"react-split-pane": "0.1.57",
@@ -127,6 +128,7 @@
127128
"node-sass": "^4.5.0",
128129
"npm-run-all": "4.0.2",
129130
"null-loader": "0.1.1",
131+
"nyc": "^11.3.0",
130132
"open": "0.0.5",
131133
"postcss-loader": "2.0.6",
132134
"raw-loader": "0.5.1",
@@ -152,5 +154,11 @@
152154
],
153155
"optionalDependencies": {
154156
"webpack-dev-server": "2.5.0"
157+
},
158+
"nyc": {
159+
"all": true,
160+
"include": [
161+
"**/src/core/plugins/**.js"
162+
]
155163
}
156164
}
Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
import React from "react"
22
import PropTypes from "prop-types"
3-
import ImPropTypes from "react-immutable-proptypes"
43

54
export default class AuthorizeOperationBtn extends React.Component {
5+
static propTypes = {
6+
isAuthorized: PropTypes.bool.isRequired,
7+
onClick: PropTypes.func
8+
}
9+
610
onClick =(e) => {
711
e.stopPropagation()
12+
let { onClick } = this.props
813

9-
let { security, authActions, authSelectors } = this.props
10-
let definitions = authSelectors.getDefinitionsByNames(security)
11-
12-
authActions.showDefinitions(definitions)
14+
if(onClick) {
15+
onClick()
16+
}
1317
}
1418

1519
render() {
16-
let { security, authSelectors } = this.props
17-
18-
let isAuthorized = authSelectors.isAuthorized(security)
19-
20-
if(isAuthorized === null) {
21-
return null
22-
}
20+
let { isAuthorized } = this.props
2321

2422
return (
2523
<button className={isAuthorized ? "authorization__btn locked" : "authorization__btn unlocked"} onClick={ this.onClick }>
@@ -30,10 +28,4 @@ export default class AuthorizeOperationBtn extends React.Component {
3028

3129
)
3230
}
33-
34-
static propTypes = {
35-
authSelectors: PropTypes.object.isRequired,
36-
authActions: PropTypes.object.isRequired,
37-
security: ImPropTypes.iterable.isRequired
38-
}
3931
}

src/core/components/content-type.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class ContentType extends React.Component {
3737

3838
return (
3939
<div className={ "content-type-wrapper " + ( className || "" ) }>
40-
<select className="content-type" value={value} onChange={this.onChangeWrapper} >
40+
<select className="content-type" value={value || ""} onChange={this.onChangeWrapper} >
4141
{ contentTypes.map( (val) => {
4242
return <option key={ val } value={ val }>{ val }</option>
4343
}).toArray()}

src/core/components/debug.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
22
import PropTypes from "prop-types"
3-
import Collapse from "react-collapse"
3+
import { Collapse } from "react-collapse"
44
import { presets } from "react-motion"
55
import ObjectInspector from "react-object-inspector"
66
import Perf from "react-addons-perf"

src/core/components/errors.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import PropTypes from "prop-types"
33
import { List } from "immutable"
4-
import Collapse from "react-collapse"
4+
import { Collapse } from "react-collapse"
55

66
export default class Errors extends React.Component {
77

src/core/components/layout-utils.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
22
import PropTypes from "prop-types"
3-
import OriCollapse from "react-collapse"
3+
import { Collapse as OriCollapse } from "react-collapse"
44

55
function xclass(...args) {
66
return args.filter(a => !!a).join(" ").trim()

src/core/components/model.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React, { Component } from "react"
1+
import React, { PureComponent } from "react"
22
import PropTypes from "prop-types"
33

4-
export default class Model extends Component {
4+
export default class Model extends PureComponent {
55
static propTypes = {
66
schema: PropTypes.object.isRequired,
77
getComponent: PropTypes.func.isRequired,
@@ -35,7 +35,7 @@ export default class Model extends Component {
3535
const PrimitiveModel = getComponent("PrimitiveModel")
3636
let type = "object"
3737
let $$ref = schema && schema.get("$$ref")
38-
38+
3939
// If we weren't passed a `name` but have a ref, grab the name from the ref
4040
if ( !name && $$ref ) {
4141
name = this.getModelName( $$ref )
@@ -44,11 +44,11 @@ export default class Model extends Component {
4444
if ( !schema && $$ref ) {
4545
schema = this.getRefSchema( name )
4646
}
47-
47+
4848
const deprecated = specSelectors.isOAS3() && schema.get("deprecated")
4949
isRef = isRef !== undefined ? isRef : !!$$ref
5050
type = schema && schema.get("type") || type
51-
51+
5252
switch(type) {
5353
case "object":
5454
return <ObjectModel

src/core/components/operation.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,13 @@ export default class Operation extends PureComponent {
183183

184184
{
185185
(!security || !security.count()) ? null :
186-
<AuthorizeOperationBtn authActions={ authActions }
187-
security={ security }
188-
authSelectors={ authSelectors }/>
186+
<AuthorizeOperationBtn
187+
isAuthorized={ authSelectors.isAuthorized(security) }
188+
onClick={() => {
189+
const applicableDefinitions = authSelectors.definitionsForRequirements(security)
190+
authActions.showDefinitions(applicableDefinitions)
191+
}}
192+
/>
189193
}
190194
</div>
191195

0 commit comments

Comments
 (0)