Skip to content

Commit 0dbb72a

Browse files
Fixed errors from circleci job which causes build failing
1 parent 4e98469 commit 0dbb72a

File tree

3 files changed

+42
-38
lines changed

3 files changed

+42
-38
lines changed

apps/st2-actions/actions-details.component.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import {
4747
DetailsToolbarSeparator,
4848
} from '@stackstorm/module-panel';
4949
import Time from '@stackstorm/module-time';
50-
import validator from 'validator';
5150

5251

5352
@connect((state) => {
@@ -195,20 +194,21 @@ export default class ActionsDetails extends React.Component {
195194
;
196195
}
197196

198-
minMax(value){
199-
if(value < 0 || value > 2492000){
200-
return true
197+
minMax (value) {
198+
if (value < 0 || value > 2492000) {
199+
return true;
201200
}
201+
return false;
202202
}
203203

204-
isValidInt(value){
205-
for (var n = 0; n < value.length; n++) {
206-
var digit = (value.charCodeAt(n) >= 48 && value.charCodeAt(n) <= 57) || value.charCodeAt(n) == 8;
207-
if(!digit){
208-
return true
209-
}
210-
}
211-
return false
204+
isValidInt (value) {
205+
for ( let n = 0; n < value.length; n += 1) {
206+
const digit = (value.charCodeAt(n) >= 48 && value.charCodeAt(n) <= 57) || value.charCodeAt(n) === 45 || value.charCodeAt(n) === 8;
207+
if (!digit) {
208+
return true;
209+
}
210+
}
211+
return false;
212212
}
213213

214214
handleSection(section) {
@@ -270,13 +270,15 @@ export default class ActionsDetails extends React.Component {
270270
{ section === 'general' ? (
271271
<DetailsBody>
272272
<DetailsToolbar key="toolbar">
273-
<Button disabled={
274-
(this.state.runValue && this.state.runValue.timeout && this.minMax(this.state.runValue.timeout)) ||
275-
(this.state.runValue && this.state.runValue.limit && this.minMax(this.state.runValue.limit)) ||
276-
(this.state.runValue && this.state.runValue.timeout && this.isValidInt(this.state.runValue.timeout)) ||
277-
(this.state.runValue && this.state.runValue.limit && this.isValidInt(this.state.runValue.limit))
278-
}
279-
value="Run" data-test="run_submit" onClick={(e) => this.handleRun(e, action.ref, this.state.runValue, this.state.runTrace || undefined)} />
273+
<Button
274+
disabled={
275+
(this.state.runValue && this.state.runValue.timeout && this.minMax(this.state.runValue.timeout)) ||
276+
(this.state.runValue && this.state.runValue.limit && this.minMax(this.state.runValue.limit)) ||
277+
(this.state.runValue && this.state.runValue.timeout && this.isValidInt(this.state.runValue.timeout)) ||
278+
(this.state.runValue && this.state.runValue.limit && this.isValidInt(this.state.runValue.limit))
279+
}
280+
value="Run" data-test="run_submit" onClick={(e) => this.handleRun(e, action.ref, this.state.runValue, this.state.runTrace || undefined)}
281+
/>
280282
<Button flat value="Preview" onClick={() => this.handleToggleRunPreview()} />
281283
<DetailsToolbarSeparator />
282284
{ action.runner_type === 'mistral-v2' || action.runner_type === 'orquesta' ? (

modules/st2-auto-form/fields/base.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ export class BaseTextField extends React.Component {
8888

8989
const invalid = this.validate(value, this.props.spec);
9090

91-
if(this.props.name === "timeout" || this.props.name === "limit"){
91+
if (this.props.name === 'timeout' || this.props.name === 'limit') {
9292
this.setState({ value, invalid }, this.props.onChange ? this.emitChange : undefined);
93-
} else{
93+
}
94+
else {
9495
this.setState({ value, invalid }, this.props.onChange && !invalid ? this.emitChange : undefined);
9596
}
9697
}

modules/st2-auto-form/fields/integer.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ export default class IntegerField extends BaseTextField {
2424
return v;
2525
}
2626

27-
if(this.props.name === 'timeout' || this.props.name === "limit"){
28-
return v
29-
}else{
27+
if (this.props.name === 'timeout' || this.props.name === 'limit') {
28+
return v ;
29+
}
30+
else {
3031
return v !== '' ? validator.toInt(v, 10) : void 0;
3132
}
3233
}
@@ -45,21 +46,21 @@ export default class IntegerField extends BaseTextField {
4546
return invalid;
4647
}
4748

48-
if(spec._name === "timeout" || spec._name === "limit"){
49-
for (var n = 0; n < v.length; n++) {
50-
var digit = (v.charCodeAt(n) >= 48 && v.charCodeAt(n) <= 57) || v.charCodeAt(n) == 45 || v.charCodeAt(n) == 8;
51-
if(!digit){
52-
return `'${v}' must be a positive integer`
53-
}else{
54-
if(v < 0){
55-
return `Value must be > 0`
56-
}
57-
else if(v > 2592000){
58-
return `Value must be <= 2592000`
59-
}else{
60-
v = v
61-
}
49+
if (spec._name === 'timeout' || spec._name === 'limit') {
50+
for (let n = 0; n < v.length; n += 1) {
51+
const digit = (v.charCodeAt(n) >= 48 && v.charCodeAt(n) <= 57) || v.charCodeAt(n) === 45 || v.charCodeAt(n) === 8;
52+
if (!digit) {
53+
return `'${v}' must be a positive integer`;
54+
}
55+
else {
56+
if (v < 0) {
57+
return 'Value must be > 0';
6258
}
59+
else if (v > 2592000) {
60+
return 'Value must be <= 2592000';
61+
}
62+
63+
}
6364
}
6465
}
6566

0 commit comments

Comments
 (0)