1- import React , { useState , useCallback , useMemo } from 'react'
1+ import React , { useCallback } from 'react'
22import { RouteComponentProps } from 'react-router-dom'
33import { useTranslation } from 'react-i18next'
4- import {
5- Stack ,
6- PrimaryButton ,
7- ChoiceGroup ,
8- IChoiceGroupOption ,
9- Text ,
10- Callout ,
11- MessageBar ,
12- MessageBarType ,
13- ActionButton ,
14- getTheme ,
15- } from 'office-ui-fabric-react'
4+ import { Stack , PrimaryButton , ChoiceGroup , IChoiceGroupOption } from 'office-ui-fabric-react'
165
176import { StateWithDispatch } from 'states/stateProvider/reducer'
18- import { setCurrentWallet , addPopup } from 'states/stateProvider/actionCreators'
7+ import { setCurrentWallet } from 'states/stateProvider/actionCreators'
198
209import { WalletWizardPath } from 'components/WalletWizard'
2110
2211import { contextMenu } from 'services/remote'
23- import { Routes , MnemonicAction , ErrorCode } from 'utils/const'
24-
25- const theme = getTheme ( )
12+ import { Routes , MnemonicAction } from 'utils/const'
2613
2714const buttons = [
2815 {
@@ -41,33 +28,11 @@ const buttons = [
4128
4229const WalletSetting = ( {
4330 wallet : { id : currentID = '' } ,
44- chain : { codeHash = '' } ,
4531 settings : { wallets = [ ] } ,
4632 dispatch,
4733 history,
4834} : React . PropsWithoutRef < StateWithDispatch & RouteComponentProps > ) => {
4935 const [ t ] = useTranslation ( )
50- const [ target , setTarget ] = useState < any > ( null )
51- const [ minerInfo , setMinerInfo ] = useState < { address : string ; identifier : string } > ( {
52- address : '' ,
53- identifier : '' ,
54- } )
55-
56- const [ showMinerInfo , hideMinerInfo ] = useMemo (
57- ( ) => [
58- ( info : { address : string ; identifier : string } ) => setMinerInfo ( info ) ,
59- ( ) => setMinerInfo ( { address : '' , identifier : '' } ) ,
60- ] ,
61- [ setMinerInfo ]
62- )
63-
64- const onCopyPubkeyHash = useCallback ( ( ) => {
65- if ( minerInfo ) {
66- window . navigator . clipboard . writeText ( minerInfo . identifier )
67- hideMinerInfo ( )
68- addPopup ( 'lock-arg-copied' ) ( dispatch )
69- }
70- } , [ minerInfo , hideMinerInfo , dispatch ] )
7136
7237 const onChange = useCallback (
7338 ( _e , option ) => {
@@ -105,24 +70,6 @@ const WalletSetting = ({
10570 < span className = "ms-ChoiceFieldLabel" onContextMenu = { onContextMenu ( wallet . id ) } >
10671 { text }
10772 </ span >
108- { wallet . minerAddress ? (
109- < Text
110- variant = "tiny"
111- className = "ms-ChoiceFieldLabel"
112- onClick = { ( e : React . MouseEvent < HTMLDivElement > ) => {
113- e . preventDefault ( )
114- setTarget ( e . target )
115- if ( wallet . minerAddress ) {
116- showMinerInfo ( wallet . minerAddress )
117- }
118- } }
119- styles = { {
120- root : [ { color : theme . semanticColors . bodySubtext , fontSize : '12px!important' } ] ,
121- } }
122- >
123- { t ( 'overview.miner-info' ) }
124- </ Text >
125- ) : null }
12673 </ Stack >
12774 )
12875 } ,
@@ -135,47 +82,6 @@ const WalletSetting = ({
13582 < PrimaryButton key = { label } onClick = { navTo ( url ) } text = { t ( label ) } />
13683 ) ) }
13784 </ Stack >
138- < Callout target = { target } hidden = { ! minerInfo . address } onDismiss = { hideMinerInfo } gapSpace = { 0 } >
139- < Stack tokens = { { padding : 15 } } >
140- { minerInfo . address ? (
141- < Stack tokens = { { childrenGap : 15 } } styles = { { root : { padding : 5 } } } >
142- < Stack tokens = { { childrenGap : 15 } } >
143- < Text variant = "small" style = { { fontWeight : 600 } } >
144- { t ( 'overview.address' ) }
145- </ Text >
146- < Text variant = "small" className = "monospacedFont" >
147- { minerInfo . address }
148- </ Text >
149- </ Stack >
150- < Stack tokens = { { childrenGap : 15 } } >
151- < Text variant = "small" style = { { fontWeight : 600 } } >
152- { t ( 'overview.code-hash' ) }
153- </ Text >
154- < Text variant = "small" className = "monospacedFont" >
155- { codeHash }
156- </ Text >
157- </ Stack >
158- < Stack tokens = { { childrenGap : 15 } } >
159- < Text variant = "small" style = { { fontWeight : 600 } } >
160- { t ( 'overview.lock-arg' ) }
161- </ Text >
162- < Text variant = "small" className = "monospacedFont" >
163- { minerInfo . identifier }
164- </ Text >
165- </ Stack >
166- < Stack horizontalAlign = "end" >
167- < ActionButton iconProps = { { iconName : 'MiniCopy' } } onClick = { onCopyPubkeyHash } >
168- { t ( 'overview.copy-pubkey-hash' ) }
169- </ ActionButton >
170- </ Stack >
171- </ Stack >
172- ) : (
173- < MessageBar messageBarType = { MessageBarType . error } >
174- { t ( `messages.codes.${ ErrorCode . FieldNotFound } ` , { fieldName : `default-address` } ) }
175- </ MessageBar >
176- ) }
177- </ Stack >
178- </ Callout >
17985 </ Stack >
18086 )
18187}
0 commit comments