@@ -9,40 +9,61 @@ import React, { useEffect, useState } from 'react';
9
9
*/
10
10
const volumeHistory = ( props ) => {
11
11
const [ volumeName , setVolumeName ] = useState ( '' ) ;
12
- const [ volumeList , setVolumeList ] = useState ( props . arrayOfVolumeNames ) ;
12
+ const [ volumeList , setVolumeList ] = useState ( '' ) ;
13
13
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
16
17
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' >
26
25
< li >
27
26
< strong > Status: </ strong >
28
- { props . volumeContainers [ i ] [ 'Status '] }
27
+ { container [ 'State '] }
29
28
</ li >
30
29
< li >
31
30
< strong > Running For: </ strong >
32
- { props . volumeContainers [ i ] [ 'RunningFor '] }
31
+ { container [ 'Status '] }
33
32
</ 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 >
34
54
</ div >
55
+ { details }
35
56
</ div >
36
57
) ;
37
58
} ) ;
38
59
39
60
// Initializes the volume history tab to be the list of volumes
40
- let renderList = renderVolumeHistory ( volumeList ) ;
61
+ let renderList = renderVolumeHistory ( props . volumeContainersList ) ;
41
62
42
63
// Search bar: Finds volume name and renders an individual card
43
64
const handleClick = ( e ) => {
44
65
e . preventDefault ( ) ;
45
- const result = props . arrayOfVolumeNames . filter ( vol => vol . Name . includes ( volumeName ) ) ;
66
+ const result = volumeList . filter ( vol => vol . Name . includes ( volumeName ) ) ;
46
67
47
68
setVolumeList ( result ) ;
48
69
renderList = renderVolumeHistory ( volumeList ) ;
0 commit comments