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 11import React from 'react' ;
22import { connect } from 'react-redux' ;
33import Grid from 'react-bootstrap/lib/Grid' ;
4+ import Alert from 'react-bootstrap/lib/Alert' ;
45import Errors from '../../constants/Errors' ;
56import { removeError } from '../../actions/errorActions' ;
67
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+
726let ErrorList = ( { errors, dispatch } ) => (
827 < Grid >
928 { errors . map ( ( error ) => (
10- < div
29+ < Alert
1130 key = { error . id }
12- className = "alert alert- danger alert-dismissible "
13- role = "alert"
31+ bsStyle = " danger"
32+ onDismiss = { ( ) => dispatch ( removeError ( error . id ) ) }
1433 >
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 >
2535 { ' ' + 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 >
4438 ) ) }
4539 </ Grid >
4640) ;
You can’t perform that action at this time.
0 commit comments