11import React , { useState , useEffect , createContext } from 'react'
22import { NavLink } from 'react-router-dom'
3- import { ButtonWithLoader , ConditionalWrap , DeleteDialog , showError , VisibleModal } from '../common'
3+ import { ButtonWithLoader , ConditionalWrap , DeleteDialog , showError , useKeyDown , VisibleModal } from '../common'
44import { Redirect , Route , Switch , useParams , useRouteMatch , useLocation , useHistory } from 'react-router'
55import { BuildStageVariable , BuildTabText , ModuleNameMap , SourceTypeMap , TriggerType , ViewType } from '../../config'
66import {
@@ -200,11 +200,11 @@ export default function CIPipeline({
200200 } )
201201 } , [ ] )
202202
203- const getSecurityModuleStatus = async ( ) : Promise < void > => {
203+ const getSecurityModuleStatus = async ( ) : Promise < void > => {
204204 try {
205205 const { result } = await getModuleInfo ( ModuleNameMap . SECURITY )
206206 if ( result ?. status === ModuleStatus . INSTALLED ) {
207- setSecurityModuleInstalled ( true )
207+ setSecurityModuleInstalled ( true )
208208 }
209209 } catch ( error ) { }
210210 }
@@ -354,7 +354,8 @@ export default function CIPipeline({
354354 validateStage ( BuildStageVariable . PreBuild , formData )
355355 validateStage ( BuildStageVariable . Build , formData )
356356 validateStage ( BuildStageVariable . PostBuild , formData )
357- const scanValidation = ! isSecurityModuleInstalled || ( formData . scanEnabled || ! window . _env_ . FORCE_SECURITY_SCANNING )
357+ const scanValidation =
358+ ! isSecurityModuleInstalled || formData . scanEnabled || ! window . _env_ . FORCE_SECURITY_SCANNING
358359 if ( ! scanValidation ) {
359360 setLoadingData ( false )
360361 toast . error ( 'Scanning is mandatory, please enable scanning' )
@@ -377,7 +378,7 @@ export default function CIPipeline({
377378 }
378379
379380 saveCIPipeline (
380- { ...formData , scanEnabled : isSecurityModuleInstalled ? formData . scanEnabled : false } ,
381+ { ...formData , scanEnabled : isSecurityModuleInstalled ? formData . scanEnabled : false } ,
381382 ciPipeline ,
382383 formData . materials ,
383384 + appId ,
@@ -511,9 +512,7 @@ export default function CIPipeline({
511512 _formDataErrorObj . name = validationRules . name ( _formData . name )
512513 _formDataErrorObj [ BuildStageVariable . Build ] . isValid = _formDataErrorObj . name . isValid
513514 let valid = _formData . materials . reduce ( ( isValid , mat ) => {
514- isValid =
515- isValid &&
516- validationRules . sourceValue ( mat . regex || mat . value ) . isValid
515+ isValid = isValid && validationRules . sourceValue ( mat . regex || mat . value ) . isValid
517516 return isValid
518517 } , true )
519518 _formDataErrorObj [ BuildStageVariable . Build ] . isValid = _formDataErrorObj . name . isValid && valid
@@ -639,6 +638,7 @@ export default function CIPipeline({
639638 const addNewTask = ( ) => {
640639 const _formData = { ...formData }
641640 const detailsFromLastStep = calculateLastStepDetail ( true , _formData , activeStageName )
641+
642642 const stage = {
643643 id : detailsFromLastStep . index ,
644644 index : detailsFromLastStep . index ,
@@ -677,6 +677,14 @@ export default function CIPipeline({
677677 )
678678 }
679679
680+ const keys = useKeyDown ( )
681+
682+ useEffect ( ( ) => {
683+ if ( keys . join ( '' ) === 'Escape' && typeof close === 'function' ) {
684+ close ( )
685+ }
686+ } , [ keys ] )
687+
680688 return (
681689 < VisibleModal className = "" >
682690 < div
0 commit comments