File tree Expand file tree Collapse file tree 1 file changed +25
-31
lines changed
src/common/components/utils Expand file tree Collapse file tree 1 file changed +25
-31
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { connect } from 'react-redux' ;
3
3
import Grid from 'react-bootstrap/lib/Grid' ;
4
+ import Alert from 'react-bootstrap/lib/Alert' ;
4
5
import Errors from '../../constants/Errors' ;
5
6
import { removeError } from '../../actions/errorActions' ;
6
7
8
+ function renderMeta ( error ) {
9
+ let messages = [ ] ;
10
+ if ( error . code === Errors . STATE_PRE_FETCHING_FAIL . code ) {
11
+ messages . push ( error . meta . detail ) ;
12
+ }
13
+ if ( error . meta . path ) {
14
+ messages . push ( `(at path '${ error . meta . path } ')` ) ;
15
+ }
16
+ if ( error . code === Errors . UNKNOWN_EXCEPTION . code ) {
17
+ messages . push ( error . meta . toString ( ) ) ;
18
+ }
19
+ return messages . map ( ( message ) => (
20
+ < p key = { message } >
21
+ { message }
22
+ </ p >
23
+ ) ) ;
24
+ }
25
+
7
26
let ErrorList = ( { errors, dispatch } ) => (
8
27
< Grid >
9
28
{ errors . map ( ( error ) => (
10
- < div
29
+ < Alert
11
30
key = { error . id }
12
- className = "alert alert- danger alert-dismissible "
13
- role = "alert"
31
+ bsStyle = " danger"
32
+ onDismiss = { ( ) => dispatch ( removeError ( error . id ) ) }
14
33
>
15
- < button
16
- type = "button"
17
- className = "close"
18
- data-dismiss = "alert"
19
- aria-label = "Close"
20
- onClick = { ( ) => dispatch ( removeError ( error . id ) ) }
21
- >
22
- < span aria-hidden = "true" > ×</ span >
23
- </ button >
24
- < strong > { error . title } </ strong >
34
+ < h4 > { error . title } </ h4 >
25
35
{ ' ' + error . detail }
26
- { error . meta && [ (
27
- < p key = "0" >
28
- { error . code === Errors . STATE_PRE_FETCHING_FAIL . code && (
29
- < span > { error . meta . detail } </ span >
30
- ) }
31
- </ p >
32
- ) , (
33
- < p key = "1" >
34
- { error . meta . path && `(at path '${ error . meta . path } ')` }
35
- </ p >
36
- ) , (
37
- < p key = "2" >
38
- { error . code === Errors . UNKNOWN_EXCEPTION . code && (
39
- < span > { error . meta . toString ( ) } </ span >
40
- ) }
41
- </ p >
42
- ) ] }
43
- </ div >
36
+ { error . meta && renderMeta ( error ) }
37
+ </ Alert >
44
38
) ) }
45
39
</ Grid >
46
40
) ;
You can’t perform that action at this time.
0 commit comments