OSDN Git Service

add password to create key
authorYongfeng LI <wliyongfeng@gmail.com>
Fri, 29 Dec 2017 02:41:51 +0000 (10:41 +0800)
committerYongfeng LI <wliyongfeng@gmail.com>
Fri, 29 Dec 2017 02:41:51 +0000 (10:41 +0800)
src/features/mockhsm/components/New.jsx
src/features/shared/components/TextField.jsx
src/sdk/api/mockHsmKeys.js

index 7408fa7..3a67c83 100644 (file)
@@ -18,7 +18,7 @@ class New extends React.Component {
 
   render() {
     const {
-      fields: { alias },
+      fields: { alias, password },
       error,
       handleSubmit,
       submitting
@@ -33,13 +33,14 @@ class New extends React.Component {
 
         <FormSection title='Key Information'>
           <TextField title='Alias' placeholder='Alias' fieldProps={alias} autoFocus={true} />
+          <TextField title='Password' placeholder='Password' fieldProps={password} autoFocus={false} type={'password'} />
         </FormSection>
       </FormContainer>
     )
   }
 }
 
-const fields = [ 'alias' ]
+const fields = [ 'alias', 'password' ]
 export default BaseNew.connect(
   BaseNew.mapStateToProps('mockhsm'),
   BaseNew.mapDispatchToProps('mockhsm'),
index 8389e8f..7b2a03b 100644 (file)
@@ -14,7 +14,8 @@ const TEXT_FIELD_PROPS = [
 class TextField extends React.Component {
   constructor(props) {
     super(props)
-    this.state = {type: 'text'}
+    const type = props.type || 'text'
+    this.state = {type}
   }
 
   render() {
index ae4283a..cf88b0c 100644 (file)
@@ -38,7 +38,7 @@ const mockHsmKeysAPI = (client) => {
     create: (params, cb) => {
       let body = Object.assign({ clientToken: uuid.v4() }, params)
       return shared.tryCallback(
-        client.request('/mockhsm/create-key', body).then(data => data),
+        client.request('/create-key', body).then(data => data),
         cb
       )
     },