@@ -48,6 +48,7 @@ import {
4848} from '@stackstorm/module-panel' ;
4949import Time from '@stackstorm/module-time' ;
5050
51+
5152@connect ( ( state ) => {
5253 const { action, executions, entrypoint } = state ;
5354 return { action, executions, entrypoint } ;
@@ -126,9 +127,10 @@ export default class ActionsDetails extends React.Component {
126127 }
127128 }
128129
130+
131+
129132 componentDidUpdate ( prevProps ) {
130133 const { id } = this . props ;
131-
132134 if ( id && id !== prevProps . id ) {
133135 this . fetchAction ( id ) ;
134136 }
@@ -192,6 +194,23 @@ export default class ActionsDetails extends React.Component {
192194 ;
193195 }
194196
197+ minMax ( value ) {
198+ if ( value < 0 || value > 2492000 ) {
199+ return true ;
200+ }
201+ return false ;
202+ }
203+
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 ;
212+ }
213+
195214 handleSection ( section ) {
196215 const { id } = this . props ;
197216 return this . props . handleNavigate ( { id, section } ) ;
@@ -220,13 +239,11 @@ export default class ActionsDetails extends React.Component {
220239
221240 handleRun ( e , ...args ) {
222241 e . preventDefault ( ) ;
223-
224242 return this . props . handleRun ( ...args ) ;
225243 }
226244
227245 render ( ) {
228246 const { section, action, executions, entrypoint } = this . props ;
229-
230247 if ( ! action ) {
231248 return null ;
232249 }
@@ -253,7 +270,15 @@ export default class ActionsDetails extends React.Component {
253270 { section === 'general' ? (
254271 < DetailsBody >
255272 < DetailsToolbar key = "toolbar" >
256- < Button 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+ />
257282 < Button flat value = "Preview" onClick = { ( ) => this . handleToggleRunPreview ( ) } />
258283 < DetailsToolbarSeparator />
259284 { action . runner_type === 'mistral-v2' || action . runner_type === 'orquesta' ? (
0 commit comments