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
82845cb8
Commit
82845cb8
authored
Jul 24, 2021
by
davidzagi93@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implementing command execution script in react
parent
7ea8d95e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
18 deletions
+75
-18
terminal.js
apps/remix-ide/src/app/panels/terminal.js
+0
-12
commands.ts
libs/remix-ui/terminal/src/lib/commands.ts
+0
-0
remix-ui-terminal.tsx
libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx
+75
-6
No files found.
apps/remix-ide/src/app/panels/terminal.js
View file @
82845cb8
...
@@ -92,18 +92,6 @@ class Terminal extends Plugin {
...
@@ -92,18 +92,6 @@ class Terminal extends Plugin {
}
}
onActivation
()
{
onActivation
()
{
// this.on('scriptRunner', 'log', (msg) => {
// this.commands.log.apply(this.commands, msg.data)
// })
// this.on('scriptRunner', 'info', (msg) => {
// this.commands.info.apply(this.commands, msg.data)
// })
// this.on('scriptRunner', 'warn', (msg) => {
// this.commands.warn.apply(this.commands, msg.data)
// })
// this.on('scriptRunner', 'error', (msg) => {
// this.commands.error.apply(this.commands, msg.data)
// })
this
.
renderComponent
()
this
.
renderComponent
()
}
}
...
...
libs/remix-ui/terminal/src/lib/commands.ts
View file @
82845cb8
libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx
View file @
82845cb8
...
@@ -217,6 +217,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
...
@@ -217,6 +217,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
// events
// events
useEffect
(()
=>
{
useEffect
(()
=>
{
registerRemixWelcomeTextAction
(
remixWelcome
,
welcomTextDispath
)
registerLogScriptRunnerAction
(
props
.
thisState
,
'log'
,
newstate
.
commands
,
scriptRunnerDispatch
)
registerLogScriptRunnerAction
(
props
.
thisState
,
'log'
,
newstate
.
commands
,
scriptRunnerDispatch
)
registerInfoScriptRunnerAction
(
props
.
thisState
,
'info'
,
newstate
.
commands
,
scriptRunnerDispatch
)
registerInfoScriptRunnerAction
(
props
.
thisState
,
'info'
,
newstate
.
commands
,
scriptRunnerDispatch
)
registerWarnScriptRunnerAction
(
props
.
thisState
,
'warn'
,
newstate
.
commands
,
scriptRunnerDispatch
)
registerWarnScriptRunnerAction
(
props
.
thisState
,
'warn'
,
newstate
.
commands
,
scriptRunnerDispatch
)
...
@@ -228,9 +229,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
...
@@ -228,9 +229,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
registerCommandAction
(
'error'
,
_blocksRenderer
(
'error'
),
{
activate
:
true
},
dispatch
)
registerCommandAction
(
'error'
,
_blocksRenderer
(
'error'
),
{
activate
:
true
},
dispatch
)
registerCommandAction
(
'script'
,
function
execute
(
args
,
scopedCommands
,
append
)
{
registerCommandAction
(
'script'
,
function
execute
(
args
,
scopedCommands
,
append
)
{
var
script
=
String
(
args
[
0
])
var
script
=
String
(
args
[
0
])
props
.
thisState
.
_shell
(
script
,
scopedCommands
,
function
(
error
,
output
)
{
_shell
(
script
,
scopedCommands
,
function
(
error
,
output
)
{
if
(
error
)
scopedCommands
.
error
(
error
)
console
.
log
({
error
},
'registerCommand scrpt'
)
else
if
(
output
)
scopedCommands
.
log
(
output
)
console
.
log
({
output
},
'registerCommand scrpt 2'
)
if
(
error
)
scriptRunnerDispatch
({
type
:
'error'
,
payload
:
{
message
:
error
}
})
else
if
(
output
)
scriptRunnerDispatch
({
type
:
'error'
,
payload
:
{
message
:
output
}
})
})
})
},
{
activate
:
true
},
dispatch
)
},
{
activate
:
true
},
dispatch
)
filterFnAction
(
'log'
,
basicFilter
,
filterDispatch
)
filterFnAction
(
'log'
,
basicFilter
,
filterDispatch
)
...
@@ -246,7 +249,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
...
@@ -246,7 +249,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
// dispatch({ type: 'html', payload: { commands: htmlresullt.commands } })
// dispatch({ type: 'html', payload: { commands: htmlresullt.commands } })
// dispatch({ type: 'log', payload: { _commands: logresult._commands } })
// dispatch({ type: 'log', payload: { _commands: logresult._commands } })
// registerCommand('log', _blocksRenderer('log'), { activate: true })
// registerCommand('log', _blocksRenderer('log'), { activate: true })
},
[])
},
[
newstate
.
journalBlocks
,
props
.
thisState
.
autoCompletePopup
,
autoCompletState
.
text
])
// handle events
// handle events
const
handlePaste
=
(
event
:
ClipboardEvent
<
HTMLInputElement
>
)
=>
{
const
handlePaste
=
(
event
:
ClipboardEvent
<
HTMLInputElement
>
)
=>
{
...
@@ -322,7 +325,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
...
@@ -322,7 +325,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
}
}
if
(
event
.
which
===
13
&&
!
autoCompletState
.
showSuggestions
)
{
if
(
event
.
which
===
13
&&
!
autoCompletState
.
showSuggestions
)
{
if
(
event
.
ctrlKey
)
{
// <ctrl+enter>
if
(
event
.
ctrlKey
)
{
// <ctrl+enter>
console
.
log
(
event
.
which
===
32
,
' enter key'
)
// on enter, append the value in the cli input to the journal
// on enter, append the value in the cli input to the journal
inputEl
.
current
.
focus
()
inputEl
.
current
.
focus
()
}
else
{
// <enter>
}
else
{
// <enter>
...
@@ -906,7 +908,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
...
@@ -906,7 +908,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
}
}
}
}
mode
=
{
mode
=
{
log
:
'text-
info
'
,
log
:
'text-
log
'
,
info
:
'text-info'
,
info
:
'text-info'
,
warn
:
'text-warning'
,
warn
:
'text-warning'
,
error
:
'text-danger'
error
:
'text-danger'
...
@@ -943,6 +945,73 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
...
@@ -943,6 +945,73 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
/* end of block content that gets rendered from script Runner */
/* end of block content that gets rendered from script Runner */
/* start of autoComplete */
const
handleSelect
=
(
text
)
=>
{
props
.
thisState
.
event
.
trigger
(
'handleSelect'
,
[
text
])
}
const
onChange
=
(
event
:
any
)
=>
{
event
.
preventDefault
()
const
inputString
=
event
.
target
.
value
console
.
log
(
event
)
console
.
log
({
inputString
})
setAutoCompleteState
(
prevState
=>
({
...
prevState
,
showSuggestions
:
true
,
userInput
:
inputString
}))
const
textList
=
inputString
.
split
(
' '
)
const
autoCompleteInput
=
textList
.
length
>
1
?
textList
[
textList
.
length
-
1
]
:
textList
[
0
]
allPrograms
.
forEach
(
item
=>
{
const
program
=
getKeyOf
(
item
)
console
.
log
({
program
})
if
(
program
.
substring
(
0
,
program
.
length
-
1
).
includes
(
autoCompleteInput
.
trim
()))
{
setAutoCompleteState
(
prevState
=>
({
...
prevState
,
data
:
{
_options
:
[
item
]
}
}))
}
else
if
(
autoCompleteInput
.
trim
().
includes
(
program
)
||
(
program
===
autoCompleteInput
.
trim
()))
{
allCommands
.
forEach
(
item
=>
{
console
.
log
({
item
})
const
command
=
getKeyOf
(
item
)
if
(
command
.
includes
(
autoCompleteInput
.
trim
()))
{
setAutoCompleteState
(
prevState
=>
({
...
prevState
,
data
:
{
_options
:
[
item
]
}
}))
}
})
}
})
autoCompletState
.
extraCommands
.
forEach
(
item
=>
{
const
command
=
getKeyOf
(
item
)
if
(
command
.
includes
(
autoCompleteInput
.
trim
()))
{
setAutoCompleteState
(
prevState
=>
({
...
prevState
,
data
:
{
_options
:
[
item
]
}
}))
}
})
if
(
autoCompletState
.
data
.
_options
.
length
===
1
&&
event
.
which
===
9
)
{
// if only one option and tab is pressed, we resolve it
event
.
preventDefault
()
textList
.
pop
()
textList
.
push
(
getKeyOf
(
autoCompletState
.
data
.
_options
[
0
]))
handleSelect
(
`
${
textList
}
`
.
replace
(
/,/g
,
' '
))
}
}
const
handleAutoComplete
=
()
=>
(
<
div
className=
"popup alert alert-secondary"
>
<
div
>
$
{
autoCompletState
.
data
.
_options
.
map
((
item
,
index
)
=>
{
return
(
<
div
key=
{
index
}
>
auto complete here
</
div
>
// <div data-id="autoCompletePopUpAutoCompleteItem" className=
{
`autoCompleteItem listHandlerHide item ${_selectedElement === index ? 'border border-primary' : ''}`
}
>
// <div value=
{
index
}
onClick
=
{(
event
)
=>
{
handleSelect
(
event
.
srcElement
.
innerText
)
}}
>
//
{
getKeyOf
(
item
)}
// </div>
// <div>
//
{
getValueOf
(
item
)}
// </div>
// </div>
)
})
}
</
div
>
{
/* <div className="listHandlerHide">
<div className="pageNumberAlignment">Page ${(self._startingElement / self._elementsToShow) + 1} of ${Math.ceil(data._options.length / self._elementsToShow)}</div>
</div> */
}
</
div
>
)
/* end of autoComplete */
return
(
return
(
<
div
style=
{
{
height
:
'323px'
,
flexGrow
:
1
}
}
className=
'panel'
>
<
div
style=
{
{
height
:
'323px'
,
flexGrow
:
1
}
}
className=
'panel'
>
{
console
.
log
({
newstate
})
}
{
console
.
log
({
newstate
})
}
...
...
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