@@ -39,9 +39,12 @@ export default function UfixitModal({
3939
4040 const [ windowContents , setWindowContents ] = useState ( 'preview' )
4141 const [ expandExample , setExpandExample ] = useState ( false )
42+ const [ showExample , setShowExample ] = useState ( false )
43+ const [ pending , setPending ] = useState ( false )
44+ const [ currentIndex , setCurrentIndex ] = useState ( 0 )
4245 const [ modalMessages , setModalMessages ] = useState ( [ ] )
4346 const [ code , setCode ] = useState ( '' )
44- const [ UfixitForm , setUfixitForm ] = useState ( null )
47+ let UfixitForm = returnIssueForm ( activeIssue )
4548
4649 const findActiveIndex = ( ) => {
4750 if ( filteredRows && activeIssue ) {
@@ -52,7 +55,6 @@ export default function UfixitModal({
5255 }
5356 }
5457 }
55-
5658 return 0 ;
5759 }
5860
@@ -257,15 +259,17 @@ export default function UfixitModal({
257259 console . info ( 'UfixitModal loaded' )
258260 console . info ( JSON . stringify ( activeIssue ) )
259261
260- const pending = ( activeIssue && ( activeIssue . pending == '1' ) )
261- const activeIndex = findActiveIndex ( )
262- setUfixitForm = returnIssueForm ( activeIssue )
262+ setPending ( activeIssue && ( activeIssue . pending == '1' ) )
263+ UfixitForm = returnIssueForm ( activeIssue )
263264
264- let showExample = false
265265 if ( ! t ( `rule.example.${ activeIssue . scanRuleId } ` ) . includes ( 'rule.example' ) ) {
266- showExample = true
266+ setShowExample ( true )
267+ }
268+ else {
269+ setShowExample ( false )
267270 }
268271
272+ setCurrentIndex ( findActiveIndex ( ) )
269273 setCode ( prepareCode ( activeIssue ) )
270274
271275 } , [ activeIssue , activeContentItem ] )
@@ -315,11 +319,15 @@ export default function UfixitModal({
315319 < Flex justifyItems = "space-between" alignItems = "start" >
316320 < Flex . Item width = "46%" padding = "0" >
317321 < View as = "div" >
318- < UfixitForm activeIssue = { activeIssue } t = { t } settings = { settings }
322+ { UfixitForm && < UfixitForm
323+ t = { t }
324+ settings = { settings }
325+ activeIssue = { activeIssue }
319326 handleIssueSave = { handleSingleIssueSave }
320327 addMessage = { addMessage }
321328 handleActiveIssue = { handleActiveIssue }
322329 handleManualScan = { handleManualScan } />
330+ }
323331 </ View >
324332 { ( 'module' !== activeContentItem . contentType ) &&
325333 < View as = "div" background = "secondary" padding = "medium" margin = "small 0 0 x-small" >
@@ -392,7 +400,7 @@ export default function UfixitModal({
392400 < Flex . Item >
393401 < InlineList delimiter = "pipe" >
394402 < InlineList . Item >
395- { t ( 'label.issue' ) } { ( activeIndex + 1 ) } { t ( 'label.of' ) } { filteredRows . length }
403+ { t ( 'label.issue' ) } { ( currentIndex + 1 ) } { t ( 'label.of' ) } { filteredRows . length }
396404 </ InlineList . Item >
397405 { activeIssue . status && ! activeIssue . pending &&
398406 < InlineList . Item >
@@ -414,10 +422,10 @@ export default function UfixitModal({
414422 </ Flex . Item >
415423 < Flex . Item >
416424 < Button margin = "0 small" interaction = { ( ! pending ) ? 'enabled' : 'disabled' } onClick = { handleCloseButton } > { t ( 'label.close' ) } </ Button >
417- < Button margin = "0 0 0 x-small" interaction = { ( ! pending ) ? 'enabled' : 'disabled' } onClick = { ( ) => handleIssueChange ( activeIndex - 1 ) } >
425+ < Button margin = "0 0 0 x-small" interaction = { ( ! pending ) ? 'enabled' : 'disabled' } onClick = { ( ) => handleIssueChange ( currentIndex - 1 ) } >
418426 { t ( 'label.previous_issue' ) }
419427 </ Button >
420- < Button margin = "0 0 0 x-small" interaction = { ( ! pending ) ? 'enabled' : 'disabled' } onClick = { ( ) => handleIssueChange ( activeIndex + 1 ) } >
428+ < Button margin = "0 0 0 x-small" interaction = { ( ! pending ) ? 'enabled' : 'disabled' } onClick = { ( ) => handleIssueChange ( currentIndex + 1 ) } >
421429 { t ( 'label.next_issue' ) }
422430 </ Button >
423431 </ Flex . Item >
0 commit comments