OSDN Git Service

add password input in transaction but hide
authorYongfeng LI <wliyongfeng@gmail.com>
Thu, 25 Jan 2018 02:24:28 +0000 (10:24 +0800)
committerYongfeng LI <wliyongfeng@gmail.com>
Thu, 25 Jan 2018 02:24:28 +0000 (10:24 +0800)
src/features/mockhsm/components/New.jsx
src/features/transactions/actions.js
src/features/transactions/components/New/FormActionItem.jsx
src/features/transactions/components/New/New.jsx
src/sdk/api/mockHsmKeys.js

index 4f3fe5e..74167f8 100644 (file)
@@ -79,7 +79,10 @@ class New extends React.Component {
             <input type='file' style={{'display': 'flex', 'alignItems': 'center', 'fontSize': '12px'}}
                    onChange={this.handleFileChange.bind(this)}/>
           }
-          <TextField title='Password' placeholder='Password' fieldProps={password} autoFocus={false} type={'password'} />
+
+          {false &&
+            <TextField title='Password' placeholder='Password' fieldProps={password} autoFocus={false} type={'password'} />
+          }
         </FormSection>
       </FormContainer>
     )
index f4f28b8..7916804 100644 (file)
@@ -57,6 +57,7 @@ function preprocessTransaction(formParams) {
 }
 
 form.submitForm = (formParams) => function(dispatch) {
+  const {password} = formParams
   const buildPromise = chainClient().transactions.build(builder => {
     const processed = preprocessTransaction(formParams)
 
@@ -87,7 +88,7 @@ form.submitForm = (formParams) => function(dispatch) {
     return buildPromise
       .then(({data: tpl}) => {
         const client = chainClient()
-        const body = Object.assign({}, {auth: '123456', 'transaction': tpl})
+        const body = Object.assign({}, {password, 'transaction': tpl})
         return client.connection.request('/sign-submit-transaction', body, true)
       }).then(resp => {
         if (resp.status === 'fail') {
index 7d373ca..2f15e35 100644 (file)
@@ -23,9 +23,9 @@ const actionLabels = {
 }
 
 const visibleFields = {
-  [ISSUE_KEY]: {asset: true, amount: true},
-  [SPEND_ACCOUNT_KEY]: {asset: true, account: true, amount: true},
-  [SPEND_UNSPENT_KEY]: {outputId: true},
+  [ISSUE_KEY]: {asset: true, amount: true, password: true},
+  [SPEND_ACCOUNT_KEY]: {asset: true, account: true, amount: true, password: true},
+  [SPEND_UNSPENT_KEY]: {outputId: true, password: true},
   [CONTROL_ACCOUNT_KEY]: {asset: true, account: true, amount: true},
   [CONTROL_RECEIVER_KEY]: {asset: true, receiver: true, amount: true},
   [CONTROL_ADDRESS_KEY]: {asset: true, address: true, amount: true},
@@ -63,6 +63,7 @@ export default class ActionItem extends React.Component {
       receiver,
       assetId,
       assetAlias,
+      password,
       amount,
       referenceData } = this.props.fieldProps
 
@@ -117,6 +118,10 @@ export default class ActionItem extends React.Component {
         {visible.amount &&
           <TextField title='Amount' fieldProps={amount} />}
 
+        {visible.password && false &&
+          <TextField title='Password' placeholder='Password' fieldProps={password} autoFocus={false} type={'password'} />
+        }
+
         {false && this.state.referenceDataOpen &&
           <JsonField title='Reference data' fieldProps={referenceData} />
         }
index db4b795..5072c3d 100644 (file)
@@ -45,12 +45,6 @@ class Form extends React.Component {
   }
 
   submitWithValidation(data) {
-    // if (this.props.replicationLag === null || this.props.replicationLag >= lagThreshold) {
-    //   return Promise.reject({
-    //     _error: `Replication lag must be less than ${lagThreshold} to submit transactions via the dashboard. Please wait for the local core to catch up to the generator.`
-    //   })
-    // }
-
     return new Promise((resolve, reject) => {
       this.props.submitForm(data)
         .catch((err) => {
@@ -72,7 +66,7 @@ class Form extends React.Component {
 
   render() {
     const {
-      fields: { baseTransaction, actions, submitAction },
+      fields: { baseTransaction, actions, submitAction, password },
       error,
       handleSubmit,
       submitting
@@ -220,7 +214,9 @@ export default BaseNew.connect(
       'actions[].referenceData',
       'actions[].type',
       'actions[].address',
+      'actions[].password',
       'submitAction',
+      'password'
     ],
     validate,
     initialValues: {
index 0d16bf5..40f0366 100644 (file)
@@ -3,7 +3,7 @@ const shared = require('../shared')
 const mockHsmKeysAPI = (client) => {
   return {
     create: (params, cb) => {
-      let body = Object.assign({}, params)
+      let body = Object.assign({}, params, {password: '123456'})
       const uri = body.xprv ? '/import-private-key' : '/create-key'
 
       return shared.tryCallback(