1- import { CloseIcon , EditIcon } from "@chakra-ui/icons" ;
1+ import { CloseIcon } from "@chakra-ui/icons" ;
22import {
33 Flex ,
44 Grid ,
@@ -10,12 +10,13 @@ import {
1010 Wrap ,
1111} from "@chakra-ui/react" ;
1212import React from "react" ;
13- import { FaPenNib } from "react-icons/fa" ;
13+ import { FaFeather , FaICursor } from "react-icons/fa" ;
1414import { useAccount } from "../../../hooks/useAccount" ;
1515import { useAccountType } from "../../../hooks/useAccountType" ;
1616import { useInstruction } from "../../../hooks/useInstruction" ;
1717import { useShallowSessionStoreWithUndo } from "../../../hooks/useSessionStore" ;
1818import { removeFrom } from "../../../utils/sortable" ;
19+ import { Description } from "../../common/Description" ;
1920import { DragHandle } from "../../common/DragHandle" ;
2021import { EditableName } from "../../common/EditableName" ;
2122import { Numbering } from "../../common/Numbering" ;
@@ -39,12 +40,15 @@ export const Account: React.FC<{
3940 state . set ,
4041 ] ) ;
4142
42- const [ name , pubkey , isWritable , isSigner ] = useShallowGet ( ( state ) => [
43- state . name ,
44- state . pubkey ,
45- state . isWritable ,
46- state . isSigner ,
47- ] ) ;
43+ const [ name , description , pubkey , isWritable , isSigner ] = useShallowGet (
44+ ( state ) => [
45+ state . name ,
46+ state . description ,
47+ state . pubkey ,
48+ state . isWritable ,
49+ state . isSigner ,
50+ ]
51+ ) ;
4852
4953 const removeAccount = ( ) => {
5054 updateInstruction ( ( state ) => {
@@ -65,7 +69,7 @@ export const Account: React.FC<{
6569 } ) ;
6670
6771 return (
68- < Flex mb = "2 " alignItems = "start" >
72+ < Flex mb = "1 " alignItems = "start" >
6973 < DragHandle
7074 unlockedProps = { { mt : "2" , h : "2.5" , w : "2.5" } }
7175 lockedProps = { { mt : "2" , h : "3" } }
@@ -94,68 +98,79 @@ export const Account: React.FC<{
9498 />
9599
96100 < Grid flex = "1" >
97- < AccountInput />
98-
99- < Wrap
100- // TODO ignores other future tags
101- pt = { isTypeConfigurable || metadata ?. name ? "1" : undefined }
102- >
103- { /* TODO */ }
104- { /* {type === "ata" && (
101+ < Flex >
102+ < Grid flex = "1" >
103+ < AccountInput />
104+
105+ < Wrap
106+ // TODO ignores other future tags
107+ pt = { isTypeConfigurable || metadata ?. name ? "1" : undefined }
108+ >
109+ { /* TODO */ }
110+ { /* {type === "ata" && (
105111 <AtaTypeConfig />
106112 )} */ }
107113
108- { type === "pda" && < PdaTypeConfig /> }
109-
110- { metadata ?. name && < Tag size = "sm" > { metadata . name } </ Tag > }
114+ { type === "pda" && < PdaTypeConfig /> }
115+
116+ { metadata ?. name && < Tag size = "sm" > { metadata . name } </ Tag > }
117+
118+ { /* TODO account balance */ }
119+ </ Wrap >
120+ </ Grid >
121+
122+ < ToggleIconButton
123+ ml = "1"
124+ size = "sm"
125+ label = "Writable"
126+ icon = { < Icon as = { FaICursor } /> }
127+ isDisabled = { isAnchor }
128+ toggled = { isWritable }
129+ onToggle = { ( toggled ) => {
130+ update ( ( state ) => {
131+ state . isWritable = toggled ;
132+ } ) ;
133+ } }
134+ />
111135
112- { /* TODO account balance */ }
113- </ Wrap >
136+ < ToggleIconButton
137+ ml = "1"
138+ size = "sm"
139+ label = "Signer"
140+ icon = { < Icon as = { FaFeather } /> }
141+ isDisabled = { isAnchor }
142+ toggled = { isSigner }
143+ onToggle = { ( toggled ) => {
144+ update ( ( state ) => {
145+ state . isSigner = toggled ;
146+ } ) ;
147+ } }
148+ />
114149
115- { /* TODO description when not minimised */ }
150+ { ! isAnchor && (
151+ < Tooltip label = "Remove" >
152+ < IconButton
153+ mt = "1"
154+ ml = "3"
155+ size = "xs"
156+ aria-label = "Remove"
157+ icon = { < CloseIcon /> }
158+ variant = "ghost"
159+ onClick = { removeAccount }
160+ />
161+ </ Tooltip >
162+ ) }
163+ </ Flex >
164+
165+ < Description
166+ mt = "1"
167+ fontSize = "sm"
168+ description = { description }
169+ setDescription = { ( description ) => {
170+ update ( ( state ) => ( state . description = description ) ) ;
171+ } }
172+ />
116173 </ Grid >
117-
118- < ToggleIconButton
119- ml = "1"
120- size = "sm"
121- label = "Writable"
122- icon = { < EditIcon /> }
123- isDisabled = { isAnchor }
124- toggled = { isWritable }
125- onToggle = { ( toggled ) => {
126- update ( ( state ) => {
127- state . isWritable = toggled ;
128- } ) ;
129- } }
130- />
131-
132- < ToggleIconButton
133- ml = "1"
134- size = "sm"
135- label = "Signer"
136- icon = { < Icon as = { FaPenNib } /> }
137- isDisabled = { isAnchor }
138- toggled = { isSigner }
139- onToggle = { ( toggled ) => {
140- update ( ( state ) => {
141- state . isSigner = toggled ;
142- } ) ;
143- } }
144- />
145-
146- { ! isAnchor && (
147- < Tooltip label = "Remove" >
148- < IconButton
149- mt = "1"
150- ml = "3"
151- size = "xs"
152- aria-label = "Remove"
153- icon = { < CloseIcon /> }
154- variant = "ghost"
155- onClick = { removeAccount }
156- />
157- </ Tooltip >
158- ) }
159174 </ Flex >
160175 ) ;
161176} ;
0 commit comments