11import React from 'react' ;
2- import { List , Button } from 'semantic-ui-react' ;
2+ import { List , Icon , Button , Label , Popup } from 'semantic-ui-react' ;
33import { ReactiveComponent } from 'oo7-react' ;
44import { runtime , secretStore } from 'oo7-substrate' ;
55import Identicon from 'polkadot-identicon' ;
66
7+ export class SecretItem extends ReactiveComponent {
8+ constructor ( ) {
9+ super ( )
10+
11+ this . state = {
12+ display : null
13+ }
14+ }
15+
16+ render ( ) {
17+ let that = this
18+ let toggle = ( ) => {
19+ let display = that . state . display
20+ switch ( display ) {
21+ case null :
22+ display = 'seed'
23+ break
24+ case 'seed' :
25+ if ( Math . random ( ) < 0.1 ) {
26+ display = 'phrase'
27+ break
28+ }
29+ default :
30+ display = null
31+ }
32+ that . setState ( { display } )
33+ }
34+ return this . state . display === 'phrase'
35+ ? < Label
36+ basic
37+ icon = 'privacy'
38+ onClick = { toggle }
39+ content = 'Seed phrase'
40+ detail = { this . props . phrase }
41+ />
42+ : this . state . display === 'seed'
43+ ? < Label
44+ basic
45+ icon = 'key'
46+ onClick = { toggle }
47+ content = 'Validator seed'
48+ detail = { '0x' + bytesToHex ( this . props . seed ) }
49+ />
50+ : < Popup trigger = { < Icon
51+ circular
52+ name = 'eye slash'
53+ onClick = { toggle }
54+ /> } content = 'Click to uncover seed/secret' />
55+ }
56+ }
57+
758export class WalletList extends ReactiveComponent {
859 constructor ( ) {
960 super ( [ ] , {
@@ -21,6 +72,7 @@ export class WalletList extends ReactiveComponent {
2172 this . state . secretStore . keys . map ( key =>
2273 < List . Item key = { key . name } >
2374 < List . Content floated = 'right' >
75+ < SecretItem phrase = { key . phrase } seed = { key . seed } />
2476 < Button size = 'small' onClick = { ( ) => secretStore ( ) . forget ( key ) } > Delete</ Button >
2577 </ List . Content >
2678 < span className = 'ui avatar image' style = { { minWidth : '36px' } } >
0 commit comments