Skip to content

Commit

Permalink
Merge pull request #798 from nervosnetwork/rc/v0.17.0-alpha.4
Browse files Browse the repository at this point in the history
[ᚬmaster] Rc/v0.17.0 alpha.4
  • Loading branch information
ashchan authored Aug 1, 2019
2 parents 73bd7af + 6b2f974 commit d7765cf
Show file tree
Hide file tree
Showing 24 changed files with 376 additions and 149 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# [0.17.0-alpha.4](https://github.com/nervosnetwork/neuron/compare/v0.17.0-alpha.3...v0.17.0-alpha.4) (2019-08-01)


### Bug Fixes

* **neuron-ui:** remove the quotation mark around error message ([5de8cba](https://github.com/nervosnetwork/neuron/commit/5de8cba))


### Features

* **neuron-ui:** show alert via electron for consistent with the behaviour of mnemonic validation ([3a3cee1](https://github.com/nervosnetwork/neuron/commit/3a3cee1))
* Add OK button to update message box ([9cba232](https://github.com/nervosnetwork/neuron/commit/9cba232))
* **neuron-ui:** add notification panel ([f7984b0](https://github.com/nervosnetwork/neuron/commit/f7984b0))



# [0.17.0-alpha.3](https://github.com/nervosnetwork/neuron/compare/v0.17.0-alpha.2...v0.17.0-alpha.3) (2019-08-01)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.17.0-alpha.3",
"version": "0.17.0-alpha.4",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "neuron",
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"version": "0.17.0-alpha.3",
"version": "0.17.0-alpha.4",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neuron-ui",
"version": "0.17.0-alpha.3",
"version": "0.17.0-alpha.4",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
88 changes: 32 additions & 56 deletions packages/neuron-ui/src/components/NetworkEditor/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect, useMemo, useCallback } from 'react'

import { AppActions, StateDispatch } from 'states/stateProvider/reducer'
import { createNetwork, updateNetwork } from 'states/stateProvider/actionCreators'
import { StateDispatch } from 'states/stateProvider/reducer'
import { createNetwork, updateNetwork, addNotification } from 'states/stateProvider/actionCreators'

import { Message, MAX_NETWORK_NAME_LENGTH } from 'utils/const'

Expand Down Expand Up @@ -68,15 +68,9 @@ export const useInitialize = (
if (network) {
initialize(network)
} else {
dispatch({
type: AppActions.AddNotification,
payload: {
networks: {
type: 'warning',
timestamp: Date.now(),
content: i18n.t('messages.network-is-not-found'),
},
},
addNotification({
type: 'warning',
content: i18n.t('messages.network-is-not-found'),
})
}
}
Expand Down Expand Up @@ -126,72 +120,54 @@ export const useHandleSubmit = (
) =>
useCallback(async () => {
const warning = {
type: 'warning',
type: 'warning' as 'warning',
timestamp: Date.now(),
content: '',
}
if (!name) {
return dispatch({
type: AppActions.AddNotification,
payload: {
...warning,
content: i18n.t(Message.NameRequired),
},
})
return addNotification({
...warning,
content: i18n.t(Message.NameRequired),
})(dispatch)
}
if (name.length > MAX_NETWORK_NAME_LENGTH) {
return dispatch({
type: AppActions.AddNotification,
payload: {
...warning,
content: i18n.t(Message.LengthOfNameShouldBeLessThanOrEqualTo, {
length: MAX_NETWORK_NAME_LENGTH,
}),
},
})
return addNotification({
...warning,
content: i18n.t(Message.LengthOfNameShouldBeLessThanOrEqualTo, {
length: MAX_NETWORK_NAME_LENGTH,
}),
})(dispatch)
}
if (!remote) {
return dispatch({
type: AppActions.AddNotification,
payload: {
...warning,
content: i18n.t(Message.URLRequired),
},
})
return addNotification({
...warning,
content: i18n.t(Message.URLRequired),
})(dispatch)
}
if (!remote.startsWith('http')) {
return dispatch({
type: AppActions.AddNotification,
payload: {
...warning,
content: i18n.t(Message.ProtocolRequired),
},
})
return addNotification({
...warning,
content: i18n.t(Message.ProtocolRequired),
})(dispatch)
}
// verification, for now, only name is unique
if (id === 'new') {
if (networks.some(network => network.name === name)) {
return dispatch({
type: AppActions.AddNotification,
payload: {
...warning,
content: i18n.t(Message.NetworkNameUsed),
},
})
return addNotification({
...warning,
content: i18n.t(Message.NetworkNameUsed),
})(dispatch)
}
return createNetwork({
name,
remote,
})(dispatch, history)
}
if (networks.some(network => network.name === name && network.id !== id)) {
return dispatch({
type: AppActions.AddNotification,
payload: {
...warning,
content: i18n.t(Message.NetworkNameUsed),
},
})
return addNotification({
...warning,
content: i18n.t(Message.NetworkNameUsed),
})(dispatch)
}
return updateNetwork({
networkID: id!,
Expand Down
63 changes: 8 additions & 55 deletions packages/neuron-ui/src/components/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
MessageBar,
MessageBarType,
} from 'office-ui-fabric-react'
import PropertyList, { Property } from 'widgets/PropertyList'

import { StateWithDispatch } from 'states/stateProvider/reducer'
import { updateTransactionList, addPopup } from 'states/stateProvider/actionCreators'
Expand All @@ -30,7 +31,7 @@ import { PAGE_SIZE, MIN_CELL_WIDTH } from 'utils/const'

const TITLE_FONT_SIZE = 'xxLarge'

const PropertyList = ({
const ActivityList = ({
columns,
items,
...props
Expand Down Expand Up @@ -181,64 +182,16 @@ const Overview = ({
)
}, [t, onTimestampRender, onTransactionTypeRender])

const balanceColumns: IColumn[] = useMemo(
() =>
[
{
key: 'label',
name: 'label',
fieldName: 'label',
maxWidth: 100,
},
{
key: 'value',
name: 'value',
fieldName: 'value',
},
].map(col => ({
isResizable: true,
minWidth: 200,
fieldName: col.key,
ariaLabel: col.name,
...col,
})),
[]
)

const blockchainStatusColumns: IColumn[] = useMemo(
() =>
[
{
key: 'label',
name: 'label',
fieldName: 'label',
maxWidth: 100,
},
{
key: 'value',
name: 'value',
fieldName: 'value',
},
].map(col => ({
isResizable: true,
minWidth: 200,
fieldName: col.key,
ariaLabel: col.name,
...col,
})),
[]
)

const balanceItems = useMemo(
const balanceProperties: Property[] = useMemo(
() => [
{
label: t('overview.balance'),
value: <span title={`${balance} shannon`}>{`${shannonToCKBFormatter(balance)} CKB`}</span>,
value: `${shannonToCKBFormatter(balance)} CKB`,
},
],
[t, balance]
)
const blockchainStatusItems = useMemo(
const blockchainStatusProperties = useMemo(
() => [
{
label: t('overview.chain-identity'),
Expand Down Expand Up @@ -293,7 +246,7 @@ const Overview = ({
{name}
</Text>
<Stack horizontal horizontalAlign="space-between">
<PropertyList columns={balanceColumns} items={balanceItems} isHeaderVisible={false} />
<PropertyList properties={balanceProperties} />
<Stack tokens={{ childrenGap: 15 }}>
<div ref={blockchainInfoRef}>
<DefaultButton onClick={showBlockchainStatus} styles={{ root: { width: '200px' } }}>
Expand All @@ -311,7 +264,7 @@ const Overview = ({
{t('overview.recent-activities')}
</Text>
{items.length ? (
<PropertyList columns={activityColumns} items={items} onRenderRow={onTransactionRowRender} />
<ActivityList columns={activityColumns} items={items} onRenderRow={onTransactionRowRender} />
) : (
<div>{t('overview.no-recent-activities')}</div>
)}
Expand All @@ -323,7 +276,7 @@ const Overview = ({
gapSpace={0}
>
<Stack tokens={{ padding: 15 }}>
<PropertyList columns={blockchainStatusColumns} items={blockchainStatusItems} isHeaderVisible={false} />
<PropertyList properties={blockchainStatusProperties} />
</Stack>
</Callout>
) : null}
Expand Down
Loading

0 comments on commit d7765cf

Please sign in to comment.