From dd4b986949c20a695f4eece14952cd6738c7faec Mon Sep 17 00:00:00 2001 From: Zhiting Lin Date: Wed, 14 Nov 2018 19:02:20 +0800 Subject: [PATCH] updated account alias. --- src/features/accounts/components/AccountShow.jsx | 2 +- src/features/app/reducers.js | 8 +++++--- src/features/mockhsm/actions.js | 23 ----------------------- src/features/shared/components/Flash/Flash.jsx | 17 +++-------------- src/locales/en/translation.json | 4 +++- src/locales/zh/translation.json | 4 +++- src/sdk/api/accounts.js | 8 ++++++++ src/sdk/api/mockHsmKeys.js | 8 +++++++- 8 files changed, 30 insertions(+), 44 deletions(-) diff --git a/src/features/accounts/components/AccountShow.jsx b/src/features/accounts/components/AccountShow.jsx index 7bae0a6..02c1678 100644 --- a/src/features/accounts/components/AccountShow.jsx +++ b/src/features/accounts/components/AccountShow.jsx @@ -101,7 +101,7 @@ class AccountShow extends BaseShow { ]} items={[ {label: 'ID', value: item.id}, - {label: t('form.alias'), value: item.alias}, + {label: t('form.alias'), value: item.alias, editUrl: `/accounts/${item.id}/alias`}, {label: t('form.xpubs'), value: (item.xpubs || []).length}, {label: t('form.quorum') , value: item.quorum}, ]} diff --git a/src/features/app/reducers.js b/src/features/app/reducers.js index 8e28bdf..256f3fe 100644 --- a/src/features/app/reducers.js +++ b/src/features/app/reducers.js @@ -83,9 +83,11 @@ export const flashMessages = (state = {}, action) => { } case 'UPDATED_ACCOUNT': { - return newSuccess(state,

- Updated account tags. -

) + return newSuccess(state, 'UPDATED_ACCOUNT') + } + + case 'UPDATED_KEY': { + return newSuccess(state, 'UPDATED_KEY') } case 'UPDATED_ASSET': { diff --git a/src/features/mockhsm/actions.js b/src/features/mockhsm/actions.js index 5ad8545..5445f69 100644 --- a/src/features/mockhsm/actions.js +++ b/src/features/mockhsm/actions.js @@ -33,29 +33,6 @@ create.submitForm = (data) => function (dispatch) { }) } -update.submitUpdateForm = (data, xpub) => { - let promise = Promise.resolve() - - return function(dispatch) { - return promise.then(() => clientApi().updateAlias({ - xpub: xpub, - newAlias: data.alias, - }).then((resp) => { - if (resp.status === 'fail') { - throw resp - } - dispatch(update.updated()) - - dispatch(push({ - pathname: `/${type}s/${xpub}`, - state: { - preserveFlash: true - } - })) - })) - } -} - const resetPassword = { submitResetForm: (params) => { let promise = Promise.resolve() diff --git a/src/features/shared/components/Flash/Flash.jsx b/src/features/shared/components/Flash/Flash.jsx index 11c0830..b9070dc 100644 --- a/src/features/shared/components/Flash/Flash.jsx +++ b/src/features/shared/components/Flash/Flash.jsx @@ -1,17 +1,6 @@ import React from 'react' import styles from './Flash.scss' -const messageLabel =[ - 'CREATED_ASSET', - 'CREATED_ACCOUNT', - 'CREATED_TRANSACTION', - 'CREATED_KEY', - 'RESET_PASSWORD_KEY', - 'CREATE_REGISTER_ACCOUNT', - 'RESTORE_SUCCESS', - 'UPDATED_ASSET' -] - class Flash extends React.Component { constructor(props) { super(props) @@ -44,7 +33,7 @@ class Flash extends React.Component { return null } - const t = this.props.t + const {t} = this.props const messages = [] // Flash messages are stored in an objecty key with a random UUID. If // multiple messages are displayed, we rely on the browser maintaining @@ -52,8 +41,8 @@ class Flash extends React.Component { // were created. Object.keys(this.props.messages).forEach(key => { const item = this.props.messages[key] - const messageKey = (messageLabel).filter(key => key === item.message) - const messageContent = messageKey.length === 0? item.message:

{t(`message.${messageKey}`)}

+ const messageContent = t([`message.${item.message}`, item.message]) + messages.push(
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 530c1c5..fc5eabb 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -567,7 +567,9 @@ "RESET_PASSWORD_KEY": "Key password has been reset successfully.", "CREATE_REGISTER_ACCOUNT": "Default account and key have been initialized successfully.", "RESTORE_SUCCESS":"Wallet restore successfully", - "UPDATED_ASSET":"Updated asset alias." + "UPDATED_ASSET":"Updated asset alias.", + "UPDATED_ACCOUNT":"Updated account alias.", + "UPDATED_KEY":"Updated key alias." }, "btmError":{ "BTM000": "Bytom API Error", diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json index 838e036..796383c 100644 --- a/src/locales/zh/translation.json +++ b/src/locales/zh/translation.json @@ -548,7 +548,9 @@ "RESET_PASSWORD_KEY": "密钥密码已经重置成功。", "CREATE_REGISTER_ACCOUNT": "默认账户和密钥已经初始化成功。", "RESTORE_SUCCESS":"钱包已经成功恢复。", - "UPDATED_ASSET":"资产别名更改成功。" + "UPDATED_ASSET":"资产别名更改成功。", + "UPDATED_ACCOUNT":"账户别名更改成功。", + "UPDATED_KEY":"密钥别名更改成功。" }, "btmError":{ "BTM000": "非比原标准错误", diff --git a/src/sdk/api/accounts.js b/src/sdk/api/accounts.js index a7502d0..c854111 100644 --- a/src/sdk/api/accounts.js +++ b/src/sdk/api/accounts.js @@ -15,6 +15,14 @@ const accountsAPI = (client) => { updateTagsBatch: (params, cb) => shared.batchRequest(client, '/update-account-tags', params, cb), + updateAlias: (params, cb) => { + const finalParams = { + account_id: params.id, + new_alias: params.alias + } + return shared.singletonBatchRequest(client, '/update-account-alias', finalParams, cb) + }, + query: (params, cb) => shared.query(client, 'accounts', '/list-accounts', params, {cb}), queryAll: (params, processor, cb) => shared.queryAll(client, 'accounts', params, processor, cb), diff --git a/src/sdk/api/mockHsmKeys.js b/src/sdk/api/mockHsmKeys.js index ff18c29..1ed2ad8 100644 --- a/src/sdk/api/mockHsmKeys.js +++ b/src/sdk/api/mockHsmKeys.js @@ -22,7 +22,13 @@ const mockHsmKeysAPI = (client) => { resetPassword: (params) => client.request('/reset-key-password', params), - updateAlias: (params) => client.request('/update-key-alias', params), + updateAlias: (params, cb) => { + const finalParams = { + xpub: params.id, + new_alias: params.alias + } + return shared.singletonBatchRequest(client, '/update-key-alias', finalParams, cb) + }, checkPassword: (params) => client.request('/check-key-password', params), -- 2.11.0