@@ -9,40 +9,61 @@ import React, { useEffect, useState } from 'react';
99 */
1010const volumeHistory = ( props ) => {
1111 const [ volumeName , setVolumeName ] = useState ( '' ) ;
12- const [ volumeList , setVolumeList ] = useState ( props . arrayOfVolumeNames ) ;
12+ const [ volumeList , setVolumeList ] = useState ( '' ) ;
1313
14- // Creates the card components of Name and container details
15- const renderVolumeHistory = ( volumeProps ) => volumeProps . map ( ( ele , i ) => {
14+ // Container details
15+ const containerDetails = ( container , i ) => {
16+ // unique key error here, fix required
1617 return (
17- < div className = "box" key = { `volume${ i } ` } >
18- < div className = "box-label" >
19- < h3 > { ele . Name } </ h3 >
20- </ div >
21- < div className = "volume-details" >
22- < li >
23- < strong > Container Names: </ strong >
24- { props . volumeContainers [ i ] [ 'Names' ] }
25- </ li >
18+ < div
19+ className = "volume-container-details"
20+ key = { `vol.${ container . Names } -${ i } ` }
21+ >
22+ < strong > Container Name: </ strong >
23+ { container [ 'Names' ] }
24+ < ul className = 'volume-container-list' >
2625 < li >
2726 < strong > Status: </ strong >
28- { props . volumeContainers [ i ] [ 'Status '] }
27+ { container [ 'State '] }
2928 </ li >
3029 < li >
3130 < strong > Running For: </ strong >
32- { props . volumeContainers [ i ] [ 'RunningFor '] }
31+ { container [ 'Status '] }
3332 </ li >
33+ </ ul >
34+ </ div >
35+ ) ;
36+ } ;
37+
38+ // Creates the card components of Name and container details
39+ const renderVolumeHistory = ( volumeProps ) => volumeProps . map ( ( ele , i ) => {
40+ const details = [ ] ;
41+
42+ ele . containers . length
43+ ? ele . containers . forEach ( el => details . push ( containerDetails ( el , i ) ) )
44+ : details . push (
45+ < div >
46+ No container found in this volume
47+ </ div >
48+ ) ;
49+
50+ return (
51+ < div className = "box" key = { `volume${ i } ` } >
52+ < div className = "box-label" >
53+ < h3 > { ele . vol_name } </ h3 >
3454 </ div >
55+ { details }
3556 </ div >
3657 ) ;
3758 } ) ;
3859
3960 // Initializes the volume history tab to be the list of volumes
40- let renderList = renderVolumeHistory ( volumeList ) ;
61+ let renderList = renderVolumeHistory ( props . volumeContainersList ) ;
4162
4263 // Search bar: Finds volume name and renders an individual card
4364 const handleClick = ( e ) => {
4465 e . preventDefault ( ) ;
45- const result = props . arrayOfVolumeNames . filter ( vol => vol . Name . includes ( volumeName ) ) ;
66+ const result = volumeList . filter ( vol => vol . Name . includes ( volumeName ) ) ;
4667
4768 setVolumeList ( result ) ;
4869 renderList = renderVolumeHistory ( volumeList ) ;
0 commit comments