Skip to content

Commit 9cb7c62

Browse files
committed
feat(neuron-ui): add a toggle of skip-data-and-type
1 parent 40c9f82 commit 9cb7c62

File tree

16 files changed

+110
-16
lines changed

16 files changed

+110
-16
lines changed

packages/neuron-ui/src/components/Addresses/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ const Addresses = ({
2828
},
2929
wallet: { addresses = [], id: walletID },
3030
chain: { networkID },
31-
settings: { showAddressBook = false, networks = [] },
31+
settings: {
32+
general: { showAddressBook = false },
33+
networks = [],
34+
},
3235
history,
3336
dispatch,
3437
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {

packages/neuron-ui/src/components/GeneralSetting/index.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1-
import React, { useCallback } from 'react'
1+
import React, { useMemo } from 'react'
22
import { Stack, Toggle } from 'office-ui-fabric-react'
33
import { useTranslation } from 'react-i18next'
44

55
import { StateWithDispatch } from 'states/stateProvider/reducer'
6-
import { toggleAddressBook } from 'states/stateProvider/actionCreators'
6+
import { toggleAddressBook, setSkipDataAndType } from 'states/stateProvider/actionCreators'
77

8-
const GeneralSetting = ({ settings: { showAddressBook }, dispatch }: React.PropsWithoutRef<StateWithDispatch>) => {
8+
const GeneralSetting = ({
9+
settings: {
10+
general: { showAddressBook, skipDataAndType },
11+
},
12+
dispatch,
13+
}: React.PropsWithoutRef<StateWithDispatch>) => {
914
const [t] = useTranslation()
10-
const onToggle = useCallback(() => {
11-
dispatch(toggleAddressBook())
12-
}, [dispatch])
15+
const [onToggleAddressVisibility, onSetSkipDataAndType] = useMemo(
16+
() => [() => dispatch(toggleAddressBook()), () => setSkipDataAndType(!skipDataAndType)(dispatch)],
17+
[dispatch, skipDataAndType]
18+
)
1319
return (
1420
<Stack tokens={{ childrenGap: 15 }}>
1521
<Toggle
1622
checked={showAddressBook}
1723
label={t('settings.general.display-address-book-in-the-navbar')}
1824
onText={t('common.toggle.on')}
1925
offText={t('common.toggle.off')}
20-
onChange={onToggle}
26+
onChange={onToggleAddressVisibility}
27+
/>
28+
<Toggle
29+
checked={skipDataAndType}
30+
label={t('settings.general.skip-data-and-type')}
31+
onText={t('common.toggle.on')}
32+
offText={t('common.toggle.off')}
33+
onChange={onSetSkipDataAndType}
2134
/>
2235
</Stack>
2336
)

packages/neuron-ui/src/containers/Navbar/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ const Navbar = ({
4242
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
4343
const neuronWallet = useState()
4444
const {
45-
settings: { wallets = [], showAddressBook = false },
45+
settings: {
46+
wallets = [],
47+
general: { showAddressBook = false },
48+
},
4649
} = neuronWallet
4750
const [t] = useTranslation()
4851

packages/neuron-ui/src/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
},
165165
"general": {
166166
"display-address-book-in-the-navbar": "Show the address book",
167+
"skip-data-and-type": "Skip the cells which contain data or type script",
167168
"show": "Show",
168169
"hide": "Hide"
169170
},

packages/neuron-ui/src/locales/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
},
165165
"general": {
166166
"display-address-book-in-the-navbar": "显示地址簿",
167+
"skip-data-and-type": "忽略包含 Data 或 Type Script 的 Cell",
167168
"show": "显示",
168169
"hide": "隐藏"
169170
},

packages/neuron-ui/src/services/remote/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from './app'
22
export * from './wallets'
33
export * from './networks'
44
export * from './transactions'
5+
export * from './skipDataAndType'
56

67
export const getLocale = () => {
78
if (!window.remote) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { controllerMethodWrapper } from './controllerMethodWrapper'
2+
3+
const CONTROLLER_NAME = 'skip-data-and-type'
4+
5+
export const setSkipDataAndType = controllerMethodWrapper(CONTROLLER_NAME)(
6+
(controller: any) => (params: Controller.SetSkipAndTypeParam) => {
7+
return controller.update(params)
8+
}
9+
)
10+
11+
export default { setSkipDataAndType }

packages/neuron-ui/src/states/initStates/settings.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { addressBook, wallets, networks } from 'services/localCache'
22

33
export const settingsState: State.Settings = {
4-
showAddressBook: addressBook.isVisible(),
4+
general: {
5+
skipDataAndType: false,
6+
showAddressBook: addressBook.isVisible(),
7+
},
58
networks: networks.load(),
69
wallets: wallets.load(),
710
}

packages/neuron-ui/src/states/stateProvider/actionCreators/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const initAppState = () => (dispatch: StateDispatch, history: any) => {
2626
syncedBlockNumber = '',
2727
connectionStatus = false,
2828
codeHash = '',
29+
skipDataAndType = false,
2930
} = res.result
3031
dispatch({
3132
type: NeuronWalletActions.InitAppState,
@@ -38,6 +39,7 @@ export const initAppState = () => (dispatch: StateDispatch, history: any) => {
3839
syncedBlockNumber,
3940
connectionStatus,
4041
codeHash,
42+
skipDataAndType,
4143
},
4244
})
4345
if (!wallet) {

packages/neuron-ui/src/states/stateProvider/actionCreators/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import app from './app'
22
import wallets from './wallets'
33
import transactions from './transactions'
44
import settings from './settings'
5+
import skipDataAndType from './skipDataAndType'
56

67
export * from './app'
78
export * from './wallets'
89
export * from './transactions'
910
export * from './settings'
11+
export * from './skipDataAndType'
1012
export const actionCreators = {
1113
...app,
1214
...wallets,
1315
...transactions,
1416
...settings,
17+
...skipDataAndType,
1518
}
1619

1720
export default actionCreators

0 commit comments

Comments
 (0)