Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
e9a96d0c
Commit
e9a96d0c
authored
Dec 09, 2020
by
LianaHus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement ok and cancel and handle arrows
parent
896a54ca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
33 deletions
+84
-33
debugger-ui.tsx
libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
+27
-8
remix-ui-modal-dialog.tsx
libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx
+53
-22
index.ts
libs/remix-ui/modal-dialog/src/lib/types/index.ts
+4
-3
No files found.
libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
View file @
e9a96d0c
...
@@ -25,7 +25,11 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
...
@@ -25,7 +25,11 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
opt
:
{
opt
:
{
debugWithGeneratedSources
:
false
debugWithGeneratedSources
:
false
},
},
showModal
:
false
showModal
:
false
,
modalOpt
:
{
title
:
''
,
message
:
''
}
})
})
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -89,6 +93,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
...
@@ -89,6 +93,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
try
{
try
{
content
=
await
debuggerModule
.
getFile
(
path
)
content
=
await
debuggerModule
.
getFile
(
path
)
}
catch
(
e
)
{
}
catch
(
e
)
{
showMsg
(
'Error'
,
e
.
message
)
console
.
log
(
'unable to fetch generated sources, the file probably doesn
\'
t exist yet'
,
e
)
console
.
log
(
'unable to fetch generated sources, the file probably doesn
\'
t exist yet'
,
e
)
}
}
if
(
content
!==
source
.
contents
)
{
if
(
content
!==
source
.
contents
)
{
...
@@ -146,8 +151,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
...
@@ -146,8 +151,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
try
{
try
{
currentReceipt
=
await
web3
.
eth
.
getTransactionReceipt
(
txNumber
)
currentReceipt
=
await
web3
.
eth
.
getTransactionReceipt
(
txNumber
)
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
'cant get tx'
,
e
)
showMsg
(
'Error'
,
e
.
messag
e
)
setState
((
prevState
)
=>
{
return
{
...
prevState
,
showModal
:
true
}
}
)
console
.
log
(
'cant get tx'
,
e
.
message
)
}
}
const
debuggerInstance
=
new
Debugger
({
const
debuggerInstance
=
new
Debugger
({
web3
,
web3
,
...
@@ -156,6 +161,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
...
@@ -156,6 +161,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
try
{
try
{
return
await
debuggerModule
.
fetchContractAndCompile
(
address
,
currentReceipt
)
return
await
debuggerModule
.
fetchContractAndCompile
(
address
,
currentReceipt
)
}
catch
(
e
)
{
}
catch
(
e
)
{
showMsg
(
'Error'
,
e
.
message
)
console
.
log
(
'cant fetch tx'
)
console
.
log
(
'cant fetch tx'
)
console
.
error
(
e
)
console
.
error
(
e
)
}
}
...
@@ -175,10 +181,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
...
@@ -175,10 +181,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
debugger
:
debuggerInstance
debugger
:
debuggerInstance
}
}
})
})
}).
catch
((
error
)
=>
{
}).
catch
(()
=>
{
console
.
log
(
'unloading while '
,
error
)
setState
((
prevState
)
=>
{
return
{
...
prevState
,
showModal
:
true
}
})
// toaster(error, null, null)
unLoad
()
unLoad
()
})
})
}
}
...
@@ -215,9 +218,25 @@ const deleteHighlights = async () => {
...
@@ -215,9 +218,25 @@ const deleteHighlights = async () => {
triggerEvent
:
state
.
debugger
&&
state
.
debugger
.
vmDebuggerLogic
?
state
.
debugger
.
vmDebuggerLogic
.
event
.
trigger
.
bind
(
state
.
debugger
.
vmDebuggerLogic
.
event
)
:
null
triggerEvent
:
state
.
debugger
&&
state
.
debugger
.
vmDebuggerLogic
?
state
.
debugger
.
vmDebuggerLogic
.
event
.
trigger
.
bind
(
state
.
debugger
.
vmDebuggerLogic
.
event
)
:
null
}
}
const hideModal = () =
>
{
setState
((
prevState
)
=>
{
return
{
...
prevState
,
showModal
:
false
}
})
}
const showMsg = (title, message) =
>
{
setState
((
prevState
)
=>
{
return
{
...
prevState
,
showModal
:
true
,
modalOpt
:
{
title
,
message
}
}
})
}
return (
return (
<
div
>
<
div
>
<
ModalDialog
title=
{
'New Modal'
}
hide=
{
!
state
.
showModal
}
content=
{
<
span
>
Text
</
span
>
}
opts=
{
{
class
:
'p-2'
,
hideClose
:
true
}
}
/>
{
state
.
showModal
&&
<
ModalDialog
title=
{
state
.
modalOpt
.
title
}
ok=
{
{
label
:
'Yes'
,
fn
:
()
=>
{
console
.
log
(
'OK'
)
}
}
}
cancel=
{
{
label
:
'No'
,
fn
:
()
=>
{
console
.
log
(
'cancel'
)
}
}
}
hide=
{
hideModal
}
content=
{
<
span
>
{
state
.
modalOpt
.
message
}
<
textarea
onKeyDown=
{
(
e
)
=>
{
e
.
stopPropagation
()
}
}
name=
""
id=
""
cols=
"30"
rows=
"10"
/></
span
>
}
opts=
{
{
class
:
'p-2'
,
hideClose
:
false
}
}
/>
}
<
div
className=
'px-2'
>
<
div
className=
'px-2'
>
<
div
className=
'mt-3'
>
<
div
className=
'mt-3'
>
<
p
className=
'mt-2 debuggerLabel'
>
Debugger Configuration
</
p
>
<
p
className=
'mt-2 debuggerLabel'
>
Debugger Configuration
</
p
>
...
...
libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx
View file @
e9a96d0c
...
@@ -8,34 +8,40 @@ import {ModalDialogProps} from './types';
...
@@ -8,34 +8,40 @@ import {ModalDialogProps} from './types';
export
const
ModalDialog
=
(
props
:
ModalDialogProps
)
=>
{
export
const
ModalDialog
=
(
props
:
ModalDialogProps
)
=>
{
const
[
state
,
setState
]
=
useState
({
const
[
state
,
setState
]
=
useState
({
toggleBtn
:
true
,
toggleBtn
:
true
hideState
:
true
})
})
const
okBtn
=
useRef
(
null
)
const
modal
=
useRef
(
null
)
const
cancelBtn
=
useRef
(
null
)
const
handleHide
=
()
=>
{
useEffect
(()
=>
{
props
.
hide
()
setState
(
prevState
=>
{
}
console
.
log
(
"useeffect to "
,
props
.
hide
)
useEffect
(
return
{...
prevState
,
hideState
:
props
.
hide
}
()
=>
{
})
modal
.
current
.
focus
()
},
[
props
.
hide
])
},
[]
)
const
modalKeyEvent
=
(
keyCode
)
=>
{
const
modalKeyEvent
=
(
keyCode
)
=>
{
console
.
log
(
"key is "
,
keyCode
)
console
.
log
(
"key is "
,
keyCode
)
if
(
keyCode
===
27
)
{
// Esc
if
(
keyCode
===
27
)
{
// Esc
if
(
props
.
cancel
&&
props
.
cancel
.
fn
)
props
.
cancel
.
fn
()
if
(
props
.
cancel
&&
props
.
cancel
.
fn
)
props
.
cancel
.
fn
()
setState
((
prevState
)
=>
{
return
{...
prevState
,
hideState
:
true
}}
)
handleHide
(
)
//
} else if (keyCode === 13) { // Enter
}
else
if
(
keyCode
===
13
)
{
// Enter
// okListen
er()
enterHandl
er
()
}
else
if
(
keyCode
===
37
)
{
}
else
if
(
keyCode
===
37
)
{
// todo && footerIsActive) { // Arrow Left
// todo && footerIsActive) { // Arrow Left
setState
((
prevState
)
=>
{
return
{...
prevState
,
toggleBtn
:
true
}})
setState
((
prevState
)
=>
{
return
{...
prevState
,
toggleBtn
:
true
}})
okBtn
.
current
.
focus
()
}
else
if
(
keyCode
===
39
)
{
}
else
if
(
keyCode
===
39
)
{
// todo && footerIsActive) { // Arrow Right
// todo && footerIsActive) { // Arrow Right
setState
((
prevState
)
=>
{
return
{...
prevState
,
toggleBtn
:
false
}})
setState
((
prevState
)
=>
{
return
{...
prevState
,
toggleBtn
:
false
}})
cancelBtn
.
current
.
focus
()
}
}
}
}
const
enterHandler
=
()
=>
{
if
(
state
.
toggleBtn
)
{
if
(
props
.
ok
&&
props
.
ok
.
fn
)
props
.
ok
.
fn
()
}
else
{
if
(
props
.
cancel
&&
props
.
cancel
.
fn
)
props
.
cancel
.
fn
()
}
handleHide
()
}
return
(<>
return
(<>
<
div
<
div
id=
"modal-dialog"
id=
"modal-dialog"
...
@@ -43,18 +49,26 @@ export const ModalDialog = (props: ModalDialogProps) => {
...
@@ -43,18 +49,26 @@ export const ModalDialog = (props: ModalDialogProps) => {
data
-
backdrop=
"static"
data
-
backdrop=
"static"
data
-
keyboard=
"false"
data
-
keyboard=
"false"
tabIndex=
{
-
1
}
tabIndex=
{
-
1
}
className=
{
"modal
"
+
(
state
.
hideState
?
"d-none"
:
"d-block"
)
}
className=
{
"modal
d-block"
}
role=
"dialog"
role=
"dialog"
onKeyDown=
{
({
keyCode
})
=>
{
modalKeyEvent
(
keyCode
)}
}
>
>
<
div
id=
"modal-background"
className=
"modal-dialog"
role=
"document"
>
<
div
id=
"modal-background"
className=
"modal-dialog"
role=
"document"
>
<
div
className=
{
"modal-content remixModalContent "
+
(
props
.
opts
?
props
.
opts
.
class
?
props
.
opts
.
class
:
''
:
''
)
}
>
<
div
tabIndex=
{
1
}
onBlur=
{
(
e
)
=>
{
e
.
stopPropagation
()
handleHide
()
}
}
ref=
{
modal
}
className=
{
"modal-content remixModalContent "
+
(
props
.
opts
?
props
.
opts
.
class
?
props
.
opts
.
class
:
''
:
''
)
}
onKeyDown=
{
({
keyCode
})
=>
{
modalKeyEvent
(
keyCode
)}
}
>
<
div
className=
"modal-header"
>
<
div
className=
"modal-header"
>
<
h6
className=
"modal-title"
data
-
id=
"modalDialogModalTitle"
>
<
h6
className=
"modal-title"
data
-
id=
"modalDialogModalTitle"
>
{
props
.
title
&&
props
.
title
}
{
props
.
title
&&
props
.
title
}
</
h6
>
</
h6
>
{
!
props
.
opts
.
hideClose
&&
{
!
props
.
opts
.
hideClose
&&
<
span
className=
"modal-close"
>
<
span
className=
"modal-close"
onClick=
{
()
=>
handleHide
()
}
>
<
i
id=
"modal-close"
title=
"Close"
className=
"fas fa-times"
aria
-
hidden=
"true"
></
i
>
<
i
id=
"modal-close"
title=
"Close"
className=
"fas fa-times"
aria
-
hidden=
"true"
></
i
>
</
span
>
</
span
>
}
}
...
@@ -66,14 +80,31 @@ export const ModalDialog = (props: ModalDialogProps) => {
...
@@ -66,14 +80,31 @@ export const ModalDialog = (props: ModalDialogProps) => {
</
div
>
</
div
>
<
div
className=
"modal-footer"
data
-
id=
"modalDialogModalFooter"
>
<
div
className=
"modal-footer"
data
-
id=
"modalDialogModalFooter"
>
{
/* todo add autofocus ^^ */
}
{
/* todo add autofocus ^^ */
}
{
props
.
ok
&&
<
span
<
span
id=
"modal-footer-ok"
id=
"modal-footer-ok"
className=
{
"modal-ok btn btn-sm "
+
(
state
.
toggleBtn
?
"btn-dark"
:
"btn-light"
)
}
className=
{
"modal-ok btn btn-sm "
+
(
state
.
toggleBtn
?
"btn-dark"
:
"btn-light"
)
}
onClick=
{
()
=>
{
if
(
props
.
ok
&&
props
.
ok
.
fn
)
props
.
ok
.
fn
()}
}
onClick=
{
()
=>
{
if
(
props
.
ok
&&
props
.
ok
.
fn
)
props
.
ok
.
fn
()
handleHide
()
}
}
tabIndex=
{
1
}
>
>
{
props
.
ok
&&
props
.
ok
.
label
?
props
.
ok
.
label
:
'OK'
}
{
props
.
ok
&&
props
.
ok
.
label
?
props
.
ok
.
label
:
'OK'
}
</
span
>
</
span
>
<
span
id=
"modal-footer-cancel"
className=
{
"modal-cancel btn btn-sm "
+
(
state
.
toggleBtn
?
"btn-light"
:
"btn-dark"
)
}
data
-
dismiss=
"modal"
>
{
props
.
cancel
&&
props
.
cancel
.
label
?
props
.
cancel
.
label
:
'Cancel'
}
</
span
>
}
<
span
id=
"modal-footer-cancel"
className=
{
"modal-cancel btn btn-sm "
+
(
state
.
toggleBtn
?
"btn-light"
:
"btn-dark"
)
}
data
-
dismiss=
"modal"
onClick=
{
()
=>
{
if
(
props
.
cancel
&&
props
.
cancel
.
fn
)
props
.
cancel
.
fn
()
handleHide
()
}
}
tabIndex=
{
2
}
>
{
props
.
cancel
&&
props
.
cancel
.
label
?
props
.
cancel
.
label
:
'Cancel'
}
</
span
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
libs/remix-ui/modal-dialog/src/lib/types/index.ts
View file @
e9a96d0c
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
export
interface
ModalDialogProps
{
export
interface
ModalDialogProps
{
title
?:
string
,
title
?:
string
,
content
?:
JSX
.
Element
,
content
?:
JSX
.
Element
,
ok
?:
{
label
:
string
,
fn
:
Function
},
ok
?:
{
label
:
string
,
fn
:
()
=>
void
},
cancel
?:
{
label
:
string
,
fn
:
Function
},
cancel
?:
{
label
:
string
,
fn
:
()
=>
void
},
focusSelector
?:
string
,
focusSelector
?:
string
,
opts
?:
{
class
:
string
,
hideClose
?:
boolean
},
opts
?:
{
class
:
string
,
hideClose
?:
boolean
},
hide
?:
boolean
hide
:
()
=>
void
}
}
\ No newline at end of file
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