15
15
// limitations under the License.
16
16
17
17
import React from 'react' ;
18
- // import { Spin } from 'antd';
19
18
import Loading from 'cuix/dist/components/Loading' ;
20
19
import Alert from 'cuix/dist/components/Alert' ;
21
20
import Table from 'cuix/dist/components/Table' ;
22
21
import useLoadData from '../../../utils/hooks/useLoadData/useLoadData' ;
23
- import { INSTALL_APP_EXAMPLES_API_URL } from '../Components/utils' ;
22
+ import { CHECK_CONFIG_EXAMPLES_API_URL } from '../Components/utils' ;
24
23
import { i18nReact } from '../../../utils/i18nReact' ;
25
24
import './Overview.scss' ;
26
25
@@ -35,7 +34,7 @@ interface CheckConfigResponse {
35
34
36
35
function ConfigStatus ( ) : JSX . Element {
37
36
const { t } = i18nReact . useTranslation ( ) ;
38
- const { data, loading, error } = useLoadData < CheckConfigResponse > ( INSTALL_APP_EXAMPLES_API_URL ) ;
37
+ const { data, loading, error } = useLoadData < CheckConfigResponse > ( CHECK_CONFIG_EXAMPLES_API_URL ) ;
39
38
40
39
const columns = [
41
40
{
@@ -48,7 +47,7 @@ function ConfigStatus(): JSX.Element {
48
47
< div >
49
48
{ record . value && (
50
49
< p >
51
- { t ( 'Current value' ) } : < span className = "config__table-name " > { record . value } </ span >
50
+ { t ( 'Current value' ) } : < span className = "config__table-value " > { record . value } </ span >
52
51
</ p >
53
52
) }
54
53
< p > { record . message } </ p >
@@ -57,67 +56,63 @@ function ConfigStatus(): JSX.Element {
57
56
}
58
57
] ;
59
58
60
- if ( error ) {
61
- return (
62
- < div >
63
- < Alert
64
- message = { t ( `Error: ${ error } ` ) }
65
- description = { t ( 'An error occurred while attempting to install app examples.' ) }
66
- type = "error"
67
- />
68
- </ div >
69
- ) ;
70
- }
71
-
72
- if ( loading ) {
73
- return < Loading spinning = { loading } className = "config__spin" /> ;
74
- }
75
-
76
59
const configErrorsExist = Boolean ( data ?. configErrors ?. length ) ;
77
60
78
61
return (
79
62
< div className = "overview-config" >
80
- < h1 > { t ( 'Checking current configuration' ) } </ h1 >
81
- { data ?. hueConfigDir && (
82
- < div >
83
- { t ( 'Configuration files located in: ' ) }
84
- < span className = "config__address-value" > { data [ 'hueConfigDir' ] } </ span >
85
- </ div >
63
+ { loading && < Loading spinning = { loading } className = "config__spin" /> }
64
+ { error && (
65
+ < Alert
66
+ message = { `${ t ( 'Error:' ) } ${ error } ` }
67
+ description = { t ( 'An error occurred while attempting to load the configuration status.' ) }
68
+ type = "error"
69
+ />
86
70
) }
87
-
88
- { configErrorsExist && data ? (
71
+ { ! loading && ! error && (
89
72
< >
90
- < Alert
91
- message = {
92
- < span >
93
- < a
94
- href = "https://docs.gethue.com/administrator/configuration/"
95
- target = "_blank"
96
- className = "config__link"
97
- >
98
- { t ( 'Potential misconfiguration detected.' ) }
99
- </ a > { ' ' }
100
- { t ( 'Fix and restart Hue.' ) }
101
- </ span >
102
- }
103
- type = "warning"
104
- className = "config__alert-margin"
105
- />
73
+ < h1 > { t ( 'Checking current configuration' ) } </ h1 >
74
+ { data ?. hueConfigDir && (
75
+ < div >
76
+ { t ( 'Configuration files located in: ' ) }
77
+ < span className = "config__address-value" > { data [ 'hueConfigDir' ] } </ span >
78
+ </ div >
79
+ ) }
106
80
107
- < Table
108
- dataSource = { data [ 'configErrors' ] }
109
- columns = { columns }
110
- rowKey = { record => `${ record . name } -${ record . message . slice ( 1 , 50 ) } ` }
111
- pagination = { false }
112
- showHeader = { false }
113
- />
81
+ { configErrorsExist && data ? (
82
+ < >
83
+ < Alert
84
+ message = {
85
+ < span >
86
+ < a
87
+ href = "https://docs.gethue.com/administrator/configuration/"
88
+ target = "_blank"
89
+ className = "config__link"
90
+ >
91
+ { t ( 'Potential misconfiguration detected.' ) }
92
+ </ a > { ' ' }
93
+ { t ( 'Fix and restart Hue.' ) }
94
+ </ span >
95
+ }
96
+ type = "warning"
97
+ className = "config__alert-margin"
98
+ />
99
+
100
+ < Table
101
+ dataSource = { data [ 'configErrors' ] }
102
+ columns = { columns }
103
+ rowKey = { record => `${ record . name } -${ record . message . slice ( 1 , 50 ) } ` }
104
+ pagination = { false }
105
+ showHeader = { false }
106
+ />
107
+ </ >
108
+ ) : (
109
+ < Alert
110
+ message = { t ( 'All OK. Configuration check passed.' ) }
111
+ type = "success"
112
+ className = "config__alert-margin"
113
+ />
114
+ ) }
114
115
</ >
115
- ) : (
116
- < Alert
117
- message = { t ( 'All OK. Configuration check passed.' ) }
118
- type = "success"
119
- className = "config__alert-margin"
120
- />
121
116
) }
122
117
</ div >
123
118
) ;
0 commit comments