Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
15a17b2f
Commit
15a17b2f
authored
Jan 24, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reset invalid compiler options; disable libraries after form submit
parent
f350b105
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
11 deletions
+32
-11
ContractVerificationFieldCompiler.tsx
...Verification/fields/ContractVerificationFieldCompiler.tsx
+6
-2
ContractVerificationFieldLibraries.tsx
...erification/fields/ContractVerificationFieldLibraries.tsx
+2
-0
ContractVerificationFieldLibraryItem.tsx
...ification/fields/ContractVerificationFieldLibraryItem.tsx
+8
-3
FancySelect.tsx
ui/shared/FancySelect/FancySelect.tsx
+16
-6
No files found.
ui/contractVerification/fields/ContractVerificationFieldCompiler.tsx
View file @
15a17b2f
...
@@ -28,7 +28,7 @@ interface Props {
...
@@ -28,7 +28,7 @@ interface Props {
const
ContractVerificationFieldCompiler
=
({
isVyper
}:
Props
)
=>
{
const
ContractVerificationFieldCompiler
=
({
isVyper
}:
Props
)
=>
{
const
[
isNightly
,
setIsNightly
]
=
React
.
useState
(
false
);
const
[
isNightly
,
setIsNightly
]
=
React
.
useState
(
false
);
const
{
formState
,
control
}
=
useFormContext
<
FormFields
>
();
const
{
formState
,
control
,
getValues
,
resetField
}
=
useFormContext
<
FormFields
>
();
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
options
=
React
.
useMemo
(()
=>
(
const
options
=
React
.
useMemo
(()
=>
(
...
@@ -38,8 +38,12 @@ const ContractVerificationFieldCompiler = ({ isVyper }: Props) => {
...
@@ -38,8 +38,12 @@ const ContractVerificationFieldCompiler = ({ isVyper }: Props) => {
),
[
isNightly
]);
),
[
isNightly
]);
const
handleCheckboxChange
=
React
.
useCallback
(()
=>
{
const
handleCheckboxChange
=
React
.
useCallback
(()
=>
{
if
(
isNightly
)
{
const
value
=
getValues
(
'
compiler
'
);
value
.
includes
(
'
nightly
'
)
&&
resetField
(
'
compiler
'
);
}
setIsNightly
(
prev
=>
!
prev
);
setIsNightly
(
prev
=>
!
prev
);
},
[]);
},
[
getValues
,
isNightly
,
resetField
]);
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
compiler
'
>
})
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
compiler
'
>
})
=>
{
const
error
=
'
compiler
'
in
formState
.
errors
?
formState
.
errors
.
compiler
:
undefined
;
const
error
=
'
compiler
'
in
formState
.
errors
?
formState
.
errors
.
compiler
:
undefined
;
...
...
ui/contractVerification/fields/ContractVerificationFieldLibraries.tsx
View file @
15a17b2f
...
@@ -39,6 +39,7 @@ const ContractVerificationFieldLibraries = () => {
...
@@ -39,6 +39,7 @@ const ContractVerificationFieldLibraries = () => {
size=
"lg"
size=
"lg"
onChange=
{
handleCheckboxChange
}
onChange=
{
handleCheckboxChange
}
mt=
{
9
}
mt=
{
9
}
isDisabled=
{
formState
.
isSubmitting
}
>
>
Add contract libraries
Add contract libraries
</
Checkbox
>
</
Checkbox
>
...
@@ -52,6 +53,7 @@ const ContractVerificationFieldLibraries = () => {
...
@@ -52,6 +53,7 @@ const ContractVerificationFieldLibraries = () => {
onAddFieldClick=
{
handleAddFieldClick
}
onAddFieldClick=
{
handleAddFieldClick
}
onRemoveFieldClick=
{
handleRemoveFieldClick
}
onRemoveFieldClick=
{
handleRemoveFieldClick
}
error=
{
'
libraries
'
in
formState
.
errors
?
formState
.
errors
.
libraries
?.[
index
]
:
undefined
}
error=
{
'
libraries
'
in
formState
.
errors
?
formState
.
errors
.
libraries
?.[
index
]
:
undefined
}
isDisabled=
{
formState
.
isSubmitting
}
/>
/>
))
}
))
}
</>
</>
...
...
ui/contractVerification/fields/ContractVerificationFieldLibraryItem.tsx
View file @
15a17b2f
...
@@ -24,9 +24,10 @@ interface Props {
...
@@ -24,9 +24,10 @@ interface Props {
};
};
onAddFieldClick
:
(
index
:
number
)
=>
void
;
onAddFieldClick
:
(
index
:
number
)
=>
void
;
onRemoveFieldClick
:
(
index
:
number
)
=>
void
;
onRemoveFieldClick
:
(
index
:
number
)
=>
void
;
isDisabled
?:
boolean
;
}
}
const
ContractVerificationFieldLibraryItem
=
({
control
,
index
,
fieldsLength
,
onAddFieldClick
,
onRemoveFieldClick
,
error
}:
Props
)
=>
{
const
ContractVerificationFieldLibraryItem
=
({
control
,
index
,
fieldsLength
,
onAddFieldClick
,
onRemoveFieldClick
,
error
,
isDisabled
}:
Props
)
=>
{
const
ref
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
ref
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
renderNameControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
`libraries.
${
number
}
.name`
>
})
=>
{
const
renderNameControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
`libraries.
${
number
}
.name`
>
})
=>
{
...
@@ -36,12 +37,13 @@ const ContractVerificationFieldLibraryItem = ({ control, index, fieldsLength, on
...
@@ -36,12 +37,13 @@ const ContractVerificationFieldLibraryItem = ({ control, index, fieldsLength, on
{
...
field
}
{
...
field
}
required
required
isInvalid=
{
Boolean
(
error
?.
name
)
}
isInvalid=
{
Boolean
(
error
?.
name
)
}
isDisabled=
{
isDisabled
}
maxLength=
{
255
}
maxLength=
{
255
}
/>
/>
<
InputPlaceholder
text=
"Library name (.sol file)"
error=
{
error
?.
name
}
/>
<
InputPlaceholder
text=
"Library name (.sol file)"
error=
{
error
?.
name
}
/>
</
FormControl
>
</
FormControl
>
);
);
},
[
error
?.
name
]);
},
[
error
?.
name
,
isDisabled
]);
const
renderAddressControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
`libraries.
${
number
}
.address`
>
})
=>
{
const
renderAddressControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
`libraries.
${
number
}
.address`
>
})
=>
{
return
(
return
(
...
@@ -49,12 +51,13 @@ const ContractVerificationFieldLibraryItem = ({ control, index, fieldsLength, on
...
@@ -49,12 +51,13 @@ const ContractVerificationFieldLibraryItem = ({ control, index, fieldsLength, on
<
Input
<
Input
{
...
field
}
{
...
field
}
isInvalid=
{
Boolean
(
error
?.
address
)
}
isInvalid=
{
Boolean
(
error
?.
address
)
}
isDisabled=
{
isDisabled
}
required
required
/>
/>
<
InputPlaceholder
text=
"Library address (0x...)"
error=
{
error
?.
address
}
/>
<
InputPlaceholder
text=
"Library address (0x...)"
error=
{
error
?.
address
}
/>
</
FormControl
>
</
FormControl
>
);
);
},
[
error
?.
address
]);
},
[
error
?.
address
,
isDisabled
]);
const
handleAddButtonClick
=
React
.
useCallback
(()
=>
{
const
handleAddButtonClick
=
React
.
useCallback
(()
=>
{
onAddFieldClick
(
index
);
onAddFieldClick
(
index
);
...
@@ -82,6 +85,7 @@ const ContractVerificationFieldLibraryItem = ({ control, index, fieldsLength, on
...
@@ -82,6 +85,7 @@ const ContractVerificationFieldLibraryItem = ({ control, index, fieldsLength, on
h=
"30px"
h=
"30px"
onClick=
{
handleRemoveButtonClick
}
onClick=
{
handleRemoveButtonClick
}
icon=
{
<
Icon
as=
{
minusIcon
}
w=
"20px"
h=
"20px"
/>
}
icon=
{
<
Icon
as=
{
minusIcon
}
w=
"20px"
h=
"20px"
/>
}
isDisabled=
{
isDisabled
}
/>
/>
)
}
)
}
{
fieldsLength
<
LIMIT
&&
(
{
fieldsLength
<
LIMIT
&&
(
...
@@ -92,6 +96,7 @@ const ContractVerificationFieldLibraryItem = ({ control, index, fieldsLength, on
...
@@ -92,6 +96,7 @@ const ContractVerificationFieldLibraryItem = ({ control, index, fieldsLength, on
h=
"30px"
h=
"30px"
onClick=
{
handleAddButtonClick
}
onClick=
{
handleAddButtonClick
}
icon=
{
<
Icon
as=
{
plusIcon
}
w=
"20px"
h=
"20px"
/>
}
icon=
{
<
Icon
as=
{
plusIcon
}
w=
"20px"
h=
"20px"
/>
}
isDisabled=
{
isDisabled
}
/>
/>
)
}
)
}
</
Flex
>
</
Flex
>
...
...
ui/shared/FancySelect/FancySelect.tsx
View file @
15a17b2f
import
{
FormControl
,
use
Boolean
,
use
Token
,
useColorMode
}
from
'
@chakra-ui/react
'
;
import
{
FormControl
,
useToken
,
useColorMode
}
from
'
@chakra-ui/react
'
;
import
type
{
Size
,
CSSObjectWithLabel
,
OptionsOrGroups
,
GroupBase
,
SingleValue
,
MultiValue
}
from
'
chakra-react-select
'
;
import
type
{
Size
,
CSSObjectWithLabel
,
OptionsOrGroups
,
GroupBase
,
SingleValue
,
MultiValue
}
from
'
chakra-react-select
'
;
import
{
Select
}
from
'
chakra-react-select
'
;
import
{
Select
}
from
'
chakra-react-select
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -19,15 +19,25 @@ interface Props {
...
@@ -19,15 +19,25 @@ interface Props {
isDisabled
?:
boolean
;
isDisabled
?:
boolean
;
isRequired
?:
boolean
;
isRequired
?:
boolean
;
error
?:
FieldError
;
error
?:
FieldError
;
value
?:
string
;
}
}
const
FancySelect
=
({
size
=
'
md
'
,
options
,
placeholder
,
name
,
onChange
,
onBlur
,
isDisabled
,
isRequired
,
error
}:
Props
)
=>
{
const
FancySelect
=
({
size
=
'
md
'
,
options
,
placeholder
,
name
,
onChange
,
onBlur
,
isDisabled
,
isRequired
,
error
,
value
:
valueFromProps
}:
Props
)
=>
{
const
[
hasValue
,
setHasValue
]
=
useBoolean
(
false
);
const
[
value
,
setValue
]
=
React
.
useState
<
SingleValue
<
Option
>
|
MultiValue
<
Option
>>
(
);
const
menuZIndex
=
useToken
(
'
zIndices
'
,
'
dropdown
'
);
const
menuZIndex
=
useToken
(
'
zIndices
'
,
'
dropdown
'
);
const
{
colorMode
}
=
useColorMode
();
const
{
colorMode
}
=
useColorMode
();
React
.
useEffect
(()
=>
{
if
(
!
valueFromProps
&&
value
)
{
setValue
(
null
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
valueFromProps
]);
const
handleChange
=
React
.
useCallback
((
newValue
:
SingleValue
<
Option
>
|
MultiValue
<
Option
>
)
=>
{
const
handleChange
=
React
.
useCallback
((
newValue
:
SingleValue
<
Option
>
|
MultiValue
<
Option
>
)
=>
{
setValue
(
newValue
);
if
(
Array
.
isArray
(
newValue
))
{
if
(
Array
.
isArray
(
newValue
))
{
return
;
return
;
}
}
...
@@ -37,9 +47,8 @@ const FancySelect = ({ size = 'md', options, placeholder, name, onChange, onBlur
...
@@ -37,9 +47,8 @@ const FancySelect = ({ size = 'md', options, placeholder, name, onChange, onBlur
return
;
return
;
}
}
setHasValue
.
on
();
onChange
(
_newValue
.
value
);
onChange
(
_newValue
.
value
);
},
[
setHasValue
,
onChange
]);
},
[
onChange
]);
const
handleBlur
=
React
.
useCallback
(()
=>
{
const
handleBlur
=
React
.
useCallback
(()
=>
{
onBlur
?.();
onBlur
?.();
...
@@ -58,7 +67,7 @@ const FancySelect = ({ size = 'md', options, placeholder, name, onChange, onBlur
...
@@ -58,7 +67,7 @@ const FancySelect = ({ size = 'md', options, placeholder, name, onChange, onBlur
isRequired=
{
isRequired
}
isRequired=
{
isRequired
}
{
...
(
error
?
{
'
aria
-
invalid
':
true
}
:
{})
}
{
...
(
error
?
{
'
aria
-
invalid
':
true
}
:
{})
}
{
...
(
isDisabled
?
{
'
aria
-
disabled
':
true
}
:
{})
}
{
...
(
isDisabled
?
{
'
aria
-
disabled
':
true
}
:
{})
}
{
...
(
hasV
alue
?
{
'
aria
-
active
':
true
}
:
{})
}
{
...
(
v
alue
?
{
'
aria
-
active
':
true
}
:
{})
}
>
>
<
Select
<
Select
menuPortalTarget=
{
window
.
document
.
body
}
menuPortalTarget=
{
window
.
document
.
body
}
...
@@ -74,6 +83,7 @@ const FancySelect = ({ size = 'md', options, placeholder, name, onChange, onBlur
...
@@ -74,6 +83,7 @@ const FancySelect = ({ size = 'md', options, placeholder, name, onChange, onBlur
isDisabled=
{
isDisabled
}
isDisabled=
{
isDisabled
}
isRequired=
{
isRequired
}
isRequired=
{
isRequired
}
isInvalid=
{
Boolean
(
error
)
}
isInvalid=
{
Boolean
(
error
)
}
value=
{
value
}
/>
/>
<
InputPlaceholder
<
InputPlaceholder
text=
{
placeholder
}
text=
{
placeholder
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment