1- import { Accordion , Header , Icon , Loader , Popup , Table } from 'semantic-ui-react' ;
2- import api , { IsUnauthorized } from '../api/api.js' ;
3- import CommandInstruction from '../util/CommandInstruction.js' ;
4- import VolumeList from './VolumeList.js' ;
1+ import { Loader , Table } from 'semantic-ui-react' ;
2+ import api , { isUnauthorized } from '../api/api.js' ;
53import Loading from '../util/Loading.js' ;
64import React , { Component } from 'react' ;
75import ReactTimeout from 'react-timeout' ;
86import styled from 'react-emotion' ;
97import { withAuth } from '../auth/Auth.js' ;
8+ import StorageRow from './StorageRow' ;
109
1110const LoaderBox = styled ( 'span' ) `
1211 float: right;
@@ -31,65 +30,13 @@ const HeaderView = ({loading}) => (
3130 </ Table . Header >
3231) ;
3332
34- const RowView = ( { name, stateColor, localPaths, storageClass, storageClassIsDefault, deleteCommand, describeCommand, expanded, toggleExpand} ) => (
35- < Table . Row >
36- < Table . Cell >
37- < Popup trigger = { < Icon name = { ( stateColor === "green" ) ? "check" : "bell" } color = { stateColor } /> } >
38- { getStateColorDescription ( stateColor ) }
39- </ Popup >
40- </ Table . Cell >
41- < Table . Cell onClick = { toggleExpand } >
42- < Accordion >
43- < Accordion . Title active = { expanded } >
44- < Icon name = 'dropdown' />
45- { name }
46- </ Accordion . Title >
47- </ Accordion >
48- </ Table . Cell >
49- < Table . Cell >
50- { localPaths . map ( ( item , index ) => < code key = { index } > { item } </ code > ) }
51- </ Table . Cell >
52- < Table . Cell >
53- { storageClass }
54- < span style = { { "float" :"right" } } >
55- { storageClassIsDefault && < Popup trigger = { < Icon name = "exclamation" /> } content = "Default storage class" /> }
56- </ span >
57- </ Table . Cell >
58- < Table . Cell >
59- < CommandInstruction
60- trigger = { < Icon link name = "zoom" /> }
61- command = { describeCommand }
62- title = "Describe local storage"
63- description = "To get more information on the state of this local storage, run:"
64- />
65- < span style = { { "float" :"right" } } >
66- < CommandInstruction
67- trigger = { < Icon link name = "trash" /> }
68- command = { deleteCommand }
69- title = "Delete local storage"
70- description = "To delete this local storage, run:"
71- />
72- </ span >
73- </ Table . Cell >
74- </ Table . Row >
75- ) ;
76-
77- const VolumesRowView = ( { name} ) => (
78- < Table . Row >
79- < Table . Cell colSpan = "5" >
80- < Header sub > Volumes</ Header >
81- < VolumeList storageName = { name } />
82- </ Table . Cell >
83- </ Table . Row >
84- ) ;
85-
8633const ListView = ( { items, loading} ) => (
8734 < Table celled >
8835 < HeaderView loading = { loading } />
8936 < Table . Body >
9037 {
9138 ( items ) ? items . map ( ( item ) =>
92- < RowComponent
39+ < StorageRow
9340 key = { item . name }
9441 name = { item . name }
9542 localPaths = { item . local_paths }
@@ -105,34 +52,6 @@ const ListView = ({items, loading}) => (
10552 </ Table >
10653) ;
10754
108- class RowComponent extends Component {
109- state = { expanded : true } ;
110-
111- onToggleExpand = ( ) => { this . setState ( { expanded : ! this . state . expanded } ) ; }
112-
113- render ( ) {
114- return [ < RowView
115- key = "datarow"
116- name = { this . props . name }
117- localPaths = { this . props . localPaths }
118- stateColor = { this . props . stateColor }
119- storageClass = { this . props . storageClass }
120- storageClassIsDefault = { this . props . storageClassIsDefault }
121- deleteCommand = { this . props . deleteCommand }
122- describeCommand = { this . props . describeCommand }
123- toggleExpand = { this . onToggleExpand }
124- expanded = { this . state . expanded }
125- /> ,
126- this . state . expanded && < VolumesRowView
127- key = "volrow"
128- name = { this . props . name }
129- expanded = { this . state . expanded }
130- toggleExpand = { this . onToggleExpand }
131- />
132- ] ;
133- }
134- }
135-
13655const EmptyView = ( ) => ( < div > No local storage resources</ div > ) ;
13756
13857function createDeleteCommand ( name ) {
@@ -143,21 +62,6 @@ function createDescribeCommand(name) {
14362 return `kubectl describe ArangoLocalStorage ${ name } ` ;
14463}
14564
146- function getStateColorDescription ( stateColor ) {
147- switch ( stateColor ) {
148- case "green" :
149- return "Everything is running smooth." ;
150- case "yellow" :
151- return "There is some activity going on, but local storage is available." ;
152- case "orange" :
153- return "There is some activity going on, local storage may be/become unavailable. You should pay attention now!" ;
154- case "red" :
155- return "The local storage is in a bad state and manual intervention is likely needed." ;
156- default :
157- return "State is not known." ;
158- }
159- }
160-
16165class StorageList extends Component {
16266 state = {
16367 items : undefined ,
@@ -185,7 +89,7 @@ class StorageList extends Component {
18589 error : e . message ,
18690 loading : false
18791 } ) ;
188- if ( IsUnauthorized ( e ) ) {
92+ if ( isUnauthorized ( e ) ) {
18993 this . props . doLogout ( ) ;
19094 return ;
19195 }
0 commit comments