11
22import  React ,  {  PropTypes ,  Component  }  from  'react' ; 
3- import  { Breadcrumb ,  Table ,  Button ,  Col }  from  'react-bootstrap' ; 
3+ import  {   Breadcrumb ,  Table ,  Button ,  Col   }  from  'react-bootstrap' ; 
44import  withStyles  from  'isomorphic-style-loader/lib/withStyles' ; 
55import  s  from  './AccessKeys.css' ; 
66import  cx  from  'classnames' ; 
@@ -25,43 +25,43 @@ class AccessKeys extends Component {
2525  static  defaultProps  =  { 
2626    isFetching : true , 
2727    rs : [ ] , 
28-     removeKey : ( name ) => { } , 
29-     patchKey : ( name ,  friendlyName = null ,  ttl = 0 ) => { } , 
28+     removeKey : ( name )   =>   { } , 
29+     patchKey : ( name ,  friendlyName   =   null ,  ttl   =   0 )   =>   { } , 
3030    isCreating : false , 
31-     createKey : ( ) => { } , 
31+     createKey : ( )   =>   { } , 
3232    isShowKey : false , 
33-     close : ( ) => { } , 
33+     close : ( )   =>   { } , 
3434    token : '' , 
3535  } ; 
3636
37-   constructor ( ) { 
37+   constructor ( )   { 
3838    super ( ) ; 
3939    this . renderRow  =  this . renderRow . bind ( this ) ; 
4040  } 
4141
4242  renderRow ( rowData ,  index )  { 
43-     let  self  =  this ; 
44-     var  moment  =  require ( 'moment' ) ; 
43+     const  self  =  this ; 
44+     const  moment  =  require ( 'moment' ) ; 
4545    return  ( 
46-       < tr  key = { index } > 
46+       < tr  key = { _ . get ( rowData ,   'id' ) } > 
4747        < td > 
48-         < MyEditor 
49-           saveData = { ( str ) => { 
50-             if  ( ! _ . eq ( str ,  _ . get ( rowData ,  'friendlyName' ) ) )  { 
51-               self . props . patchKey ( _ . get ( rowData ,  'friendlyName' ) ,  str ) ; 
52-             } 
53-           } } 
54-           value = { _ . get ( rowData ,  'friendlyName' ) } 
48+            < MyEditor 
49+              saveData = { ( str )   =>   { 
50+                if  ( ! _ . eq ( str ,  _ . get ( rowData ,  'friendlyName' ) ) )  { 
51+                  self . props . patchKey ( _ . get ( rowData ,  'friendlyName' ) ,  str ) ; 
52+                } 
53+              } } 
54+              value = { _ . get ( rowData ,  'friendlyName' ) } 
5555          /> 
5656        </ td > 
5757        < td > { _ . get ( rowData ,  'createdBy' ) } </ td > 
58-         < td > { _ . get ( rowData ,  'isSession' )  ? 'session' : 'accessKey' } </ td > 
58+         < td > { _ . get ( rowData ,  'isSession' )  ? 'session'   : 'accessKey' } </ td > 
5959        < td > { moment ( _ . get ( rowData ,  'createdTime' ) ) . fromNow ( ) } </ td > 
6060        < td > { moment ( _ . get ( rowData ,  'expires' ) ) . fromNow ( ) } </ td > 
6161        < td > 
62-         < Button 
63-           onClick = { ( ) => { self . props . removeKey ( _ . get ( rowData ,  'friendlyName' ) ) } } 
64-           bsStyle = "danger" 
62+            < Button 
63+              onClick = { ( )   =>   {   self . props . removeKey ( _ . get ( rowData ,  'friendlyName' ) ) ;   } } 
64+              bsStyle = "danger" 
6565          > 
6666          移除
6767        </ Button > 
@@ -71,10 +71,10 @@ class AccessKeys extends Component {
7171  } 
7272
7373  render ( )  { 
74-     let  self  =  this ; 
74+     const  self  =  this ; 
7575    let  tipText  =  '暂无数据' ; 
7676    if  ( this . props . isFetching )  { 
77-       tipText  =  '加载数据中...' 
77+       tipText  =  '加载数据中...' ; 
7878    } 
7979    return  ( 
8080      < div  className = { s . root } > 
@@ -85,41 +85,39 @@ class AccessKeys extends Component {
8585        /> 
8686        < div  className = { s . container } > 
8787          < Breadcrumb > 
88-           < Breadcrumb . Item  active = { true } > 
88+              < Breadcrumb . Item  active > 
8989            密钥列表
9090          </ Breadcrumb . Item > 
9191          </ Breadcrumb > 
92-           < Col  style = { { marginBottom :'20px' } } > 
92+           < Col  style = { {   marginBottom :  '20px'   } } > 
9393            < Button 
94-               onClick = { ( ) => { 
94+               onClick = { ( )   =>   { 
9595                self . props . createKey ( ) ; 
9696              } } 
9797              bsStyle = "primary" 
98-               disabled = { this . props . isCreating  ?  true : false    } 
98+               disabled = { ! ! this . props . isCreating } 
9999            > 
100100              创建key
101101            </ Button > 
102102          </ Col > 
103103          < Table  striped  bordered  condensed  hover  responsive > 
104104            < thead > 
105105              < tr > 
106-                 < th  style = { {  textAlign :'center'  } }  > 名字</ th > 
107-                 < th  style = { {  textAlign :'center'  } }  > 创建者</ th > 
108-                 < th  style = { {  textAlign :'center'  } }  > 类型</ th > 
109-                 < th  style = { {  textAlign :'center'  } }  > 创建时间</ th > 
110-                 < th  style = { {  textAlign :'center'  } }  > 过期时间</ th > 
111-                 < th  style = { {  textAlign :'center'  } }  > 操作</ th > 
106+                 < th  style = { {  textAlign :  'center'  } }  > 名字</ th > 
107+                 < th  style = { {  textAlign :  'center'  } }  > 创建者</ th > 
108+                 < th  style = { {  textAlign :  'center'  } }  > 类型</ th > 
109+                 < th  style = { {  textAlign :  'center'  } }  > 创建时间</ th > 
110+                 < th  style = { {  textAlign :  'center'  } }  > 过期时间</ th > 
111+                 < th  style = { {  textAlign :  'center'  } }  > 操作</ th > 
112112              </ tr > 
113113            </ thead > 
114114            < tbody > 
115115              { 
116116                 this . props . rs . length  >  0  ?
117-                  _ . map ( this . props . rs ,  function  ( item ,  index )  { 
118-                    return  self . renderRow ( item ,  index ) ; 
119-                  } ) 
117+                  _ . map ( this . props . rs ,  ( item ,  index )  =>  self . renderRow ( item ,  index ) ) 
120118                 :
121119                 < tr > 
122-                   < td  colSpan = "6"  > { tipText } </ td > 
120+                     < td  colSpan = "6"  > { tipText } </ td > 
123121                 </ tr > 
124122               } 
125123            </ tbody > 
0 commit comments