Skip to content

Commit

Permalink
Fixed errors from circleci job which causes build failing
Browse files Browse the repository at this point in the history
  • Loading branch information
pradnya-orchestral committed Apr 26, 2021
1 parent 4e98469 commit 0dbb72a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 38 deletions.
40 changes: 21 additions & 19 deletions apps/st2-actions/actions-details.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
DetailsToolbarSeparator,
} from '@stackstorm/module-panel';
import Time from '@stackstorm/module-time';
import validator from 'validator';


@connect((state) => {
Expand Down Expand Up @@ -195,20 +194,21 @@ export default class ActionsDetails extends React.Component {
;
}

minMax(value){
if(value < 0 || value > 2492000){
return true
minMax (value) {
if (value < 0 || value > 2492000) {
return true;
}
return false;
}

isValidInt(value){
for (var n = 0; n < value.length; n++) {
var digit = (value.charCodeAt(n) >= 48 && value.charCodeAt(n) <= 57) || value.charCodeAt(n) == 8;
if(!digit){
return true
}
}
return false
isValidInt (value) {
for ( let n = 0; n < value.length; n += 1) {
const digit = (value.charCodeAt(n) >= 48 && value.charCodeAt(n) <= 57) || value.charCodeAt(n) === 45 || value.charCodeAt(n) === 8;
if (!digit) {
return true;
}
}
return false;
}

handleSection(section) {
Expand Down Expand Up @@ -270,13 +270,15 @@ export default class ActionsDetails extends React.Component {
{ section === 'general' ? (
<DetailsBody>
<DetailsToolbar key="toolbar">
<Button disabled={
(this.state.runValue && this.state.runValue.timeout && this.minMax(this.state.runValue.timeout)) ||
(this.state.runValue && this.state.runValue.limit && this.minMax(this.state.runValue.limit)) ||
(this.state.runValue && this.state.runValue.timeout && this.isValidInt(this.state.runValue.timeout)) ||
(this.state.runValue && this.state.runValue.limit && this.isValidInt(this.state.runValue.limit))
}
value="Run" data-test="run_submit" onClick={(e) => this.handleRun(e, action.ref, this.state.runValue, this.state.runTrace || undefined)} />
<Button
disabled={
(this.state.runValue && this.state.runValue.timeout && this.minMax(this.state.runValue.timeout)) ||
(this.state.runValue && this.state.runValue.limit && this.minMax(this.state.runValue.limit)) ||
(this.state.runValue && this.state.runValue.timeout && this.isValidInt(this.state.runValue.timeout)) ||
(this.state.runValue && this.state.runValue.limit && this.isValidInt(this.state.runValue.limit))
}
value="Run" data-test="run_submit" onClick={(e) => this.handleRun(e, action.ref, this.state.runValue, this.state.runTrace || undefined)}
/>
<Button flat value="Preview" onClick={() => this.handleToggleRunPreview()} />
<DetailsToolbarSeparator />
{ action.runner_type === 'mistral-v2' || action.runner_type === 'orquesta' ? (
Expand Down
5 changes: 3 additions & 2 deletions modules/st2-auto-form/fields/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ export class BaseTextField extends React.Component {

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

if(this.props.name === "timeout" || this.props.name === "limit"){
if (this.props.name === 'timeout' || this.props.name === 'limit') {
this.setState({ value, invalid }, this.props.onChange ? this.emitChange : undefined);
} else{
}
else {
this.setState({ value, invalid }, this.props.onChange && !invalid ? this.emitChange : undefined);
}
}
Expand Down
35 changes: 18 additions & 17 deletions modules/st2-auto-form/fields/integer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ export default class IntegerField extends BaseTextField {
return v;
}

if(this.props.name === 'timeout' || this.props.name === "limit"){
return v
}else{
if (this.props.name === 'timeout' || this.props.name === 'limit') {
return v ;
}
else {
return v !== '' ? validator.toInt(v, 10) : void 0;
}
}
Expand All @@ -45,21 +46,21 @@ export default class IntegerField extends BaseTextField {
return invalid;
}

if(spec._name === "timeout" || spec._name === "limit"){
for (var n = 0; n < v.length; n++) {
var digit = (v.charCodeAt(n) >= 48 && v.charCodeAt(n) <= 57) || v.charCodeAt(n) == 45 || v.charCodeAt(n) == 8;
if(!digit){
return `'${v}' must be a positive integer`
}else{
if(v < 0){
return `Value must be > 0`
}
else if(v > 2592000){
return `Value must be <= 2592000`
}else{
v = v
}
if (spec._name === 'timeout' || spec._name === 'limit') {
for (let n = 0; n < v.length; n += 1) {
const digit = (v.charCodeAt(n) >= 48 && v.charCodeAt(n) <= 57) || v.charCodeAt(n) === 45 || v.charCodeAt(n) === 8;
if (!digit) {
return `'${v}' must be a positive integer`;
}
else {
if (v < 0) {
return 'Value must be > 0';
}
else if (v > 2592000) {
return 'Value must be <= 2592000';
}

}
}
}

Expand Down

0 comments on commit 0dbb72a

Please sign in to comment.