@@ -2,12 +2,14 @@ import React from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import { translate } from 'react-i18next' ;
4
4
import { observer , inject } from 'mobx-react' ;
5
+ import _ from 'lodash' ;
5
6
6
7
import { Button , Icon , Table } from 'components/Base' ;
7
8
import { Card } from 'components/Layout' ;
8
9
import Status from 'components/Status' ;
9
10
import DetailTabs from 'components/DetailTabs' ;
10
11
import Toolbar from 'components/Toolbar' ;
12
+ import NoData from 'components/base/Table/noData' ;
11
13
12
14
import columns from './columns' ;
13
15
import { getFilterOptions } from '../utils' ;
@@ -39,19 +41,23 @@ export default class HelmCluster extends React.Component {
39
41
40
42
return (
41
43
< DetailTabs
42
- tabs = { [ 'Deployment Pods' , 'StatefulSet Pods' , 'DaemonSet Pods' ] }
44
+ tabs = { [ 'Deployment Pods' , 'StatefulSet Pods' , 'DaemonSet Pods' , 'Additional Info' ] }
43
45
changeTab = { onChangeK8sTag }
44
46
/>
45
47
) ;
46
48
}
47
49
48
50
renderToolbar ( ) {
49
51
const { clusterDetailStore, t } = this . props ;
50
- const { searchNode, onSearchNode, onClearNode, onRefreshNode } = clusterDetailStore ;
52
+ const { nodeType, searchNode, onSearchNode, onClearNode, onRefreshNode } = clusterDetailStore ;
53
+
54
+ if ( nodeType === 'Additional' ) {
55
+ return null ;
56
+ }
51
57
52
58
return (
53
59
< Toolbar
54
- placeholder = { t ( 'Search Node ' ) }
60
+ placeholder = { t ( 'Search Pods ' ) }
55
61
searchWord = { searchNode }
56
62
onSearch = { onSearchNode }
57
63
onClear = { onClearNode }
@@ -65,6 +71,7 @@ export default class HelmCluster extends React.Component {
65
71
const clusterNodes = clusterDetailStore . helmClusterNodes . toJSON ( ) ;
66
72
67
73
const {
74
+ nodeType,
68
75
onChangeNodeStatus,
69
76
selectNodeStatus,
70
77
extendedRowKeys,
@@ -89,6 +96,10 @@ export default class HelmCluster extends React.Component {
89
96
}
90
97
} ;
91
98
99
+ if ( nodeType === 'Additional' ) {
100
+ return this . renderAdditionInfo ( ) ;
101
+ }
102
+
92
103
props . rowKey = '' ;
93
104
props . expandedRowRender = record =>
94
105
record . nodes . map ( ( { name, status, host_id, host_ip, private_ip } ) => (
@@ -122,6 +133,40 @@ export default class HelmCluster extends React.Component {
122
133
return < Table { ...props } /> ;
123
134
}
124
135
136
+ renderAdditionInfo ( ) {
137
+ const { clusterDetailStore, t } = this . props ;
138
+ const additionalInfo = _ . get ( clusterDetailStore , 'cluster.additional_info' ) ;
139
+ if ( ! additionalInfo ) return < NoData type = "Clusters" /> ;
140
+
141
+ const info = JSON . parse ( additionalInfo ) ;
142
+
143
+ const renderTable = key => {
144
+ if ( _ . get ( info , `${ key } .length` ) === 0 ) {
145
+ return null ;
146
+ }
147
+ const columns = _ . keys ( _ . first ( info [ key ] ) ) . map ( tableKey => ( {
148
+ title : t ( tableKey ) ,
149
+ key : tableKey ,
150
+ render : item => < div > { item [ tableKey ] } </ div >
151
+ } ) ) ;
152
+ const props = {
153
+ columns,
154
+ dataSource : info [ key ] ,
155
+ pagination : {
156
+ total : 0
157
+ }
158
+ } ;
159
+ return (
160
+ < div key = { key } >
161
+ < h3 className = { styles . additionalTitle } > { key } </ h3 >
162
+ < Table className = { styles . additionalTable } { ...props } />
163
+ </ div >
164
+ ) ;
165
+ } ;
166
+
167
+ return _ . keys ( info ) . map ( key => renderTable ( key ) ) ;
168
+ }
169
+
125
170
renderModals ( ) {
126
171
//
127
172
}
0 commit comments